CC-3085 : Repeating shows get added to the wrong days
This commit is contained in:
parent
54ef9f2b03
commit
40b99dfc0f
|
@ -493,7 +493,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
$startsDateTime = new DateTime($show->getStartDate()." ".$show->getStartTime(), new DateTimeZone("UTC"));
|
||||
$endsDateTime = new DateTime($show->getEndDate()." ".$show->getEndTime(), new DateTimeZone("UTC"));
|
||||
|
||||
|
||||
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
|
@ -508,13 +508,16 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
||||
}
|
||||
|
||||
//need to get the days of the week in the php timezone (for the front end).
|
||||
$days = array();
|
||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
||||
foreach($showDays as $showDay){
|
||||
array_push($days, $showDay->getDbDay());
|
||||
$showStartDay = new DateTime($showDay->getDbFirstShow(), new DateTimeZone($showDay->getDbTimezone()));
|
||||
$showStartDay->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
array_push($days, $showStartDay->format('w'));
|
||||
}
|
||||
|
||||
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone("UTC"));
|
||||
$displayedEndDate = new DateTime($show->getRepeatingEndDate(), new DateTimeZone($showDays[0]->getDbTimezone()));
|
||||
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
|
||||
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
|
||||
|
@ -742,7 +745,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$this->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$this->view->rebroadcast = $formRebroadcast;
|
||||
$this->view->addNewShow = true;
|
||||
|
||||
|
||||
//the form still needs to be "update" since
|
||||
//the validity test failed.
|
||||
if ($data['add_show_id'] != -1){
|
||||
|
@ -751,9 +754,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
if (!$startDateModified){
|
||||
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
||||
}
|
||||
|
||||
|
||||
$this->view->form = $this->view->render('schedule/add-show-form.phtml');
|
||||
|
||||
|
||||
}
|
||||
}else{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
|
|
@ -187,14 +187,16 @@ class Application_Model_Show {
|
|||
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
||||
$showId = $this->getId();
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
$timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
$sql = "DELETE FROM cc_show_instances"
|
||||
." WHERE EXTRACT(DOW FROM starts) IN ($uncheckedDaysImploded)"
|
||||
." AND starts > TIMESTAMP '$timestamp'"
|
||||
." AND show_id = $showId";
|
||||
|
||||
Logging::log("sql for removing unchecked days");
|
||||
Logging::log($sql);
|
||||
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
|
@ -856,7 +858,8 @@ class Application_Model_Show {
|
|||
//What we are doing here is checking if the show repeats or if
|
||||
//any repeating days have been checked. If not, then by default
|
||||
//the "selected" DOW is the initial day.
|
||||
$startDow = gmdate("w", $utcStartDateTime->getTimestamp());
|
||||
//DOW in local time.
|
||||
$startDow = date("w", $startDateTime->getTimestamp());
|
||||
if (!$data['add_show_repeats']) {
|
||||
$data['add_show_day_check'] = array($startDow);
|
||||
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||
|
@ -907,7 +910,10 @@ class Application_Model_Show {
|
|||
$showDay->setDbRecord($isRecorded);
|
||||
$showDay->save();
|
||||
} else {
|
||||
Logging::log("startDow is: {$startDow}");
|
||||
foreach ($data['add_show_day_check'] as $day) {
|
||||
Logging::log("day is: {$day}");
|
||||
|
||||
$daysAdd=0;
|
||||
$startDateTimeClone = clone $startDateTime;
|
||||
if ($startDow !== $day){
|
||||
|
@ -916,7 +922,10 @@ class Application_Model_Show {
|
|||
else
|
||||
$daysAdd = $day - $startDow;
|
||||
|
||||
Logging::log("days to add: {$daysAdd}");
|
||||
|
||||
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
|
||||
Logging::log("start date: {$startDateTimeClone->format("Y-m-d")}");
|
||||
}
|
||||
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
|
||||
$showDay = new CcShowDays();
|
||||
|
|
Loading…
Reference in New Issue