diff --git a/api/BusinessLogic/Calendar/BusinessHours.php b/api/BusinessLogic/Calendar/BusinessHours.php new file mode 100644 index 00000000..27c41a41 --- /dev/null +++ b/api/BusinessLogic/Calendar/BusinessHours.php @@ -0,0 +1,15 @@ +calendarGateway->deleteEvent($id, $userContext, $heskSettings); } + + public function getBusinessHours($heskSettings) { + return $this->calendarGateway->getBusinessHours($heskSettings); + } } \ No newline at end of file diff --git a/api/Controllers/Calendar/CalendarController.php b/api/Controllers/Calendar/CalendarController.php index 0440f54a..df9a1cc3 100644 --- a/api/Controllers/Calendar/CalendarController.php +++ b/api/Controllers/Calendar/CalendarController.php @@ -124,4 +124,12 @@ class CalendarController extends \BaseClass { return $event; } + + static function getBusinessHours() { + global $applicationContext, $hesk_settings; + + $calendarHandler = $applicationContext->get(CalendarHandler::clazz()); + + return output($calendarHandler->getBusinessHours($hesk_settings)); + } } \ No newline at end of file diff --git a/api/DataAccess/Calendar/CalendarGateway.php b/api/DataAccess/Calendar/CalendarGateway.php index 39c73c44..f0f95885 100644 --- a/api/DataAccess/Calendar/CalendarGateway.php +++ b/api/DataAccess/Calendar/CalendarGateway.php @@ -4,6 +4,7 @@ namespace DataAccess\Calendar; use BusinessLogic\Calendar\AbstractEvent; +use BusinessLogic\Calendar\BusinessHours; use BusinessLogic\Calendar\CalendarEvent; use BusinessLogic\Calendar\ReminderUnit; use BusinessLogic\Calendar\SearchEventsFilter; @@ -243,4 +244,23 @@ class CalendarGateway extends CommonDao { $this->close(); } + + public function getBusinessHours($heskSettings) { + $this->init(); + + $rs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "mfh_calendar_business_hours`"); + $businessHours = array(); + while ($row = hesk_dbFetchAssoc($rs)) { + $businessHour = new BusinessHours(); + $businessHour->dayOfWeek = intval($row['day_of_week']); + $businessHour->startTime = $row['start_time']; + $businessHour->endTime = $row['end_time']; + + $businessHours[] = $businessHour; + } + + $this->close(); + + return $businessHours; + } } \ No newline at end of file diff --git a/api/index.php b/api/index.php index ebdb36c7..ec493347 100644 --- a/api/index.php +++ b/api/index.php @@ -211,6 +211,7 @@ Link::all(array( // Settings '/v1/settings' => action(\Controllers\Settings\SettingsController::clazz(), RequestMethod::all()), // Calendar + '/v1/calendar/business-hours' => action(\Controllers\Calendar\CalendarController::clazz() . '::getBusinessHours', array(RequestMethod::GET), SecurityHandler::OPEN), '/v1/calendar/events' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET), SecurityHandler::OPEN), '/v1/calendar/events/staff' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::GET, RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN), '/v1/calendar/events/staff/{i}' => action(\Controllers\Calendar\CalendarController::clazz(), array(RequestMethod::PUT, RequestMethod::DELETE), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),