history records for a show have times validated within show range.
This commit is contained in:
parent
5a8957273f
commit
15e27f8166
|
@ -202,7 +202,6 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
public function editListItemAction()
|
||||
{
|
||||
$id = $this->_getParam('id', null);
|
||||
Logging::info("Id is: $id");
|
||||
|
||||
$populate = isset($id) ? true : false;
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'cc_subjs' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
|
@ -27,4 +25,15 @@ class CcSubjs extends BaseCcSubjs {
|
|||
->filterByDbHost($this->getDbId())
|
||||
->count() > 0;
|
||||
}
|
||||
|
||||
public function isHostOfShowInstance($instanceId)
|
||||
{
|
||||
$showInstance = CcShowInstancesQuery::create()
|
||||
->findPk($instanceId);
|
||||
|
||||
return CcShowHostsQuery::create()
|
||||
->filterByDbShow($showInstance->getDbShowId())
|
||||
->filterByDbHost($this->getDbId())
|
||||
->count() > 0;
|
||||
}
|
||||
} // CcSubjs
|
||||
|
|
|
@ -803,31 +803,72 @@ class Application_Service_HistoryService
|
|||
return $select;
|
||||
}
|
||||
|
||||
private function validateHistoryItem($instanceId, $form) {
|
||||
|
||||
/*
|
||||
$userService = new Application_Service_UserService();
|
||||
$currentUser = $userService->getCurrentUser();
|
||||
|
||||
if (!$currentUser->isAdminOrPM()) {
|
||||
if (empty($instance_id) ) {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$valid = true;
|
||||
|
||||
$recordStartsEl = $form->getElement("his_item_starts");
|
||||
$recordStarts = $recordStartsEl->getValue();
|
||||
$recordEndsEl = $form->getElement("his_item_starts");
|
||||
$recordEnds = $recordEndsEl->getValue();
|
||||
|
||||
$timezoneLocal = new DateTimeZone($this->timezone);
|
||||
|
||||
$startDT = new DateTime($recordStarts, $timezoneLocal);
|
||||
$endDT = new DateTime($recordEnds, $timezoneLocal);
|
||||
|
||||
if ($recordStarts > $recordEnds) {
|
||||
$valid = false;
|
||||
$recordEndsEl->addErrorMessage("End time must be after start time");
|
||||
}
|
||||
|
||||
if (isset($instanceId)) {
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPk($instanceId, $this->con);
|
||||
$inStartsDT = $instance->getDbStarts(null);
|
||||
$inEndsDT = $instance->getDbEnds(null);
|
||||
|
||||
if ($startDT < $inStartsDT) {
|
||||
$valid = false;
|
||||
$form->addErrorMessage("History item begins before show.");
|
||||
}
|
||||
else if ($startDT > $inEndsDT) {
|
||||
$valid = false;
|
||||
$form->addErrorMessage("History item begins after show.");
|
||||
}
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
public function createPlayedItem($data) {
|
||||
|
||||
try {
|
||||
$form = $this->makeHistoryItemForm(null);
|
||||
$history_id = $form->getElement("his_item_id");
|
||||
$instance_id = $data["instance_id"];
|
||||
$instanceId = $data["instance_id"];
|
||||
$json = array();
|
||||
|
||||
if ($form->isValid($data)) {
|
||||
if ($form->isValid($data) && $this->validateHistoryItem($instanceId, $form)) {
|
||||
|
||||
$history_id->setIgnore(true);
|
||||
$values = $form->getValues();
|
||||
|
||||
Logging::info("created list item");
|
||||
Logging::info($values);
|
||||
|
||||
$this->populateTemplateItem($values, null, $instance_id);
|
||||
$this->populateTemplateItem($values, null, $instanceId);
|
||||
}
|
||||
else {
|
||||
Logging::info("created list item NOT VALID");
|
||||
|
||||
$msgs = $form->getMessages();
|
||||
Logging::info($msgs);
|
||||
|
||||
$json["form"] = $form;
|
||||
$json["error"] = $msgs;
|
||||
}
|
||||
|
||||
return $json;
|
||||
|
@ -842,31 +883,21 @@ class Application_Service_HistoryService
|
|||
|
||||
try {
|
||||
$id = $data["his_item_id"];
|
||||
$instance_id = $data["instance_id"];
|
||||
$instanceId = $data["instance_id"];
|
||||
$form = $this->makeHistoryItemForm($id);
|
||||
$history_id = $form->getElement("his_item_id");
|
||||
$history_id->setRequired(true);
|
||||
|
||||
Logging::info($data);
|
||||
$json = array();
|
||||
|
||||
if ($form->isValid($data)) {
|
||||
if ($form->isValid($data) && $this->validateHistoryItem($instanceId, $form)) {
|
||||
|
||||
$history_id->setIgnore(true);
|
||||
$values = $form->getValues();
|
||||
|
||||
Logging::info("edited list item");
|
||||
Logging::info($values);
|
||||
|
||||
$this->populateTemplateItem($values, $id, $instance_id);
|
||||
$this->populateTemplateItem($values, $id, $instanceId);
|
||||
}
|
||||
else {
|
||||
Logging::info("edited list item NOT VALID");
|
||||
|
||||
$msgs = $form->getMessages();
|
||||
Logging::info($msgs);
|
||||
|
||||
$json["form"] = $form;
|
||||
$json["error"] = $msgs;
|
||||
}
|
||||
|
||||
return $json;
|
||||
|
@ -885,22 +916,15 @@ class Application_Service_HistoryService
|
|||
$history_id = $form->getElement("his_file_id");
|
||||
$history_id->setRequired(true);
|
||||
|
||||
Logging::info($data);
|
||||
$json = array();
|
||||
|
||||
if ($form->isValid($data)) {
|
||||
$history_id->setIgnore(true);
|
||||
$values = $form->getValues();
|
||||
|
||||
Logging::info("edited list item");
|
||||
Logging::info($values);
|
||||
|
||||
$this->populateTemplateFile($values, $id);
|
||||
}
|
||||
else {
|
||||
$msgs = $form->getMessages();
|
||||
Logging::info($msgs);
|
||||
|
||||
$json["error"] = $msgs;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*define('UTYPE_HOST' , 'H');
|
||||
define('UTYPE_ADMIN' , 'A');
|
||||
define('UTYPE_GUEST' , 'G');
|
||||
define('UTYPE_PROGRAM_MANAGER' , 'P');*/
|
||||
|
||||
class Application_Service_UserService
|
||||
{
|
||||
private $currentUser;
|
||||
|
@ -18,7 +13,7 @@ class Application_Service_UserService
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns a CcSubjs object
|
||||
*/
|
||||
public function getCurrentUser()
|
||||
|
|
|
@ -3,6 +3,15 @@
|
|||
|
||||
<dl class="zend_form">
|
||||
|
||||
<?php $formErrors = $form->getErrorMessages() ?>
|
||||
<?php if (count($formErrors) > 0) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach ($formErrors as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $name = "his_item_id"; ?>
|
||||
<dd id="<?php echo $name;?>-element">
|
||||
<?php echo $form->getElement($name); ?>
|
||||
|
|
|
@ -486,13 +486,19 @@ var AIRTIME = (function(AIRTIME) {
|
|||
});
|
||||
}
|
||||
|
||||
function makeHistoryDialog(html) {
|
||||
$hisDialogEl = $(html);
|
||||
function processDialogHtml($el) {
|
||||
|
||||
if (inShowsTab) {
|
||||
$hisDialogEl.find("#his_choose_instance").remove();
|
||||
$el.find("#his_choose_instance").remove();
|
||||
}
|
||||
|
||||
return $el
|
||||
}
|
||||
|
||||
function makeHistoryDialog(html) {
|
||||
$hisDialogEl = $(html);
|
||||
$hisDialogEl = processDialogHtml($hisDialogEl);
|
||||
|
||||
$hisDialogEl.dialog({
|
||||
title: $.i18n._("Edit History Record"),
|
||||
modal: false,
|
||||
|
@ -604,6 +610,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
if (json.form !== undefined) {
|
||||
var $newForm = $(json.form);
|
||||
$newForm = processDialogHtml($newForm);
|
||||
$hisDialogEl.html($newForm.html());
|
||||
initializeDialog();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue