Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Scheduler #979

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schema/data-actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
["Scheduler", "allocate"],
["Scheduler", "attendance"],
["Scheduler", "default"],
["Scheduler", "programming"],
["SIS", "remote"],
["SIS", "messages.markread"],
["SIS", "news.parse"],
Expand Down
1 change: 1 addition & 0 deletions schema/data-actionsauth.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
10 changes: 7 additions & 3 deletions src/Classes/ServiceAPI/MyRadio_Timeslot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)) {
Expand Down Expand Up @@ -863,6 +866,7 @@ private function cancelTimeslotAdmin($reason)

private function cancelTimeslotSelfService($reason)
{

$r = $this->deleteTimeslot();
if (!$r) {
return false;
Expand Down Expand Up @@ -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;
}

Expand Down
30 changes: 30 additions & 0 deletions src/Classes/ServiceAPI/MyRadio_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
44 changes: 44 additions & 0 deletions src/Controllers/Scheduler/programming.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* Controller for making basic programming and scheduling tasks easier,
* 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;

$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", "Your Upcoming Timeslots")
->addVariable("tabledata", $timeslots)
->render();
9 changes: 9 additions & 0 deletions src/Public/js/myradio.scheduler.programming.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$(".twig-datatable").dataTable({
"aoColumns": [
//Cancel
{
"bVisible": true
}
],
"bPaginate": true
});