diff --git a/app/contacts/app_config.php b/app/contacts/app_config.php index 0f925caa9c..5ff94167ae 100644 --- a/app/contacts/app_config.php +++ b/app/contacts/app_config.php @@ -169,6 +169,20 @@ $apps[$x]['permissions'][$y]['name'] = "contact_extension_view"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "admin"; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'contact_time_view'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'contact_time_add'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'contact_time_edit'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + $apps[$x]['permissions'][$y]['name'] = 'contact_time_delete'; + $apps[$x]['permissions'][$y]['groups'][] = 'superadmin'; + $y++; + //schema details $y = 0; //table array index @@ -699,4 +713,49 @@ $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Enter the URL description."; $z++; + $y = 9; //table array index + $apps[$x]['db'][$y]['table'] = 'v_contact_times'; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'contact_time_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'contact_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_contact'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'contact_uuid'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'user_uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid'; + $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)'; + $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_users'; + $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'user_uuid'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'time_start'; + $apps[$x]['db'][$y]['fields'][$z]['type'] = 'timestamp'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Start'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'time_stop'; + $apps[$x]['db'][$y]['fields'][$z]['type'] = 'timestamp'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Stop'; + $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'time_description'; + $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Description'; + $z++; + ?> \ No newline at end of file diff --git a/app/contacts/app_languages.php b/app/contacts/app_languages.php index 26b1cc8abf..3355747c45 100644 --- a/app/contacts/app_languages.php +++ b/app/contacts/app_languages.php @@ -27,6 +27,24 @@ $text['title-contacts']['pl'] = "Kontakty"; $text['title-contacts']['uk'] = "Контакти"; $text['title-contacts']['sv-se'] = "Kontakter"; +$text['title-contact_time_edit']['en-us'] = "Time Edit"; +$text['title-contact_time_edit']['es-cl'] = "Tiempo de Redacción"; +$text['title-contact_time_edit']['pt-pt'] = "Tempo Editar"; +$text['title-contact_time_edit']['fr-fr'] = "Modifier Temps"; +$text['title-contact_time_edit']['pt-br'] = "Tempo Editar"; +$text['title-contact_time_edit']['pl'] = "Czas Edycja"; +$text['title-contact_time_edit']['uk'] = "час Редагувати"; +$text['title-contact_time_edit']['sv-se'] = "Redigera Tid"; + +$text['title-contact_time_add']['en-us'] = "Time Add"; +$text['title-contact_time_add']['es-cl'] = "Tiempo Agregar"; +$text['title-contact_time_add']['pt-pt'] = "Time Adicionar"; +$text['title-contact_time_add']['fr-fr'] = "Ajouter Temps"; +$text['title-contact_time_add']['pt-br'] = "Time Adicionar"; +$text['title-contact_time_add']['pl'] = "Czas Dodawania"; +$text['title-contact_time_add']['uk'] = "час додавання"; +$text['title-contact_time_add']['sv-se'] = "Time Lägg"; + $text['title-contact_setting_edit']['en-us'] = "Contact Setting Edit"; $text['title-contact_setting_edit']['es-cl'] = "Configuraciones de contacto"; $text['title-contact_setting_edit']['pt-pt'] = "Definições do Contacto"; @@ -593,6 +611,69 @@ $text['label-true']['pl'] = "Tak"; $text['label-true']['uk'] = "Так"; $text['label-true']['sv-se'] = "Sann"; +$text['label-time_user']['en-us'] = "User"; +$text['label-time_user']['es-cl'] = "Usuario"; +$text['label-time_user']['pt-pt'] = "Usuário"; +$text['label-time_user']['fr-fr'] = "Utilisateur"; +$text['label-time_user']['pt-br'] = "Usuário"; +$text['label-time_user']['pl'] = "Użytkownik"; +$text['label-time_user']['uk'] = "Користувач"; +$text['label-time_user']['sv-se'] = "Användare"; + +$text['label-time_timer']['en-us'] = "Timer"; +$text['label-time_timer']['es-cl'] = "Timer"; +$text['label-time_timer']['pt-pt'] = "Cronômetro"; +$text['label-time_timer']['fr-fr'] = "Minuteur"; +$text['label-time_timer']['pt-br'] = "Cronômetro"; +$text['label-time_timer']['pl'] = "Regulator Czasowy"; +$text['label-time_timer']['uk'] = "таймер"; +$text['label-time_timer']['sv-se'] = "Timer"; + +$text['label-time_time']['en-us'] = "Time"; +$text['label-time_time']['es-cl'] = "Tiempo"; +$text['label-time_time']['pt-pt'] = "Tempo"; +$text['label-time_time']['fr-fr'] = "Temps"; +$text['label-time_time']['pt-br'] = "Tempo"; +$text['label-time_time']['pl'] = "Czas"; +$text['label-time_time']['uk'] = "час"; +$text['label-time_time']['sv-se'] = "Tid"; + +$text['label-time_duration']['en-us'] = "Duration"; +$text['label-time_duration']['es-cl'] = "Duración"; +$text['label-time_duration']['pt-pt'] = "Duração"; +$text['label-time_duration']['fr-fr'] = "Durée"; +$text['label-time_duration']['pt-br'] = "Duração"; +$text['label-time_duration']['pl'] = "Czas Trwania"; +$text['label-time_duration']['uk'] = "тривалість"; +$text['label-time_duration']['sv-se'] = "Varaktighet"; + +$text['label-time_stop']['en-us'] = "Stop"; +$text['label-time_stop']['es-cl'] = "Deténgase"; +$text['label-time_stop']['pt-pt'] = "Pare"; +$text['label-time_stop']['fr-fr'] = "Stop"; +$text['label-time_stop']['pt-br'] = "Pare"; +$text['label-time_stop']['pl'] = "Stop"; +$text['label-time_stop']['uk'] = "стоп"; +$text['label-time_stop']['sv-se'] = "Stanna"; + +$text['label-time_start']['en-us'] = "Start"; +$text['label-time_start']['es-cl'] = "Comienzo"; +$text['label-time_start']['pt-pt'] = "Começo"; +$text['label-time_start']['fr-fr'] = "Début"; +$text['label-time_start']['pt-br'] = "Começo"; +$text['label-time_start']['pl'] = "Początek"; +$text['label-time_start']['uk'] = "початок"; +$text['label-time_start']['sv-se'] = "Start"; + +$text['label-time_description']['en-us'] = "Description"; +$text['label-time_description']['es-cl'] = "Descripción"; +$text['label-time_description']['pt-pt'] = "Descrição"; +$text['label-time_description']['fr-fr'] = "Description"; +$text['label-time_description']['pt-br'] = "Descrição"; +$text['label-time_description']['pl'] = "Opis"; +$text['label-time_description']['uk'] = "Опис"; +$text['label-time_description']['sv-se'] = "Beskrivning"; + $text['label-text']['en-us'] = "Text"; $text['label-text']['es-cl'] = "Texto"; $text['label-text']['pt-pt'] = "Texto"; @@ -1355,6 +1436,33 @@ $text['header-contact_url-add']['pl'] = "Dodaj kontakt URL "; $text['header-contact_url-add']['uk'] = ""; $text['header-contact_url-add']['sv-se'] = "Lägg Till Kontakt URL"; +$text['header_contact_times']['en-us'] = "Times"; +$text['header_contact_times']['es-cl'] = "Veces"; +$text['header_contact_times']['pt-pt'] = "Vezes"; +$text['header_contact_times']['fr-fr'] = "Fois"; +$text['header_contact_times']['pt-br'] = "Vezes"; +$text['header_contact_times']['pl'] = "Czasy"; +$text['header_contact_times']['uk'] = "раз"; +$text['header_contact_times']['sv-se'] = "Gånger"; + +$text['header-contact_time_edit']['en-us'] = "Time Edit"; +$text['header-contact_time_edit']['es-cl'] = "Tiempo de Redacción"; +$text['header-contact_time_edit']['pt-pt'] = "Tempo Editar"; +$text['header-contact_time_edit']['fr-fr'] = "Modifier Temps"; +$text['header-contact_time_edit']['pt-br'] = "Tempo Editar"; +$text['header-contact_time_edit']['pl'] = "Czas Edycja"; +$text['header-contact_time_edit']['uk'] = "час Редагувати"; +$text['header-contact_time_edit']['sv-se'] = "Redigera Tid"; + +$text['header-contact_time_add']['en-us'] = "Time Add"; +$text['header-contact_time_add']['es-cl'] = "Tiempo Agregar"; +$text['header-contact_time_add']['pt-pt'] = "Time Adicionar"; +$text['header-contact_time_add']['fr-fr'] = "Ajouter Temps"; +$text['header-contact_time_add']['pt-br'] = "Time Adicionar"; +$text['header-contact_time_add']['pl'] = "Czas Dodawania"; +$text['header-contact_time_add']['uk'] = "час додавання"; +$text['header-contact_time_add']['sv-se'] = "Time Lägg"; + $text['header-contact_setting_edit']['en-us'] = "Contact Setting Edit"; $text['header-contact_setting_edit']['es-cl'] = "Configuraciones de contacto"; $text['header-contact_setting_edit']['pt-pt'] = "Definições do Contacto"; @@ -1488,6 +1596,15 @@ $text['description-url_primary']['pl'] = "Ustaw jako podstawowy adres URL dla te $text['description-url_primary']['uk'] = ""; $text['description-url_primary']['sv-se'] = "Ställ in som primär URL för denna kontakt."; +$text['description_timer']['en-us'] = "Stop the Timer before closing the window, if desired."; +$text['description_timer']['es-cl'] = "Detenga el temporizador antes de cerrar la ventana, si se desea."; +$text['description_timer']['pt-pt'] = "Parar o temporizador antes de fechar a janela, se desejar."; +$text['description_timer']['fr-fr'] = "Arrêter le retardateur avant la fermeture de la fenêtre, si désiré."; +$text['description_timer']['pt-br'] = "Parar o temporizador antes de fechar a janela, se desejar."; +$text['description_timer']['pl'] = "Zatrzymac samowyzwalacz przed zamknieciem okna, w razie potrzeby."; +$text['description_timer']['uk'] = "Зупинити таймер перед закриттям вікна, якщо це необхідно."; +$text['description_timer']['sv-se'] = "Stoppa timer innan du stänger fönstret, om så önskas."; + $text['description-shared_import']['en-us'] = "Share contacts with other users on the domain."; $text['description-shared_import']['es-cl'] = "Comparte estos contactos con otros usuarios en el dominio."; $text['description-shared_import']['pt-pt'] = "Compartilhe estes contatos com outros usuários do domínio."; @@ -2089,6 +2206,42 @@ $text['button-upload']['pl'] = "Wyślij"; $text['button-upload']['uk'] = "Завантажити"; $text['button-upload']['sv-se'] = "Ladda Upp"; +$text['button-time']['en-us'] = "Time"; +$text['button-time']['es-cl'] = "Tiempo"; +$text['button-time']['pt-pt'] = "Tempo"; +$text['button-time']['fr-fr'] = "Temps"; +$text['button-time']['pt-br'] = "Tempo"; +$text['button-time']['pl'] = "Czas"; +$text['button-time']['uk'] = "час"; +$text['button-time']['sv-se'] = "Tid"; + +$text['button-timer']['en-us'] = "Timer"; +$text['button-timer']['es-cl'] = "Timer"; +$text['button-timer']['pt-pt'] = "Cronômetro"; +$text['button-timer']['fr-fr'] = "Minuteur"; +$text['button-timer']['pt-br'] = "Cronômetro"; +$text['button-timer']['pl'] = "Regulator Czasowy"; +$text['button-timer']['uk'] = "таймер"; +$text['button-timer']['sv-se'] = "Timer"; + +$text['button-stop']['en-us'] = "Stop"; +$text['button-stop']['es-cl'] = "Deténgase"; +$text['button-stop']['pt-pt'] = "Pare"; +$text['button-stop']['fr-fr'] = "Stop"; +$text['button-stop']['pt-br'] = "Pare"; +$text['button-stop']['pl'] = "Stop"; +$text['button-stop']['uk'] = "стоп"; +$text['button-stop']['sv-se'] = "Stanna"; + +$text['button-start']['en-us'] = "Start"; +$text['button-start']['es-cl'] = "Comienzo"; +$text['button-start']['pt-pt'] = "Começo"; +$text['button-start']['fr-fr'] = "Début"; +$text['button-start']['pt-br'] = "Começo"; +$text['button-start']['pl'] = "Początek"; +$text['button-start']['uk'] = "початок"; +$text['button-start']['sv-se'] = "Start"; + $text['button-sign_out']['en-us'] = "Sign Out"; $text['button-sign_out']['es-cl'] = "Desconectar"; $text['button-sign_out']['pt-pt'] = "Sair"; diff --git a/app/contacts/contact_edit.php b/app/contacts/contact_edit.php index 01ae0d5c4d..d11157a79a 100644 --- a/app/contacts/contact_edit.php +++ b/app/contacts/contact_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): @@ -338,6 +338,26 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo " \n"; if ($action == "update") { + if (permission_exists('contact_time_add')) { + //detect timer state (and start time) + $sql = "select "; + $sql .= "time_start "; + $sql .= "from v_contact_times "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and user_uuid = '".$_SESSION['user']['user_uuid']."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $sql .= "and time_start is not null "; + $sql .= "and time_stop is null "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_NAMED); + if ($result['time_start'] != '') { + $time_start = $result['time_start']; + $btn_mod = "style='background-color: #a00; background-image: none;'"; + } + unset ($sql, $prep_statement, $result); + echo " \n"; + } echo " \n"; echo " \n"; } @@ -706,6 +726,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (permission_exists('contact_extension_view')) { require "contact_extensions.php"; } if (permission_exists('contact_relation_view')) { require "contact_relations.php"; } if (permission_exists('contact_note_view')) { require "contact_notes.php"; } + if (permission_exists('contact_time_view')) { require "contact_times.php"; } if (permission_exists('contact_setting_view')) { require "contact_settings.php"; } echo "\n"; } diff --git a/app/contacts/contact_settings.php b/app/contacts/contact_settings.php index 31af54a6a1..05599e967a 100644 --- a/app/contacts/contact_settings.php +++ b/app/contacts/contact_settings.php @@ -106,7 +106,7 @@ else { echo " \n"; echo " ".ucwords($row['contact_setting_enabled'])." \n"; echo " ".$row['contact_setting_description']." \n"; - echo " "; + echo " "; if (permission_exists('contact_setting_edit')) { echo "$v_link_label_edit"; } diff --git a/app/contacts/contact_time_delete.php b/app/contacts/contact_time_delete.php new file mode 100644 index 0000000000..1ab7e7b06f --- /dev/null +++ b/app/contacts/contact_time_delete.php @@ -0,0 +1,63 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('contact_time_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the http values and set as variables + if (count($_GET) > 0) { + $contact_time_uuid = check_str($_GET["id"]); + $contact_uuid = check_str($_GET["contact_uuid"]); + } + +//delete the record + if (strlen($contact_time_uuid) > 0) { + $sql = "delete from v_contact_times "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $sql .= "and contact_time_uuid = '".$contact_time_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the browser + $_SESSION["message"] = $text['message-delete']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + +?> \ No newline at end of file diff --git a/app/contacts/contact_time_edit.php b/app/contacts/contact_time_edit.php new file mode 100644 index 0000000000..cab8a0f4fa --- /dev/null +++ b/app/contacts/contact_time_edit.php @@ -0,0 +1,231 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('contact_time_edit') || permission_exists('contact_time_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $contact_time_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["contact_uuid"]) > 0) { + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $time_start = check_str($_POST["time_start"]); + $time_stop = check_str($_POST["time_stop"]); + $time_description = check_str($_POST["time_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $contact_time_uuid = check_str($_POST["contact_time_uuid"]); + } + + //check for all required data + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + + + if ($action == "add") { + $contact_time_uuid = uuid(); + $sql = "insert into v_contact_times "; + $sql .= "( "; + $sql .= "domain_uuid, "; + $sql .= "contact_time_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "user_uuid, "; + $sql .= "time_start, "; + $sql .= "time_stop, "; + $sql .= "time_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "( "; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'".$contact_time_uuid."', "; + $sql .= "'".$contact_uuid."', "; + $sql .= "'".$_SESSION["user"]["user_uuid"]."', "; + $sql .= "'".$time_start."', "; + $sql .= "'".$time_stop."', "; + $sql .= "'".$time_description."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + $_SESSION["message"] = $text['message-add']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_contact_times "; + $sql .= "set "; + $sql .= "time_start = '".$time_start."', "; + $sql .= "time_stop = '".$time_stop."', "; + $sql .= "time_description = '".$time_description."' "; + $sql .= "where "; + $sql .= "contact_time_uuid = '".$contact_time_uuid."' "; + $sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $sql .= "and user_uuid = '".$_SESSION["user"]["user_uuid"]."' "; + $db->exec(check_sql($sql)); + unset($sql); + + $_SESSION["message"] = $text['message-update']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $contact_time_uuid = $_GET["id"]; + $sql = "select ct.*, u.username "; + $sql .= "from v_contact_times as ct, v_users as u "; + $sql .= "where ct.user_uuid = u.user_uuid "; + $sql .= "and ct.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ct.contact_uuid = '".$contact_uuid."' "; + $sql .= "and contact_time_uuid = '".$contact_time_uuid."' "; + $sql .= "order by ct.time_start desc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_NAMED); + $time_start = $result["time_start"]; + $time_stop = $result["time_stop"]; + $time_description = $result["time_description"]; + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + if ($action == "update") { + $document['title'] = $text['title-contact_time_edit']; + } + else if ($action == "add") { + $document['title'] = $text['title-contact_time_add']; + } + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + if ($action == "update") { + echo $text['header-contact_time_edit']; + } + else if ($action == "add") { + echo $text['header-contact_time_add']; + } + echo ""; + echo " "; + echo " \n"; + echo "
\n"; + echo "
\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo " ".$text['label-time_start']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-time_stop']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-time_description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "

