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_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; } diff --git a/src/Classes/ServiceAPI/MyRadio_User.php b/src/Classes/ServiceAPI/MyRadio_User.php index 765199207..19722de7d 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -1013,6 +1013,36 @@ 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..c7efe881e --- /dev/null +++ b/src/Controllers/Scheduler/programming.php @@ -0,0 +1,44 @@ +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", "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