Skip to content

Commit

Permalink
Terms API
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-grace authored May 29, 2024
1 parent 581c08f commit 23116a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/Classes/ServiceAPI/MyRadio_Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function __construct($term_id) {
$this->descr = $result['descr'] . date(" Y", strtotime($this->start_date));
$this->num_weeks = (int) $result['weeks'];
$this->week_names = json_decode($result['week_names']);
if ($this->week_names == null) {
$this->week_names = [];
}

}

Expand Down Expand Up @@ -80,9 +83,13 @@ public static function addTerm($start, $descr, $num_weeks)
*/
public static function getAllTerms($currentOnly = false)
{
$query = 'SELECT termid, EXTRACT(EPOCH FROM start) AS start FROM terms WHERE ';
$query .= $currentOnly ? 'start <= now() AND ' : '';
$query .= 'finish > now() ORDER BY start ASC';
if ($currentOnly == "false") {
$currentOnly = false;
}

$query = 'SELECT termid, EXTRACT(EPOCH FROM start) AS start FROM terms ';
$query .= $currentOnly ? 'WHERE start <= now() AND finish > now() ' : '';
$query .= 'ORDER BY start ASC';
$result = self::$db->fetchAll($query);

$terms = [];
Expand Down Expand Up @@ -202,10 +209,10 @@ public static function getTermForm()
public function toDataSource($mixins = []) {
return [
"term_id" => $this->getID(),
"descr" => $this->getTermDescr(),
"start" => $this->getTermStartDate(),
"descr" => $this->getTermDescr(),
"num_weeks" => $this->getTermWeeks(),
"week_names" => $this->getTermWeekNames(),
"start" => $this->getTermStartDate()
"week_names" => $this->getTermWeekNames()
];
}
}
2 changes: 1 addition & 1 deletion src/Public/js/myradio.scheduler.termlist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$(".twig-datatable").dataTable({
"aaSorting": [[2, "desc"]],
"aoColumns": [
//termid
//term_id
{
"bVisible": false
},
Expand Down

0 comments on commit 23116a4

Please sign in to comment.