CC-3085 : Repeating shows get added to the wrong days
This commit is contained in:
parent
54ef9f2b03
commit
40b99dfc0f
|
@ -508,13 +508,16 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$formWhen->getElement('add_show_start_date')->setOptions(array('disabled' => true));
|
$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();
|
$days = array();
|
||||||
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
$showDays = CcShowDaysQuery::create()->filterByDbShowId($showInstance->getShowId())->find();
|
||||||
foreach($showDays as $showDay){
|
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->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
|
||||||
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
$displayedEndDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
|
|
|
@ -187,14 +187,16 @@ class Application_Model_Show {
|
||||||
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
$uncheckedDaysImploded = implode(",", $p_uncheckedDays);
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
|
|
||||||
$date = new Application_Model_DateHelper;
|
$timestamp = gmdate("Y-m-d H:i:s");
|
||||||
$timestamp = $date->getTimestamp();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM cc_show_instances"
|
$sql = "DELETE FROM cc_show_instances"
|
||||||
." 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 for removing unchecked days");
|
||||||
|
Logging::log($sql);
|
||||||
|
|
||||||
$CC_DBC->query($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
|
//What we are doing here is checking if the show repeats or if
|
||||||
//any repeating days have been checked. If not, then by default
|
//any repeating days have been checked. If not, then by default
|
||||||
//the "selected" DOW is the initial day.
|
//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']) {
|
if (!$data['add_show_repeats']) {
|
||||||
$data['add_show_day_check'] = array($startDow);
|
$data['add_show_day_check'] = array($startDow);
|
||||||
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
} else if ($data['add_show_repeats'] && $data['add_show_day_check'] == "") {
|
||||||
|
@ -907,7 +910,10 @@ class Application_Model_Show {
|
||||||
$showDay->setDbRecord($isRecorded);
|
$showDay->setDbRecord($isRecorded);
|
||||||
$showDay->save();
|
$showDay->save();
|
||||||
} else {
|
} else {
|
||||||
|
Logging::log("startDow is: {$startDow}");
|
||||||
foreach ($data['add_show_day_check'] as $day) {
|
foreach ($data['add_show_day_check'] as $day) {
|
||||||
|
Logging::log("day is: {$day}");
|
||||||
|
|
||||||
$daysAdd=0;
|
$daysAdd=0;
|
||||||
$startDateTimeClone = clone $startDateTime;
|
$startDateTimeClone = clone $startDateTime;
|
||||||
if ($startDow !== $day){
|
if ($startDow !== $day){
|
||||||
|
@ -916,7 +922,10 @@ class Application_Model_Show {
|
||||||
else
|
else
|
||||||
$daysAdd = $day - $startDow;
|
$daysAdd = $day - $startDow;
|
||||||
|
|
||||||
|
Logging::log("days to add: {$daysAdd}");
|
||||||
|
|
||||||
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
|
$startDateTimeClone->add(new DateInterval("P".$daysAdd."D"));
|
||||||
|
Logging::log("start date: {$startDateTimeClone->format("Y-m-d")}");
|
||||||
}
|
}
|
||||||
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
|
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
|
||||||
$showDay = new CcShowDays();
|
$showDay = new CcShowDays();
|
||||||
|
|
Loading…
Reference in New Issue