Changes to schedule for frontend
This commit is contained in:
@@ -146,11 +146,9 @@ QUERY
|
||||
/**
|
||||
* Programmaschema per week
|
||||
*/
|
||||
public function schedule(Request $request, $weeksAhead = null) {
|
||||
if($weeksAhead === null) { $weeksAhead = 1; }
|
||||
else if($weeksAhead <= 0) { return abort(400); }
|
||||
$start = new \DateTimeImmutable('Monday this week');
|
||||
$einde = $start->add(\DateInterval::createFromDateString((int)$weeksAhead . ' weeks'));
|
||||
public function schedule(Request $request, $shiftWeeks = null) {
|
||||
$start = (new \DateTimeImmutable('Monday this week'))->add(\DateInterval::createFromDateString((int)$shiftWeeks . ' weeks'));
|
||||
$einde = $start->add(\DateInterval::createFromDateString('1 week'));
|
||||
|
||||
return response()->json($this->createSchedule($start, $einde));
|
||||
}
|
||||
@@ -231,30 +229,29 @@ QUERY
|
||||
$actieveProgrammas[$programma->priority] = $programma;
|
||||
for($prio = $programma->priority; $prio >= 0; --$prio) {
|
||||
if($actieveProgrammas[$prio] != null) {
|
||||
if(($index == -1) || ($schema[$index]['time'] != $tijdstip)) { $index++; }
|
||||
$schema[$index] = ['time' => $tijdstip, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
|
||||
if(($index == -1) || ($schema[$index]['starttime'] != $tijdstip)) { $index++; }
|
||||
$schema[$index] = ['starttime' => $tijdstip, 'endtime' => null, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else /*if($programmaWissel[PW_TYPE] == PROGRAMMA_EINDE)*/ {
|
||||
$actieveProgrammas[$programma->priority] = null;
|
||||
if(($index == -1) || ($schema[$index]['program'] != null)) { $index++; }
|
||||
$schema[$index] = ['time' => $tijdstip, 'program' => null];
|
||||
$schema[$index] = ['starttime' => $tijdstip, 'program' => null];
|
||||
for($prio = $programma->priority; $prio < count($actieveProgrammas); ++$prio) {
|
||||
if($actieveProgrammas[$prio] != null) {
|
||||
$schema[$index] = ['time' => $tijdstip, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
|
||||
$schema[$index] = ['starttime' => $tijdstip, 'endtime' => null, 'program' => $programmaInfo[$actieveProgrammas[$prio]->id]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(false) {
|
||||
for($i = 1; $i <= count($schema); $i++) {
|
||||
$eindTijd = ($i == count($schema)) ? $einde : $schema[$i]['time'];
|
||||
$programma = $schema[$i-1]['program'];
|
||||
print $schema[$i-1]['time']->format('D d-m-Y, H:i:s') . " - " . $eindTijd->format('D d-m-Y, H:i:s') . ": " . ($programma != null ? $programma->name : "NULL") . "\n";
|
||||
}
|
||||
for($i = 1; $i <= count($schema); $i++) {
|
||||
$eindTijd = ($i == count($schema)) ? $einde : $schema[$i]['starttime'];
|
||||
$schema[$i - 1]['endtime'] = $eindTijd;
|
||||
//$programma = $schema[$i-1]['program'];
|
||||
//print $schema[$i-1]['starttime']->format('D d-m-Y, H:i:s') . " - " . $eindTijd->format('D d-m-Y, H:i:s') . ": " . ($programma != null ? $programma->name : "NULL") . "\n";
|
||||
}
|
||||
|
||||
return ['startdate' => $start, 'enddate' => $einde, 'schedule' => $schema, 'errors' => $fouten];
|
||||
|
||||
@@ -30,7 +30,7 @@ $app->get('podcast/download/{id:\d+}/[{title}]', 'PodcastController@download' );
|
||||
$app->get('podcast/stream/{id:\d+}/[{title}]', 'PodcastController@stream' );
|
||||
|
||||
$app->get('programma/schema/nustraks', 'ProgramController@comingup' );
|
||||
$app->get('programma/schema/week[/{weeksAhead:\d+}]', 'ProgramController@schedule' );
|
||||
$app->get('programma/schema/week[/{shiftWeeks:-?\d+}]', 'ProgramController@schedule' );
|
||||
$app->get('/programma/details/{id:\d+}', 'ProgramController@details' );
|
||||
|
||||
// live/onair
|
||||
|
||||
Reference in New Issue
Block a user