converting to a jquery UI based datepicker.

This commit is contained in:
Naomi Aro 2013-08-16 15:12:00 -04:00
parent 7230b3ef58
commit 9b45b9dc72
7 changed files with 2197 additions and 64 deletions

View file

@ -55,7 +55,7 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/datatables/plugin/TableTools-2.1.5/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'js/bootstrap-datetime/bootstrap-datetimepicker.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery-ui-timepicker-addon.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$offset = date("Z") * -1; $offset = date("Z") * -1;
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds"); $this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
@ -67,13 +67,14 @@ class PlayouthistoryController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'js/datatables/plugin/TableTools-2.1.5/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/playouthistory.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/bootstrap-datetimepicker.min.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery-ui-timepicker-addon.css?'.$CC_CONFIG['airtime_version']);
//set datatables columns for display of data. //set datatables columns for display of data.
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$columns = json_encode($historyService->getDatatablesLogSheetColumns()); $columns = json_encode($historyService->getDatatablesLogSheetColumns());
$script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) ); "; $script = "localStorage.setItem( 'datatables-historyitem-aoColumns', JSON.stringify($columns) ); ";
$columns = json_encode($historyService->getDatatablesFileSummaryColumns()); $columns = json_encode($historyService->getDatatablesFileSummaryColumns());
$script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );"; $script.= "localStorage.setItem( 'datatables-historyfile-aoColumns', JSON.stringify($columns) );";
$this->view->headScript()->appendScript($script); $this->view->headScript()->appendScript($script);
@ -84,18 +85,18 @@ class PlayouthistoryController extends Zend_Controller_Action
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $current_time = time();
$params = $request->getParams(); $params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24)); $starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time); $ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); $startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$r = $historyService->getFileSummaryData($startsDT, $endsDT, $params); $r = $historyService->getFileSummaryData($startsDT, $endsDT, $params);
$this->view->sEcho = $r["sEcho"]; $this->view->sEcho = $r["sEcho"];
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"]; $this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
$this->view->iTotalRecords = $r["iTotalRecords"]; $this->view->iTotalRecords = $r["iTotalRecords"];
@ -112,19 +113,19 @@ class PlayouthistoryController extends Zend_Controller_Action
try { try {
$request = $this->getRequest(); $request = $this->getRequest();
$current_time = time(); $current_time = time();
$params = $request->getParams(); $params = $request->getParams();
$starts_epoch = $request->getParam("start", $current_time - (60*60*24)); $starts_epoch = $request->getParam("start", $current_time - (60*60*24));
$ends_epoch = $request->getParam("end", $current_time); $ends_epoch = $request->getParam("end", $current_time);
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC")); $startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
//$r = $historyService->getListView($startsDT, $endsDT, $params); //$r = $historyService->getListView($startsDT, $endsDT, $params);
$r = $historyService->getPlayedItemData($startsDT, $endsDT, $params); $r = $historyService->getPlayedItemData($startsDT, $endsDT, $params);
$this->view->sEcho = $r["sEcho"]; $this->view->sEcho = $r["sEcho"];
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"]; $this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
$this->view->iTotalRecords = $r["iTotalRecords"]; $this->view->iTotalRecords = $r["iTotalRecords"];
@ -155,10 +156,10 @@ class PlayouthistoryController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
Logging::info($params); Logging::info($params);
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$json = $historyService->createPlayedItem($params); $json = $historyService->createPlayedItem($params);
$this->_helper->json->sendJson($json); $this->_helper->json->sendJson($json);
} }
catch (Exception $e) { catch (Exception $e) {
@ -171,7 +172,7 @@ class PlayouthistoryController extends Zend_Controller_Action
{ {
$id = $this->_getParam('id', null); $id = $this->_getParam('id', null);
Logging::info("Id is: $id"); Logging::info("Id is: $id");
$populate = isset($id) ? true : false; $populate = isset($id) ? true : false;
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
@ -197,10 +198,10 @@ class PlayouthistoryController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
Logging::info($params); Logging::info($params);
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$json = $historyService->editPlayedItem($params); $json = $historyService->editPlayedItem($params);
$this->_helper->json->sendJson($json); $this->_helper->json->sendJson($json);
} }
catch (Exception $e) { catch (Exception $e) {
@ -225,7 +226,7 @@ class PlayouthistoryController extends Zend_Controller_Action
{ {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir(); $baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
@ -235,29 +236,29 @@ class PlayouthistoryController extends Zend_Controller_Action
} }
public function configureTemplateAction() { public function configureTemplateAction() {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir(); $baseUrl = Application_Common_OsPath::getBaseDir();
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/configuretemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
try { try {
$templateId = $this->_getParam('id'); $templateId = $this->_getParam('id');
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$template = $historyService->loadTemplate($templateId); $template = $historyService->loadTemplate($templateId);
$templateType = $template["type"]; $templateType = $template["type"];
$supportedTypes = $historyService->getSupportedTemplateTypes(); $supportedTypes = $historyService->getSupportedTemplateTypes();
if (!in_array($templateType, $supportedTypes)) { if (!in_array($templateType, $supportedTypes)) {
throw new Exception("Error: $templateType is not supported."); throw new Exception("Error: $templateType is not supported.");
} }
$getMandatoryFields = "mandatory".ucfirst($templateType)."Fields"; $getMandatoryFields = "mandatory".ucfirst($templateType)."Fields";
$mandatoryFields = $historyService->$getMandatoryFields(); $mandatoryFields = $historyService->$getMandatoryFields();
$this->view->template_id = $templateId; $this->view->template_id = $templateId;
$this->view->template_name = $template["name"]; $this->view->template_name = $template["name"];
$this->view->template_fields = $template["fields"]; $this->view->template_fields = $template["fields"];
@ -271,7 +272,7 @@ class PlayouthistoryController extends Zend_Controller_Action
Logging::info("Error?"); Logging::info("Error?");
Logging::info($e); Logging::info($e);
Logging::info($e->getMessage()); Logging::info($e->getMessage());
$this->_forward('template', 'playouthistory'); $this->_forward('template', 'playouthistory');
} }
} }
@ -279,34 +280,34 @@ class PlayouthistoryController extends Zend_Controller_Action
public function createTemplateAction() public function createTemplateAction()
{ {
$templateType = $this->_getParam('type', null); $templateType = $this->_getParam('type', null);
$request = $this->getRequest(); $request = $this->getRequest();
$params = $request->getPost(); $params = $request->getPost();
try { try {
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$supportedTypes = $historyService->getSupportedTemplateTypes(); $supportedTypes = $historyService->getSupportedTemplateTypes();
if (!in_array($templateType, $supportedTypes)) { if (!in_array($templateType, $supportedTypes)) {
throw new Exception("Error: $templateType is not supported."); throw new Exception("Error: $templateType is not supported.");
} }
$id = $historyService->createTemplate($params); $id = $historyService->createTemplate($params);
$this->view->url = $this->view->baseUrl("Playouthistory/configure-template/id/{$id}"); $this->view->url = $this->view->baseUrl("Playouthistory/configure-template/id/{$id}");
} }
catch (Exception $e) { catch (Exception $e) {
Logging::info($e); Logging::info($e);
Logging::info($e->getMessage()); Logging::info($e->getMessage());
$this->view->error = $e->getMessage(); $this->view->error = $e->getMessage();
} }
} }
public function setTemplateDefaultAction() public function setTemplateDefaultAction()
{ {
$templateId = $this->_getParam('id', null); $templateId = $this->_getParam('id', null);
try { try {
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$historyService->setConfiguredTemplate($templateId); $historyService->setConfiguredTemplate($templateId);
@ -318,11 +319,11 @@ class PlayouthistoryController extends Zend_Controller_Action
} }
public function updateTemplateAction() public function updateTemplateAction()
{ {
$templateId = $this->_getParam('id', null); $templateId = $this->_getParam('id', null);
$name = $this->_getParam('name', null); $name = $this->_getParam('name', null);
$fields = $this->_getParam('fields', array()); $fields = $this->_getParam('fields', array());
try { try {
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$historyService->updateItemTemplate($templateId, $name, $fields); $historyService->updateItemTemplate($templateId, $name, $fields);
@ -336,7 +337,7 @@ class PlayouthistoryController extends Zend_Controller_Action
public function deleteTemplateAction() public function deleteTemplateAction()
{ {
$templateId = $this->_getParam('id'); $templateId = $this->_getParam('id');
try { try {
$historyService = new Application_Service_HistoryService(); $historyService = new Application_Service_HistoryService();
$historyService->deleteTemplate($templateId); $historyService->deleteTemplate($templateId);

View file

@ -5,7 +5,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory
const ID_PREFIX = "his_item_"; const ID_PREFIX = "his_item_";
public function init() { public function init() {
parent::init(); parent::init();
$this->setDecorators(array( $this->setDecorators(array(
@ -17,7 +17,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory
$starts->setValidators(array( $starts->setValidators(array(
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT) new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)
)); ));
$starts->setAttrib('class', self::TEXT_INPUT_CLASS); $starts->setAttrib('class', self::TEXT_INPUT_CLASS." datepicker");
$starts->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT); $starts->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
$starts->addFilter('StringTrim'); $starts->addFilter('StringTrim');
$starts->setLabel(_('Start Time')); $starts->setLabel(_('Start Time'));
@ -29,7 +29,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory
$ends->setValidators(array( $ends->setValidators(array(
new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT) new Zend_Validate_Date(self::VALIDATE_DATETIME_FORMAT)
)); ));
$ends->setAttrib('class', self::TEXT_INPUT_CLASS); $ends->setAttrib('class', self::TEXT_INPUT_CLASS." datepicker");
$ends->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT); $ends->setAttrib('data-format', self::TIMEPICKER_DATETIME_FORMAT);
$ends->addFilter('StringTrim'); $ends->addFilter('StringTrim');
$ends->setLabel(_('End Time')); $ends->setLabel(_('End Time'));
@ -37,9 +37,9 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory
$ends->setRequired(true); $ends->setRequired(true);
$this->addElement($ends); $this->addElement($ends);
} }
public function createFromTemplate($template, $required) { public function createFromTemplate($template, $required) {
parent::createFromTemplate($template, $required); parent::createFromTemplate($template, $required);
} }
} }

View file

@ -13,21 +13,16 @@
<label for="<?php echo $name;?>"><?php echo $form->getElement($name)->getLabel() ?></label> <label for="<?php echo $name;?>"><?php echo $form->getElement($name)->getLabel() ?></label>
</dt> </dt>
<dd id="<?php echo $name;?>-element"> <dd id="<?php echo $name;?>-element">
<div class="well">
<div id="<?php echo $name;?>_datetimepicker" class="input-append date"> <?php echo $form->getElement($name) ?>
<?php echo $form->getElement($name) ?>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
<?php if ($form->getElement($name)->hasErrors()) : ?> <?php if ($form->getElement($name)->hasErrors()) : ?>
<ul class='errors'> <ul class='errors'>
<?php foreach ($form->getElement($name)->getMessages() as $error): ?> <?php foreach ($form->getElement($name)->getMessages() as $error): ?>
<li><?php echo $error; ?></li> <li><?php echo $error; ?></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<?php endforeach;?> <?php endforeach;?>
@ -45,7 +40,7 @@
<li><?php echo $error; ?></li> <li><?php echo $error; ?></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<?php endforeach; ?> <?php endforeach; ?>

View file

@ -0,0 +1,10 @@
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
.ui-timepicker-rtl{ direction: rtl; }
.ui-timepicker-rtl dl { text-align: right; }
.ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }

View file

@ -1552,9 +1552,6 @@ button, input {
background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png); background-image:url(redmond/images/ui-icons_ff5d1a_256x240.png);
} }
#ui-datepicker-div { z-index: 10 !important }
.button-bar-top { .button-bar-top {
text-align:right; text-align:right;
height:38px; height:38px;

View file

@ -220,11 +220,13 @@ var AIRTIME = (function(AIRTIME) {
$hisDialogEl.dialog({ $hisDialogEl.dialog({
title: $.i18n._("Edit History Record"), title: $.i18n._("Edit History Record"),
modal: true, modal: false,
open: function( event, ui ) { open: function( event, ui ) {
$hisDialogEl.find('.date').datetimepicker({ $hisDialogEl.find('.datepicker').datetimepicker({
"pick12HourFormat": false dateFormat: 'yy-mm-dd',
}); timeFormat: 'HH:mm:ss'
})
.blur();
}, },
close: function() { close: function() {
removeHistoryDialog(); removeHistoryDialog();

File diff suppressed because it is too large Load diff