PlayouthistoryController.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <?php
  2. class PlayouthistoryController extends Zend_Controller_Action
  3. {
  4. public function init()
  5. {
  6. $ajaxContext = $this->_helper->getHelper('AjaxContext');
  7. $ajaxContext
  8. ->addActionContext('file-history-feed', 'json')
  9. ->addActionContext('item-history-feed', 'json')
  10. ->addActionContext('show-history-feed', 'json')
  11. ->addActionContext('edit-file-item', 'json')
  12. ->addActionContext('create-list-item', 'json')
  13. ->addActionContext('edit-list-item', 'json')
  14. ->addActionContext('delete-list-item', 'json')
  15. ->addActionContext('delete-list-items', 'json')
  16. ->addActionContext('update-list-item', 'json')
  17. ->addActionContext('update-file-item', 'json')
  18. ->initContext();
  19. }
  20. public function indexAction()
  21. {
  22. $CC_CONFIG = Config::getConfig();
  23. $baseUrl = Application_Common_OsPath::getBaseDir();
  24. list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($this->getRequest());
  25. $userTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
  26. $startsDT->setTimezone($userTimezone);
  27. $endsDT->setTimezone($userTimezone);
  28. $form = new Application_Form_DateRange();
  29. $form->populate(array(
  30. 'his_date_start' => $startsDT->format("Y-m-d"),
  31. 'his_time_start' => $startsDT->format("H:i"),
  32. 'his_date_end' => $endsDT->format("Y-m-d"),
  33. 'his_time_end' => $endsDT->format("H:i")
  34. ));
  35. $this->view->date_form = $form;
  36. $this->view->headScript()->appendFile($baseUrl.'js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  37. $this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  38. $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  39. $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  40. $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  41. $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  42. $this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  43. $this->view->headScript()->appendFile($baseUrl.'js/bootstrap-datetime/bootstrap-datetimepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  44. $this->view->headScript()->appendFile($baseUrl.'js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  45. $this->view->headScript()->appendFile($baseUrl.'js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  46. $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
  47. $this->view->headLink()->appendStylesheet($baseUrl.'css/bootstrap-datetimepicker.min.css?'.$CC_CONFIG['airtime_version']);
  48. $this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
  49. $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
  50. $this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
  51. $this->view->headLink()->appendStylesheet($baseUrl.'css/history_styles.css?'.$CC_CONFIG['airtime_version']);
  52. $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
  53. //set datatables columns for display of data.
  54. $historyService = new Application_Service_HistoryService();
  55. $columns = json_encode($historyService->getDatatablesLogSheetColumns());
  56. $script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) ); ";
  57. $columns = json_encode($historyService->getDatatablesFileSummaryColumns());
  58. $script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );";
  59. $this->view->headScript()->appendScript($script);
  60. $user = Application_Model_User::getCurrentUser();
  61. $this->view->userType = $user->getType();
  62. }
  63. public function fileHistoryFeedAction()
  64. {
  65. try {
  66. $request = $this->getRequest();
  67. $params = $request->getParams();
  68. $instance = $request->getParam("instance_id", null);
  69. list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
  70. $historyService = new Application_Service_HistoryService();
  71. $r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
  72. $this->view->sEcho = $r["sEcho"];
  73. $this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
  74. $this->view->iTotalRecords = $r["iTotalRecords"];
  75. $this->view->history = $r["history"];
  76. }
  77. catch (Exception $e) {
  78. Logging::info($e);
  79. Logging::info($e->getMessage());
  80. }
  81. }
  82. public function itemHistoryFeedAction()
  83. {
  84. try {
  85. $request = $this->getRequest();
  86. $params = $request->getParams();
  87. $instance = $request->getParam("instance_id", null);
  88. list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
  89. $historyService = new Application_Service_HistoryService();
  90. $r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance);
  91. $this->view->sEcho = $r["sEcho"];
  92. $this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
  93. $this->view->iTotalRecords = $r["iTotalRecords"];
  94. $this->view->history = $r["history"];
  95. }
  96. catch (Exception $e) {
  97. Logging::info($e);
  98. Logging::info($e->getMessage());
  99. }
  100. }
  101. public function showHistoryFeedAction()
  102. {
  103. try {
  104. $request = $this->getRequest();
  105. $params = $request->getParams();
  106. $instance = $request->getParam("instance_id", null);
  107. list($startsDT, $endsDT) = Application_Common_HTTPHelper::getStartEndFromRequest($request);
  108. $historyService = new Application_Service_HistoryService();
  109. $shows = $historyService->getShowList($startsDT, $endsDT);
  110. $this->_helper->json->sendJson($shows);
  111. }
  112. catch (Exception $e) {
  113. Logging::info($e);
  114. Logging::info($e->getMessage());
  115. }
  116. }
  117. public function editFileItemAction()
  118. {
  119. $file_id = $this->_getParam('id');
  120. $historyService = new Application_Service_HistoryService();
  121. $form = $historyService->makeHistoryFileForm($file_id);
  122. $this->view->form = $form;
  123. $this->view->dialog = $this->view->render('playouthistory/dialog.phtml');
  124. unset($this->view->form);
  125. }
  126. public function createListItemAction()
  127. {
  128. try {
  129. $request = $this->getRequest();
  130. $params = $request->getPost();
  131. Logging::info($params);
  132. $historyService = new Application_Service_HistoryService();
  133. $json = $historyService->createPlayedItem($params);
  134. if (isset($json["form"])) {
  135. $this->view->form = $json["form"];
  136. $json["form"] = $this->view->render('playouthistory/dialog.phtml');
  137. unset($this->view->form);
  138. }
  139. $this->_helper->json->sendJson($json);
  140. }
  141. catch (Exception $e) {
  142. Logging::info($e);
  143. Logging::info($e->getMessage());
  144. }
  145. }
  146. public function editListItemAction()
  147. {
  148. $id = $this->_getParam('id', null);
  149. $populate = isset($id) ? true : false;
  150. $historyService = new Application_Service_HistoryService();
  151. $form = $historyService->makeHistoryItemForm($id, $populate);
  152. $this->view->form = $form;
  153. $this->view->dialog = $this->view->render('playouthistory/dialog.phtml');
  154. unset($this->view->form);
  155. }
  156. public function deleteListItemAction()
  157. {
  158. $history_id = $this->_getParam('id');
  159. $historyService = new Application_Service_HistoryService();
  160. $historyService->deletePlayedItem($history_id);
  161. }
  162. public function deleteListItemsAction()
  163. {
  164. $history_ids = $this->_getParam('ids');
  165. $historyService = new Application_Service_HistoryService();
  166. $historyService->deletePlayedItems($history_ids);
  167. }
  168. public function updateListItemAction()
  169. {
  170. try {
  171. $request = $this->getRequest();
  172. $params = $request->getPost();
  173. Logging::info($params);
  174. $historyService = new Application_Service_HistoryService();
  175. $json = $historyService->editPlayedItem($params);
  176. if (isset($json["form"])) {
  177. $this->view->form = $json["form"];
  178. $json["form"] = $this->view->render('playouthistory/dialog.phtml');
  179. unset($this->view->form);
  180. }
  181. $this->_helper->json->sendJson($json);
  182. }
  183. catch (Exception $e) {
  184. Logging::info($e);
  185. Logging::info($e->getMessage());
  186. }
  187. }
  188. public function updateFileItemAction()
  189. {
  190. $request = $this->getRequest();
  191. $params = $request->getPost();
  192. Logging::info($params);
  193. $historyService = new Application_Service_HistoryService();
  194. $json = $historyService->editPlayedFile($params);
  195. $this->_helper->json->sendJson($json);
  196. }
  197. }