can put in multiple days for end show, checks show_end epoch.

working on moving shows
This commit is contained in:
naomiaro 2010-12-09 14:33:34 -05:00
parent 8b404f3c62
commit 6ff92ee7b3
5 changed files with 118 additions and 76 deletions

View file

@ -53,6 +53,8 @@
<actionMethod actionName="index"/> <actionMethod actionName="index"/>
<actionMethod actionName="eventFeed"/> <actionMethod actionName="eventFeed"/>
<actionMethod actionName="addShowDialog"/> <actionMethod actionName="addShowDialog"/>
<actionMethod actionName="moveShow"/>
<actionMethod actionName="resizeShow"/>
</controllerFile> </controllerFile>
</controllersDirectory> </controllersDirectory>
<formsDirectory> <formsDirectory>
@ -167,6 +169,12 @@
<viewControllerScriptsDirectory forControllerName="Schedule"> <viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="addShowDialog"/> <viewScriptFile forActionName="addShowDialog"/>
</viewControllerScriptsDirectory> </viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="moveShow"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Schedule">
<viewScriptFile forActionName="resizeShow"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory> </viewScriptsDirectory>
<viewHelpersDirectory/> <viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/> <viewFiltersDirectory enabled="false"/>

View file

@ -32,6 +32,10 @@ class ScheduleController extends Zend_Controller_Action
$end = $this->_getParam('end', null); $end = $this->_getParam('end', null);
$weekday = $this->_getParam('weekday', null); $weekday = $this->_getParam('weekday', null);
if(!is_null($weekday)) {
$weekday = array($weekday);
}
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show($userInfo->type); $show = new Show($userInfo->type);
@ -56,33 +60,21 @@ class ScheduleController extends Zend_Controller_Action
$this->view->form = $form->__toString(); $this->view->form = $form->__toString();
} }
function addShow() public function moveShowAction()
{ {
//name, description, hosts, allDay, repeats, $deltaDay = $this->_getParam('day');
//start_time, duration, start_date, end_date, dofw $deltaMin = $this->_getParam('min');
$showId = $this->_getParam('showId');
/* $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$name = $this->_getParam('name', 'Default Name');
$description = $this->_getParam('description', '');
$hosts = $this->_getParam('hosts');
$allDay = $this->_getParam('all_day', false);
$repeats = $this->_getParam('repeats', false);
$startTime = $this->_getParam('start_time');
$duration = $this->_getParam('duration');
$startDate = $this->_getParam('start_date');
$endDate = $this->_getParam('end_date', null);
$dofw = $this->_getParam('dofw');
if($repeats === false) $show = new Show($userInfo->type);
$endDate = $startDate; $show->moveShow($showId, $deltaDay, $deltaMin);
}
$repeats = $repeats ? 1 : 0; public function resizeShowAction()
*/ {
// action body
//$userInfo = Zend_Auth::getInstance()->getStorage()->read();
//$show = new Show($userInfo->type);
//$show->addShow($name, $startDate, $endDate, $startTime, $duration, $repeats, $dofw, $description);
} }
@ -94,3 +86,7 @@ class ScheduleController extends Zend_Controller_Action

View file

@ -30,17 +30,6 @@ class Application_Form_AddShow extends Zend_Form
) )
)); ));
// Add end date element
$this->addElement('text', 'end_date', array(
'label' => 'Date End:',
'required' => false,
'filters' => array('StringTrim'),
'validators' => array(
'NotEmpty',
array('date', false, array('YYYY-MM-DD'))
)
));
// Add start time element // Add start time element
$this->addElement('text', 'start_time', array( $this->addElement('text', 'start_time', array(
'label' => 'Start Time:', 'label' => 'Start Time:',
@ -52,23 +41,6 @@ class Application_Form_AddShow extends Zend_Form
) )
)); ));
/*
$this->addElement(
'select',
'start_time',
array(
'label' => 'Start Time:',
'required' => true,
'multiOptions' => array(
"00:00" => "00:00",
"00:30" => "00:30",
"01:00" => "01:00",
"01:30" => "01:30",
"02:00" => "02:00",
),
));
*/
// Add duration element // Add duration element
$this->addElement('text', 'duration', array( $this->addElement('text', 'duration', array(
'label' => 'Duration:', 'label' => 'Duration:',
@ -80,6 +52,12 @@ class Application_Form_AddShow extends Zend_Form
) )
)); ));
// Add repeats element
$this->addElement('checkbox', 'repeats', array(
'label' => 'repeats',
'required' => false,
));
$this->addElement( $this->addElement(
'multiCheckbox', 'multiCheckbox',
'day_check', 'day_check',
@ -97,15 +75,16 @@ class Application_Form_AddShow extends Zend_Form
), ),
)); ));
$this->addElement('checkbox', 'all_day', array( // Add end date element
'label' => 'all day', $this->addElement('text', 'end_date', array(
'label' => 'Date End:',
'required' => false, 'required' => false,
)); 'filters' => array('StringTrim'),
'validators' => array(
$this->addElement('checkbox', 'repeats', array( 'NotEmpty',
'label' => 'repeats', array('date', false, array('YYYY-MM-DD'))
'required' => false, )
)); ));
$this->addElement('checkbox', 'no_end', array( $this->addElement('checkbox', 'no_end', array(
'label' => 'no end', 'label' => 'no end',

View file

@ -53,6 +53,7 @@ class Show {
if($data['no_end']) { if($data['no_end']) {
$endDate = NULL; $endDate = NULL;
$data['repeats'] = 1;
} }
else if($data['repeats']) { else if($data['repeats']) {
$endDate = $data['end_date']; $endDate = $data['end_date'];
@ -97,7 +98,29 @@ class Show {
} }
public function getShows($start=NULL, $end=NULL, $weekday=NULL) { public function moveShow($showId, $deltaDay, $deltaMin){
global $CC_DBC;
$sql = "SELECT * FROM cc_show WHERE show_id = '{$showId}'";
$res = $CC_DBC->GetAll($sql);
$show = $res[0];
$start = $show["first_show"];
$end = $show["last_show"];
$days = array();
$s_time = $show["start_time"];
$e_time = $show["end_time"];
foreach($res as $show) {
$days[] = $show["day"];
}
$shows_overlap = $this->getShows($start, $end, $days, $s_time, $e_time);
echo $shows_overlap;
}
public function getShows($start=NULL, $end=NULL, $days=NULL, $s_time=NULL, $e_time=NULL) {
global $CC_DBC; global $CC_DBC;
$sql; $sql;
@ -113,12 +136,27 @@ class Show {
$sql = $sql_gen ." WHERE ". $sql_range; $sql = $sql_gen ." WHERE ". $sql_range;
} }
if(!is_null($weekday)){ if(!is_null($days)){
$sql_day = "day = {$weekday}";
$sql_opt = array();
foreach ($days as $day) {
$sql_opt[] = "day = {$day}";
}
$sql_day = join(" OR ", $sql_opt);
$sql = $sql_gen ." WHERE (". $sql_day ." AND (". $sql_range ."))"; $sql = $sql_gen ." WHERE (". $sql_day ." AND (". $sql_range ."))";
} }
if(!is_null($s_time) && !is_null($e_time)) {
$sql_time = "(start_time <= '{$s_time}' AND end_time >= '{$e_time}')
OR (start_time >= '{$s_time}' AND end_time <= '{$e_time}')
OR (end_time > '{$s_time}' AND end_time <= '{$e_time}')
OR (start_time >= '{$s_time}' AND start_time < '{$e_time}')";
$sql = $sql_gen ." WHERE (". $sql_day ." AND (". $sql_range .") AND (". $sql_time ."))";
}
//echo $sql;
return $CC_DBC->GetAll($sql); return $CC_DBC->GetAll($sql);
} }
@ -150,15 +188,24 @@ class Show {
$end_epoch = strtotime($end); $end_epoch = strtotime($end);
//add repeating events until the show end is reached or fullcalendar's end date is reached.
if($row["repeats"]) { if($row["repeats"]) {
if(!is_null($row["last_show"])) {
$time = $row["last_show"] ." ".$row["end_time"];
$show_end_epoch = strtotime($time);
}
while(true) { while(true) {
$diff = "SELECT date '{$newDate}' + integer '7'"; $diff = "SELECT date '{$newDate}' + integer '7'";
$repeatDate = $CC_DBC->GetOne($diff); $repeatDate = $CC_DBC->GetOne($diff);
$repeat_epoch = strtotime($repeatDate); $repeat_epoch = strtotime($repeatDate);
if ($repeat_epoch < $end_epoch ) { if (isset($show_end_epoch) && $repeat_epoch < $show_end_epoch && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
}
else if(!isset($show_end_epoch) && $repeat_epoch < $end_epoch) {
$shows[] = $this->makeFullCalendarEvent($row, $repeatDate); $shows[] = $this->makeFullCalendarEvent($row, $repeatDate);
} }
else { else {

View file

@ -113,13 +113,34 @@ function eventMouseout(event, jsEvent, view) {
} }
function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
var x; var url;
url = '/Schedule/move-show/format/json';
$.post(url,
{day: dayDelta, min: minuteDelta, showId: event.id},
function(json){
if(json.error) {
revertFunc();
}
});
} }
function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) { function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) {
var x; var x;
} }
function openShowDialog() {
var url;
url = '/Schedule/add-show-dialog/format/json';
$.get(url, function(json){
var dialog = makeShowDialog(json.form);
dialog.dialog('open');
});
}
$(document).ready(function() { $(document).ready(function() {
$('#schedule_calendar').fullCalendar({ $('#schedule_calendar').fullCalendar({
@ -130,6 +151,7 @@ $(document).ready(function() {
}, },
defaultView: 'agendaDay', defaultView: 'agendaDay',
editable: false, editable: false,
allDaySlot: false,
events: function(start, end, callback) { events: function(start, end, callback) {
var url, start_date, end_date; var url, start_date, end_date;
@ -170,17 +192,7 @@ $(document).ready(function() {
}) })
$('#schedule_add_show').click(function() { $('#schedule_add_show').click(openShowDialog);
var url;
url = '/Schedule/add-show-dialog/format/json';
$.get(url, function(json){
var dialog = makeShowDialog(json.form);
dialog.dialog('open');
});
});
}); });