Example #1
0
 private function getAppointmentCalendar(\DateTime $period, \Application\RoomItem $room, \Core\Database $db, \DBMappers\AppointmentItem $appMapper)
 {
     $result = array();
     $last_day = \Utility\DateHelper::GetLastDayInMonth($period);
     for ($i = 1; $i <= $last_day; $i++) {
         $query_date = \Utility\DateHelper::DateOfDay($period, $i);
         $result[$i] = $appMapper->getDayAppointments($room->getId(), $query_date, $db);
     }
     return $result;
 }
 public function getCrossingAppointments(\Application\AppointmentChain $chain, \DBMappers\AppointmentItem $mapper, \Core\Database $db)
 {
     $result = array();
     foreach ($chain as $appointment) {
         $day_apps = $mapper->getDayAppointments($appointment->getRoomId(), $appointment->getTimeStart(), $db);
         foreach ($day_apps as $match) {
             if (!is_null($appointment->getChain()) && $appointment->getChain() == $match->getChain()) {
                 continue;
                 // пропускаем, если из той же цепочки
             }
             if ($appointment->isCrossing($match->getTimeStart(), $match->getTimeEnd())) {
                 $result[] = $match;
             }
         }
     }
     return $result;
 }
Example #3
0
 public function delete($urlParameters, \Core\Http $http, \Core\Application $app, \Core\Database $db, \DBMappers\AppointmentItem $appMapper)
 {
     $appointment = $appMapper->getById($urlParameters[0], $db);
     $chain = $appMapper->getChain($appointment->getChain(), $db);
     $chain->applyFilter(new \DateTime());
     $deleted_count = 0;
     if ($http->post()['apply_chain_proxy'] == 1) {
         foreach ($chain as $member) {
             $appMapper->deleteById($member->getId(), $db);
             ++$deleted_count;
         }
     } else {
         if ($chain->isMeetFilter($appointment)) {
             $appMapper->deleteById($appointment->getId(), $db);
             ++$deleted_count;
         }
     }
     if ($deleted_count > 0) {
         $message = "{$deleted_count} events were deleted successfully.";
     } else {
         $message = 'No events were deleted.';
     }
     //error_log("\ndelete:" . print_r($urlParameters, true), 3, 'my_errors.txt');
     $app->setMessage($message);
     $app->setStateRedirect(DETAILS_RETURN_URL);
 }