From f6e3cae17e7a059c45ad83b4744732f8abda3a69 Mon Sep 17 00:00:00 2001
From: Naomi <naomiaro@gmail.com>
Date: Wed, 2 Apr 2014 12:02:35 -0400
Subject: [PATCH] CC-5766 : Fix Show Contents action on calendar

removed a lot of old useless view files.
fixed a conversion for boolean fields in history.
---
 .../controllers/ScheduleController.php        | 11 ++--
 .../application/models/ShowInstance.php       | 65 -------------------
 .../views/scripts/schedule/add-show.phtml     |  0
 .../schedule/cancel-current-show.phtml        |  0
 .../views/scripts/schedule/cancel-show.phtml  |  0
 .../views/scripts/schedule/clear-show.phtml   |  0
 .../views/scripts/schedule/delete-show.phtml  |  0
 .../views/scripts/schedule/edit-show.phtml    |  1 -
 .../views/scripts/schedule/event-feed.phtml   |  0
 .../schedule/get-current-playlist.phtml       |  3 -
 .../views/scripts/schedule/get-form.phtml     |  1 -
 .../scripts/schedule/get-show-data.phtml      |  3 -
 .../scripts/schedule/make-context-menu.phtml  |  0
 .../views/scripts/schedule/move-show.phtml    |  0
 .../views/scripts/schedule/remove-group.phtml |  0
 .../views/scripts/schedule/resize-show.phtml  |  0
 .../scripts/schedule/schedule-show.phtml      |  7 --
 .../schedule/show-content-dialog.phtml        | 30 +--------
 .../views/scripts/schedule/show-list.phtml    |  2 -
 .../js/airtime/library/lib_separate_table.js  |  4 +-
 .../js/airtime/playouthistory/historytable.js |  2 +-
 .../public/js/airtime/schedule/schedule.js    | 14 +---
 22 files changed, 12 insertions(+), 131 deletions(-)
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/add-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/cancel-current-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/cancel-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/clear-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/delete-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/edit-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/event-feed.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/get-current-playlist.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/get-form.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/get-show-data.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/make-context-menu.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/move-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/remove-group.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/resize-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/schedule-show.phtml
 delete mode 100644 airtime_mvc/application/views/scripts/schedule/show-list.phtml

diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php
index e2f574782..8c6ba4366 100644
--- a/airtime_mvc/application/controllers/ScheduleController.php
+++ b/airtime_mvc/application/controllers/ScheduleController.php
@@ -20,7 +20,6 @@ class ScheduleController extends Zend_Controller_Action
                     ->addActionContext('show-content-dialog', 'json')
                     ->addActionContext('clear-show', 'json')
                     ->addActionContext('get-current-playlist', 'json')
-                    ->addActionContext('remove-group', 'json')
                     ->addActionContext('populate-show-form', 'json')
                     ->addActionContext('populate-repeating-show-instance-form', 'json')
                     ->addActionContext('delete-show', 'json')
@@ -351,13 +350,13 @@ class ScheduleController extends Zend_Controller_Action
                     $originalDateTime->format("l, F jS"),
                     $originalDateTime->format("G:i"));
         }
-        $this->view->showLength = $show->getShowLength();
-        $this->view->timeFilled = $show->getTimeScheduled();
-        $this->view->percentFilled = $show->getPercentScheduled();
-        $this->view->showContent = $show->getShowListContent();
+        //$this->view->showLength = $show->getShowLength();
+        //$this->view->timeFilled = $show->getTimeScheduled();
+        //$this->view->percentFilled = $show->getPercentScheduled();
+        //$this->view->showContent = $show->getShowListContent();
         $this->view->dialog = $this->view->render('schedule/show-content-dialog.phtml');
         $this->view->showTitle = htmlspecialchars($show->getName());
-        unset($this->view->showContent);
+        //unset($this->view->showContent);
     }
 
     public function populateRepeatingShowInstanceFormAction()
diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php
index cdcfc6e4d..76bf1ce2e 100644
--- a/airtime_mvc/application/models/ShowInstance.php
+++ b/airtime_mvc/application/models/ShowInstance.php
@@ -538,71 +538,6 @@ SQL;
     {
         $con = Propel::getConnection();
 
-        $sql = <<<SQL
-SELECT *
-FROM (
-        (SELECT s.starts,
-                0::INTEGER as type ,
-                f.id           AS item_id,
-                f.track_title,
-                f.album_title  AS album,
-                f.genre        AS genre,
-                f.length       AS length,
-                f.artist_name  AS creator,
-                f.file_exists  AS EXISTS,
-                f.filepath     AS filepath,
-                f.mime         AS mime
-         FROM cc_schedule AS s
-         LEFT JOIN cc_files AS f ON f.id = s.file_id
-         WHERE s.instance_id = :instance_id1
-           AND s.playout_status >= 0
-           AND s.file_id IS NOT NULL
-           AND f.hidden = 'false')
-      UNION
-        (SELECT s.starts,
-                1::INTEGER as type,
-                ws.id AS item_id,
-                (ws.name || ': ' || ws.url) AS title,
-                null            AS album,
-                null            AS genre,
-                ws.length       AS length,
-                sub.login       AS creator,
-                't'::boolean    AS EXISTS,
-                ws.url          AS filepath,
-                ws.mime as mime
-         FROM cc_schedule AS s
-         LEFT JOIN cc_webstream AS ws ON ws.id = s.stream_id
-         LEFT JOIN cc_subjs AS sub ON ws.creator_id = sub.id
-         WHERE s.instance_id = :instance_id2
-           AND s.playout_status >= 0
-           AND s.stream_id IS NOT NULL)) AS temp
-ORDER BY starts;
-SQL;
-
-        $stmt = $con->prepare($sql);
-        $stmt->execute(array(
-            ':instance_id1' => $this->_instanceId,
-            ':instance_id2' => $this->_instanceId
-        ));
-        $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
-        
-        $userTimezone = Application_Model_Preference::GetUserTimezone();
-        $displayTimezone = new DateTimeZone($userTimezone);
-        $utcTimezone = new DateTimeZone("UTC");
-
-        foreach ($results as &$row) {
-
-            $dt = new DateTime($row["starts"], $utcTimezone);
-            $dt->setTimezone($displayTimezone);
-            $row["starts"] = $dt->format("Y-m-d H:i:s");
-
-            if (isset($row['length'])) {
-                $formatter = new LengthFormatter($row["length"]);
-                $row["length"] = $formatter->format();
-            }
-        }
-
-
         return $results;
     }
 
