CC-3177 : editing a show in the calendar brakes show edit form
will only update shows if the duration is 24:00 or less.
This commit is contained in:
parent
1b8e1455d6
commit
72952024b7
|
@ -120,6 +120,10 @@ class Application_Model_Show {
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
|
if ($deltaDay > 0) {
|
||||||
|
return "shows can have a max length of 24 hours.";
|
||||||
|
}
|
||||||
|
|
||||||
$hours = $deltaMin/60;
|
$hours = $deltaMin/60;
|
||||||
if($hours > 0)
|
if($hours > 0)
|
||||||
$hours = floor($hours);
|
$hours = floor($hours);
|
||||||
|
@ -129,15 +133,18 @@ class Application_Model_Show {
|
||||||
$mins = abs($deltaMin%60);
|
$mins = abs($deltaMin%60);
|
||||||
|
|
||||||
//current timesamp in UTC.
|
//current timesamp in UTC.
|
||||||
$current_timestamp = Application_Model_DateHelper::ConvertToUtcDateTime(date("Y-m-d H:i:s"))->format("Y-m-d H:i:s");
|
$current_timestamp = gmdate("Y-m-d H:i:s");
|
||||||
|
|
||||||
//update all cc_show_instances that are in the future.
|
//update all cc_show_instances that are in the future.
|
||||||
$sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
|
$sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
|
||||||
WHERE (show_id = {$this->_showId} AND starts > '$current_timestamp');";
|
WHERE (show_id = {$this->_showId} AND starts > '$current_timestamp')
|
||||||
|
AND ((ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}' - starts) <= interval '24:00');";
|
||||||
|
|
||||||
//update cc_show_days so future shows can be created with the new duration.
|
//update cc_show_days so future shows can be created with the new duration.
|
||||||
|
//only setting new duration if it is less than or equal to 24 hours.
|
||||||
$sql = $sql . " UPDATE cc_show_days SET duration = (CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
|
$sql = $sql . " UPDATE cc_show_days SET duration = (CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
|
||||||
WHERE show_id = {$this->_showId}";
|
WHERE show_id = {$this->_showId}
|
||||||
|
AND ((CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') <= interval '24:00')";
|
||||||
|
|
||||||
//do both the queries at once.
|
//do both the queries at once.
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
|
Loading…
Reference in New Issue