"; + echo "
"; + +//include the footer + require_once "resources/footer.php"; +?> diff --git a/app/contacts/contact_timer.php b/app/contacts/contact_timer.php new file mode 100644 index 0000000000..9fa2606376 --- /dev/null +++ b/app/contacts/contact_timer.php @@ -0,0 +1,372 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (!permission_exists('contact_time_add')) { echo "access denied"; exit; } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get contact uuid + $contact_uuid = check_str($_REQUEST['contact_uuid']); + +//get posted variables & set time status + if (sizeof($_POST) > 0) { + $domain_uuid = check_str($_POST['domain_uuid']); + $contact_time_uuid = check_str($_POST['contact_time_uuid']); + $contact_uuid = check_str($_POST['contact_uuid']); + $time_action = check_str($_POST['time_action']); + $time_description = check_str($_POST['time_description']); + + if ($time_description == 'Description...') { unset($time_description); } + + if ($time_action == 'start') { + $contact_time_uuid = uuid(); + $sql = "insert into v_contact_times "; + $sql .= "( "; + $sql .= "domain_uuid, "; + $sql .= "contact_time_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "user_uuid, "; + $sql .= "time_start, "; + $sql .= "time_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "( "; + $sql .= "'".$domain_uuid."', "; + $sql .= "'".$contact_time_uuid."', "; + $sql .= "'".$contact_uuid."', "; + $sql .= "'".$_SESSION["user"]["user_uuid"]."', "; + $sql .= "'".date("Y-m-d H:i:s")."', "; + $sql .= "'".$time_description."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + if ($time_action == 'stop') { + $sql = "update v_contact_times "; + $sql .= "set "; + $sql .= "time_stop = '".date("Y-m-d H:i:s")."', "; + $sql .= "time_description = '".$time_description."' "; + $sql .= "where "; + $sql .= "contact_time_uuid = '".$contact_time_uuid."' "; + $sql .= "and domain_uuid = '".$domain_uuid."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $sql .= "and user_uuid = '".$_SESSION["user"]["user_uuid"]."' "; + $db->exec(check_sql($sql)); + unset($sql); + } + header("contact_timer.php?contact_uuid=".$contact_uuid); + } + +//get contact details + $sql = "select "; + $sql .= "contact_organization, "; + $sql .= "contact_name_given, "; + $sql .= "contact_name_family, "; + $sql .= "contact_nickname "; + $sql .= "from v_contacts "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_NAMED); + if (sizeof($result) > 0) { + $contact_organization = $result["contact_organization"]; + $contact_name_given = $result["contact_name_given"]; + $contact_name_family = $result["contact_name_family"]; + $contact_nickname = $result["contact_nickname"]; + } + else { + exit; + } + unset ($sql, $prep_statement, $result); + +//determine timer state and action + $sql = "select "; + $sql .= "contact_time_uuid, "; + $sql .= "time_description "; + $sql .= "from v_contact_times "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and user_uuid = '".$_SESSION['user']['user_uuid']."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $sql .= "and time_start is not null "; + $sql .= "and time_stop is null "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_NAMED); + if (sizeof($result) > 0) { + $contact_time_uuid = $result["contact_time_uuid"]; + $time_description = $result["time_description"]; + } + unset ($sql, $prep_statement, $result); + + $timer_state = ($contact_time_uuid != '') ? 'running' : 'stopped'; + $timer_action = ($timer_state == 'running') ? 'stop' : 'start'; + +//determine contact name to display + if ($contact_nickname != '') { + $contact = $contact_nickname; + } + else if ($contact_name_given != '') { + $contact = $contact_name_given; + } + if ($contact_name_family != '') { + $contact .= ($contact != '') ? ' '.$contact_name_family : $contact_name_family; + } + if ($contact_organization != '') { + $contact .= ($contact != '') ? ', '.$contact_organization : $contact_organization; + } +?> + + + + Timer: <?php echo $contact; ?> + + + + + +<?php echo $text['label-time_timer']; ?> + +

