Portions created by the Initial Developer are Copyright (C) 2008-2015 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes files require_once dirname(__DIR__, 2) . "/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 $domain_uuid = $_REQUEST['domain_uuid']; $contact_uuid = $_REQUEST['contact_uuid']; //get posted variables & set time status if (!empty($_POST)) { $contact_time_uuid = $_POST['contact_time_uuid']; $contact_uuid = $_POST['contact_uuid']; $time_action = $_POST['time_action']; $time_description = $_POST['time_description']; if ($time_description == 'Description...') { unset($time_description); } if ($time_action == 'start') { $contact_time_uuid = uuid(); $array['contact_times'][0]['domain_uuid'] = $domain_uuid; $array['contact_times'][0]['contact_time_uuid'] = $contact_time_uuid; $array['contact_times'][0]['contact_uuid'] = $contact_uuid; $array['contact_times'][0]['user_uuid'] = $_SESSION["user"]["user_uuid"]; $array['contact_times'][0]['time_start'] = date("Y-m-d H:i:s"); $array['contact_times'][0]['time_description'] = $time_description; } if ($time_action == 'stop') { $array['contact_times'][0]['contact_time_uuid'] = $contact_time_uuid; $array['contact_times'][0]['time_stop'] = date("Y-m-d H:i:s"); $array['contact_times'][0]['time_description'] = $time_description; } if (!empty($array)) { $database = new database; $database->app_name = 'contacts'; $database->app_uuid = '04481e0e-a478-c559-adad-52bd4174574c'; $database->save($array); unset($array); } header("Location: contact_timer.php?domain_uuid=".$domain_uuid."&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 = :domain_uuid "; $sql .= "and contact_uuid = :contact_uuid "; $parameters['domain_uuid'] = $domain_uuid; $parameters['contact_uuid'] = $contact_uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); if (!empty($row)) { $contact_organization = $row["contact_organization"]; $contact_name_given = $row["contact_name_given"]; $contact_name_family = $row["contact_name_family"]; $contact_nickname = $row["contact_nickname"]; } else { exit; } unset($sql, $parameters, $row); //determine timer state and action $sql = "select "; $sql .= "contact_time_uuid, "; $sql .= "time_description "; $sql .= "from v_contact_times "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and user_uuid = :user_uuid "; $sql .= "and contact_uuid = :contact_uuid "; $sql .= "and time_start is not null "; $sql .= "and time_stop is null "; $parameters['domain_uuid'] = $domain_uuid; $parameters['user_uuid'] = $_SESSION['user']['user_uuid']; $parameters['contact_uuid'] = $contact_uuid ?? ''; $database = new database; $row = $database->select($sql, $parameters, 'row'); if (!empty($row)) { $contact_time_uuid = $row["contact_time_uuid"]; $time_description = $row["time_description"]; } unset($sql, $parameters, $row); $timer_state = is_uuid($contact_time_uuid) ? 'running' : 'stopped'; $timer_action = $timer_state == 'running' ? 'stop' : 'start'; //determine contact name to display if (!empty($contact_nickname)) { $contact = $contact_nickname; } else if (!empty($contact_name_given)) { $contact = $contact_name_given; } if (!empty($contact_name_family)) { $contact .= (!empty($contact)) ? ' '.$contact_name_family : $contact_name_family; } if (!empty($contact_organization)) { $contact .= (!empty($contact)) ? ', '.$contact_organization : $contact_organization; } //get the browser version $user_agent = http_user_agent(); $browser_version = $user_agent['version']; $browser_name = $user_agent['name']; $browser_version_array = explode('.', $browser_version); //set the doctype echo ($browser_name != "Internet Explorer") ? "\n" : "\n"; ?> <?php echo $text['label-time_timer']; ?>: <?php echo $contact; ?> <?php echo $text['label-time_timer']; ?>





00:00:00