diff --git a/airtime_mvc/application/views/scripts/schedule/add-show.phtml b/airtime_mvc/application/views/scripts/schedule/add-show.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/cancel-current-show.phtml b/airtime_mvc/application/views/scripts/schedule/cancel-current-show.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/cancel-show.phtml b/airtime_mvc/application/views/scripts/schedule/cancel-show.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/clear-show.phtml b/airtime_mvc/application/views/scripts/schedule/clear-show.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/delete-show.phtml b/airtime_mvc/application/views/scripts/schedule/delete-show.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/edit-show.phtml b/airtime_mvc/application/views/scripts/schedule/edit-show.phtml
deleted file mode 100644
index bf01724e3..000000000
--- a/airtime_mvc/application/views/scripts/schedule/edit-show.phtml
+++ /dev/null
@@ -1 +0,0 @@
-//left empty on purpose
diff --git a/airtime_mvc/application/views/scripts/schedule/event-feed.phtml b/airtime_mvc/application/views/scripts/schedule/event-feed.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/get-current-playlist.phtml b/airtime_mvc/application/views/scripts/schedule/get-current-playlist.phtml
deleted file mode 100644
index 789c0e6d5..000000000
--- a/airtime_mvc/application/views/scripts/schedule/get-current-playlist.phtml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php 
-echo $this->entries;
-?>
diff --git a/airtime_mvc/application/views/scripts/schedule/get-form.phtml b/airtime_mvc/application/views/scripts/schedule/get-form.phtml
deleted file mode 100644
index bf01724e3..000000000
--- a/airtime_mvc/application/views/scripts/schedule/get-form.phtml
+++ /dev/null
@@ -1 +0,0 @@
-//left empty on purpose
diff --git a/airtime_mvc/application/views/scripts/schedule/get-show-data.phtml b/airtime_mvc/application/views/scripts/schedule/get-show-data.phtml
deleted file mode 100644
index 0b7c8ed63..000000000
--- a/airtime_mvc/application/views/scripts/schedule/get-show-data.phtml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-    echo $this->data;
-?>
\ No newline at end of file
diff --git a/airtime_mvc/application/views/scripts/schedule/make-context-menu.phtml b/airtime_mvc/application/views/scripts/schedule/make-context-menu.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/move-show.phtml b/airtime_mvc/application/views/scripts/schedule/move-show.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/remove-group.phtml b/airtime_mvc/application/views/scripts/schedule/remove-group.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/resize-show.phtml b/airtime_mvc/application/views/scripts/schedule/resize-show.phtml
deleted file mode 100644
index e69de29bb..000000000
diff --git a/airtime_mvc/application/views/scripts/schedule/schedule-show.phtml b/airtime_mvc/application/views/scripts/schedule/schedule-show.phtml
deleted file mode 100644
index 5630d2598..000000000
--- a/airtime_mvc/application/views/scripts/schedule/schedule-show.phtml
+++ /dev/null
@@ -1,7 +0,0 @@
-<div id="schedule_playlist_dialog">
-	<input id="schedule_playlist_search" type="text"></input>
-	<div>
-		<ul id="schedule_playlist_choice"></ul>
-		<ul id="schedule_playlist_chosen"></ul>
-	</div>
-</div>
diff --git a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml
index 799b10d2a..ee13b8526 100644
--- a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml
+++ b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml
@@ -1,31 +1,3 @@
 <div id="show_content_dialog">
-<div><?php echo $this->additionalShowInfo; ?></div>
-<table width="100%" border="0" cellspacing="0" cellpadding="0" class="datatable">
-    <tr>
-        <th><?php echo _("Start") ?></th>
-        <th><?php echo _("Title") ?></th>
-        <th><?php echo _("Creator") ?></th>
-        <th><?php echo _("Album") ?></th>
-        <th><?php echo _("Length") ?></th>
-        <th><?php echo _("Genre") ?></th>
-    </tr>
-<?php $i=0; ?>
-<?php foreach($this->showContent as $row): ?>
-    <tr id="au_<?php echo $row["item_id"] ?>" class="<?php if($i&1){echo "even";}else{echo "odd";}?>">
-        <td><?php echo $row["starts"] ?></td>
-        <td><?php echo $this->escape($row["track_title"]) ?></td>
-        <td><?php echo $this->escape($row["creator"]) ?></td>
-        <td><?php echo $this->escape($row["album"]) ?></td>
-        <td class="library_length"><?php echo $row["length"] ?></td>
-        <td><?php echo $row["genre"] ?></td>
-    </tr>
-<?php $i=$i+1; ?>
-<?php endforeach; ?>
-</table>
-<br/>
-<div id="show_time_info">
-    <span id="show_time_filled" class="time"><?php echo $this->timeFilled; ?></span>
-    <div id="show_progressbar"></div>
-    <span id="show_length" class="time"><?php echo $this->showLength; ?></span>
-</div>
+	<div><?php echo $this->additionalShowInfo; ?></div>
 </div>
