예제 #1
0
 /**
  * 
  * @param array $data
  * @return results of insert new Event
  */
 protected function insert($data)
 {
     $schedules = new Schedules();
     $date_start = new DateTime($data['year'] . '-' . $data['month'] . '-' . $data['day'] . ' ' . $data['hour_start'] . ':' . $data['min_start']);
     $date_end = new DateTime($data['year'] . '-' . $data['month'] . '-' . $data['day'] . ' ' . $data['hour_end'] . ':' . $data['min_end']);
     if (!$data['recurring']) {
         if ($schedules->addAppointment($date_start->format('Y-m-d H:i:s'), $date_end->format('Y-m-d H:i:s'), $data)) {
             return $this->added($date_start->format('Y-m-d H:i') . ' - ' . $date_end->format('Y-m-d H:i'), $data['specifics']);
         } else {
             return $this->failed();
         }
     } else {
         if ($schedules->addRecurringAppointments($date_start->format('Y-m-d H:i:s'), $date_end->format('Y-m-d H:i:s'), $data)) {
             return $this->added($date_start->format('Y-m-d H:i') . ' - ' . $date_end->format('Y-m-d H:i'), $data['specifics']);
         } else {
             return $this->failed();
         }
     }
 }