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 $domain_uuid = check_str($_REQUEST['domain_uuid']); $contact_uuid = check_str($_REQUEST['contact_uuid']); //get posted variables & set time status if (sizeof($_POST) > 0) { $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("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."' "; $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 = '".$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; } ?> <?php echo $text['label-time_timer']; ?>: <?php echo $contact; ?> <?php echo $text['label-time_timer']; ?>





00:00:00