예제 #1
0
 /**
  * destroy
  */
 public function destroy()
 {
     $res = new Reponse();
     $rec = Object\Shift::getById($this->id);
     if ($rec) {
         $rec->delete();
         $res->success = true;
         $res->message = 'Destroyed';
     } else {
         $res->message = "Failed to destroy";
     }
     return $res;
 }
예제 #2
0
 public function getEventsAction()
 {
     $this->requete = new Request();
     $data = $this->requete->params;
     $METHOD = $this->requete->method;
     // Short-circuit if the client did not give us a date range.
     if (!isset($data['start']) || !isset($data['end'])) {
         die("Veuillez indiquer une plage de dates/Please provide a date range.");
     }
     if ($data['timezone']) {
         date_default_timezone_set($data['timezone']);
     } else {
         date_default_timezone_set('Europe/Paris');
     }
     // Parse the start/end parameters.
     // These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
     // Since no timezone will be present, they will parsed as UTC.
     $range_start = Object\Shift::parseDateTime($data['start']);
     $range_end = Object\Shift::parseDateTime($data['end']);
     $data[] = $range_start->toString(\Zend_Date::ISO_8601);
     $data[] = $range_end->toString(\Zend_Date::ISO_8601);
     // Parse the timezone parameter if it is present.
     $input_arrays = $this->selectedLocation ? $this->selectedLocation->getShifts($range_start, $range_end) : array();
     //new Object\Shift\Listing (); // json_decode($json, true);
     // Accumulate an output array of event data arrays.
     $output_arrays = array();
     foreach ($input_arrays as $event) {
         if ($event->isWithinDayRange($range_start, $range_end)) {
             $output_arrays[] = $event->toCalendar();
         }
     }
     // Send JSON to the client.
     $reponse = new Reponse();
     $reponse->data = $output_arrays;
     // $input_arrays;
     $reponse->message = "TXT_SHIFTS_SENT";
     $reponse->success = true;
     $this->render($reponse);
 }
예제 #3
0
 public function getHolidaysAction()
 {
     $this->requete = new Request();
     $data = $this->requete->params;
     $METHOD = $this->requete->method;
     // Short-circuit if the client did not give us a date range.
     if (!isset($data['start']) || !isset($data['end'])) {
         die("Veuillez indiquer une plage de dates/Please provide a date range.");
     }
     if ($data['timezone']) {
         date_default_timezone_set($data['timezone']);
     } else {
         date_default_timezone_set('Europe/Paris');
     }
     // Parse the start/end parameters.
     // These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
     // Since no timezone will be present, they will parsed as UTC.
     $range_start = Object\Shift::parseDateTime($data['start']);
     $range_end = Object\Shift::parseDateTime($data['end']);
     $output_arrays = array();
     $reponse = new Reponse();
     $output_arrays = $this->getSpecialEventsAction($range_start, $range_end, $output_arrays);
     //exit;
     $reponse->data = $output_arrays;
     // $input_arrays;
     $reponse->message = "TXT_SHIFTS_SENT";
     $reponse->success = true;
     $this->render($reponse);
 }
예제 #4
0
 public function getEventsAction()
 {
     // PHP will fatal error if we attempt to use the DateTime class without this being set.
     date_default_timezone_set('UTC');
     // Short-circuit if the client did not give us a date range.
     if (!isset($_GET['start']) || !isset($_GET['end'])) {
         die("Please provide a date range.");
     }
     // Parse the start/end parameters.
     // These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
     // Since no timezone will be present, they will parsed as UTC.
     $range_start = Object\Shift::parseDateTime($_GET['start']);
     $range_end = Object\Shift::parseDateTime($_GET['end']);
     $data[] = $range_start->toString(\Zend_Date::ISO_8601);
     $data[] = $range_end->toString(\Zend_Date::ISO_8601);
     // Parse the timezone parameter if it is present.
     $timezone = null;
     if (isset($_GET['timezone'])) {
         $timezone = new DateTimeZone($_GET['timezone']);
     }
     // Read and parse our events JSON file into an array of event data arrays.
     $json = file_get_contents(PIMCORE_LAYOUTS_DIRECTORY . '/assets/json/events.json');
     $input_arrays = new Object\Shift\Listing();
     // json_decode($json, true);
     // Accumulate an output array of event data arrays.
     $output_arrays = array();
     foreach ($input_arrays as $event) {
         // Convert the input array into a useful Event object
         // $event2 = Object\Shift::create($event->toArray());
         // $event2->setKey(Pimcore_File::getValidFilename('New Name 10'));
         // $event2->setParentId(53);
         // $event2->save();
         // $output_arrays['new'] = $event2 ;
         // $data[]= $event->getEnd()->toString(\Zend_Date::ISO_8601);
         // If the event is in-bounds, add it to the output
         if ($event->isWithinDayRange($range_start, $range_end)) {
             $output_arrays[] = $event->toCalendar();
         }
     }
     // Send JSON to the client.
     $reponse = new Reponse();
     $reponse->data = $output_arrays;
     // $input_arrays;
     $reponse->message = "TXT_SHIFTS_SENT";
     $reponse->success = true;
     $this->render($reponse);
     // echo json_encode($output_arrays);
 }