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()
|
public function editListItemAction()
|
||||||
{
|
{
|
||||||
$id = $this->_getParam('id', null);
|
$id = $this->_getParam('id', null);
|
||||||
Logging::info("Id is: $id");
|
|
||||||
|
|
||||||
$populate = isset($id) ? true : false;
|
$populate = isset($id) ? true : false;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skeleton subclass for representing a row from the 'cc_subjs' table.
|
* Skeleton subclass for representing a row from the 'cc_subjs' table.
|
||||||
*
|
*
|
||||||
|
@ -27,4 +25,15 @@ class CcSubjs extends BaseCcSubjs {
|
||||||
->filterByDbHost($this->getDbId())
|
->filterByDbHost($this->getDbId())
|
||||||
->count() > 0;
|
->count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isHostOfShowInstance($instanceId)
|
||||||
|
{
|
||||||
|
$showInstance = CcShowInstancesQuery::create()
|
||||||
|
->findPk($instanceId);
|
||||||
|
|
||||||
|
return CcShowHostsQuery::create()
|
||||||
|
->filterByDbShow($showInstance->getDbShowId())
|
||||||
|
->filterByDbHost($this->getDbId())
|
||||||
|
->count() > 0;
|
||||||
|
}
|
||||||
} // CcSubjs
|
} // CcSubjs
|
||||||
|
|
|
@ -803,31 +803,72 @@ class Application_Service_HistoryService
|
||||||
return $select;
|
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) {
|
public function createPlayedItem($data) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form = $this->makeHistoryItemForm(null);
|
$form = $this->makeHistoryItemForm(null);
|
||||||
$history_id = $form->getElement("his_item_id");
|
$history_id = $form->getElement("his_item_id");
|
||||||
$instance_id = $data["instance_id"];
|
$instanceId = $data["instance_id"];
|
||||||
$json = array();
|
$json = array();
|
||||||
|
|
||||||
if ($form->isValid($data)) {
|
if ($form->isValid($data) && $this->validateHistoryItem($instanceId, $form)) {
|
||||||
|
|
||||||
$history_id->setIgnore(true);
|
$history_id->setIgnore(true);
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
|
|
||||||
Logging::info("created list item");
|
$this->populateTemplateItem($values, null, $instanceId);
|
||||||
Logging::info($values);
|
|
||||||
|
|
||||||
$this->populateTemplateItem($values, null, $instance_id);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logging::info("created list item NOT VALID");
|
|
||||||
|
|
||||||
$msgs = $form->getMessages();
|
|
||||||
Logging::info($msgs);
|
|
||||||
|
|
||||||
$json["form"] = $form;
|
$json["form"] = $form;
|
||||||
$json["error"] = $msgs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $json;
|
return $json;
|
||||||
|
@ -842,31 +883,21 @@ class Application_Service_HistoryService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$id = $data["his_item_id"];
|
$id = $data["his_item_id"];
|
||||||
$instance_id = $data["instance_id"];
|
$instanceId = $data["instance_id"];
|
||||||
$form = $this->makeHistoryItemForm($id);
|
$form = $this->makeHistoryItemForm($id);
|
||||||
$history_id = $form->getElement("his_item_id");
|
$history_id = $form->getElement("his_item_id");
|
||||||
$history_id->setRequired(true);
|
$history_id->setRequired(true);
|
||||||
|
|
||||||
Logging::info($data);
|
|
||||||
$json = array();
|
$json = array();
|
||||||
|
|
||||||
if ($form->isValid($data)) {
|
if ($form->isValid($data) && $this->validateHistoryItem($instanceId, $form)) {
|
||||||
|
|
||||||
$history_id->setIgnore(true);
|
$history_id->setIgnore(true);
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
|
$this->populateTemplateItem($values, $id, $instanceId);
|
||||||
Logging::info("edited list item");
|
|
||||||
Logging::info($values);
|
|
||||||
|
|
||||||
$this->populateTemplateItem($values, $id, $instance_id);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logging::info("edited list item NOT VALID");
|
|
||||||
|
|
||||||
$msgs = $form->getMessages();
|
|
||||||
Logging::info($msgs);
|
|
||||||
|
|
||||||
$json["form"] = $form;
|
$json["form"] = $form;
|
||||||
$json["error"] = $msgs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $json;
|
return $json;
|
||||||
|
@ -885,22 +916,15 @@ class Application_Service_HistoryService
|
||||||
$history_id = $form->getElement("his_file_id");
|
$history_id = $form->getElement("his_file_id");
|
||||||
$history_id->setRequired(true);
|
$history_id->setRequired(true);
|
||||||
|
|
||||||
Logging::info($data);
|
|
||||||
$json = array();
|
$json = array();
|
||||||
|
|
||||||
if ($form->isValid($data)) {
|
if ($form->isValid($data)) {
|
||||||
$history_id->setIgnore(true);
|
$history_id->setIgnore(true);
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
|
|
||||||
Logging::info("edited list item");
|
|
||||||
Logging::info($values);
|
|
||||||
|
|
||||||
$this->populateTemplateFile($values, $id);
|
$this->populateTemplateFile($values, $id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$msgs = $form->getMessages();
|
|
||||||
Logging::info($msgs);
|
|
||||||
|
|
||||||
$json["error"] = $msgs;
|
$json["error"] = $msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*define('UTYPE_HOST' , 'H');
|
|
||||||
define('UTYPE_ADMIN' , 'A');
|
|
||||||
define('UTYPE_GUEST' , 'G');
|
|
||||||
define('UTYPE_PROGRAM_MANAGER' , 'P');*/
|
|
||||||
|
|
||||||
class Application_Service_UserService
|
class Application_Service_UserService
|
||||||
{
|
{
|
||||||
private $currentUser;
|
private $currentUser;
|
||||||
|
|
|
@ -3,6 +3,15 @@
|
||||||
|
|
||||||
<dl class="zend_form">
|
<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"; ?>
|
<?php $name = "his_item_id"; ?>
|
||||||
<dd id="<?php echo $name;?>-element">
|
<dd id="<?php echo $name;?>-element">
|
||||||
<?php echo $form->getElement($name); ?>
|
<?php echo $form->getElement($name); ?>
|
||||||
|
|
|
@ -486,13 +486,19 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeHistoryDialog(html) {
|
function processDialogHtml($el) {
|
||||||
$hisDialogEl = $(html);
|
|
||||||
|
|
||||||
if (inShowsTab) {
|
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({
|
$hisDialogEl.dialog({
|
||||||
title: $.i18n._("Edit History Record"),
|
title: $.i18n._("Edit History Record"),
|
||||||
modal: false,
|
modal: false,
|
||||||
|
@ -604,6 +610,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
|
|
||||||
if (json.form !== undefined) {
|
if (json.form !== undefined) {
|
||||||
var $newForm = $(json.form);
|
var $newForm = $(json.form);
|
||||||
|
$newForm = processDialogHtml($newForm);
|
||||||
$hisDialogEl.html($newForm.html());
|
$hisDialogEl.html($newForm.html());
|
||||||
initializeDialog();
|
initializeDialog();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue