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