} if ($user_proxy_id) { $event_start = strtotime("-12 months 00:00:00"); $event_finish = strtotime("+12 months 23:59:59"); if (isset($_GET["start"]) && ($tmp_input = clean_input($_GET["start"], array("trim", "int")))) { $event_start = $tmp_input; } if (isset($_GET["end"]) && ($tmp_input = clean_input($_GET["end"], array("trim", "int")))) { $event_finish = $tmp_input; } if ($user_group == "faculty" || $user_group == "staff" || $user_group == "medtech") { $learning_events = events_fetch_filtered_events($user_proxy_id, $user_group, $user_role, $user_organisation_id, "date", "asc", "custom", $event_start, $event_finish, events_filters_faculty($seleted_course, $user_group, $user_role), true, 1, 1750, 0, $user_group == "student" ? true : false); } else { $learning_events = events_fetch_filtered_events($user_proxy_id, $user_group, $user_role, $user_organisation_id, "date", "asc", "custom", $event_start, $event_finish, events_filters_defaults($user_proxy_id, $user_group, $user_role, 0, $seleted_course), true, 1, 1750, 0, $user_group == "student" ? true : false); } if ($ENTRADA_ACL->amIAllowed("clerkship", "read")) { $query = "\tSELECT c.*\n\t\t\t\t\tFROM `" . CLERKSHIP_DATABASE . "`.`events` AS a\n\t\t\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`event_contacts` AS b\n\t\t\t\t\tON b.`event_id` = a.`event_id`\n\t\t\t\t\tLEFT JOIN `" . CLERKSHIP_DATABASE . "`.`global_lu_rotations` AS c\n\t\t\t\t\tON c.`rotation_id` = a.`rotation_id`\n\t\t\t\t\tWHERE a.`event_finish` >= " . $db->qstr(strtotime("00:00:00")) . "\n\t\t\t\t\tAND (a.`event_status` = 'published' OR a.`event_status` = 'approval')\n\t\t\t\t\tAND b.`econtact_type` = 'student'\n\t\t\t\t\tAND b.`etype_id` = " . $db->qstr($user_proxy_id) . "\n\t\t\t\t\tORDER BY a.`event_start` ASC"; $clerkship_schedule = $db->GetRow($query); if (isset($clerkship_schedule) && $clerkship_schedule && $clerkship_schedule["rotation_id"] != MAX_ROTATION) { $course_id = $clerkship_schedule["course_id"]; $course_ids = array(); $query = "SELECT `course_id` FROM `" . CLERKSHIP_DATABASE . "`.`global_lu_rotations`\n\t\t\t\t\tWHERE `course_id` <> " . $db->qstr($course_id) . "\n\t\t\t\t\tAND `course_id` <> 0"; $course_ids_array = $db->GetAll($query); foreach ($course_ids_array as $id) { $course_ids[] = $id; } foreach ($learning_events["events"] as $key => $event) { if (array_search($event["course_id"], $course_ids) !== false) { unset($learning_events["events"][$key]); } }
add_statistic("encounter_tracking", "insert", "lentry_id", $db->Insert_ID(), $ENTRADA_USER->getID()); echo json_encode(array("status" => "success", "data" => array("The entry has been saved successfully."))); } else { application_log("error", "Error occurred when updating logbook entry, DB said: " . $db->ErrorMsg()); echo json_encode(array("status" => "error", "data" => array("An error occurred when attempting to create a new logbook entry, an administrator has been informed, please try again later."))); } } } else { echo json_encode(array("status" => "error", "data" => array("Please ensure all required fields are complete."))); } break; } } break; case "hash": echo json_encode(array('authenticated' => 'true', 'hash' => $user_details["private_hash"], 'firstname' => $user_details['firstname'], 'lastname' => $user_details['lastname'], 'logbook_access' => $ENTRADA_ACL->amIAllowed('encounter_tracking', 'read'))); break; case "credentials": echo true; break; case "registertoken": if (isset($device_token)) { $query = "SELECT * FROM `" . AUTH_DATABASE . "`.`apns_device_tokens` WHERE `proxy_id` = ?"; $results = $db->GetAll($query, array($ENTRADA_USER->getId())); if ($results) { $user_device_tokens = array(); foreach ($results as $result) { $user_device_tokens[] = $result["device_token"]; } if (!in_array($device_token, $user_device_tokens)) { if (!$db->AutoExecute(AUTH_DATABASE . ".apns_device_tokens", array("proxy_id" => $result["proxy_id"], "device_token" => $device_token, "max_notice_id" => $result["max_notice_id"], "new_notices" => $result["new_notices"], "updated_date" => time()), "INSERT")) {