<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ $calendar_id = isset($_GET['calendar_id']) ? (int) $_GET['calendar_id'] : 0; $calendar = module_calendar::get_calendar($calendar_id); if (!$calendar_id || !isset($calendar['calendar_id']) || $calendar['calendar_id'] != $calendar_id) { $calendar_id = $calendar['calendar_id'] = 0; if (isset($_REQUEST['customer_id']) && $_REQUEST['customer_id']) { $calendar['customer_id'] = (int) $_REQUEST['customer_id']; } // if the user only has access to a single customer, add that customer id in here by default. if (isset($_POST['start_date_time']) && $_POST['start_date_time']) { $start_time = js2PhpTime($_POST['start_date_time']); $calendar['start'] = $start_time; } if (isset($_POST['end_date_time']) && $_POST['end_date_time']) { $end_time = js2PhpTime($_POST['end_date_time']); $calendar['end'] = $end_time; } if (isset($_POST['is_all_day']) && $_POST['is_all_day']) { $calendar['is_all_day'] = $_POST['is_all_day']; } if (isset($_POST['title']) && $_POST['title']) {
function listCalendarByRange($sd, $ed) { $ret = array(); $ret['events'] = array(); $ret["issort"] = true; $ret["start"] = php2JsTime($sd); $ret["end"] = php2JsTime($ed); $ret['error'] = null; $calendar_data_access = module_calendar::get_calendar_data_access(); // hook into things like jobs and stuff who want to return calendar entries. $hook_results = hook_handle_callback('calendar_events', $sd, $ed); if (is_array($hook_results) && count($hook_results)) { foreach ($hook_results as $hook_result) { if (is_array($hook_result)) { foreach ($hook_result as $result) { // format our hook results to match our bad (indexed) array, // will update that array in the future /*$calendar_events[] = array( 'subject' => $job['name'], 'customer_id' => $job['customer_id'], 'start_time' => $job['date_start'], 'user_id' => $job['user_id'], 'description' => 'Test Description', 'link' => module_job::link_open($job['job_id'],true,$job), );*/ $staff_names = array(); if (isset($result['staff_ids']) && count($result['staff_ids'])) { switch ($calendar_data_access) { case _CALENDAR_ACCESS_ALL: break; case _CALENDAR_ACCESS_ASSIGNED: default: $current_user = module_security::get_loggedin_id(); if (!in_array($current_user, $result['staff_ids'])) { continue 2; } break; } foreach ($result['staff_ids'] as $staff_id) { $staff_names[] = module_user::link_open($staff_id, true); } } $staff_names = implode(', ', $staff_names); $result[0] = false; // no calendar ID at the moment $result[1] = $result['subject']; $result[2] = php2JsTime($result['start_time']); $result[3] = php2JsTime(isset($result['end_time']) ? $result['end_time'] : $result['start_time']); $result[4] = !isset($result['all_day']) || $result['all_day']; $result[5] = 0; $result[6] = 0; $result[7] = 0; //col $result[8] = 2; $result[9] = 0; $result[10] = 0; $result[13] = $result['customer_id']; $result[12] = $result['link']; $result[14] = isset($_REQUEST['customer_id']) && $_REQUEST['customer_id'] != $result['customer_id'] ? 'chip-fade' : ''; $result['staff'] = $staff_names; $ret['events'][] = $result; } } } } try { $sql = "select * from `" . _DB_PREFIX . "calendar` where `start` >= '" . mysql_real_escape_string($sd) . "' AND `start` <= '" . mysql_real_escape_string($ed) . "'"; // echo $sql; $rows = qa($sql); foreach ($rows as $row) { //$ret['events'][] = $row; //$attends = $row->AttendeeNames; //if($row->OtherAttendee){ // $attends .= $row->OtherAttendee; //} //echo $row->StartTime; $more_than_1_day = date('Ymd', $row['start']) == date('Ymd', $row['end']) ? 0 : 1; $customer_name = $customer_link = ''; if ($row['customer_id'] > 0) { $customer_data = module_customer::get_customer($row['customer_id'], true, true); if (!$customer_data || $customer_data['customer_id'] != $row['customer_id']) { $row['customer_id'] = 0; } else { switch ($calendar_data_access) { case _CALENDAR_ACCESS_ALL: break; case _CALENDAR_ACCESS_ASSIGNED: default: if (isset($customer_data['_no_access'])) { continue 2; } break; } $customer_name = $customer_data['customer_name']; $customer_link = module_customer::link_open($row['customer_id'], true, $customer_data); } } $calendar_event = module_calendar::get_calendar($row['calendar_id']); $staff_names = array(); if (count($calendar_event['staff_ids'])) { switch ($calendar_data_access) { case _CALENDAR_ACCESS_ALL: break; case _CALENDAR_ACCESS_ASSIGNED: default: $current_user = module_security::get_loggedin_id(); if (!in_array($current_user, $calendar_event['staff_ids'])) { continue 2; } break; } foreach ($calendar_event['staff_ids'] as $staff_id) { $staff_names[] = module_user::link_open($staff_id, true); } } $staff_names = implode(', ', $staff_names); $ret['events'][] = array(0 => $row['calendar_id'], 1 => $row['subject'], 2 => php2JsTime($row['start']), 3 => php2JsTime($row['end']), 4 => $row['is_all_day'], 5 => $more_than_1_day, 6 => 0, 7 => $row['color'], 8 => 1, 9 => '', 10 => '', 11 => $customer_name, 12 => $customer_link, 13 => $row['customer_id'], 14 => isset($_REQUEST['customer_id']) && $_REQUEST['customer_id'] != $row['customer_id'] ? 'chip-fade' : '', 'staff' => $staff_names); } } catch (Exception $e) { $ret['error'] = $e->getMessage(); } // build bubble content based on event data: foreach ($ret['events'] as $event_id => $event) { if (!isset($event['bubble'])) { $ret['events'][$event_id]['bubble'] = '<div id="bbit-cs-buddle" style="z-index: 1080; width: 400px;visibility:hidden;" class="bubble"><table class="bubble-table" cellSpacing="0" cellPadding="0"><tbody><tr><td class="bubble-cell-side"><div id="tl1" class="bubble-corner"><div class="bubble-sprite bubble-tl"></div></div><td class="bubble-cell-main"><div class="bubble-top"></div><td class="bubble-cell-side"><div id="tr1" class="bubble-corner"><div class="bubble-sprite bubble-tr"></div></div> <tr><td class="bubble-mid" colSpan="3"><div style="overflow: hidden" id="bubbleContent1"><div><div></div><div class="cb-root"><table class="cb-table" cellSpacing="0" cellPadding="0"><tbody>' . '<tr>' . '<td class="cb-value"><div class="textbox-fill-wrapper"><div class="textbox-fill-mid"><div id="bbit-cs-what" title="' . htmlspecialchars(_l('View Details')) . '" class="textbox-fill-div lk" style="cursor:pointer;">' . htmlspecialchars($event[1]) . '</div></div></div></td></tr><tr><td class=cb-value><div id="bbit-cs-buddle-timeshow"></div></td>' . '</tr>' . '<tr><td class=cb-value><div id="bbit-cs-customer-link">' . _l('Customer: %s', $event[12] ? $event[12] : _l('N/A')) . '</div></td></tr>' . (isset($event['other_details']) && strlen($event['other_details']) ? '<tr><td class=cb-value><div id="bbit-cs-customer-link">' . $event['other_details'] . '</div></td></tr>' : '') . '<tr><td class=cb-value><div id="bbit-cs-staff-link">' . _l('Staff: %s', $event['staff'] ? $event['staff'] : _l('N/A')) . '</div></td></tr>' . '</tbody></table>' . ($event[8] == 1 ? '<div class="bbit-cs-split"><input id="bbit-cs-id" type="hidden" value=""/>' . (module_calendar::can_i('delete', 'Calendar') ? '[ <span id="bbit-cs-delete" class="lk">' . htmlspecialchars(_l('Delete')) . '</span> ] ' : '') . (module_calendar::can_i('edit', 'Calendar') ? ' <span id="bbit-cs-editLink" class="lk">' . htmlspecialchars(_l('Edit Event')) . ' </span>' : '') . '</div> ' : '') . '</div></div></div><tr><td><div id="bl1" class="bubble-corner"><div class="bubble-sprite bubble-bl"></div></div><td><div class="bubble-bottom"></div><td><div id="br1" class="bubble-corner"><div class="bubble-sprite bubble-br"></div></div></tr></tbody></table><div id="bubbleClose2" class="bubble-closebutton"></div><div id="prong1" class="prong"><div class=bubble-sprite></div></div></div>'; } } return $ret; }