CC-3094 : Rebroadcast editing problems
This commit is contained in:
parent
b7a9e89095
commit
878fa3461d
2 changed files with 38 additions and 33 deletions
|
@ -566,7 +566,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach ($rebroadcastsAbsolute as $rebroadcast){
|
foreach ($rebroadcastsAbsolute as $rebroadcast){
|
||||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
|
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
|
||||||
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Application_Model_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
|
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = $rebroadcast['start_time'];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
|
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);
|
||||||
|
|
|
@ -183,10 +183,10 @@ class Application_Model_Show {
|
||||||
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
//need to convert local doftw to UTC doftw (change made for 2.0 since shows are stored in UTC)
|
//need to convert local doftw to UTC doftw (change made for 2.0 since shows are stored in UTC)
|
||||||
$daysRemovedUTC = array();
|
$daysRemovedUTC = array();
|
||||||
|
|
||||||
$showDays = CcShowDaysQuery::create()
|
$showDays = CcShowDaysQuery::create()
|
||||||
->filterByDbShowId($this->getId())
|
->filterByDbShowId($this->getId())
|
||||||
->find();
|
->find();
|
||||||
|
@ -195,12 +195,12 @@ class Application_Model_Show {
|
||||||
foreach($p_uncheckedDays as $day) {
|
foreach($p_uncheckedDays as $day) {
|
||||||
Logging::log($day);
|
Logging::log($day);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($showDays as $showDay) {
|
foreach($showDays as $showDay) {
|
||||||
Logging::log("Local show day is: {$showDay->getDbDay()}");
|
Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||||
Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
Logging::log("First show day is: {$showDay->getDbFirstShow()}");
|
||||||
Logging::log("Id show days is: {$showDay->getDbId()}");
|
Logging::log("Id show days is: {$showDay->getDbId()}");
|
||||||
|
|
||||||
if (in_array($showDay->getDbDay(), $p_uncheckedDays)) {
|
if (in_array($showDay->getDbDay(), $p_uncheckedDays)) {
|
||||||
$showDay->reload();
|
$showDay->reload();
|
||||||
//Logging::log("Local show day is: {$showDay->getDbDay()}");
|
//Logging::log("Local show day is: {$showDay->getDbDay()}");
|
||||||
|
@ -214,7 +214,7 @@ class Application_Model_Show {
|
||||||
Logging::log("UTC show day is: {$startDay->format('w')}");
|
Logging::log("UTC show day is: {$startDay->format('w')}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$uncheckedDaysImploded = implode(",", $daysRemovedUTC);
|
$uncheckedDaysImploded = implode(",", $daysRemovedUTC);
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class Application_Model_Show {
|
||||||
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
Logging::log($sql);
|
Logging::log($sql);
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
|
@ -278,22 +278,27 @@ class Application_Model_Show {
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT date(starts) "
|
|
||||||
."FROM cc_show_instances "
|
|
||||||
."WHERE show_id = $showId "
|
|
||||||
."AND record = 1 "
|
|
||||||
."AND modified_instance != TRUE";
|
|
||||||
$baseDate = $CC_DBC->GetOne($sql);
|
|
||||||
|
|
||||||
if (is_null($baseDate)){
|
$sql = "SELECT starts FROM cc_show_instances "
|
||||||
return array();
|
."WHERE instance_id = $showId "
|
||||||
|
."ORDER BY starts";
|
||||||
|
|
||||||
|
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
|
$rebroadcastsLocal = array();
|
||||||
|
//get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time.
|
||||||
|
$i = 0;
|
||||||
|
foreach ($rebroadcasts as $show) {
|
||||||
|
$startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC"));
|
||||||
|
$startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
|
$rebroadcastsLocal[$i]["start_date"] = $startDateTime->format("Y-m-d");
|
||||||
|
$rebroadcastsLocal[$i]["start_time"] = $startDateTime->format("H:i");
|
||||||
|
|
||||||
|
$i = $i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT date(DATE '$baseDate' + day_offset::INTERVAL) as start_date, start_time FROM cc_show_rebroadcast "
|
return $rebroadcastsLocal;
|
||||||
."WHERE show_id = $showId "
|
|
||||||
."ORDER BY start_date";
|
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -815,21 +820,21 @@ class Application_Model_Show {
|
||||||
$daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']);
|
$daysRemoved = array_diff($showDaysArray, $p_data['add_show_day_check']);
|
||||||
|
|
||||||
if (count($daysRemoved) > 0){
|
if (count($daysRemoved) > 0){
|
||||||
|
|
||||||
$this->removeUncheckedDaysInstances($daysRemoved);
|
$this->removeUncheckedDaysInstances($daysRemoved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($p_data['add_show_start_date'] != $this->getStartDate()
|
if ($p_data['add_show_start_date'] != $this->getStartDate()
|
||||||
|| $p_data['add_show_start_time'] != $this->getStartTime()){
|
|| $p_data['add_show_start_time'] != $this->getStartTime()){
|
||||||
//start date/time has changed
|
//start date/time has changed
|
||||||
|
|
||||||
$newDate = strtotime($p_data['add_show_start_date']);
|
$newDate = strtotime($p_data['add_show_start_date']);
|
||||||
$oldDate = strtotime($this->getStartDate());
|
$oldDate = strtotime($this->getStartDate());
|
||||||
if ($newDate > $oldDate){
|
if ($newDate > $oldDate){
|
||||||
$this->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
$this->removeAllInstancesBeforeDate($p_data['add_show_start_date']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updateStartDateTime($p_data, $p_endDate);
|
$this->updateStartDateTime($p_data, $p_endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1538,23 +1543,23 @@ class Application_Model_Show {
|
||||||
return $event;
|
return $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Takes in a UTC DateTime object.
|
/* Takes in a UTC DateTime object.
|
||||||
* Converts this to local time, since cc_show days
|
* Converts this to local time, since cc_show days
|
||||||
* requires local time. */
|
* requires local time. */
|
||||||
public function setShowFirstShow($p_dt){
|
public function setShowFirstShow($p_dt){
|
||||||
|
|
||||||
//clone object since we are modifying it and it was passed by reference.
|
//clone object since we are modifying it and it was passed by reference.
|
||||||
$dt = clone $p_dt;
|
$dt = clone $p_dt;
|
||||||
|
|
||||||
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
$showDay = CcShowDaysQuery::create()
|
$showDay = CcShowDaysQuery::create()
|
||||||
->filterByDbShowId($this->_showId)
|
->filterByDbShowId($this->_showId)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
$showDay->setDbFirstShow($dt)
|
$showDay->setDbFirstShow($dt)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
Logging::log("setting show's first show.");
|
Logging::log("setting show's first show.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1562,15 +1567,15 @@ class Application_Model_Show {
|
||||||
* Converts this to local time, since cc_show days
|
* Converts this to local time, since cc_show days
|
||||||
* requires local time. */
|
* requires local time. */
|
||||||
public function setShowLastShow($p_dt){
|
public function setShowLastShow($p_dt){
|
||||||
|
|
||||||
//clone object since we are modifying it and it was passed by reference.
|
//clone object since we are modifying it and it was passed by reference.
|
||||||
$dt = clone $p_dt;
|
$dt = clone $p_dt;
|
||||||
|
|
||||||
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
$dt->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
//add one day since the Last Show date in CcShowDays is non-inclusive.
|
//add one day since the Last Show date in CcShowDays is non-inclusive.
|
||||||
$dt->add(new DateInterval("P1D"));
|
$dt->add(new DateInterval("P1D"));
|
||||||
|
|
||||||
$showDay = CcShowDaysQuery::create()
|
$showDay = CcShowDaysQuery::create()
|
||||||
->filterByDbShowId($this->_showId)
|
->filterByDbShowId($this->_showId)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue