From d7a729e8b5fe7f7bbcf26644efefa8a4188e39a7 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 4 Aug 2023 14:09:08 +0100 Subject: [PATCH 1/5] Schedule : Add name filter, change Campaign column heading, allow filtering calendar by just layout or campaign. --- lib/Controller/Schedule.php | 6 ++++++ lib/Factory/ScheduleFactory.php | 14 ++++++++++++++ ui/src/core/xibo-calendar.js | 11 ++++++++--- views/inline.twig | 4 ++-- views/schedule-page.twig | 19 +++++++++++++------ 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/lib/Controller/Schedule.php b/lib/Controller/Schedule.php index 484b95034c..f58dd3e20c 100644 --- a/lib/Controller/Schedule.php +++ b/lib/Controller/Schedule.php @@ -304,6 +304,9 @@ public function eventData(Request $request, Response $response) 'geoAware' => $sanitizedParams->getInt('geoAware'), 'recurring' => $sanitizedParams->getInt('recurring'), 'eventTypeId' => $sanitizedParams->getInt('eventTypeId'), + 'name' => $sanitizedParams->getString('name'), + 'useRegexForName' => $sanitizedParams->getCheckbox('useRegexForName'), + 'logicalOperatorName' => $sanitizedParams->getString('logicalOperatorName'), ]; if ($campaignId != null) { @@ -2150,6 +2153,9 @@ public function grid(Request $request, Response $response) 'recurring' => $params->getInt('recurring'), 'campaignId' => $params->getInt('campaignId'), 'displayGroupIds' => $params->getIntArray('displayGroupIds'), + 'name' => $params->getString('name'), + 'useRegexForName' => $params->getCheckbox('useRegexForName'), + 'logicalOperatorName' => $params->getString('logicalOperatorName'), 'gridFilter' => 1 ], $params) ); diff --git a/lib/Factory/ScheduleFactory.php b/lib/Factory/ScheduleFactory.php index b6c8943300..2520c1b99d 100644 --- a/lib/Factory/ScheduleFactory.php +++ b/lib/Factory/ScheduleFactory.php @@ -553,6 +553,20 @@ public function query($sortOrder = null, $filterBy = []) $params['syncGroupId'] = $parsedFilter->getInt('syncGroupId'); } + if ($parsedFilter->getString('name') != null) { + $terms = explode(',', $parsedFilter->getString('name')); + $logicalOperator = $parsedFilter->getString('logicalOperatorName', ['default' => 'OR']); + $this->nameFilter( + 'schedule', + 'name', + $terms, + $body, + $params, + ($parsedFilter->getCheckbox('useRegexForName') == 1), + $logicalOperator + ); + } + // Sorting? $order = ''; if ($parsedFilter->getInt('gridFilter') === 1 && $sortOrder === null) { diff --git a/ui/src/core/xibo-calendar.js b/ui/src/core/xibo-calendar.js index 0ea85cc1da..c4aa969ab5 100644 --- a/ui/src/core/xibo-calendar.js +++ b/ui/src/core/xibo-calendar.js @@ -260,16 +260,21 @@ $(document).ready(function() { let eventTypes = $('#eventTypeId').serialize(); let geoAware = $('#geoAware').serialize(); let recurring = $('#recurring').serialize(); + let name = $('#name').serialize(); + let nameRegEx = 'useRegexForName=' + $('#useRegexForName').is('checked'); + let nameLogicalOperator = $('#logicalOperatorName').serialize(); - !displayGroups ? $calendarErrorMessage.show() : $calendarErrorMessage.hide() + !displayGroups && !displayLayouts ? $calendarErrorMessage.show() : $calendarErrorMessage.hide() var url = calendarOptions.eventSource; // Append the selected filters - url += '?' + displayLayouts + '&' + eventTypes + '&' + geoAware + '&' + recurring; + url += '?' + displayLayouts + '&' + eventTypes + '&' + geoAware + + '&' + recurring + '&' + name + + '&' + nameRegEx + '&' + nameLogicalOperator; // Should we append displays? - if (isShowAll) { + if (!displayGroups && displayLayouts !== '') { // Ignore the display list url += '&' + 'displayGroupIds[]=-1'; } else if (displayGroups !== '') { diff --git a/views/inline.twig b/views/inline.twig index 2977ab07ac..7689747990 100644 --- a/views/inline.twig +++ b/views/inline.twig @@ -238,8 +238,8 @@ {% endmacro %} -{% macro inputNameGrid(name, title) %} -
+{% macro inputNameGrid(name, title, groupClass) %} +
diff --git a/views/schedule-page.twig b/views/schedule-page.twig index e77edbc266..a7c0401b91 100644 --- a/views/schedule-page.twig +++ b/views/schedule-page.twig @@ -80,6 +80,9 @@ {% set title %}{% trans 'To Date' %}{% endset %} {{ inline.dateTime("toDt", title, "", "", "custom-date-range", "", "") }} + {% set title %}{% trans "Name" %}{% endset %} + {{ inline.inputNameGrid('name', title, "non-agenda-filter") }} + {% set title %}{% trans 'Event Type' %}{% endset %} {{ inline.dropdown("eventTypeId", "single", title, "", [{eventTypeId: null, eventTypeName: "All"}]|merge(eventTypes), "eventTypeId", "eventTypeName", "", "non-agenda-filter") }} @@ -191,7 +194,7 @@ {% trans 'Name' %} {% trans 'Start' %} {% trans 'End' %} - {% trans 'Campaign' %} + {% trans 'Event' %} {% trans 'Campaign ID' %} {% trans 'Display Groups' %} {% trans 'SoV' %} @@ -219,7 +222,7 @@
- {% trans "Please select a Display or Display Group to view the calendar" %} + {% trans "Please select a Display, Display Group or Layout / Campaign to view the calendar" %}
@@ -1229,7 +1232,9 @@ }); // Set up our show all selector control - $('#showAll, #eventTypeId, #recurring, #geoAware, #DisplayList, #DisplayGroupList', dialog) + $('#showAll, #eventTypeId, #recurring, #geoAware,' + + ' #DisplayList, #DisplayGroupList,' + + ' #name, #useRegexForName, #logicalOperatorName', dialog) .on('change', function () { setTimeout(calendar.view(), 1000); }); @@ -1357,10 +1362,12 @@ className: 'align-middle', responsivePriority: 2, data: function (data) { - if (data.eventTypeId !== 9) { - return data.campaign; - } else { + if (data.eventTypeId === 9) { return data.syncType; + } else if (data.eventTypeId === 2) { + return data.command; + } else { + return data.campaign; } } }, From b07a50313b641a94096cdc8e5962130a57151764 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 4 Aug 2023 14:21:34 +0100 Subject: [PATCH 2/5] phpcs. --- lib/Controller/Schedule.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/Controller/Schedule.php b/lib/Controller/Schedule.php index f58dd3e20c..8ce3c38207 100644 --- a/lib/Controller/Schedule.php +++ b/lib/Controller/Schedule.php @@ -417,8 +417,12 @@ public function eventData(Request $request, Response $response) $toDt = Carbon::createFromTimestamp($scheduleEvent->toDt); // Set the row from/to date to be an ISO date for display - $scheduleEvent->fromDt = Carbon::createFromTimestamp($scheduleEvent->fromDt)->format(DateFormatHelper::getSystemFormat()); - $scheduleEvent->toDt = Carbon::createFromTimestamp($scheduleEvent->toDt)->format(DateFormatHelper::getSystemFormat()); + $scheduleEvent->fromDt = + Carbon::createFromTimestamp($scheduleEvent->fromDt) + ->format(DateFormatHelper::getSystemFormat()); + $scheduleEvent->toDt = + Carbon::createFromTimestamp($scheduleEvent->toDt) + ->format(DateFormatHelper::getSystemFormat()); $this->getLog()->debug(sprintf('Start date is ' . $fromDt->toRssString() . ' ' . $scheduleEvent->fromDt)); $this->getLog()->debug(sprintf('End date is ' . $toDt->toRssString() . ' ' . $scheduleEvent->toDt)); @@ -525,7 +529,12 @@ public function eventList(Request $request, Response $response, $id) // Reset the seconds $date->second(0); - $this->getLog()->debug(sprintf('Generating eventList for DisplayGroupId ' . $id . ' on date ' . $date->format(DateFormatHelper::getSystemFormat()))); + $this->getLog()->debug( + sprintf( + 'Generating eventList for DisplayGroupId ' . $id . ' on date ' + . $date->format(DateFormatHelper::getSystemFormat()) + ) + ); // Get a list of scheduled events $events = []; @@ -799,7 +808,7 @@ private function calculateIntermediates($display, $displayGroup, $eventDisplayGr * @throws InvalidArgumentException * @throws NotFoundException */ - function addForm(Request $request, Response $response, ?string $from, ?int $id): Response|ResponseInterface + public function addForm(Request $request, Response $response, ?string $from, ?int $id): Response|ResponseInterface { // Get the display groups added to the session (if there are some) $displayGroupIds = $this->session->get('displayGroupIds'); @@ -1179,9 +1188,12 @@ public function add(Request $request, Response $response) throw new InvalidArgumentException(__('Please enter a from date'), 'fromDt'); } - $logToDt = isset($toDt) ? $toDt->format(DateFormatHelper::getSystemFormat()) : null; - $logRecurrenceRange = isset($recurrenceRange) ? $recurrenceRange->format(DateFormatHelper::getSystemFormat()) : null; - $this->getLog()->debug('Times received are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat()) . '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange); + $logToDt = $toDt?->format(DateFormatHelper::getSystemFormat()); + $logRecurrenceRange = $recurrenceRange?->format(DateFormatHelper::getSystemFormat()); + $this->getLog()->debug( + 'Times received are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat()) + . '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange + ); if (!$schedule->isCustomDayPart() && !$schedule->isAlwaysDayPart()) { // Daypart selected From 10a68b746be6578f18a48530b9f3324d25e768d4 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 4 Aug 2023 14:26:20 +0100 Subject: [PATCH 3/5] phpcs. --- lib/Controller/Schedule.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/Controller/Schedule.php b/lib/Controller/Schedule.php index 8ce3c38207..600f86d56c 100644 --- a/lib/Controller/Schedule.php +++ b/lib/Controller/Schedule.php @@ -1217,9 +1217,13 @@ public function add(Request $request, Response $response) } if ($recurrenceRange != null) { - $schedule->recurrenceRange = $recurrenceRange->setTime($recurrenceRange->hour, $recurrenceRange->minute, 0)->format('U'); + $schedule->recurrenceRange = + $recurrenceRange->setTime( + $recurrenceRange->hour, + $recurrenceRange->minute, + 0 + )->format('U'); } - } else { $schedule->fromDt = $fromDt->format('U'); @@ -1232,9 +1236,12 @@ public function add(Request $request, Response $response) } } - $logToDt = isset($toDt) ? $toDt->format(DateFormatHelper::getSystemFormat()) : null; - $logRecurrenceRange = isset($recurrenceRange) ? $recurrenceRange->format(DateFormatHelper::getSystemFormat()) : null; - $this->getLog()->debug('Processed times are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat()) . '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange ); + $logToDt = $toDt?->format(DateFormatHelper::getSystemFormat()); + $logRecurrenceRange = $recurrenceRange?->format(DateFormatHelper::getSystemFormat()); + $this->getLog()->debug( + 'Processed times are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat()) + . '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange + ); } // Ready to do the add From 7583d0aa542adf84b27035e145ae03eab3e415a1 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 4 Aug 2023 14:38:03 +0100 Subject: [PATCH 4/5] more phpcs. --- lib/Controller/Schedule.php | 74 ++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/lib/Controller/Schedule.php b/lib/Controller/Schedule.php index 600f86d56c..7903469836 100644 --- a/lib/Controller/Schedule.php +++ b/lib/Controller/Schedule.php @@ -855,7 +855,11 @@ public function addForm(Request $request, Response $response, ?string $from, ?in if (!empty($from) && !empty($id)) { $formNowData = [ 'eventTypeId' => $this->getEventTypeId($from), - 'campaign' => (($from == 'Campaign' || $from == 'Layout') ? $this->campaignFactory->getById($id) : null), + 'campaign' => ( + ($from == 'Campaign' || $from == 'Layout') + ? $this->campaignFactory->getById($id) + : null + ), 'displayGroup' => (($from == 'DisplayGroup') ? [$this->displayGroupFactory->getById($id)] : null), 'displayGroupId' => (($from == 'DisplayGroup') ? (int)$id : 0), 'mediaId' => (($from === 'Library') ? $id : null), @@ -908,21 +912,24 @@ public function addForm(Request $request, Response $response, ?string $from, ?in * @SWG\Parameter( * name="eventTypeId", * in="formData", - * description="The Event Type Id to use for this Event. 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action, 7=Media Library, 8=Playlist", + * description="The Event Type Id to use for this Event. + * 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action, 7=Media Library, 8=Playlist", * type="integer", * required=true * ), * @SWG\Parameter( * name="campaignId", * in="formData", - * description="The Campaign ID to use for this Event. If a Layout is needed then the Campaign specific ID for that Layout should be used.", + * description="The Campaign ID to use for this Event. + * If a Layout is needed then the Campaign specific ID for that Layout should be used.", * type="integer", * required=false * ), * @SWG\Parameter( * name="fullScreenCampaignId", * in="formData", - * description="For Media or Playlist eventyType. The Layout specific Campaign ID to use for this Event. This needs to be the Layout created with layout/fullscreen function", + * description="For Media or Playlist eventyType. The Layout specific Campaign ID to use for this Event. + * This needs to be the Layout created with layout/fullscreen function", * type="integer", * required=false * ), @@ -1172,7 +1179,10 @@ public function add(Request $request, Response $response) $schedule->recurrenceDetail = $sanitizedParams->getInt('recurrenceDetail'); $recurrenceRepeatsOn = $sanitizedParams->getIntArray('recurrenceRepeatsOn'); $schedule->recurrenceRepeatsOn = (empty($recurrenceRepeatsOn)) ? null : implode(',', $recurrenceRepeatsOn); - $schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt('recurrenceMonthlyRepeatsOn', ['default' => 0]); + $schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt( + 'recurrenceMonthlyRepeatsOn', + ['default' => 0] + ); foreach ($sanitizedParams->getIntArray('displayGroupIds', ['default' => []]) as $displayGroupId) { $schedule->assignDisplayGroup($this->displayGroupFactory->getById($displayGroupId)); @@ -1348,14 +1358,20 @@ function editForm(Request $request, Response $response, $id) $schedule->fromDt = ''; $schedule->toDt = ''; } else { - $schedule->fromDt = Carbon::createFromTimestamp($schedule->fromDt)->format(DateFormatHelper::getSystemFormat()); + $schedule->fromDt = + Carbon::createFromTimestamp($schedule->fromDt) + ->format(DateFormatHelper::getSystemFormat()); if ($schedule->toDt != null) { - $schedule->toDt = Carbon::createFromTimestamp($schedule->toDt)->format(DateFormatHelper::getSystemFormat()); + $schedule->toDt = + Carbon::createFromTimestamp($schedule->toDt) + ->format(DateFormatHelper::getSystemFormat()); } } if ($schedule->recurrenceRange != null) { - $schedule->recurrenceRange = Carbon::createFromTimestamp($schedule->recurrenceRange)->format(DateFormatHelper::getSystemFormat()); + $schedule->recurrenceRange = + Carbon::createFromTimestamp($schedule->recurrenceRange) + ->format(DateFormatHelper::getSystemFormat()); } // Get all reminders $scheduleReminders = $this->scheduleReminderFactory->query(null, ['eventId' => $id]); @@ -1383,19 +1399,22 @@ function editForm(Request $request, Response $response, $id) $this->getState()->template = 'schedule-form-edit'; $this->getState()->setData([ 'event' => $schedule, - 'campaigns' => $this->campaignFactory->query(null, ['isLayoutSpecific' => -1, 'retired' => 0, 'includeCampaignId' => $schedule->campaignId]), + 'campaigns' => $this->campaignFactory->query( + null, + ['isLayoutSpecific' => -1, 'retired' => 0, 'includeCampaignId' => $schedule->campaignId] + ), 'commands' => $this->commandFactory->query(), 'dayParts' => $this->dayPartFactory->allWithSystem(), 'displayGroups' => $schedule->displayGroups, 'campaign' => ($schedule->campaignId != '') ? $this->campaignFactory->getById($schedule->campaignId) : null, - 'displayGroupIds' => array_map(function($element) { + 'displayGroupIds' => array_map(function ($element) { return $element->displayGroupId; }, $schedule->displayGroups), 'layoutCodes' => $this->layoutFactory->getLayoutCodes(), 'reminders' => $scheduleReminders, 'defaultLat' => $defaultLat, 'defaultLong' => $defaultLong, - 'recurringEvent' => ($schedule->recurrenceType != '') ? true : false, + 'recurringEvent' => $schedule->recurrenceType != '', 'eventStart' => $eventStart, 'eventEnd' => $eventEnd, 'eventTypes' => \Xibo\Entity\Schedule::getEventTypesForm(), @@ -1415,7 +1434,7 @@ function editForm(Request $request, Response $response, $id) * @throws NotFoundException * @throws ControllerNotImplemented */ - function deleteRecurrenceForm(Request $request, Response $response, $id) + public function deleteRecurrenceForm(Request $request, Response $response, $id) { $sanitizedParams = $this->getSanitizer($request->getParams()); // Recurring event start/end @@ -1521,14 +1540,16 @@ public function deleteRecurrence(Request $request, Response $response, $id) * @SWG\Parameter( * name="eventTypeId", * in="formData", - * description="The Event Type Id to use for this Event. 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action", + * description="The Event Type Id to use for this Event. + * 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action", * type="integer", * required=true * ), * @SWG\Parameter( * name="campaignId", * in="formData", - * description="The Campaign ID to use for this Event. If a Layout is needed then the Campaign specific ID for that Layout should be used.", + * description="The Campaign ID to use for this Event. + * If a Layout is needed then the Campaign specific ID for that Layout should be used.", * type="integer", * required=false * ), @@ -1556,7 +1577,8 @@ public function deleteRecurrence(Request $request, Response $response, $id) * @SWG\Parameter( * name="displayGroupIds", * in="formData", - * description="The Display Group IDs for this event. Display specific Group IDs should be used to schedule on single displays.", + * description="The Display Group IDs for this event. + * Display specific Group IDs should be used to schedule on single displays.", * type="array", * required=true, * @SWG\Items(type="integer") @@ -1703,16 +1725,19 @@ public function edit(Request $request, Response $response, $id) ? $sanitizedParams->getInt('fullScreenCampaignId') : $sanitizedParams->getInt('campaignId'); $schedule->commandId = $sanitizedParams->getInt('commandId'); - $schedule->displayOrder = $sanitizedParams->getInt('displayOrder',['default' => $schedule->displayOrder]); + $schedule->displayOrder = $sanitizedParams->getInt('displayOrder', ['default' => $schedule->displayOrder]); $schedule->isPriority = $sanitizedParams->getInt('isPriority', ['default' => $schedule->isPriority]); - $schedule->dayPartId = $sanitizedParams->getInt('dayPartId',['default' => $schedule->dayPartId]); + $schedule->dayPartId = $sanitizedParams->getInt('dayPartId', ['default' => $schedule->dayPartId]); $schedule->syncTimezone = $sanitizedParams->getCheckbox('syncTimezone'); $schedule->syncEvent = $this->isSyncEvent($schedule->eventTypeId); $schedule->recurrenceType = $sanitizedParams->getString('recurrenceType'); $schedule->recurrenceDetail = $sanitizedParams->getInt('recurrenceDetail'); $recurrenceRepeatsOn = $sanitizedParams->getIntArray('recurrenceRepeatsOn'); $schedule->recurrenceRepeatsOn = (empty($recurrenceRepeatsOn)) ? null : implode(',', $recurrenceRepeatsOn); - $schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt('recurrenceMonthlyRepeatsOn', ['default' => 0]); + $schedule->recurrenceMonthlyRepeatsOn = $sanitizedParams->getInt( + 'recurrenceMonthlyRepeatsOn', + ['default' => 0] + ); $schedule->displayGroups = []; $schedule->isGeoAware = $sanitizedParams->getCheckbox('isGeoAware'); $schedule->actionType = $sanitizedParams->getString('actionType'); @@ -1787,9 +1812,12 @@ public function edit(Request $request, Response $response, $id) throw new InvalidArgumentException(__('Please enter a from date'). 'fromDt'); } - $logToDt = isset($toDt) ? $toDt->format(DateFormatHelper::getSystemFormat()) : null; - $logRecurrenceRange = isset($recurrenceRange) ? $recurrenceRange->format(DateFormatHelper::getSystemFormat()) : null; - $this->getLog()->debug('Times received are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat()) . '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange); + $logToDt = $toDt?->format(DateFormatHelper::getSystemFormat()); + $logRecurrenceRange = $recurrenceRange?->format(DateFormatHelper::getSystemFormat()); + $this->getLog()->debug( + 'Times received are: FromDt=' . $fromDt->format(DateFormatHelper::getSystemFormat()) + . '. ToDt=' . $logToDt . '. recurrenceRange=' . $logRecurrenceRange + ); if (!$schedule->isCustomDayPart() && !$schedule->isAlwaysDayPart()) { // Daypart selected @@ -1810,7 +1838,9 @@ public function edit(Request $request, Response $response, $id) $schedule->toDt = $toDt->setTime($toDt->hour, $toDt->minute, 0)->format('U'); } - $schedule->recurrenceRange = ($recurrenceRange === null) ? null : $recurrenceRange->setTime($recurrenceRange->hour, $recurrenceRange->minute, 0)->format('U'); + $schedule->recurrenceRange = ($recurrenceRange === null) + ? null + : $recurrenceRange->setTime($recurrenceRange->hour, $recurrenceRange->minute, 0)->format('U'); } else { $schedule->fromDt = $fromDt->format('U'); From 5ccfc5371a54973cd3b27c3e188c19ec8709908f Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 4 Aug 2023 14:52:53 +0100 Subject: [PATCH 5/5] even more phpcs. --- lib/Controller/Schedule.php | 3 ++- lib/Factory/ScheduleFactory.php | 32 +++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/Controller/Schedule.php b/lib/Controller/Schedule.php index 7903469836..729e0a97cd 100644 --- a/lib/Controller/Schedule.php +++ b/lib/Controller/Schedule.php @@ -2126,7 +2126,8 @@ private function getEventTypeId($from) * in="query", * required=false, * type="integer", - * description="Filter grid by eventTypeId. 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action, 7=Media Library, 8=Playlist" + * description="Filter grid by eventTypeId. + * 1=Layout, 2=Command, 3=Overlay, 4=Interrupt, 5=Campaign, 6=Action, 7=Media Library, 8=Playlist" * ), * @SWG\Parameter( * name="fromDt", diff --git a/lib/Factory/ScheduleFactory.php b/lib/Factory/ScheduleFactory.php index 2520c1b99d..74cbfc2cda 100644 --- a/lib/Factory/ScheduleFactory.php +++ b/lib/Factory/ScheduleFactory.php @@ -70,8 +70,16 @@ class ScheduleFactory extends BaseFactory * @param ScheduleExclusionFactory $scheduleExclusionFactory * @param User $user */ - public function __construct($config, $pool, $displayGroupFactory, $dayPartFactory, $userFactory, $scheduleReminderFactory, $scheduleExclusionFactory, $user) - { + public function __construct( + $config, + $pool, + $displayGroupFactory, + $dayPartFactory, + $userFactory, + $scheduleReminderFactory, + $scheduleExclusionFactory, + $user + ) { $this->setAclDependencies($user, $userFactory); $this->config = $config; $this->pool = $pool; @@ -478,19 +486,29 @@ public function query($sortOrder = null, $filterBy = []) // End both dates if ($parsedFilter->getIntArray('displayGroupIds') != null) { - $body .= ' AND `schedule`.eventId IN (SELECT `lkscheduledisplaygroup`.eventId FROM `lkscheduledisplaygroup` WHERE displayGroupId IN (' . implode(',', $parsedFilter->getIntArray('displayGroupIds')) . ')) '; + $body .= ' AND `schedule`.eventId IN (SELECT `lkscheduledisplaygroup`.eventId FROM `lkscheduledisplaygroup` + WHERE displayGroupId IN (' . implode(',', $parsedFilter->getIntArray('displayGroupIds')) . ')) '; } // Future schedules? - if ($parsedFilter->getInt('futureSchedulesFrom') !== null && $parsedFilter->getInt('futureSchedulesTo') === null) { + if ($parsedFilter->getInt('futureSchedulesFrom') !== null + && $parsedFilter->getInt('futureSchedulesTo') === null + ) { // Get schedules that end after this date, or that recur after this date - $body .= ' AND (IFNULL(`schedule`.toDt, `schedule`.fromDt) >= :futureSchedulesFrom OR `schedule`.recurrence_range >= :futureSchedulesFrom OR (IFNULL(`schedule`.recurrence_range, 0) = 0) AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\') '; + $body .= ' AND (IFNULL(`schedule`.toDt, `schedule`.fromDt) >= :futureSchedulesFrom + OR `schedule`.recurrence_range >= :futureSchedulesFrom OR (IFNULL(`schedule`.recurrence_range, 0) = 0) + AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\') '; $params['futureSchedulesFrom'] = $parsedFilter->getInt('futureSchedulesFrom'); } - if ($parsedFilter->getInt('futureSchedulesFrom') !== null && $parsedFilter->getInt('futureSchedulesTo') !== null) { + if ($parsedFilter->getInt('futureSchedulesFrom') !== null + && $parsedFilter->getInt('futureSchedulesTo') !== null + ) { // Get schedules that end after this date, or that recur after this date - $body .= ' AND ((schedule.fromDt < :futureSchedulesTo AND IFNULL(`schedule`.toDt, `schedule`.fromDt) >= :futureSchedulesFrom) OR `schedule`.recurrence_range >= :futureSchedulesFrom OR (IFNULL(`schedule`.recurrence_range, 0) = 0 AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\') ) '; + $body .= ' AND ((schedule.fromDt < :futureSchedulesTo + AND IFNULL(`schedule`.toDt, `schedule`.fromDt) >= :futureSchedulesFrom) + OR `schedule`.recurrence_range >= :futureSchedulesFrom OR (IFNULL(`schedule`.recurrence_range, 0) = 0 + AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\') ) '; $params['futureSchedulesFrom'] = $parsedFilter->getInt('futureSchedulesFrom'); $params['futureSchedulesTo'] = $parsedFilter->getInt('futureSchedulesTo'); }