+ +

+ +

+
>00:00:00
+
+
+ + + + + + + + +
+ + + +
+
+
+ + + + + +
+
+ + \ No newline at end of file diff --git a/app/contacts/contact_timer_inc.php b/app/contacts/contact_timer_inc.php new file mode 100644 index 0000000000..56f32f6a8f --- /dev/null +++ b/app/contacts/contact_timer_inc.php @@ -0,0 +1,56 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (!permission_exists('contact_time_add')) { echo "access denied"; exit; } + +//get contact and time uuids + $contact_uuid = check_str($_REQUEST['contact_uuid']); + $contact_time_uuid = check_str($_REQUEST['contact_time_uuid']); + +//get time quantity + $sql = "select "; + $sql .= "time_start "; + $sql .= "from v_contact_times "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_time_uuid = '".$contact_time_uuid."' "; + $sql .= "and user_uuid = '".$_SESSION['user']['user_uuid']."' "; + $sql .= "and contact_uuid = '".$contact_uuid."' "; + $sql .= "and time_start is not null "; + $sql .= "and time_stop is null "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetch(PDO::FETCH_NAMED); + if (sizeof($result) > 0) { + $time_start = strtotime($result["time_start"]); + $time_now = strtotime(date("Y-m-d H:i:s")); + $time_diff = gmdate("H:i:s", ($time_now - $time_start)); + echo $time_diff; + echo ""; + } + unset ($sql, $prep_statement, $result); +?> \ No newline at end of file diff --git a/app/contacts/contact_times.php b/app/contacts/contact_times.php new file mode 100644 index 0000000000..6084a7a40f --- /dev/null +++ b/app/contacts/contact_times.php @@ -0,0 +1,137 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('contact_time_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//show the content + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".$text['header_contact_times']." 
\n"; + + //get the contact list + $sql = "select ct.*, u.username "; + $sql .= "from v_contact_times as ct, v_users as u "; + $sql .= "where ct.user_uuid = u.user_uuid "; + $sql .= "and ct.domain_uuid = '".$domain_uuid."' "; + $sql .= "and u.domain_uuid = '".$domain_uuid."' "; + $sql .= "and ct.contact_uuid = '".$contact_uuid."' "; + $sql .= "order by ct.time_start desc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".$text['label-time_user']."".$text['label-time_start']."".$text['label-time_duration']."".$text['label-time_description'].""; + echo img_spacer('25px', '1px', 'none'); + if (permission_exists('contact_time_add')) { + echo "$v_link_label_add"; + } + else { + echo img_spacer('25px', '1px', 'none'); + } + echo "
\n"; + + echo "
"; + echo "\n"; + if ($result_count > 0) { + foreach($result as $row) { + if (permission_exists('contact_time_edit')) { + $tr_link = "href='contact_time_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['contact_time_uuid']."'"; + } + echo "\n"; + if ($row["time_start"] != '' && $row['time_stop'] != '') { + $time_start = strtotime($row["time_start"]); + $time_stop = strtotime($row['time_stop']); + $time = gmdate("H:i:s", ($time_stop - $time_start)); + } + else { unset($time); } + $tmp = explode(' ', $row['time_start']); + $time_start = $tmp[0]; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $c = ($c) ? 0 : 1; + } //end foreach + unset($sql, $result, $row_count); + } //end if results + echo "
".$row["username"]." ".$time_start." ".$time." ".$row['time_description']." "; + if (permission_exists('contact_time_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('contact_time_delete')) { + echo "$v_link_label_delete"; + } + echo "
"; + echo "
\n"; + + echo "\n"; + +?> \ No newline at end of file diff --git a/app/contacts/resources/images/icon_timer.png b/app/contacts/resources/images/icon_timer.png new file mode 100644 index 0000000000..d3cc2bc630 Binary files /dev/null and b/app/contacts/resources/images/icon_timer.png differ diff --git a/resources/functions.php b/resources/functions.php index a36a9bc790..c5b1d13068 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -1286,4 +1286,11 @@ function number_pad($number,$n) { } } +//transparent gif + if (!function_exists('img_spacer')) { + function img_spacer($width = '1px', $height = '1px', $border = 'none') { + return ""; + } + } + ?>