}
}
- public function hasSchedule()
+ public function hasSchedule($pageId)
{
try {
$this->dbh = Toolkit_Database::getInstance();
$sql = "
SELECT *
FROM schedules
- WHERE active = true";
- $scheduleData = $this->dbh->query($sql)->fetch(PDO::FETCH_ASSOC);
+ WHERE page = :page";
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->bindParam(':page', $pageId, PDO::PARAM_INT);
+ $stmt->execute();
+
+ $scheduleData = $stmt->fetch(PDO::FETCH_ASSOC);
+
if (!$scheduleData) {
return false;
} else {
*
* @return type
*/
- public function toHtml()
+ public function toHtml($pageId)
{
// load ZendConfig
$this->config = new Zend_Config_Ini(
$cals = new Toolkit_Schedule_Calendar();
// get the active schedule if no active schedule is found then return
// nothing
- $scheduleData = $this->hasSchedule();
+ $scheduleData = $this->hasSchedule($pageId);
if (!$scheduleData) {
return false;
}
/**
* addScheduleAction
- *
+ *
* adds a empty schedule and echos id
* this is used in ajax call so exit do not return just echo and exit
*/
/**
* getCalendarYearAction
- *
+ *
* this is used in a ajax call so don't return just echo it and exit
* gets the set year calendars as html for output
*/
$html = $schedule->toHtml($this->registry);
return $html;
}
-
+
/**
* removeDepartureSetAction
- *
+ *
* removes the departures record and then removes all times and dates
*/
public function removeDepartureSetAction()
exit;
}
+ public function updatePageAction()
+ {
+ $scheduleId = filter_input(
+ INPUT_GET,
+ 'id',
+ FILTER_SANITIZE_NUMBER_INT
+ );
+ $page = filter_input(
+ INPUT_GET,
+ 'page',
+ FILTER_VALIDATE_INT
+ );
+ if (!$scheduleId) {
+ echo 0;
+ exit;
+ }
+ try {
+ $dbh = Toolkit_Database::getInstance();
+ $sql = "
+ UPDATE schedules
+ SET page = :page
+ WHERE id = :id";
+ $update = $dbh->prepare($sql);
+ $update->bindParam(
+ ':id',
+ $scheduleId,
+ PDO::PARAM_INT
+ );
+ $update->bindParam(
+ ':page',
+ $page,
+ PDO::PARAM_INT
+ );
+ $update->execute();
+ } catch(PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ exit;
+ }
+
/**
* updateScheduleYearAction
- *
+ *
* this is ajax call so don't return just echo and exit
* update the year field for the schedule record
*/
protected $timesBvi = array();
protected $dates = array();
+ const LEVELS_DEEP = 5;
+
/**
* For the Ajax call to add a departure set create the html and exit
*/
return $select;
}
- private function _parentSelect($catid = null)
+ private function _parentSelect($registry, $catid = null)
{
// select catid portion
$qs = "
SELECT id,navigation_name,parent
FROM toolbox.pages
+ WHERE id != ".HOME_ID."
ORDER BY parent,pos";
$dbh = $registry->dbh;
$data = $dbh->query($qs)->fetchAll(PDO::FETCH_ASSOC);
$data1 = $this->_sort_by_parent($data);
- $select = '<select name="page"><option value=""></option>';
+ $select = '<select name="page" id="schedulePageId"><option value=""></option>';
$parts = $this->_convertParent($data1, $data1[0]);
if (is_array($parts)) {
foreach($parts as $key => $value) {
if ($scheduleId) {
$page->departures = $this->getDepartures($registry, $scheduleId);
}
- $page->pageSelect = $this->_parentSelect();
+ $page->pageSelect
+ = $this->_parentSelect(
+ $registry,
+ $this->getSchedulePageId(
+ $registry,
+ $scheduleId
+ )
+ );
$page->colors = $this->colors;
$page->timesChx = $this->timesChx;
$page->timesBvi = $this->timesBvi;
for ($i = $startingYear; $i <= $endingYear; ++$i) {
$years[$i] = $i;
}
- $elements['schedule_year']->setOptions($years);
- $elements['schedule_year']->setValue($scheduleData['schedule_year']);
+ //$elements['schedule_year']->setOptions($years);
+ //$elements['schedule_year']->setValue($scheduleData['schedule_year']);
$html .= $tpl->bufferedOutputObject($page, $elements);
return $html;
}
+
+ public function getSchedulePageId($registry, $scheduleId)
+ {
+ try {
+ $sql = "
+ SELECT page
+ FROM boats.schedules
+ WHERE id = :id";
+ $stmt = $registry->dbh->prepare($sql);
+ $stmt->bindParam(':id', $scheduleId, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetchColumn();
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
}
$('.commentSave').live('click', function(){
var departureId = $(this).attr('rel');
var comments = $('#comments' + departureId).val();
-
+
$.ajax({
cache: false,
url: glm_baseUrl + "schedules/Edit/updateComment/",
$('.nameSave').live('click', function(){
var scheduleId = $(this).attr('rel');
var name = $('#scheduleNameText').val();
-
+
$.ajax({
cache: false,
url: glm_baseUrl + "schedules/Edit/updateName/",
}
});
});
+ // setup pageSave click for all future events
+ $('.pageSave').live('click', function(){
+ var scheduleId = $(this).attr('rel');
+ var page = $('#schedulePageId').val();
+
+ $.ajax({
+ cache: false,
+ url: glm_baseUrl + "schedules/Edit/updatePage/",
+ data: "id=" + scheduleId
+ + "&page=" + encodeURIComponent(page),
+ statusCode: {
+ 404: function() {
+ alert('page not found');
+ }
+ }
+ });
+ });
// for all glm_departures (from flexy phpToJson) setup departures
for (i in glm_departures) {
EditSchedule.setupDepartureById(glm_departures[i]);
"Edit Time": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
-
+
bValid = bValid && checkLength( depart_time, "Time", 4);
-
+
if (depart_time.val()) {
bValid = bValid && checkRegexp( depart_time, /([0-9]{1,2}:[0-9]{2} [APMapm]{2})$/i, "time in HH:MM AM or PM" );
}
$('.chxTime.addTime[rel="'+data.departure_id+'"]').before(
'<label class="timeLabel">' +
'<span rel="'+data.id+'" class="form-element">'+ data.time + '</span>' +
- '<span rel="'+data.id+'" class="ui-icon ui-icon-circle-minus"></span>' +
+ '<span rel="'+data.id+'" class="ui-icon ui-icon-circle-minus"></span>' +
'</label>'
);
} else if (data.dock == 2) {
$('.bviTime.addTime[rel="'+data.departure_id+'"]').before(
'<label class="timeLabel">' +
'<span rel="'+data.id+'" class="form-element">'+ data.time + '</span>' +
- '<span rel="'+data.id+'" class="ui-icon ui-icon-circle-minus"></span>' +
+ '<span rel="'+data.id+'" class="ui-icon ui-icon-circle-minus"></span>' +
'</label>'
);
}
}
});
}
-
+
$( this ).dialog( "close" );
}
},
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
-
+
},
// setup the departures by id
setupDepartureById: function(id){
}
});
});
-
+
$('#departureCal' + id).click(function(){
var ajaxUrl = glm_baseUrl + "schedules/Edit/getCalendarYear/";
var departureId = $(this).attr('rel');
var timeDate = new Date();
- ajaxUrl += "?id=" + glm_scheduleId
- + "&departId=" + id
+ ajaxUrl += "?id=" + glm_scheduleId
+ + "&departId=" + id
+ "&year=" + glm_scheduleYear
+ "&_=" + timeDate.getTime();
$('#departure' + departureId).load(ajaxUrl).dialog({
monthsHeight="monthsHeight"
/>
<div id="breadcrumbs"><a href="{backUrl:h}">Schedules</a> > {name:h} </div>
-<div>
- <label>
- Year for Schedule
- <select id="schedule_year" name="schedule_year">
- </select>
- </label>
-</div>
<div id="scheduleName" class="edit-field">
<input id="scheduleNameText" name="scheduleName" value="{name:h}" >
<button rel="{scheduleId}" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only nameSave">
</div>
<div id="schedulePage" class="edit-field">
{pageSelect:h}
- <button rel="{scheduleId}" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only nameSave">
+ <button rel="{scheduleId}" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only pageSave">
<span class="ui-button-text">Save</span>
</button>
</div>
$breadCrumbs = $breadCrumbsBuilder->toHtml($this->id);
$secondaryParagraphs = $this->getSecondaryParagraphs($this->id);
$primaryParagraph = $this->getPrimaryParagraph($this->id);
+ $schedules = new Toolkit_Schedule_DepartureCalendar();
+ $scheduleDisplay = $schedules->toHtml($this->id);
+
$coupons = null;
if (defined('COUPONS') && COUPONS) {
$coupons = $this->_getPageCoupons($this->id);
$primaryParagraph .
$secondaryParagraphs .
$staticPageContent .
+ $scheduleDisplay .
$coupons .
$photoGalleryContent;
}
+++ /dev/null
-<?php
-// need to get the config for app loaded
-$schedules = new Toolkit_Schedule_DepartureCalendar();
-echo $schedules->toHtml();
\ No newline at end of file