From 079e93674467f4ceb4ab432bb947b21eb759db0c Mon Sep 17 00:00:00 2001 From: michael-grace Date: Wed, 3 Feb 2021 22:17:50 +0000 Subject: [PATCH 1/3] can't cancel show in past --- src/Classes/ServiceAPI/MyRadio_Timeslot.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Classes/ServiceAPI/MyRadio_Timeslot.php b/src/Classes/ServiceAPI/MyRadio_Timeslot.php index 8918eb20c..d3d33b1f2 100644 --- a/src/Classes/ServiceAPI/MyRadio_Timeslot.php +++ b/src/Classes/ServiceAPI/MyRadio_Timeslot.php @@ -811,8 +811,6 @@ public static function getCurrentAndNextObjects($time = null, $n = 1, $filter = * * @param string $reason , Why the episode was cancelled. * - * @todo Make the smarter - check if it's a programming team person, in which case just do this, if it's not then if - * >48hrs away just do it but email programming, but <48hrs should hide it but tell prog to confirm reason * @todo Response codes? i.e. error/db or error/403 etc */ public function cancelTimeslot($reason) @@ -822,6 +820,11 @@ public function cancelTimeslot($reason) //Yep, do an administrative drop $r = $this->cancelTimeslotAdmin($reason); } elseif ($this->getSeason()->getShow()->isCurrentUserAnOwner()) { + // Check if its in the past. Only admin drops can be in the past + if ($this->getStartTime() < time()) { + return false; + } + //Get if the User is a Creditor //Yaay, depending on time they can do an self-service drop or cancellation request if ($this->getStartTime() > time() + (48 * 3600)) { @@ -863,6 +866,7 @@ private function cancelTimeslotAdmin($reason) private function cancelTimeslotSelfService($reason) { + $r = $this->deleteTimeslot(); if (!$r) { return false; @@ -906,7 +910,7 @@ private function cancelTimeslotRequest($reason) ['show_season_timeslot_id' => $this->getID(), 'reason' => base64_encode($reason)] ); - MyRadioEmail::sendEmailToList(MyRadio_List::getByName('presenting'), 'Show Cancellation Request', $email); + MyRadioEmail::sendEmailToList(MyRadio_List::getByName('programming'), 'Show Cancellation Request', $email); return true; } From a5eb76316f9da4b1bde245030c663c7992d9ecb4 Mon Sep 17 00:00:00 2001 From: michael-grace Date: Wed, 3 Feb 2021 23:19:28 +0000 Subject: [PATCH 2/3] get future timeslots into programming --- schema/data-actions.json | 1 + schema/data-actionsauth.json | 1 + src/Classes/ServiceAPI/MyRadio_User.php | 29 +++++++++++++++++++++++ src/Controllers/Scheduler/programming.php | 19 +++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 src/Controllers/Scheduler/programming.php diff --git a/schema/data-actions.json b/schema/data-actions.json index 065fcefce..8eb887875 100644 --- a/schema/data-actions.json +++ b/schema/data-actions.json @@ -129,6 +129,7 @@ ["Scheduler", "allocate"], ["Scheduler", "attendance"], ["Scheduler", "default"], + ["Scheduler", "programming"], ["SIS", "remote"], ["SIS", "messages.markread"], ["SIS", "news.parse"], diff --git a/schema/data-actionsauth.json b/schema/data-actionsauth.json index fd394cd3a..453cfe2c0 100644 --- a/schema/data-actionsauth.json +++ b/schema/data-actionsauth.json @@ -147,6 +147,7 @@ ["Scheduler", "stop", "AUTH_STOPBROADCAST"], ["Scheduler", "upgrade", "AUTH_ALLOCATESLOTS"], ["Scheduler", "upgradeRefs", "AUTH_ALLOCATESLOTS"], + ["Scheduler", "programming", "AUTH_APPLYFORSHOW"], ["SIS", "default", "AUTH_USESIS"], ["SIS", "help.hide", "AUTH_USESIS"], ["SIS", "messages.markread", "AUTH_USESIS"], diff --git a/src/Classes/ServiceAPI/MyRadio_User.php b/src/Classes/ServiceAPI/MyRadio_User.php index 765199207..25fa5e4ef 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -1013,6 +1013,35 @@ public function getTimeline() return $events; } + /** + * Get upcoming shows for the user. + * This is for scheduling niceities, because Scheduler module isn't the most user friendly + * + * @return MyRadio_Timeslot[] + */ + + public function getUpcomingTimeslots() { + // fetchColumn to return ids, start_time needed in SQL because ordering and distinct :( + $result = self::$db->fetchColumn( + "SELECT DISTINCT(show_season_timeslot_id), show_season_timeslot.start_time FROM schedule.show_season_timeslot + INNER JOIN schedule.show_season USING (show_season_id) + INNER JOIN schedule.show USING (show_id) + INNER JOIN schedule.show_credit USING (show_id) + WHERE show_credit.creditid = $1 + AND show_season_timeslot.start_time > NOW() + AND show_credit.effective_to IS NULL + ORDER BY show_season_timeslot.start_time;", + [$this->memberid] + ); + + if (empty($result)) { + return []; + } else { + return MyRadio_Timeslot::resultSetToObjArray($result); + } + + } + /** * @param string $paramName The key to update, e.g. account_locked. * Don't be silly and try to set memberid. Bad things will happen. diff --git a/src/Controllers/Scheduler/programming.php b/src/Controllers/Scheduler/programming.php new file mode 100644 index 000000000..296fddd82 --- /dev/null +++ b/src/Controllers/Scheduler/programming.php @@ -0,0 +1,19 @@ +getUpcomingTimeslots(); + +CoreUtils::getTemplateObject()->setTemplate("table.twig") + ->addVariable("tablescript", "myradio.scheduler.programming") + ->addVariable("title", "Upcoming Timeslots") + ->addVariable("tabledata", CoreUtils::setToDataSource($upcomingTimeslots)) + ->render(); \ No newline at end of file From 131eb16cebbfd3c78bce1eee5227f69caa687683 Mon Sep 17 00:00:00 2001 From: michael-grace Date: Wed, 3 Feb 2021 23:43:27 +0000 Subject: [PATCH 3/3] start of all things programming page --- src/Classes/ServiceAPI/MyRadio_User.php | 9 ++--- src/Controllers/Scheduler/programming.php | 33 ++++++++++++++++--- .../js/myradio.scheduler.programming.js | 9 +++++ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 src/Public/js/myradio.scheduler.programming.js diff --git a/src/Classes/ServiceAPI/MyRadio_User.php b/src/Classes/ServiceAPI/MyRadio_User.php index 25fa5e4ef..19722de7d 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -1016,14 +1016,16 @@ public function getTimeline() /** * Get upcoming shows for the user. * This is for scheduling niceities, because Scheduler module isn't the most user friendly - * + * * @return MyRadio_Timeslot[] */ - public function getUpcomingTimeslots() { + public function getUpcomingTimeslots() + { // fetchColumn to return ids, start_time needed in SQL because ordering and distinct :( $result = self::$db->fetchColumn( - "SELECT DISTINCT(show_season_timeslot_id), show_season_timeslot.start_time FROM schedule.show_season_timeslot + "SELECT DISTINCT(show_season_timeslot_id), show_season_timeslot.start_time + FROM schedule.show_season_timeslot INNER JOIN schedule.show_season USING (show_season_id) INNER JOIN schedule.show USING (show_id) INNER JOIN schedule.show_credit USING (show_id) @@ -1039,7 +1041,6 @@ public function getUpcomingTimeslots() { } else { return MyRadio_Timeslot::resultSetToObjArray($result); } - } /** diff --git a/src/Controllers/Scheduler/programming.php b/src/Controllers/Scheduler/programming.php index 296fddd82..c7efe881e 100644 --- a/src/Controllers/Scheduler/programming.php +++ b/src/Controllers/Scheduler/programming.php @@ -2,18 +2,43 @@ /** * Controller for making basic programming and scheduling tasks easier, - * by giving user's a better interface + * by giving user"s a better interface * * 1. List Future Timeslots + * + * @todo Select timeslot link + * @todo Request new episodes (Big Deal) + * @todo Apply for more of your old shows (also needs terms page..aahh) */ use MyRadio\MyRadio\CoreUtils; +use MyRadio\MyRadio\URLUtils; use MyRadio\ServiceAPI\MyRadio_User; -$upcomingTimeslots = MyRadio_User::getInstance($_SESSION["memberid"])->getUpcomingTimeslots(); +$fullUpcomingTimeslots = MyRadio_User::getInstance($_SESSION["memberid"])->getUpcomingTimeslots(); + +$timeslots = []; + +foreach ($fullUpcomingTimeslots as $timeslot) { + $timeslots[] = [ + "Title" => $timeslot->getMeta("title"), + "Time" => CoreUtils::happyTime($timeslot->getStartTime()), + "Duration" => $timeslot->getDuration(), + "Cancel" => [ + "display" => "text", + "value" => "Cancel Episode", + "title" => "Cancel Episode", + "url" => URLUtils::makeURL( + "Scheduler", + "cancelEpisode", + ["show_season_timeslot_id" => $timeslot->getID()] + ), + ] + ]; +} CoreUtils::getTemplateObject()->setTemplate("table.twig") ->addVariable("tablescript", "myradio.scheduler.programming") - ->addVariable("title", "Upcoming Timeslots") - ->addVariable("tabledata", CoreUtils::setToDataSource($upcomingTimeslots)) + ->addVariable("title", "Your Upcoming Timeslots") + ->addVariable("tabledata", $timeslots) ->render(); \ No newline at end of file diff --git a/src/Public/js/myradio.scheduler.programming.js b/src/Public/js/myradio.scheduler.programming.js new file mode 100644 index 000000000..4f0c8d417 --- /dev/null +++ b/src/Public/js/myradio.scheduler.programming.js @@ -0,0 +1,9 @@ +$(".twig-datatable").dataTable({ + "aoColumns": [ + //Cancel + { + "bVisible": true + } + ], + "bPaginate": true +}); \ No newline at end of file