CC-2326 Can't edit a show more than once (End Date problems)

show editing assumed inclusive end dates while show creating assumed non inclusive.
This commit is contained in:
Naomi 2011-05-26 15:41:47 -04:00
parent 765897600d
commit 8d59c18bef
4 changed files with 100 additions and 95 deletions

View File

@ -456,9 +456,13 @@ class ScheduleController extends Zend_Controller_Action
array_push($days, $showDay->getDbDay());
}
$displayedEndDate = new DateTime($show->getRepeatingEndDate());
$displayedEndDate->sub(new DateInterval("P1D"));//end dates are stored non-inclusively.
$displayedEndDate = $displayedEndDate->format("Y-m-d");
$formRepeats->populate(array('add_show_repeat_type' => $show->getRepeatType(),
'add_show_day_check' => $days,
'add_show_end_date' => $show->getRepeatingEndDate(),
'add_show_end_date' => $displayedEndDate,
'add_show_no_end' => ($show->getRepeatingEndDate() == '')));
$formRecord->populate(array('add_show_record' => $show->isRecorded(),

View File

@ -320,7 +320,7 @@ class Show {
* @param string $p_date
* The date which to delete after
*/
public function removeAllInstancesAfterDate($p_date){
public function removeAllInstancesFromDate($p_date){
global $CC_DBC;
$date = new DateHelper;
@ -328,7 +328,7 @@ class Show {
$showId = $this->getId();
$sql = "DELETE FROM cc_show_instances "
." WHERE date(starts) > DATE '$p_date'"
." WHERE date(starts) >= DATE '$p_date'"
." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
@ -590,7 +590,7 @@ class Show {
//show "Never Ends" option was toggled.
if ($p_data['add_show_no_end']){
} else {
$p_show->removeAllInstancesAfterDate($p_endDate);
$p_show->removeAllInstancesFromDate($p_endDate);
}
}
if ($p_show->getRepeatingEndDate() != $p_data['add_show_end_date']){
@ -599,7 +599,7 @@ class Show {
$newDate = strtotime($p_data['add_show_end_date']);
$oldDate = strtotime($p_show->getRepeatingEndDate());
if ($newDate < $oldDate){
$p_show->removeAllInstancesAfterDate($p_endDate);
$p_show->removeAllInstancesFromDate($p_endDate);
}
}
}
@ -608,7 +608,7 @@ class Show {
/**
* Create a show.
*
* Note: end dates are non inclusive.
* Note: end dates are inclusive.
*
* @param array $data
* @return int
@ -624,17 +624,18 @@ class Show {
if ($data['add_show_no_end']) {
$endDate = NULL;
//$data['add_show_repeats'] = 1;
}
else if ($data['add_show_repeats']) {
$sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' ";
$r = $con->query($sql);
$endDate = $r->fetchColumn(0);
//$sql = "SELECT date '{$data['add_show_end_date']}' + INTERVAL '1 day' ";
//$r = $con->query($sql);
//$endDate = $r->fetchColumn(0);
$endDate = $data['add_show_end_date'];
}
else {
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '1 day' ";
$r = $con->query($sql);
$endDate = $r->fetchColumn(0);
//$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '1 day' ";
//$r = $con->query($sql);
//$endDate = $r->fetchColumn(0);
$endDate = $data['add_show_start_date'];
}
//only want the day of the week from the start date.
@ -703,7 +704,7 @@ class Show {
$start = $data['add_show_start_date'];
}
if (strtotime($start) < strtotime($endDate) || is_null($endDate)) {
if (strtotime($start) <= strtotime($endDate) || is_null($endDate)) {
$showDay = new CcShowDays();
$showDay->setDbFirstShow($start);
$showDay->setDbLastShow($endDate);
@ -921,7 +922,7 @@ class Show {
$rebroadcasts = $CC_DBC->GetAll($sql);
$show = new Show($show_id);
while(strtotime($next_date) < strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
$start = $next_date;

View File

@ -55,6 +55,16 @@ function findHosts(request, callback) {
}
function beginEditShow(data){
$("#add-show-form")
.empty()
.append(data.newForm);
removeAddShowButton();
setAddShowEvents();
openAddShowForm();
}
function setAddShowEvents() {
var form = $("#add-show-form");

View File

@ -46,16 +46,6 @@ function removeAddShowButton(){
span.remove();
}
function beginEditShow(data){
$("#add-show-form")
.empty()
.append(data.newForm);
removeAddShowButton();
setAddShowEvents();
openAddShowForm();
}
function makeTimeStamp(date){
var sy, sm, sd, h, m, s, timestamp;
sy = date.getFullYear();