diff --git a/airtime_mvc/application/views/scripts/schedule/show-list.phtml b/airtime_mvc/application/views/scripts/schedule/show-list.phtml
deleted file mode 100644
index 939ab6afd..000000000
--- a/airtime_mvc/application/views/scripts/schedule/show-list.phtml
+++ /dev/null
@@ -1,2 +0,0 @@
-<div id='json-string'></div>
-<div id='demo'></div>
\ No newline at end of file
diff --git a/airtime_mvc/public/js/airtime/library/lib_separate_table.js b/airtime_mvc/public/js/airtime/library/lib_separate_table.js
index e0c4e5118..bbe0e08a8 100644
--- a/airtime_mvc/public/js/airtime/library/lib_separate_table.js
+++ b/airtime_mvc/public/js/airtime/library/lib_separate_table.js
@@ -302,7 +302,7 @@ var AIRTIME = (function(AIRTIME) {
 			"bJQueryUI": true,
 			"bAutoWidth": true,
 			
-			"sDom": 'Rlf<"btn-table-search"><"dt-process-rel"r><"H"<"library_toolbar"C>><"dataTables_scrolling"t><"F"ip>',
+			"sDom": 'Rlf<"dt-process-rel"r><"H"<"library_toolbar"C>><"dataTables_scrolling"t><"F"ip>',
 			
 			"oColVis": {
 				"sAlign": "right",
@@ -346,7 +346,7 @@ var AIRTIME = (function(AIRTIME) {
 	        	});
 	        	
 	        	//append a search button
-	        	$panel.find(".dataTables_filter").append('<button class="btn btn-search" type="button">Search</button>');
+	        	$panel.find(".dataTables_filter").append('<button class="btn btn-small btn-search" type="button">Search</button>');
 	        	
 	        	//only search on enter.
 	        	$panel.on("keypress", ".advanced_search input", function(e) {
diff --git a/airtime_mvc/public/js/airtime/playouthistory/historytable.js b/airtime_mvc/public/js/airtime/playouthistory/historytable.js
index 5c431ddeb..cef8029be 100644
--- a/airtime_mvc/public/js/airtime/playouthistory/historytable.js
+++ b/airtime_mvc/public/js/airtime/playouthistory/historytable.js
@@ -393,7 +393,7 @@ var AIRTIME = (function(AIRTIME) {
         	
         	for (b in booleans) {
             	
-            	text = aData[b] ? checkedCheckBox : emptyCheckBox;
+            	text = aData[b] === "1" ? checkedCheckBox : emptyCheckBox;
             	text = text + " " + booleans[b];
             	
             	$nRow.find(".his_"+b).html(text);
diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js
index 485e10dd8..9b5153190 100644
--- a/airtime_mvc/public/js/airtime/schedule/schedule.js
+++ b/airtime_mvc/public/js/airtime/schedule/schedule.js
@@ -171,9 +171,7 @@ function buildScheduleDialog (json, instance_id) {
             {
                 text: $.i18n._("Ok"),
                 "class": "btn",
-                click: function() {
-                    $(this).dialog("close");
-                }
+                click: closeDialogCalendar
             }
         ]
     });
@@ -211,10 +209,6 @@ function buildContentDialog (json){
         alertShowErrorAndReload();
     }
           
-    dialog.find("#show_progressbar").progressbar({
-        value: json.percentFilled
-    });
-     
     dialog.dialog({
         autoOpen: false,
         title: $.i18n._("Contents of Show") +" '" + json.showTitle + "'",
@@ -226,9 +220,7 @@ function buildContentDialog (json){
             {
                 text: $.i18n._("Ok"),
                 "class": "btn",
-                click: function() {
-                    dialog.remove();
-                }
+                click: closeDialogCalendar
             }
         ]
     });
@@ -416,7 +408,7 @@ $(document).ready(function() {
                     
                     callback = function() {
                         $.get(oItems.content.url, {format: "json", id: data.id}, function(json){
-                            buildContentDialog(json);
+                            buildContentDialog(json, data.id);
                         });
                     };
                     oItems.content.callback = callback;