Skip to content

Commit 23116a4

Browse files
Terms API
1 parent 581c08f commit 23116a4

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/Classes/ServiceAPI/MyRadio_Term.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function __construct($term_id) {
4040
$this->descr = $result['descr'] . date(" Y", strtotime($this->start_date));
4141
$this->num_weeks = (int) $result['weeks'];
4242
$this->week_names = json_decode($result['week_names']);
43+
if ($this->week_names == null) {
44+
$this->week_names = [];
45+
}
4346

4447
}
4548

@@ -80,9 +83,13 @@ public static function addTerm($start, $descr, $num_weeks)
8083
*/
8184
public static function getAllTerms($currentOnly = false)
8285
{
83-
$query = 'SELECT termid, EXTRACT(EPOCH FROM start) AS start FROM terms WHERE ';
84-
$query .= $currentOnly ? 'start <= now() AND ' : '';
85-
$query .= 'finish > now() ORDER BY start ASC';
86+
if ($currentOnly == "false") {
87+
$currentOnly = false;
88+
}
89+
90+
$query = 'SELECT termid, EXTRACT(EPOCH FROM start) AS start FROM terms ';
91+
$query .= $currentOnly ? 'WHERE start <= now() AND finish > now() ' : '';
92+
$query .= 'ORDER BY start ASC';
8693
$result = self::$db->fetchAll($query);
8794

8895
$terms = [];
@@ -202,10 +209,10 @@ public static function getTermForm()
202209
public function toDataSource($mixins = []) {
203210
return [
204211
"term_id" => $this->getID(),
205-
"descr" => $this->getTermDescr(),
212+
"start" => $this->getTermStartDate(),
213+
"descr" => $this->getTermDescr(),
206214
"num_weeks" => $this->getTermWeeks(),
207-
"week_names" => $this->getTermWeekNames(),
208-
"start" => $this->getTermStartDate()
215+
"week_names" => $this->getTermWeekNames()
209216
];
210217
}
211218
}

src/Public/js/myradio.scheduler.termlist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(".twig-datatable").dataTable({
22
"aaSorting": [[2, "desc"]],
33
"aoColumns": [
4-
//termid
4+
//term_id
55
{
66
"bVisible": false
77
},

0 commit comments

Comments
 (0)