add show form is broken up into tabs.
This commit is contained in:
parent
42e2e0d407
commit
c83244fb3a
|
@ -98,19 +98,19 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
$data = $request->getPost();
|
||||
|
||||
if ($formWhat->isValid($data) && $formWhen->isValid($data) && $formWho->isValid($data) && $formStyle->isValid($data)) {
|
||||
|
||||
if ($formStyle->isValid($data) && $formWhen->isValid($data) && $formWho->isValid($data) && $formStyle->isValid($data)) {
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
||||
$show = new Show(new User($userInfo->id, $userInfo->type));
|
||||
$overlap = $show->addShow($form->getValues());
|
||||
$overlap = $show->addShow($data);
|
||||
|
||||
if(isset($overlap)) {
|
||||
$this->view->overlap = $overlap;
|
||||
$this->view->form = $this->view->render('schedule/add-show-dialog.phtml');
|
||||
}
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Application_Form_AddShow extends Zend_Form
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
// Add name element
|
||||
$this->addElement('text', 'name', array(
|
||||
'label' => 'Name:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array('NotEmpty')
|
||||
));
|
||||
|
||||
// Add the description element
|
||||
$this->addElement('textarea', 'description', array(
|
||||
'label' => 'Description:',
|
||||
'required' => false,
|
||||
));
|
||||
|
||||
// Add start date element
|
||||
$this->addElement('text', 'start_date', array(
|
||||
'label' => 'Date Start:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('YYYY-MM-DD'))
|
||||
)
|
||||
));
|
||||
|
||||
// Add start time element
|
||||
$this->addElement('text', 'start_time', array(
|
||||
'label' => 'Start Time:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm'))
|
||||
)
|
||||
));
|
||||
|
||||
// Add duration element
|
||||
$this->addElement('text', 'duration', array(
|
||||
'label' => 'Duration:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
'validators' => array(
|
||||
'NotEmpty',
|
||||
array('date', false, array('HH:mm'))
|
||||
)
|
||||
));
|
||||
|
||||
// Add repeats element
|
||||
$this->addElement('checkbox', 'repeats', array(
|
||||
'label' => 'repeats',
|
||||
'required' => false,
|
||||
));
|
||||
|
||||
// Add days checkboxes
|
||||
$this->addElement(
|
||||
'multiCheckbox',
|
||||
'day_check',
|
||||
array(
|
||||
'label' => 'Select Days:',
|
||||
'required' => false,
|
||||
'multiOptions' => array(
|
||||
"0" => "Sun",
|
||||
"1" => "Mon",
|
||||
"2" => "Tue",
|
||||
"3" => "Wed",
|
||||
"4" => "Thu",
|
||||
"5" => "Fri",
|
||||
"6" => "Sat",
|
||||
),
|
||||
));
|
||||
|
||||
// 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 no end element
|
||||
$this->addElement('checkbox', 'no_end', array(
|
||||
'label' => 'no end',
|
||||
'required' => false,
|
||||
));
|
||||
|
||||
// Add hosts autocomplete
|
||||
$this->addElement('text', 'hosts_autocomplete', array(
|
||||
'label' => 'Type a Host:',
|
||||
'required' => false
|
||||
));
|
||||
|
||||
$options = array();
|
||||
$hosts = User::getHosts();
|
||||
|
||||
foreach ($hosts as $host) {
|
||||
$options[$host['id']] = $host['login'];
|
||||
}
|
||||
|
||||
//Add hosts selection
|
||||
$hosts = new Zend_Form_Element_MultiCheckbox('hosts');
|
||||
$hosts->setLabel('Hosts:')
|
||||
->setMultiOptions($options)
|
||||
->setRequired(true);
|
||||
|
||||
$this->addElement($hosts);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
// Add days checkboxes
|
||||
$this->addElement(
|
||||
'multiCheckbox',
|
||||
'day_check',
|
||||
'add_show_day_check',
|
||||
array(
|
||||
'label' => 'Select Days:',
|
||||
'required' => false,
|
||||
|
@ -24,7 +24,7 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
));
|
||||
|
||||
// Add end date element
|
||||
$this->addElement('text', 'end_date', array(
|
||||
$this->addElement('text', 'add_show_end_date', array(
|
||||
'label' => 'Date End:',
|
||||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
|
@ -35,7 +35,7 @@ class Application_Form_AddShowRepeats extends Zend_Form_SubForm
|
|||
));
|
||||
|
||||
// Add no end element
|
||||
$this->addElement('checkbox', 'no_end', array(
|
||||
$this->addElement('checkbox', 'add_show_no_end', array(
|
||||
'label' => 'no end',
|
||||
'required' => false,
|
||||
));
|
||||
|
|
|
@ -6,7 +6,7 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
|||
public function init()
|
||||
{
|
||||
// Add show background-color input
|
||||
$this->addElement('text', 'show-background-color', array(
|
||||
$this->addElement('text', 'add_show_background_color', array(
|
||||
'label' => 'Background Colour:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
|
@ -14,7 +14,7 @@ class Application_Form_AddShowStyle extends Zend_Form_SubForm
|
|||
));
|
||||
|
||||
// Add show color input
|
||||
$this->addElement('text', 'show-color', array(
|
||||
$this->addElement('text', 'add_show_color', array(
|
||||
'label' => 'Text Colour',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
|
|
|
@ -6,7 +6,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
public function init()
|
||||
{
|
||||
// Add start date element
|
||||
$this->addElement('text', 'start_date', array(
|
||||
$this->addElement('text', 'add_show_start_date', array(
|
||||
'label' => 'Date Start:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
|
@ -17,7 +17,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
));
|
||||
|
||||
// Add start time element
|
||||
$this->addElement('text', 'start_time', array(
|
||||
$this->addElement('text', 'add_show_start_time', array(
|
||||
'label' => 'Start Time:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
|
@ -28,7 +28,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
));
|
||||
|
||||
// Add duration element
|
||||
$this->addElement('text', 'duration', array(
|
||||
$this->addElement('text', 'add_show_duration', array(
|
||||
'label' => 'Duration:',
|
||||
'required' => true,
|
||||
'filters' => array('StringTrim'),
|
||||
|
@ -39,7 +39,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
|
|||
));
|
||||
|
||||
// Add repeats element
|
||||
$this->addElement('checkbox', 'repeats', array(
|
||||
$this->addElement('checkbox', 'add_show_repeats', array(
|
||||
'label' => 'repeats',
|
||||
'required' => false,
|
||||
));
|
||||
|
|
|
@ -6,7 +6,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
|
|||
public function init()
|
||||
{
|
||||
// Add hosts autocomplete
|
||||
$this->addElement('text', 'hosts_autocomplete', array(
|
||||
$this->addElement('text', 'add_show_hosts_autocomplete', array(
|
||||
'label' => 'Type a Host:',
|
||||
'required' => false
|
||||
));
|
||||
|
@ -19,7 +19,7 @@ class Application_Form_AddShowWho extends Zend_Form_SubForm
|
|||
}
|
||||
|
||||
//Add hosts selection
|
||||
$hosts = new Zend_Form_Element_MultiCheckbox('hosts');
|
||||
$hosts = new Zend_Form_Element_MultiCheckbox('add_show_hosts');
|
||||
$hosts->setLabel('Hosts:')
|
||||
->setMultiOptions($options)
|
||||
->setRequired(true);
|
||||
|
|
|
@ -16,48 +16,48 @@ class Show {
|
|||
|
||||
$con = Propel::getConnection(CcShowPeer::DATABASE_NAME);
|
||||
|
||||
$sql = "SELECT time '{$data['start_time']}' + INTERVAL '{$data['duration']} hour' ";
|
||||
$sql = "SELECT time '{$data['add_show_start_time']}' + INTERVAL '{$data['add_show_duration']} hour' ";
|
||||
$r = $con->query($sql);
|
||||
$endTime = $r->fetchColumn(0);
|
||||
|
||||
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$data['start_date']} {$data['start_time']}')";
|
||||
$sql = "SELECT EXTRACT(DOW FROM TIMESTAMP '{$data['add_show_start_date']} {$data['add_show_start_time']}')";
|
||||
$r = $con->query($sql);
|
||||
$startDow = $r->fetchColumn(0);
|
||||
|
||||
if($data['no_end']) {
|
||||
if($data['add_show_no_end']) {
|
||||
$endDate = NULL;
|
||||
$data['repeats'] = 1;
|
||||
$data['add_show_repeats'] = 1;
|
||||
}
|
||||
else if($data['repeats']) {
|
||||
$sql = "SELECT date '{$data['end_date']}' + INTERVAL '1 day' ";
|
||||
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);
|
||||
}
|
||||
else {
|
||||
$sql = "SELECT date '{$data['start_date']}' + INTERVAL '1 day' ";
|
||||
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '1 day' ";
|
||||
$r = $con->query($sql);
|
||||
$endDate = $r->fetchColumn(0);
|
||||
}
|
||||
|
||||
if($data['day_check'] === null) {
|
||||
$data['day_check'] = array($startDow);
|
||||
if(!isset($data['add_show_day_check'])) {
|
||||
$data['add_show_day_check'] = array($startDow);
|
||||
}
|
||||
|
||||
$overlap = $this->getShows($data['start_date'], $endDate, $data['day_check'], $data['start_time'], $endTime);
|
||||
$overlap = $this->getShows($data['add_show_start_date'], $endDate, $data['add_show_day_check'], $data['add_show_start_time'], $endTime);
|
||||
|
||||
if(count($overlap) > 0) {
|
||||
return $overlap;
|
||||
}
|
||||
|
||||
$show = new CcShow();
|
||||
$show->setDbName($data['name']);
|
||||
$show->setDbRepeats($data['repeats']);
|
||||
$show->setDbDescription($data['description']);
|
||||
$show->setDbName($data['add_show_name']);
|
||||
$show->setDbRepeats($data['add_show_repeats']);
|
||||
$show->setDbDescription($data['add_show_description']);
|
||||
$show->save();
|
||||
|
||||
$showId = $show->getDbId();
|
||||
|
||||
foreach ($data['day_check'] as $day) {
|
||||
foreach ($data['add_show_day_check'] as $day) {
|
||||
|
||||
if($startDow !== $day){
|
||||
|
||||
|
@ -66,25 +66,25 @@ class Show {
|
|||
else
|
||||
$daysAdd = $day - $startDow;
|
||||
|
||||
$sql = "SELECT date '{$data['start_date']}' + INTERVAL '{$daysAdd} day' ";
|
||||
$sql = "SELECT date '{$data['add_show_start_date']}' + INTERVAL '{$daysAdd} day' ";
|
||||
$r = $con->query($sql);
|
||||
$start = $r->fetchColumn(0);
|
||||
}
|
||||
else {
|
||||
$start = $data['start_date'];
|
||||
$start = $data['add_show_start_date'];
|
||||
}
|
||||
|
||||
$showDay = new CcShowDays();
|
||||
$showDay->setDbFirstShow($start);
|
||||
$showDay->setDbLastShow($endDate);
|
||||
$showDay->setDbStartTime($data['start_time']);
|
||||
$showDay->setDbStartTime($data['add_show_start_time']);
|
||||
$showDay->setDbEndTime($endTime);
|
||||
$showDay->setDbDay($day);
|
||||
$showDay->setDbShowId($showId);
|
||||
$showDay->save();
|
||||
}
|
||||
|
||||
foreach ($data['hosts'] as $host) {
|
||||
foreach ($data['add_show_hosts'] as $host) {
|
||||
$showHost = new CcShowHosts();
|
||||
$showHost->setDbShow($showId);
|
||||
$showHost->setDbHost($host);
|
||||
|
|
|
@ -59,10 +59,10 @@ function submitShow() {
|
|||
$.post("/Schedule/add-show-dialog/format/json",
|
||||
formData,
|
||||
function(data){
|
||||
if(data.form) {
|
||||
if(data.content) {
|
||||
dialog.find("form").remove();
|
||||
dialog.find("#show_overlap_error").remove();
|
||||
dialog.append(data.form);
|
||||
dialog.append(data.content);
|
||||
|
||||
var start = dialog.find("#start_date");
|
||||
var end = dialog.find("#end_date");
|
||||
|
@ -121,8 +121,8 @@ function makeShowDialog(json) {
|
|||
dialog.append(json.content);
|
||||
dialog.find("#tabs").tabs();
|
||||
|
||||
var start = dialog.find("#start_date");
|
||||
var end = dialog.find("#end_date");
|
||||
var start = dialog.find("#add_show_start_date");
|
||||
var end = dialog.find("#add_show_end_date");
|
||||
|
||||
createDateInput(start, startDpSelect);
|
||||
createDateInput(end, endDpSelect);
|
||||
|
@ -131,7 +131,7 @@ function makeShowDialog(json) {
|
|||
return {value: el.id, label: el.login};
|
||||
});
|
||||
|
||||
dialog.find("#hosts_autocomplete").autocomplete({
|
||||
dialog.find("#add_show_hosts_autocomplete").autocomplete({
|
||||
source: auto,
|
||||
select: autoSelect
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue