tells you what shows overlap on add, re adds datepickers to newly displayed form.

This commit is contained in:
naomiaro 2010-12-10 15:44:36 -05:00
parent cc1715426f
commit 52c8bc3a01
4 changed files with 67 additions and 23 deletions

View File

@ -14,7 +14,8 @@ class ScheduleController extends Zend_Controller_Action
$ajaxContext->addActionContext('event-feed', 'json')
->addActionContext('add-show-dialog', 'json')
->addActionContext('add-show', 'json')
->addActionContext('move-show', 'json')
->addActionContext('move-show', 'json')
->addActionContext('resize-show', 'json')
->initContext();
}
@ -39,7 +40,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show($userInfo->type);
$show = new Show($userInfo->id, $userInfo->type);
$this->view->events = $show->getFullCalendarEvents($start, $end, $weekday);
}
@ -53,8 +54,14 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show($userInfo->type);
$show->addShow($form->getValues());
$show = new Show($userInfo->id, $userInfo->type);
$overlap = $show->addShow($form->getValues());
if(isset($overlap)) {
$this->view->overlap = $overlap;
$this->view->form = $form->__toString();
}
return;
}
}
@ -69,7 +76,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show($userInfo->type);
$show = new Show($userInfo->id, $userInfo->type);
$overlap = $show->moveShow($showId, $deltaDay, $deltaMin);
@ -85,7 +92,7 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$show = new Show($userInfo->type);
$show = new Show($userInfo->id, $userInfo->type);
$overlap = $show->resizeShow($showId, $deltaDay, $deltaMin);

View File

@ -99,14 +99,12 @@ class Application_Form_AddShow extends Zend_Form
$options[$host['id']] = $host['login'];
}
$this->addElement(
'multiselect',
'hosts',
array(
'label' => 'Hosts:',
'required' => true,
'multiOptions' => $options
));
$hosts = new Zend_Form_Element_Multiselect('hosts');
$hosts->setLabel('Hosts:')
->setMultiOptions($options)
->setRequired(true);
$this->addElement($hosts);
}

View File

@ -3,11 +3,12 @@
class Show {
private $_userRole;
private $_userId;
public function __construct($userType='G')
public function __construct($userId, $userType='G')
{
$this->_userRole = $userType;
$this->_userId = $userId;
}
//end dates are non inclusive.
@ -41,6 +42,12 @@ class Show {
if($data['day_check'] === null) {
$data['day_check'] = array($startDow);
}
$overlap = $this->getShows($data['start_date'], $endDate, $data['day_check'], $data['start_time'], $endTime);
if(count($overlap) > 0) {
return $overlap;
}
$show = new CcShow();
$show->setDbName($data['name']);
@ -76,7 +83,13 @@ class Show {
$showDay->setDbShowId($showId);
$showDay->save();
}
foreach ($data['hosts'] as $host) {
$showHost = new CcShowHosts();
$showHost->setDbShow($showId);
$showHost->setDbHost($host);
$showHost->save();
}
}
public function moveShow($showId, $deltaDay, $deltaMin){
@ -121,7 +134,6 @@ class Show {
$show->setDbEndTime($e_time);
$show->save();
}
}
public function resizeShow($showId, $deltaDay, $deltaMin){
@ -188,7 +200,7 @@ class Show {
$sql = $sql_gen ." WHERE ". $sql_range;
}
if(!is_null($start) && is_null($end)) {
$sql_range = "(last_show IS NULL)
$sql_range = "(first_show <= '{$start}' AND last_show IS NULL)
OR (last_show > '{$start}')";
$sql = $sql_gen ." WHERE ". $sql_range;

View File

@ -47,8 +47,35 @@ function submitShow() {
formData,
function(data){
if(data.form) {
$("#schedule_add_event_dialog").find("form").remove();
$("#schedule_add_event_dialog").append(data.form);
dialog.find("form").remove();
dialog.append(data.form);
var start = dialog.find("#start_date");
var end = dialog.find("#end_date");
createDateInput(start, startDpSelect);
createDateInput(end, endDpSelect);
if(data.overlap) {
var table, tr, days;
table = $("<table/>");
days = $.datepicker.regional[''].dayNamesShort;
$.each(data.overlap, function(i, val){
tr = $("<tr/>");
tr
.append("<td>"+val.name+"</td>")
.append("<td>"+days[val.day]+"</td>")
.append("<td>"+val.start_time+"</td>")
.append("<td>"+val.end_time+"</td>");
table.append(tr);
});
dialog.append("<span>Cannot add show. New show overlaps the following shows:</span>");
dialog.append(table);
}
}
else {
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
@ -82,7 +109,7 @@ function makeShowDialog(html) {
width: 950,
height: 400,
close: closeDialog,
buttons: { "Ok": submitShow }
buttons: { "Cancel": closeDialog, "Ok": submitShow}
});
return dialog;
@ -155,7 +182,7 @@ $(document).ready(function() {
$('#schedule_calendar').fullCalendar({
header: {
left: 'next, today',
left: 'prev, next, today',
center: 'title',
right: 'agendaDay, agendaWeek, month'
},