tells you what shows overlap on add, re adds datepickers to newly displayed form.
This commit is contained in:
parent
cc1715426f
commit
52c8bc3a01
|
@ -14,7 +14,8 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$ajaxContext->addActionContext('event-feed', 'json')
|
$ajaxContext->addActionContext('event-feed', 'json')
|
||||||
->addActionContext('add-show-dialog', 'json')
|
->addActionContext('add-show-dialog', 'json')
|
||||||
->addActionContext('add-show', 'json')
|
->addActionContext('add-show', 'json')
|
||||||
->addActionContext('move-show', 'json')
|
->addActionContext('move-show', 'json')
|
||||||
|
->addActionContext('resize-show', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$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);
|
$this->view->events = $show->getFullCalendarEvents($start, $end, $weekday);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +54,14 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
|
|
||||||
$show = new Show($userInfo->type);
|
$show = new Show($userInfo->id, $userInfo->type);
|
||||||
$show->addShow($form->getValues());
|
$overlap = $show->addShow($form->getValues());
|
||||||
|
|
||||||
|
if(isset($overlap)) {
|
||||||
|
$this->view->overlap = $overlap;
|
||||||
|
$this->view->form = $form->__toString();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +76,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
|
|
||||||
$show = new Show($userInfo->type);
|
$show = new Show($userInfo->id, $userInfo->type);
|
||||||
|
|
||||||
$overlap = $show->moveShow($showId, $deltaDay, $deltaMin);
|
$overlap = $show->moveShow($showId, $deltaDay, $deltaMin);
|
||||||
|
|
||||||
|
@ -85,7 +92,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||||
|
|
||||||
$show = new Show($userInfo->type);
|
$show = new Show($userInfo->id, $userInfo->type);
|
||||||
|
|
||||||
$overlap = $show->resizeShow($showId, $deltaDay, $deltaMin);
|
$overlap = $show->resizeShow($showId, $deltaDay, $deltaMin);
|
||||||
|
|
||||||
|
|
|
@ -99,14 +99,12 @@ class Application_Form_AddShow extends Zend_Form
|
||||||
$options[$host['id']] = $host['login'];
|
$options[$host['id']] = $host['login'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addElement(
|
$hosts = new Zend_Form_Element_Multiselect('hosts');
|
||||||
'multiselect',
|
$hosts->setLabel('Hosts:')
|
||||||
'hosts',
|
->setMultiOptions($options)
|
||||||
array(
|
->setRequired(true);
|
||||||
'label' => 'Hosts:',
|
|
||||||
'required' => true,
|
$this->addElement($hosts);
|
||||||
'multiOptions' => $options
|
|
||||||
));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
class Show {
|
class Show {
|
||||||
|
|
||||||
private $_userRole;
|
private $_userRole;
|
||||||
|
private $_userId;
|
||||||
|
|
||||||
public function __construct($userType='G')
|
public function __construct($userId, $userType='G')
|
||||||
{
|
{
|
||||||
$this->_userRole = $userType;
|
$this->_userRole = $userType;
|
||||||
|
$this->_userId = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//end dates are non inclusive.
|
//end dates are non inclusive.
|
||||||
|
@ -41,6 +42,12 @@ class Show {
|
||||||
if($data['day_check'] === null) {
|
if($data['day_check'] === null) {
|
||||||
$data['day_check'] = array($startDow);
|
$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 = new CcShow();
|
||||||
$show->setDbName($data['name']);
|
$show->setDbName($data['name']);
|
||||||
|
@ -76,7 +83,13 @@ class Show {
|
||||||
$showDay->setDbShowId($showId);
|
$showDay->setDbShowId($showId);
|
||||||
$showDay->save();
|
$showDay->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($data['hosts'] as $host) {
|
||||||
|
$showHost = new CcShowHosts();
|
||||||
|
$showHost->setDbShow($showId);
|
||||||
|
$showHost->setDbHost($host);
|
||||||
|
$showHost->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveShow($showId, $deltaDay, $deltaMin){
|
public function moveShow($showId, $deltaDay, $deltaMin){
|
||||||
|
@ -121,7 +134,6 @@ class Show {
|
||||||
$show->setDbEndTime($e_time);
|
$show->setDbEndTime($e_time);
|
||||||
$show->save();
|
$show->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resizeShow($showId, $deltaDay, $deltaMin){
|
public function resizeShow($showId, $deltaDay, $deltaMin){
|
||||||
|
@ -188,7 +200,7 @@ class Show {
|
||||||
$sql = $sql_gen ." WHERE ". $sql_range;
|
$sql = $sql_gen ." WHERE ". $sql_range;
|
||||||
}
|
}
|
||||||
if(!is_null($start) && is_null($end)) {
|
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}')";
|
OR (last_show > '{$start}')";
|
||||||
|
|
||||||
$sql = $sql_gen ." WHERE ". $sql_range;
|
$sql = $sql_gen ." WHERE ". $sql_range;
|
||||||
|
|
|
@ -47,8 +47,35 @@ function submitShow() {
|
||||||
formData,
|
formData,
|
||||||
function(data){
|
function(data){
|
||||||
if(data.form) {
|
if(data.form) {
|
||||||
$("#schedule_add_event_dialog").find("form").remove();
|
dialog.find("form").remove();
|
||||||
$("#schedule_add_event_dialog").append(data.form);
|
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 {
|
else {
|
||||||
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
|
$("#schedule_calendar").fullCalendar( 'refetchEvents' );
|
||||||
|
@ -82,7 +109,7 @@ function makeShowDialog(html) {
|
||||||
width: 950,
|
width: 950,
|
||||||
height: 400,
|
height: 400,
|
||||||
close: closeDialog,
|
close: closeDialog,
|
||||||
buttons: { "Ok": submitShow }
|
buttons: { "Cancel": closeDialog, "Ok": submitShow}
|
||||||
});
|
});
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
@ -155,7 +182,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$('#schedule_calendar').fullCalendar({
|
$('#schedule_calendar').fullCalendar({
|
||||||
header: {
|
header: {
|
||||||
left: 'next, today',
|
left: 'prev, next, today',
|
||||||
center: 'title',
|
center: 'title',
|
||||||
right: 'agendaDay, agendaWeek, month'
|
right: 'agendaDay, agendaWeek, month'
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue