diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index 4b33ee698..c8ac571bc 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -575,26 +575,38 @@ class Application_Service_HistoryService $instanceEnd = $showInstance->getDbEnds(null); $itemEnd = $item->getDbEnds(null); + $recordStart = $item->getDbStarts(null); $recordEnd = ($instanceEnd < $itemEnd) ? $instanceEnd : $itemEnd; - - $history = new CcPlayoutHistory(); - $history->setDbFileId($fileId); - $history->setDbStarts($item->getDbStarts(null)); - $history->setDbEnds($recordEnd); - $history->setDbInstanceId($item->getDbInstanceId()); - - foreach ($metadata as $key => $val) { - $meta = new CcPlayoutHistoryMetaData(); - $meta->setDbKey($key); - $meta->setDbValue($val); - - $history->addCcPlayoutHistoryMetaData($meta); - } - - $history->save($this->con); - } - - $this->con->commit(); + + //first check if this is a duplicate + // (caused by restarting liquidsoap) + + $prevRecord = CcPlayoutHistoryQuery::create() + ->filterByDbStarts($recordStart) + ->filterByDbEnds($recordEnd) + ->filterByDbFileId($fileId) + ->findOne($this->con); + + if (empty($prevRecord)) { + + $history = new CcPlayoutHistory(); + $history->setDbFileId($fileId); + $history->setDbStarts($recordStart); + $history->setDbEnds($recordEnd); + $history->setDbInstanceId($item->getDbInstanceId()); + + foreach ($metadata as $key => $val) { + $meta = new CcPlayoutHistoryMetaData(); + $meta->setDbKey($key); + $meta->setDbValue($val); + + $history->addCcPlayoutHistoryMetaData($meta); + } + + $history->save($this->con); + $this->con->commit(); + } + } } catch (Exception $e) { $this->con->rollback(); diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js index 69f3b900d..f28e405eb 100644 --- a/airtime_mvc/public/js/airtime/schedule/schedule.js +++ b/airtime_mvc/public/js/airtime/schedule/schedule.js @@ -13,8 +13,13 @@ var AIRTIME = (function(AIRTIME){ var serverTimezoneOffset = 0; function closeDialogCalendar(event, ui) { - //$("#schedule_calendar").fullCalendar( 'refetchEvents' ); - $(this).remove(); + + $el = $(this); + $el.dialog('destroy'); + $el.remove(); + + //need to refetch the events to update scheduled status. + $("#schedule_calendar").fullCalendar( 'refetchEvents' ); } function checkShowLength(json) {