Example #1
0
 /**
  * Validate Data on Event Popup Window 
  * @access public
  * @return array results of Validation
  */
 public function validateData()
 {
     $json = '';
     $validate = new Form();
     $date1 = new DateTime($_REQUEST['date'] . ' ' . $_REQUEST['start_time']);
     $date2 = new DateTime($_REQUEST['date'] . ' ' . $_REQUEST['end_time']);
     $error['date'] = $validate->validateDate($date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'));
     if (!$error['date']) {
         $json['date'] = 'Invalid Date';
     }
     $error['description'] = $validate->validateText($_REQUEST['specifics'], 3, 1000);
     if (!$error['description']) {
         $json['description'] = 'Minimum 3 characters maximum 1000 characters';
     }
     $schedules = new Schedules();
     $appointments = $schedules->getAppointmentsByDate($_REQUEST['boardroom_id'], $date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'), $_REQUEST['schedule_id']);
     if ($appointments) {
         $json['appointments'] = $appointments[0];
     }
     if (!$json) {
         if ($appointments = $schedules->updateAppointments($date1->format('Y-m-d H:i:s'), $date2->format('Y-m-d H:i:s'), $_REQUEST)) {
             $json['success'] = "Event changed";
         } else {
             $json['success'] = "Something was broken";
         }
     }
     echo json_encode($json);
     die;
 }