Example #1
0
 public function process()
 {
     if ("ajax_calendar" == $_REQUEST['_process'] && module_calendar::can_i('view', 'Calendar')) {
         // ajax functions from wdCalendar. copied from the datafeed.php sample files.
         header('Content-type: text/javascript');
         $ret = array();
         $method = isset($_REQUEST['method']) ? $_REQUEST['method'] : false;
         switch ($method) {
             case "quick_add":
                 if (module_calendar::can_i('create', 'Calendar')) {
                     $ret = addCalendar($_POST["CalendarStartTime"], $_POST["CalendarEndTime"], $_POST["CalendarTitle"], $_POST["IsAllDayEvent"]);
                 }
                 break;
             case "list":
                 $ret = listCalendar($_POST["showdate"], $_POST["viewtype"]);
                 break;
             case "quick_update":
                 if (module_calendar::can_i('edit', 'Calendar')) {
                     $ret = updateCalendar($_POST["calendarId"], $_POST["CalendarStartTime"], $_POST["CalendarEndTime"]);
                 }
                 break;
             case "quick_remove":
                 if (module_calendar::can_i('delete', 'Calendar')) {
                     $ret = removeCalendar($_POST["calendarId"]);
                 }
                 break;
         }
         echo json_encode($ret);
         exit;
     }
     if ("save_calendar_entry" == $_REQUEST['_process']) {
         header('Content-type: text/javascript');
         $calendar_id = isset($_REQUEST['calendar_id']) ? (int) $_REQUEST['calendar_id'] : 0;
         $response = array();
         if ($calendar_id && module_calendar::can_i('edit', 'Calendar') || !$calendar_id && module_calendar::can_i('create', 'Calendar')) {
             $data = $_REQUEST;
             if (isset($data['start'])) {
                 $start_time = $data['start'];
                 if (isset($data['start_time']) && (!isset($data['is_all_day']) || !$data['is_all_day'])) {
                     $data['is_all_day'] = 0;
                     $time_hack = $data['start_time'];
                     $time_hack = str_ireplace(_l("am"), '', $time_hack);
                     $time_hack = str_ireplace(_l("pm"), '', $time_hack);
                     $bits = explode(':', $time_hack);
                     if (strpos($data['end_time'], _l("pm"))) {
                         if ($bits[0] < 12) {
                             $bits[0] += 12;
                         }
                     }
                     // add the time if it exists
                     $start_time .= ' ' . implode(':', $bits) . ':00';
                     $data['start'] = strtotime(input_date($start_time, true));
                 } else {
                     $data['start'] = strtotime(input_date($start_time));
                 }
             }
             if (isset($data['end'])) {
                 $end_time = $data['end'];
                 if (isset($data['end_time']) && (!isset($data['is_all_day']) || !$data['is_all_day'])) {
                     $data['is_all_day'] = 0;
                     $time_hack = $data['end_time'];
                     $time_hack = str_ireplace(_l("am"), '', $time_hack);
                     $time_hack = str_ireplace(_l("pm"), '', $time_hack);
                     $bits = explode(':', $time_hack);
                     if (strpos($data['end_time'], _l("pm"))) {
                         if ($bits[0] < 12) {
                             $bits[0] += 12;
                         }
                     }
                     // add the time if it exists
                     $end_time .= ' ' . implode(':', $bits) . ':00';
                     //echo $end_time;
                     $data['end'] = strtotime(input_date($end_time, true));
                 } else {
                     $data['end'] = strtotime(input_date($end_time));
                 }
             }
             if (!$data['start'] || !$data['end']) {
                 $response['message'] = 'Missing Date';
             } else {
                 //print_r($_REQUEST); print_r($data); exit;
                 $calendar_id = update_insert('calendar_id', $calendar_id, 'calendar', $data);
                 if ($calendar_id) {
                     // save staff members.
                     $staff_ids = isset($_REQUEST['staff_ids']) && is_array($_REQUEST['staff_ids']) ? $_REQUEST['staff_ids'] : array();
                     delete_from_db('calendar_user_rel', 'calendar_id', $calendar_id);
                     foreach ($staff_ids as $staff_id) {
                         if ((int) $staff_id > 0) {
                             $sql = "INSERT INTO `" . _DB_PREFIX . "calendar_user_rel` SET calendar_id = " . (int) $calendar_id . ", user_id = " . (int) $staff_id;
                             query($sql);
                         }
                     }
                     $response['calendar_id'] = $calendar_id;
                     $response['message'] = 'Success';
                 } else {
                     $response['message'] = 'Error Saving';
                 }
             }
         } else {
             $response['message'] = 'Access Denied';
         }
         echo json_encode($response);
         exit;
     }
 }
    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']) {
        $calendar['subject'] = $_POST['title'];
    }
}
if ($calendar_id && module_calendar::can_i('edit', 'Calendar') || !$calendar_id && module_calendar::can_i('create', 'Calendar')) {
    // perms are good to go!
} else {
    die('Permission denied');
}
?>
<form action="" method="post" id="calendar_event_form">
<?php 
module_form::set_required(array('fields' => array('subject' => 'Subject', 'start' => 'Start Date', 'end' => 'End Date')));
$customer_list = array();
$customers = module_customer::get_customers();
foreach ($customers as $customer) {
    $customer_list[$customer['customer_id']] = $customer['customer_name'];
}
$staff_members = module_user::get_staff_members();
$staff_member_rel = array();
Example #3
0
      <div id="calhead" style="padding-left:1px;padding-right:1px;">
            <div class="cHead"><div class="ftitle">&nbsp;</div>
            <div id="loadingpannel" class="ptogtitle loadicon" style="display: none;"><?php 
_e('Loading data...');
?>
</div>
             <div id="errorpannel" class="ptogtitle loaderror" style="display: none;"><?php 
_e('Sorry, could not load your data, please try again later');
?>
</div>
            </div>

            <div id="caltoolbar" class="ctoolbar">
              <?php 
if (module_calendar::can_i('create', 'Calendar')) {
    ?>
<div id="faddbtn" class="fbutton">
                <div><span title='Click to Create New Event' class="addcal">
                <?php 
    _e('New Event');
    ?>
                </span></div>
            </div>
              <?php 
}
?>
                <div class="btnseparator"></div>
             <div id="showtodaybtn" class="fbutton">
                <div><span title='Click to back to today ' class="showtoday">
                <?php