diff --git a/.zfproject.xml b/.zfproject.xml index 182da779d..bc8f59d24 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -72,6 +72,7 @@ + @@ -254,6 +255,9 @@ + + + diff --git a/application/configs/navigation.php b/application/configs/navigation.php index 6ccfe4c96..1790e0ac1 100644 --- a/application/configs/navigation.php +++ b/application/configs/navigation.php @@ -56,7 +56,16 @@ $pages = array( 'module' => 'default', 'controller' => 'Schedule', 'action' => 'index', - 'resource' => 'schedule' + 'resource' => 'schedule', + 'pages' => array( + array( + 'label' => 'Add Show', + 'module' => 'default', + 'controller' => 'Schedule', + 'action' => 'add-show-dialog', + 'resource' => 'schedule' + ) + ) ), array( 'label' => 'Logout', diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 026ce792c..8959948a0 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -33,15 +33,12 @@ class ScheduleController extends Zend_Controller_Action { $this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript'); $this->view->headScript()->appendFile('/js/contextmenu/jquery.contextMenu.js','text/javascript'); - $this->view->headScript()->appendFile('/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript'); - $this->view->headScript()->appendFile('/js/colorpicker/js/colorpicker.js','text/javascript'); - - + //$this->view->headScript()->appendFile('/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript'); + $this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript'); $this->view->headScript()->appendFile('/js/airtime/schedule/schedule.js','text/javascript'); $this->view->headLink()->appendStylesheet('/css/jquery.contextMenu.css'); $this->view->headLink()->appendStylesheet('/css/fullcalendar.css'); - $this->view->headLink()->appendStylesheet('/css/colorpicker/css/colorpicker.css'); $this->view->headLink()->appendStylesheet('/css/schedule.css'); @@ -76,6 +73,15 @@ class ScheduleController extends Zend_Controller_Action public function addShowDialogAction() { + $this->view->headScript()->appendFile('/js/fullcalendar/fullcalendar.min.js','text/javascript'); + $this->view->headScript()->appendFile('/js/colorpicker/js/colorpicker.js','text/javascript'); + $this->view->headScript()->appendFile('/js/airtime/schedule/full-calendar-functions.js','text/javascript'); + $this->view->headScript()->appendFile('/js/airtime/schedule/add-show.js','text/javascript'); + + $this->view->headLink()->appendStylesheet('/css/fullcalendar.css'); + $this->view->headLink()->appendStylesheet('/css/colorpicker/css/colorpicker.css'); + $this->view->headLink()->appendStylesheet('/css/add-show.css'); + $request = $this->getRequest(); $formWhat = new Application_Form_AddShowWhat(); $formWhat->removeDecorator('DtDdWrapper'); @@ -87,18 +93,18 @@ class ScheduleController extends Zend_Controller_Action $formRepeats->removeDecorator('DtDdWrapper'); $formStyle = new Application_Form_AddShowStyle(); $formStyle->removeDecorator('DtDdWrapper'); - - $this->view->what = $formWhat; - $this->view->when = $formWhen; - $this->view->repeats = $formRepeats; - $this->view->who = $formWho; - $this->view->style = $formStyle; if ($request->isPost()) { $data = $request->getPost(); - if ($formStyle->isValid($data) && $formWhen->isValid($data) && $formWho->isValid($data) && $formStyle->isValid($data)) { + $what = $formWhat->isValid($data); + $when = $formWhen->isValid($data); + $repeats = $formRepeats->isValid($data); + $who = $formWho->isValid($data); + $style = $formStyle->isValid($data); + + if ($what && $when && $repeats && $who && $style) { $userInfo = Zend_Auth::getInstance()->getStorage()->read(); @@ -107,15 +113,18 @@ class ScheduleController extends Zend_Controller_Action if(isset($overlap)) { $this->view->overlap = $overlap; - $this->view->form = $this->view->render('schedule/add-show-dialog.phtml'); } - - return; - } + else { + $this->_redirect('Schedule'); + } + } } - - $this->view->content = $this->view->render('schedule/add-show-dialog.phtml'); - $this->view->hosts = User::getHosts(); + + $this->view->what = $formWhat; + $this->view->when = $formWhen; + $this->view->repeats = $formRepeats; + $this->view->who = $formWho; + $this->view->style = $formStyle; } public function moveShowAction() diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index f255dd600..ba3b7ddfa 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -30,7 +30,15 @@ class UserController extends Zend_Controller_Action $this->view->form = $form; } + public function getHostsAction() + { + $this->view->hosts = User::getHosts(); + } + + } + + diff --git a/application/models/Users.php b/application/models/Users.php index 198bda1f6..0d25bbb16 100644 --- a/application/models/Users.php +++ b/application/models/Users.php @@ -39,14 +39,13 @@ class User { } - public static function getUsers($type=NULL) { + public static function getUsers($type=NULL, $search=NULL) { global $CC_DBC; $sql; - $sql_gen = "SELECT id, login, type FROM cc_subjs "; + $sql_gen = "SELECT id, login FROM cc_subjs "; $sql = $sql_gen; - if(!is_null($type)){ @@ -62,6 +61,9 @@ class User { $sql = $sql_gen ." WHERE ". $sql_type; } + if(!is_null($search)) { + $like = "login ILIKE '{$search}'"; + } $sql = $sql . " ORDER BY login"; diff --git a/application/views/scripts/schedule/add-show-dialog.phtml b/application/views/scripts/schedule/add-show-dialog.phtml index e4034620d..13cb4600d 100644 --- a/application/views/scripts/schedule/add-show-dialog.phtml +++ b/application/views/scripts/schedule/add-show-dialog.phtml @@ -1,24 +1,34 @@ -
-
- -
- what ?> -
-
-
- when ?> - repeats ?> -
-
- who ?> -
-
- style ?> -
+
+ +
+ +
+ what ?> +
+
+ when ?> + repeats ?> +
+
+ who ?> +
+
+ style ?> +
+
+ + +
+ +
+
+ overlap)) : ?> +
Overlap
+ partialLoop('schedule/show-overlap.phtml', $this->overlap); ?> +
- diff --git a/application/views/scripts/schedule/index.phtml b/application/views/scripts/schedule/index.phtml index 3f8400647..7c2dc4443 100644 --- a/application/views/scripts/schedule/index.phtml +++ b/application/views/scripts/schedule/index.phtml @@ -1,4 +1,3 @@ -
Add Show
    diff --git a/application/views/scripts/schedule/show-overlap.phtml b/application/views/scripts/schedule/show-overlap.phtml new file mode 100644 index 000000000..8b365fff8 --- /dev/null +++ b/application/views/scripts/schedule/show-overlap.phtml @@ -0,0 +1,4 @@ +
    + name ?> + start_time ?>-end_time ?> +
    diff --git a/application/views/scripts/user/get-hosts.phtml b/application/views/scripts/user/get-hosts.phtml new file mode 100644 index 000000000..1bee582a8 --- /dev/null +++ b/application/views/scripts/user/get-hosts.phtml @@ -0,0 +1 @@ +

    View script for controller User and script/action name getHosts
    \ No newline at end of file diff --git a/public/css/add-show.css b/public/css/add-show.css new file mode 100644 index 000000000..8761f4b2a --- /dev/null +++ b/public/css/add-show.css @@ -0,0 +1,22 @@ +#schedule-add-show, +#fullcalendar_show_display { + float: left; +} + +#schedule-add-show { + font-size: 12px; + width: 600px; +} + +#schedule-add-show textarea { + width: 100%; + height: 100px; +} + +#fullcalendar_show_display { + width: 400px; +} + +#schedule-add-show-overlap { + clear: left; +} diff --git a/public/css/schedule.css b/public/css/schedule.css index d9114f141..63317fe68 100644 --- a/public/css/schedule.css +++ b/public/css/schedule.css @@ -120,4 +120,8 @@ div.ui-datepicker { height: 200px; } +#fullcalendar_show_display { + width: 400px; +} + diff --git a/public/js/airtime/schedule/add-show.js b/public/js/airtime/schedule/add-show.js new file mode 100644 index 000000000..9e132427b --- /dev/null +++ b/public/js/airtime/schedule/add-show.js @@ -0,0 +1,105 @@ +/** +* +* Schedule Dialog creation methods. +* +*/ + +//dateText mm-dd-yy +function startDpSelect(dateText, inst) { + var time, date; + + time = dateText.split("-"); + date = new Date(time[0], time[1] - 1, time[2]); + + $("#end_date").datepicker("option", "minDate", date); +} + +function endDpSelect(dateText, inst) { + var time, date; + + time = dateText.split("-"); + date = new Date(time[0], time[1] - 1, time[2]); + + $("#start_date").datepicker( "option", "maxDate", date); +} + +function createDateInput(el, onSelect) { + var date; + + el.datepicker({ + minDate: new Date(), + onSelect: onSelect, + dateFormat: 'yy-mm-dd' + }); + + date = $.datepicker.formatDate("yy-mm-dd", new Date()); + el.val(date); +} + +function autoSelect(event, ui) { + + $("#hosts-"+ui.item.value).attr("checked", "checked"); + event.preventDefault(); +} + +function findHosts(request, callback) { + var search = request.term; + + +} + +function setAddShowEvents() { + var start, end; + + $("#schedule-add-show-tabs").tabs(); + + start = $("#add_show_start_date"); + end = $("#add_show_end_date"); + + createDateInput(start, startDpSelect); + createDateInput(end, endDpSelect); + + $("#add_show_hosts_autocomplete").autocomplete({ + source: findHosts, + select: autoSelect + }); + + $("#schedule-show-style input").ColorPicker({ + onSubmit: function(hsb, hex, rgb, el) { + $(el).val(hex); + $(el).ColorPickerHide(); + }, + onBeforeShow: function () { + $(this).ColorPickerSetColor(this.value); + } + }); + + $("#add-show-submit") + .button() + .click(function(){ + $("form").submit(); + }); +} + +$(document).ready(function() { + + setAddShowEvents(); + + $("#fullcalendar_show_display").fullCalendar({ + header: { + left: 'prev, next, today', + center: '', + right: '' + }, + defaultView: 'agendaDay', + editable: false, + allDaySlot: false, + lazyFetching: false, + + events: getFullCalendarEvents, + + //callbacks + eventRender: eventRender + }); + +}); diff --git a/public/js/airtime/schedule/full-calendar-functions.js b/public/js/airtime/schedule/full-calendar-functions.js new file mode 100644 index 000000000..3a078dfdc --- /dev/null +++ b/public/js/airtime/schedule/full-calendar-functions.js @@ -0,0 +1,147 @@ +/** +* +* Full Calendar callback methods. +* +*/ + +function makeTimeStamp(date){ + var sy, sm, sd, h, m, s, timestamp; + sy = date.getFullYear(); + sm = date.getMonth() + 1; + sd = date.getDate(); + h = date.getHours(); + m = date.getMinutes(); + s = date.getSeconds(); + + timestamp = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s; + return timestamp; +} + +function dayClick(date, allDay, jsEvent, view) { + var x; +} + +function eventRender(event, element, view) { + //element.qtip({ + // content: event.description + // }); + + if(view.name === 'agendaDay' || view.name === 'agendaWeek') { + var div = $('
    '); + div + .height('5px') + .width('100px') + .css('margin-top', '5px') + .progressbar({ + value: event.percent + }); + + if(event.percent === 0) { + // even at 0, the bar still seems to display a little bit of progress... + div.find("div").hide(); + } + + $(element).find(".fc-event-title").after(div); + + } + + if(event.backgroundColor !== "") { + $(element) + .css({'border-color': '#'+event.backgroundColor}) + .find(".fc-event-time, a") + .css({'background-color': '#'+event.backgroundColor, 'border-color': '#'+event.backgroundColor}); + } + if(event.color !== "") { + $(element) + .find(".fc-event-time, a") + .css({'color': '#'+event.color}); + } +} + +function eventAfterRender( event, element, view ) { + var today = new Date(); + + if(event.isHost === true && event.start > today) { + $(element).contextMenu( + {menu: 'schedule_event_host_menu'}, eventMenu + ); + } + else{ + $(element).contextMenu( + {menu: 'schedule_event_default_menu'}, eventMenu + ); + } + + $(element).data({'event': event}); +} + +function eventClick(event, jsEvent, view) { + var x; +} + +function eventMouseover(event, jsEvent, view) { +} + +function eventMouseout(event, jsEvent, view) { +} + +function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { + var url; + + if (event.repeats && dayDelta !== 0) { + revertFunc(); + return; + } + + url = '/Schedule/move-show/format/json'; + + $.post(url, + {day: dayDelta, min: minuteDelta, showId: event.id}, + function(json){ + if(json.overlap) { + revertFunc(); + } + }); +} + +function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) { + var url; + + url = '/Schedule/resize-show/format/json'; + + $.post(url, + {day: dayDelta, min: minuteDelta, showId: event.id}, + function(json){ + if(json.overlap) { + revertFunc(); + } + }); +} + +function getFullCalendarEvents(start, end, callback) { + var url, start_date, end_date; + + var sy, sm, sd, ey, em, ed; + sy = start.getFullYear(); + sm = start.getMonth() + 1; + sd = start.getDate(); + + start_date = sy +"-"+ sm +"-"+ sd; + + ey = end.getFullYear(); + em = end.getMonth() + 1; + ed = end.getDate(); + end_date = ey +"-"+ em +"-"+ ed; + + url = '/Schedule/event-feed'; + + if ((ed - sd) === 1) { + url = url + '/weekday/' + start.getDay(); + } + + var d = new Date(); + + $.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){ + callback(json.events); + }); +} diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index c014dd79e..7c8e621a8 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -4,166 +4,11 @@ * */ -function makeTimeStamp(date){ - var sy, sm, sd, h, m, s, timestamp; - sy = date.getFullYear(); - sm = date.getMonth() + 1; - sd = date.getDate(); - h = date.getHours(); - m = date.getMinutes(); - s = date.getSeconds(); - - timestamp = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s; - return timestamp; -} - -//dateText mm-dd-yy -function startDpSelect(dateText, inst) { - var time, date; - - time = dateText.split("-"); - date = new Date(time[0], time[1] - 1, time[2]); - - $("#end_date").datepicker("option", "minDate", date); -} - -function endDpSelect(dateText, inst) { - var time, date; - - time = dateText.split("-"); - date = new Date(time[0], time[1] - 1, time[2]); - - $("#start_date").datepicker( "option", "maxDate", date); -} - -function createDateInput(el, onSelect) { - var date; - - el.datepicker({ - minDate: new Date(), - onSelect: onSelect, - dateFormat: 'yy-mm-dd' - }); - - date = $.datepicker.formatDate("yy-mm-dd", new Date()); - el.val(date); -} - -function submitShow() { - - var formData, dialog; - - formData = $("#schedule_add_event_dialog").find("form").serializeArray(); - dialog = $(this); - - $.post("/Schedule/add-show-dialog/format/json", - formData, - function(data){ - if(data.content) { - - dialog.find("form").remove(); - makeShowDialog(dialog, data); - - if(data.overlap) { - var div, table, tr, days; - div = dialog.find("#show_overlap_error"); - table = $(''); - days = $.datepicker.regional[''].dayNamesShort; - - $.each(data.overlap, function(i, val){ - tr = $(""); - tr - .append("") - .append("") - .append("") - .append(""); - - table.append(tr); - }); - - div.append("Cannot add show. New show overlaps the following shows:"); - div.append(table); - dialog.append(div); - } - - } - else { - $("#schedule_calendar").fullCalendar( 'refetchEvents' ); - dialog.remove(); - } - }); -} - function closeDialog(event, ui) { $("#schedule_calendar").fullCalendar( 'refetchEvents' ); $(this).remove(); } -function autoSelect(event, ui) { - - $("#hosts-"+ui.item.value).attr("checked", "checked"); - event.preventDefault(); -} - -function makeShowDialog(dialog, json) { - - dialog.append(json.content); - dialog.find("#tabs").tabs(); - - var start = dialog.find("#add_show_start_date"); - var end = dialog.find("#add_show_end_date"); - - createDateInput(start, startDpSelect); - createDateInput(end, endDpSelect); - - var auto = json.hosts.map(function(el) { - return {value: el.id, label: el.login}; - }); - - dialog.find("#add_show_hosts_autocomplete").autocomplete({ - source: auto, - select: autoSelect - }); - - dialog.find("#schedule-show-style input").ColorPicker({ - onSubmit: function(hsb, hex, rgb, el) { - $(el).val(hex); - $(el).ColorPickerHide(); - }, - onBeforeShow: function () { - $(this).ColorPickerSetColor(this.value); - } - }); - - return dialog; -} - -function openShowDialog() { - var url; - - url = '/Schedule/add-show-dialog/format/json'; - - $.get(url, function(json){ - - var dialog; - - //main jqueryUI dialog - dialog = $('
    '); - makeShowDialog(dialog, json); - - dialog.dialog({ - autoOpen: false, - title: 'Add Show', - width: 1100, - height: 500, - modal: true, - close: closeDialog, - buttons: { "Cancel": closeDialog, "Ok": submitShow} - }); - - dialog.dialog('open'); - }); -} function setScheduleDialogHtml(json) { @@ -315,15 +160,18 @@ function openScheduleDialog(show) { } function eventMenu(action, el, pos) { - var method, event, date; + var method, event, start_timestamp, url; method = action.split('/').pop(); event = $(el).data('event'); - date = makeTimeStamp(event.start); + start_timestamp = makeTimeStamp(event.start); if (method === 'delete-show') { + + url = '/Schedule/delete-show'; + $.post(action, - {format: "json", showId: event.id, date: date}, + {format: "json", showId: event.id, date: start_timestamp}, function(json){ $("#schedule_calendar").fullCalendar( 'refetchEvents' ); }); @@ -333,125 +181,17 @@ function eventMenu(action, el, pos) { openScheduleDialog(event); } else if (method === 'clear-show') { - start_date = makeTimeStamp(event.start); - - url = '/Schedule/clear-show/format/json'; + + url = '/Schedule/clear-show'; $.post(url, - {start: start_date, showId: event.id}, + {format: "json", start: start_timestamp, showId: event.id}, function(json){ $("#schedule_calendar").fullCalendar( 'refetchEvents' ); }); } } -/** -* -* Full Calendar callback methods. -* -*/ - -function dayClick(date, allDay, jsEvent, view) { - var x; -} - -function eventRender(event, element, view) { - //element.qtip({ - // content: event.description - // }); - - if(view.name === 'agendaDay' || view.name === 'agendaWeek') { - var div = $('
    '); - div - .height('5px') - .width('100px') - .css('margin-top', '5px') - .progressbar({ - value: event.percent - }); - - if(event.percent === 0) { - // even at 0, the bar still seems to display a little bit of progress... - div.find("div").hide(); - } - - $(element).find(".fc-event-title").after(div); - - } - - if(event.backgroundColor !== "") { - $(element) - .css({'border-color': '#'+event.backgroundColor}) - .find(".fc-event-time, a") - .css({'background-color': '#'+event.backgroundColor, 'border-color': '#'+event.backgroundColor}); - } - if(event.color !== "") { - $(element) - .find(".fc-event-time, a") - .css({'color': '#'+event.color}); - } -} - -function eventAfterRender( event, element, view ) { - var today = new Date(); - - if(event.isHost === true && event.start > today) { - $(element).contextMenu( - {menu: 'schedule_event_host_menu'}, eventMenu - ); - } - else{ - $(element).contextMenu( - {menu: 'schedule_event_default_menu'}, eventMenu - ); - } - - $(element).data({'event': event}); -} - -function eventClick(event, jsEvent, view) { - var x; -} - -function eventMouseover(event, jsEvent, view) { -} - -function eventMouseout(event, jsEvent, view) { -} - -function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { - var url; - - if (event.repeats && dayDelta !== 0) { - revertFunc(); - return; - } - - url = '/Schedule/move-show/format/json'; - - $.post(url, - {day: dayDelta, min: minuteDelta, showId: event.id}, - function(json){ - if(json.overlap) { - revertFunc(); - } - }); -} - -function eventResize( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) { - var url; - - url = '/Schedule/resize-show/format/json'; - - $.post(url, - {day: dayDelta, min: minuteDelta, showId: event.id}, - function(json){ - if(json.overlap) { - revertFunc(); - } - }); -} - $(document).ready(function() { $('#schedule_calendar').fullCalendar({ @@ -465,35 +205,9 @@ $(document).ready(function() { allDaySlot: false, lazyFetching: false, - events: function(start, end, callback) { - var url, start_date, end_date; - - var sy, sm, sd, ey, em, ed; - sy = start.getFullYear(); - sm = start.getMonth() + 1; - sd = start.getDate(); + events: getFullCalendarEvents, - start_date = sy +"-"+ sm +"-"+ sd; - - ey = end.getFullYear(); - em = end.getMonth() + 1; - ed = end.getDate(); - end_date = ey +"-"+ em +"-"+ ed; - - url = '/Schedule/event-feed'; - - if ((ed - sd) === 1) { - url = url + '/weekday/' + start.getDay(); - } - - var d = new Date(); - - $.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){ - callback(json.events); - }); - }, - - //callbacks + //callbacks (from full-calendar-functions.js dayClick: dayClick, eventRender: eventRender, eventAfterRender: eventAfterRender, @@ -503,9 +217,7 @@ $(document).ready(function() { eventDrop: eventDrop, eventResize: eventResize - }) - - $('#schedule_add_show').click(openShowDialog); + }); });
    "+val.name+""+days[val.day]+""+val.start_time+""+val.end_time+"