From: Steve Sutton Date: Fri, 6 Jun 2014 15:20:16 +0000 (-0400) Subject: Setting up the boat schedule application from beaverisland X-Git-Tag: v1.0^2~91^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c3e92f5783ef3acc7ac34e711a665a6c33e9debc;p=web%2FSooLocks.git Setting up the boat schedule application from beaverisland Taking the beaverislandboatcompany schedule application. This is a start of it as it will need some work. --- diff --git a/Toolkit/Database.php b/Toolkit/Database.php index f6e6521..ef279b7 100644 --- a/Toolkit/Database.php +++ b/Toolkit/Database.php @@ -221,6 +221,11 @@ class Toolkit_Database $stmt->bindValue(':schema', 'videos', PDO::PARAM_STR); $stmt->execute(); } + if (defined('SCHEDULES') && SCHEDULES) { + // define videos search path + $stmt->bindValue(':schema', 'boats', PDO::PARAM_STR); + $stmt->execute(); + } if (defined('EVENT_MANAGEMENT') && EVENT_MANAGEMENT) { // define event management search path $stmt->bindValue(':schema', 'reservations', PDO::PARAM_STR); diff --git a/Toolkit/Schedule/Calendar.php b/Toolkit/Schedule/Calendar.php new file mode 100644 index 0000000..b93d00e --- /dev/null +++ b/Toolkit/Schedule/Calendar.php @@ -0,0 +1,161 @@ +build($dates); + $calYear = $wrapper->thisYear(); + $calMonthName = date( + 'F', + mktime( + 0, + 0, + 0, + $mCal->thisMonth(), + $mCal->thisDay(), + $mCal->thisYear() + ) + ); + $html = ' + + + + +
+ + + + + + + + + + + + + + '; + while ($day = $wrapper->fetch('Toolkit_Schedule_CalendarMonthDecorator')) { + if ($day->isFirst()) { + $html .= ' + '; + } + if ($day->isEmpty()) { + $html .= ''; + } else { + $class = ($day->isSelected()) + ? ' '.$day->calendar->class + : ' noDeparture'; + $html .= ''; + } + + if ($day->isLast()) { + $html .= ' + '; + } + } + $html .= ' +
'.$calMonthName.' '.$calYear.'
SMTWTFS
 '.$day->thisDay().'
+
+ '; + return $html; + } + + /** + * getDepartureColors + * + * @param type $scheduleId + * @return type + */ + public function getDepartureColors($scheduleId) + { + $colors = array(); + $scheduleId = (int)$scheduleId + 0; + if (!is_numeric($scheduleId)) { + throw new Exception('ScheduleId must be a digit'); + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + SELECT id,color + FROM departures + WHERE schedule_id = :schedule_id"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->execute(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $colors[$row['id']] = $row['color']; + } + } catch(PDOException $e){ + Toolkit_Common::handleError($e); + } + return $colors; + } + + /** + * getDepartureDates + * + * @param type $scheduleId + * @return Calendar_Day + */ + public function getDepartureDates($scheduleId) + { + $dates = array(); + if (!ctype_digit($scheduleId)) { + throw new Exception('ScheduleId must be a digit'); + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + SELECT id,departure_id,departure_date + FROM departure_dates + WHERE schedule_id = :schedule_id"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->execute(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $timeStamp = strtotime($row['departure_date']); + $date = new Date($timeStamp); + $day = new Calendar_Day( + $date->getYear(), + $date->getMonth(), + $date->getDay() + ); + $day->class = 'depart'.$row['departure_id']; + $dates[$row['id']] = $day; + } + } catch(PDOException $e){ + Toolkit_Common::handleError($e); + } + return $dates; + } +} diff --git a/Toolkit/Schedule/CalendarMonthDecorator.php b/Toolkit/Schedule/CalendarMonthDecorator.php new file mode 100644 index 0000000..bb66889 --- /dev/null +++ b/Toolkit/Schedule/CalendarMonthDecorator.php @@ -0,0 +1,15 @@ +dbh = Toolkit_Database::getInstance(); + $sql = " + SELECT * + FROM departure_dates + WHERE schedule_id = :schedule_id + ORDER BY departure_date"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->execute(); + $scheduleDates = $stmt->fetchAll(PDO::FETCH_ASSOC); + if (!$scheduleDates) { + return false; + } else { + $dates = array(); + foreach ($scheduleDates as $row) { + $dates[] = $row['departure_date']; + } + return $dates; + } + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + public function getDeparturesForDate() + { + $date = filter_input( + INPUT_POST, + 'departDate', + FILTER_SANITIZE_STRING + ); + if ($date) { + $isDate = preg_match('/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/', $date); + } else { + $isDate = false; + } + $dock = filter_input( + INPUT_POST, + 'dock', + FILTER_SANITIZE_NUMBER_INT + ); + if ($dock && $isDate) { + try { + // get the comments for the date + $sql = " + SELECT comments + FROM departures + WHERE id IN ( + SELECT departure_id + FROM departure_dates + WHERE departure_date = :date)"; + $stmt1 = $this->dbh->prepare($sql); + $stmt1->bindParam( + ':date', + $date, + PDO::PARAM_STR + ); + $stmt1->execute(); + $sql = " + SELECT * + FROM departure_times + WHERE departure_id IN ( + SELECT departure_id + FROM departure_dates + WHERE departure_date = :date) + AND dock = :dock"; + $stmt = $this->dbh->prepare($sql); + $stmt->bindParam( + ':dock', + $dock, + PDO::PARAM_INT + ); + $stmt->bindParam( + ':date', + $date, + PDO::PARAM_STR + ); + $stmt->execute(); + return array( + 'comments' => nl2br($stmt1->fetchColumn()), + 'times' => $stmt->fetchAll(PDO::FETCH_ASSOC), + 'date' => $date, + 'dock' => ( + ($dock == 1) + ? 'Charlevoix' + : 'Beaver Island' + ) + ); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + } + + public function hasSchedule() + { + try { + $this->dbh = Toolkit_Database::getInstance(); + $sql = " + SELECT * + FROM schedules + WHERE active = true"; + $scheduleData = $this->dbh->query($sql)->fetch(PDO::FETCH_ASSOC); + if (!$scheduleData) { + return false; + } else { + return $scheduleData; + } + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + /** + * toHtml + * + * return the html for the schedules + * + * @return type + */ + public function toHtml() + { + // load ZendConfig + $this->config = new Zend_Config_Ini( + BASE . 'Toolkit/Schedule/application.ini', + strtolower($_ENV['GLM_HOST_ID']) + ); + // setup flexy options from global then override with config values + $this->flexyOptions = $GLOBALS['flexyOptions']; + $this->flexyOptions['templateDir'] + = $this->config->flexy->options->templateDir; + $this->flexyOptions['compileDir'] + = $this->config->flexy->options->compileDir; + $cals = new Toolkit_Schedule_Calendar(); + // get the active schedule if no active schedule is found then return + // nothing + $scheduleData = $this->hasSchedule(); + if (!$scheduleData) { + return false; + } + $scheduleId = (string)$scheduleData['id']; + $scheduleName = $scheduleData['name']; + $year = $scheduleData['schedule_year']; + + $colors + = ($scheduleId) + ? $cals->getDepartureColors($scheduleId) + : null; + $style = ''; + if ($colors) { + foreach ($colors as $departId => $color) { + $style .= ".depart{$departId} {background-color:{$color};}\n"; + } + } + $selected = $cals->getDepartureDates($scheduleId); + $year + = ($year) + ? $year + : date('Y'); + $page = new stdClass(); + $startingMonth = $this->config->months->start; + $endingMonth = $this->config->months->end; + for ($i = $startingMonth; $i <= $endingMonth; ++$i) { + $page->calendarsHtml .= $cals->buildCalendar($i, $year, $selected); + } + $tpl = new HTML_Template_Flexy($this->flexyOptions); + $page->style = $style; + $page->appBase = GLM_APP_BASE_URL; + $page->baseUrl = BASE_URL; + $page->scheduleId = $scheduleId; + $page->scheduleName = $scheduleName; + $page->departByDate = $this->getDeparturesForDate(); + $ScheduleEdit = new Toolkit_Schedule_EditSchedule(); + $page->departures = $ScheduleEdit->getDeparturesForSchedules( + $this, + $scheduleId + ); + $tpl->compile('departuresScheduleCalendar.html'); + $calendars = $tpl->bufferedOutputObject($page); + return $calendars; + } +} diff --git a/Toolkit/Schedule/EditController.php b/Toolkit/Schedule/EditController.php new file mode 100644 index 0000000..b9337ec --- /dev/null +++ b/Toolkit/Schedule/EditController.php @@ -0,0 +1,703 @@ +addDepartureSet( + $this->registry, + $scheduleId + ); + echo json_encode($data); + exit; + } + + /** + * addScheduleAction + * + * adds a empty schedule and echos id + * this is used in ajax call so exit do not return just echo and exit + */ + public function addScheduleAction() + { + $schedule = new Toolkit_Schedule_EditSchedule(); + $scheduleId = $schedule->addSchedule($this->registry); + echo $scheduleId; + 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 + */ + public function getCalendarYearAction() + { + $cals = new Toolkit_Schedule_Calendar(); + $scheduleId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $departureId = filter_input( + INPUT_GET, + 'departId', + FILTER_SANITIZE_NUMBER_INT + ); + $year = filter_input( + INPUT_GET, + 'year', + FILTER_SANITIZE_NUMBER_INT + ); + $colors + = ($scheduleId) + ? $cals->getDepartureColors($scheduleId) + : null; + $style = ''; + if ($colors) { + foreach ($colors as $departId => $color) { + $style .= ".depart{$departId} {background-color:{$color};}\n"; + } + } + $selected = $cals->getDepartureDates($scheduleId); + $year + = ($year) + ? $year + : date('Y'); + $page = new stdClass(); + $startingMonth = $this->registry->config->months->start; + $endingMonth = $this->registry->config->months->end; + for ($i = $startingMonth; $i <= $endingMonth; ++$i) { + $page->calendarsHtml .= $cals->buildCalendar($i, $year, $selected); + } + $tpl = new HTML_Template_Flexy( + $this->registry->flexyOptions + ); + $page->prevYear = $year - 1; + $page->nextYear = $year + 1; + $page->style = $style; + $page->appBase = GLM_APP_BASE_URL; + $page->baseUrl = BASE_URL; + $page->scheduleId = $scheduleId; + $page->departureId = $departureId; + $tpl->compile('scheduleCalendar.html'); + $tpl->outputObject($page); + exit; + } + + /** + * getTimeAction + * + * grab the data for a given departure_times record + * based on the id in GET + */ + public function getTimeAction() + { + $departureTimeId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + if (!$departureTimeId) { + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + SELECT * + FROM departure_times + WHERE id = :id"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam( + ':id', + $departureTimeId, + PDO::PARAM_INT + ); + $stmt->execute(); + $formData = $stmt->fetch(PDO::FETCH_ASSOC); + if ($formData) { + echo json_encode($formData); + } else { + echo 0; + } + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } + + /** + * indexAction + * + * default action if no action is set in GET['ac'] + * + * @return type string HTML + */ + public function indexAction() + { + $schedule = new Toolkit_Schedule_EditSchedule(); + $html = $schedule->toHtml($this->registry); + return $html; + } + + /** + * removeDepartureSetAction + * + * removes the departures record and then removes all times and dates + */ + public function removeDepartureSetAction() + { + $dbh = Toolkit_Database::getInstance(); + $departureId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + if (!$departureId) { + echo 0; + exit; + } + $schedules = new Toolkit_Schedule_EditSchedule(); + $deleted = $schedules->removeDeparturesById($dbh, $departureId); + if ($deleted) { + $schedules->removeDepartureDatesById($dbh, $departureId); + $schedules->removeDepartureTimesById($dbh, $departureId); + } + echo 1; + exit; + } + + /** + * removeTimeAction + * + * remove the departure_times record based on the id in GET + */ + public function removeTimeAction() + { + $departureTimeId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + if (!$departureTimeId) { + echo 0; + exit; + } + + try { + $dbh = Toolkit_Database::getInstance(); + if ($departureTimeId) { + $sql = " + DELETE + FROM departure_times + WHERE id = :id"; + $delete = $dbh->prepare($sql); + $delete->bindParam( + ':id', + $departureTimeId, + PDO::PARAM_INT + ); + $delete->execute(); + } + echo 1; + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } + + /** + * saveTimeAction + * + * save the date from the edit form for the departure_times record + */ + public function saveTimeAction() + { + $departureTimeId = filter_input( + INPUT_POST, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $departureTime = filter_input( + INPUT_POST, + 'depart_time', + FILTER_SANITIZE_STRING + ); + $dock = filter_input( + INPUT_POST, + 'dock', + FILTER_SANITIZE_NUMBER_INT + ); + $departureId = filter_input( + INPUT_POST, + 'departure_id', + FILTER_SANITIZE_NUMBER_INT + ); + if (!$departureTime) { + echo 0; + exit; + } + + try { + $dbh = Toolkit_Database::getInstance(); + $departureTime = strtoupper($departureTime); + if ($departureTimeId) { + $sql = " + UPDATE departure_times + SET departure_time = :departure_time + WHERE id = :id"; + $update = $dbh->prepare($sql); + $update->bindParam( + ':id', + $departureTimeId, + PDO::PARAM_INT + ); + $update->bindParam( + ':departure_time', + $departureTime, + PDO::PARAM_STR + ); + $update->execute(); + } else { + if ($departureId && $dock) { + $sql = " + SELECT schedule_id + FROM departures + WHERE id = :id"; + $get = $dbh->prepare($sql); + $get->bindParam(':id', $departureId, PDO::PARAM_INT); + $get->execute(); + $scheduleId = $get->fetchColumn(); + if (!$scheduleId) { + echo 0; + } + $sql = " + INSERT INTO departure_times + (departure_id,dock,departure_time,schedule_id) + VALUES + (:departure_id,:dock,:departure_time,:schedule_id) + RETURNING id"; + $insert = $dbh->prepare($sql); + $insert->bindParam( + ':departure_time', + $departureTime, + PDO::PARAM_STR + ); + $insert->bindParam( + ':departure_id', + $departureId, + PDO::PARAM_INT + ); + $insert->bindParam( + ':dock', + $dock, + PDO::PARAM_INT + ); + $insert->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $insert->execute(); + $departureTimeId = $insert->fetchColumn(); + } + } + echo json_encode( + array( + 'id' => $departureTimeId, + 'departure_id' => $departureId, + 'time' => $departureTime, + 'dock' => $dock + ) + ); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } + + /** + * updateActiveAction + * + * update which schedule is active + * turn off all others + */ + public function updateActiveAction() + { + $scheduleId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + if ($scheduleId === false) { + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + UPDATE schedules + SET active = true + WHERE id = :id"; + $update = $dbh->prepare($sql); + $update->bindParam( + ':id', + $scheduleId, + PDO::PARAM_INT + ); + $update->execute(); + $sql = " + UPDATE schedules + SET active = false + WHERE id != :id"; + $updateOthers = $dbh->prepare($sql); + $updateOthers->bindParam( + ':id', + $scheduleId, + PDO::PARAM_INT + ); + $updateOthers->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } + + /** + * updateColorAction + * + * update the color for the departule record + */ + public function updateColorAction() + { + $departureId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $color = filter_input( + INPUT_GET, + 'color', + FILTER_SANITIZE_STRING + ); + if (!$departureId) { + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + UPDATE departures + SET color = :color + WHERE id = :id"; + $update = $dbh->prepare($sql); + $update->bindParam( + ':id', + $departureId, + PDO::PARAM_INT + ); + $update->bindParam( + ':color', + $color, + PDO::PARAM_STR + ); + $update->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } + + /** + * updateCommentAction + * + * update the comment for the departures record from the edit form + */ + public function updateCommentAction() + { + $departureId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $comments = filter_input( + INPUT_GET, + 'comments', + FILTER_SANITIZE_STRING + ); + if (!$departureId) { + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + UPDATE departures + SET comments = :comments + WHERE id = :id"; + $update = $dbh->prepare($sql); + $update->bindParam( + ':id', + $departureId, + PDO::PARAM_INT + ); + $update->bindParam( + ':comments', + $comments, + PDO::PARAM_STR + ); + $update->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } + + /** + * updateDatesAction + * + * when you update a departure_dates record you'll have to check to see if + * this schedule_id has any other departure_dates with that date and update + * that record to the new departure_id for. + * else + * you'll insert a new date for that departure + * one condition though if the date for it exists as the departure_id you're + * setting up then delete that departure_dates record + */ + public function updateDatesAction() + { + $scheduleId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $depatureId = filter_input( + INPUT_GET, + 'departId', + FILTER_SANITIZE_NUMBER_INT + ); + $date = filter_input( + INPUT_GET, + 'date', + FILTER_SANITIZE_STRING + ); + if (!$scheduleId || !$depatureId || !$date) { +// var_dump($scheduleId); +// var_dump($depatureId); +// var_dump($date); +// echo 'hi no vars'; + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + SELECT departure_id + FROM departure_dates + WHERE schedule_id = :schedule_id + AND departure_date = :departure_date"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->bindParam( + ':departure_date', + $date, + PDO::PARAM_INT + ); + $stmt->execute(); + $hasDate = $stmt->fetchColumn(); + if ($hasDate == $depatureId) { + // then delete the record + $sql = " + DELETE + FROM departure_dates + WHERE schedule_id = :schedule_id + AND departure_date = :departure_date"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->bindParam( + ':departure_date', + $date, + PDO::PARAM_INT + ); + $stmt->execute(); + echo ''; + exit; + } else if ($hasDate) { + // need to update the date to have the new departure_id + $sql = " + UPDATE departure_dates + SET departure_id = :departure_id + WHERE schedule_id = :schedule_id + AND departure_date = :departure_date"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->bindParam( + ':departure_date', + $date, + PDO::PARAM_INT + ); + $stmt->bindParam( + ':departure_id', + $depatureId, + PDO::PARAM_INT + ); + $stmt->execute(); + echo 'depart'.$depatureId; + exit; + } else { + // insert a new record for this one + $sql = " + INSERT INTO departure_dates + (departure_id,schedule_id,departure_date) + VALUES + (:departure_id,:schedule_id,:departure_date) + RETURNING id"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->bindParam( + ':departure_date', + $date, + PDO::PARAM_INT + ); + $stmt->bindParam( + ':departure_id', + $depatureId, + PDO::PARAM_INT + ); + $stmt->execute(); + echo 'depart'.$depatureId; + exit; + } + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + echo 0; + exit; + } + + /** + * updateNameAction + * + * update the name for the schedules record from the edit form + */ + public function updateNameAction() + { + $scheduleId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $name = filter_input( + INPUT_GET, + 'name', + FILTER_SANITIZE_STRING + ); + if (!$scheduleId) { + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + UPDATE schedules + SET name = :name + WHERE id = :id"; + $update = $dbh->prepare($sql); + $update->bindParam( + ':id', + $scheduleId, + PDO::PARAM_INT + ); + $update->bindParam( + ':name', + $name, + PDO::PARAM_STR + ); + $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 + */ + public function updateScheduleYearAction() + { + $scheduleId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $year = filter_input( + INPUT_GET, + 'year', + FILTER_SANITIZE_STRING + ); + if (!$scheduleId) { + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + UPDATE schedules + SET schedule_year = :year + WHERE id = :id"; + $update = $dbh->prepare($sql); + $update->bindParam( + ':id', + $scheduleId, + PDO::PARAM_INT + ); + $update->bindParam( + ':year', + $year, + PDO::PARAM_STR + ); + $update->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } +} diff --git a/Toolkit/Schedule/EditSchedule.php b/Toolkit/Schedule/EditSchedule.php new file mode 100644 index 0000000..24a8e08 --- /dev/null +++ b/Toolkit/Schedule/EditSchedule.php @@ -0,0 +1,424 @@ +dbh; + // create the record first then fetch it and output the html + // exit after this (it's used in an ajax request) + $tpl = new HTML_Template_Flexy($registry->flexyOptions); + $tpl->compile('departureRow.html'); + $page = new stdClass(); + $page->appBase = GLM_APP_BASE_URL; + try { + $sql = " + INSERT INTO departures + (schedule_id) + VALUES + (:schedule_id) + RETURNING *"; + $insert = $dbh->prepare($sql); + $insert->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $insert->execute(); + $page->departures = $insert->fetchAll(); + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + } + return array( + 'id' => $page->departures[0]['id'], + 'html' => $tpl->bufferedOutputObject($page) + ); + } + + /** + * addSchedule + * + * Creates a new empty schedule record + * return the new id + * + * @param type $registry + * @return type + */ + public function addSchedule($registry) + { + $dbh = $registry->dbh; + try { + $year = date('Y'); + $sql = " + INSERT INTO schedules + (name,schedule_year) + VALUES + ('default name',{$year}) + RETURNING id"; + $insert = $dbh->query($sql); + return $insert->fetchColumn(); + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + /** + * add times to the timesBvi array + * + * @param type $times array of times + */ + protected function addTimesBvi($times) + { + if (is_array($times) && !empty($times)) { + foreach ($times as $time) { + $this->timesBvi[] = $time['id']; + } + } + } + + /** + * add times to the timesChx array + * + * @param type $times array of times + */ + protected function addTimesChx($times) + { + if (is_array($times) && !empty($times)) { + foreach ($times as $time) { + $this->timesChx[] = $time['id']; + } + } + } + + /** + * get the departure times for dock 1 for a departureId + * + * @param type $registry Registry class obj + * @param type $departureId id of the departure record + * @return type data array + */ + protected function getDepartTimesChx($registry, $departureId) + { + try { + $sql = " + SELECT * + FROM departure_times + WHERE departure_id = :departure_id + AND dock = 1 + ORDER BY id"; + $stmt = $registry->dbh->prepare($sql); + $stmt->bindParam( + ':departure_id', + $departureId, + PDO::PARAM_INT + ); + $stmt->execute(); + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + /** + * get the departure dates for a departureId + * + * @param type $registry Registry class obj + * @param type $departureId id of the departure record + * @return type data array + */ + protected function getDepartDates($registry, $departureId) + { + try { + $sql = " + SELECT * + FROM departure_dates + WHERE departure_id = :departure_id + ORDER BY id"; + $stmt = $registry->dbh->prepare($sql); + $stmt->bindParam( + ':departure_id', + $departureId, + PDO::PARAM_INT + ); + $stmt->execute(); + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + /** + * get the departure times for dock 2 for a departureId + * + * @param type $registry Registry class obj + * @param type $departureId id of the departure record + * @return type data array + */ + protected function getDepartTimesBeaver($registry, $departureId) + { + try { + $sql = " + SELECT * + FROM departure_times + WHERE departure_id = :departure_id + AND dock = 2 + ORDER BY id"; + $stmt = $registry->dbh->prepare($sql); + $stmt->bindParam( + ':departure_id', + $departureId, + PDO::PARAM_INT + ); + $stmt->execute(); + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + /** + * get all departures for a schedule + * + * @param type $registry Registry Obj + * @param type $scheduleId schedule id + * @return type array of data + */ + protected function getDepartures($registry, $scheduleId) + { + try { + $sql = " + SELECT * + FROM departures + WHERE schedule_id = :schedule_id + ORDER BY id"; + $stmt = $registry->dbh->prepare($sql); + $stmt->bindParam( + ':schedule_id', + $scheduleId, + PDO::PARAM_INT + ); + $stmt->execute(); + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $this->colors[] = $row['id']; + $departures[$row['id']] = $row; + $chxTimes = $this->getDepartTimesChx( + $registry, + $row['id'] + ); + $departures[$row['id']]['cTimes'] = $chxTimes; + $this->addTimesChx($chxTimes); + $bviTimes = $this->getDepartTimesBeaver( + $registry, + $row['id'] + ); + $departures[$row['id']]['bTimes'] = $bviTimes; + $this->addTimesBvi($bviTimes); + $dates = $this->getDepartDates($registry, $row['id']); + if ($dates) { + $departDates = array(); + foreach ($dates as $date) { + $departDates[] = $date['departure_time']; + } + $departures[$row['id']]['dates'] = implode(',', $departDates); + } + } + return $departures; + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + public function getDeparturesForSchedules($registry, $scheduleId) + { + return $this->getDepartures($registry, $scheduleId); + } + + /** + * Get the schedule name from and scheduleId + * + * @param PDO $dbh PDO obj + * @param type $scheduleId id for schedule record + * @return type string name of schedule + */ + protected function getSheduleData(PDO $dbh, $scheduleId) + { + try { + $sql = " + SELECT * + FROM schedules + WHERE id = :id"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam(':id', $scheduleId, PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetch(PDO::FETCH_ASSOC); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + + /** + * removeDeparturesById + * + * Removes the departures record by id + * + * @param PDO $dbh PDO object + * @param type $departureId id to delete + * @return type + */ + public function removeDeparturesById(PDO $dbh, $departureId) + { + if (!ctype_digit($departureId)) { + throw new Exception('DepartureId need to be a Integer'); + } + try { + $sql = " + DELETE + FROM departures + WHERE id = :id"; + $delete = $dbh->prepare($sql); + $delete->bindParam( + ':id', + $departureId, + PDO::PARAM_INT + ); + $delete->execute(); + return true; + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + return false; + } + } + + /** + * removeDepartureDatesById + * + * Removes all the departure dates record by id + * + * @param PDO $dbh PDO object + * @param type $departureId id to delete + * @return type + */ + public function removeDepartureDatesById(PDO $dbh, $departureId) + { + if (!ctype_digit($departureId)) { + throw new Exception('DepartureId need to be a Integer'); + } + try { + $sql = " + DELETE + FROM departure_dates + WHERE departure_id = :id"; + $delete = $dbh->prepare($sql); + $delete->bindParam( + ':id', + $departureId, + PDO::PARAM_INT + ); + $delete->execute(); + return true; + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + return false; + } + } + + /** + * removeDepartureTimesById + * + * Removes all the departure times record by id + * + * @param PDO $dbh PDO object + * @param type $departureId id to delete + * @return type + */ + public function removeDepartureTimesById(PDO $dbh, $departureId) + { + if (!ctype_digit($departureId)) { + throw new Exception('DepartureId need to be a Integer'); + } + try { + $sql = " + DELETE + FROM departure_times + WHERE departure_id = :id"; + $delete = $dbh->prepare($sql); + $delete->bindParam( + ':id', + $departureId, + PDO::PARAM_INT + ); + $delete->execute(); + return true; + } catch (PDOException $e) { + Toolkit_Common::handleError($e); + return false; + } + } + + /** + * Return the html for the edit form + * + * @param type $registry Registry obj + * @return type string HTML + */ + public function toHtml($registry) + { + $GLOBALS['styleSheets'][] + = GLM_APP_BASE_URL . + 'libjs/jqueryui/1.8.13/development-bundle/themes/cupertino/jquery.ui.all.css'; + $GLOBALS['bottomScripts'][] + = GLM_APP_BASE_URL . + 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js'; + // css and js for "Really Simple Color Picker" + $GLOBALS['styleSheets'][] + = BASE_URL . 'css/colorPicker.css'; + $GLOBALS['bottomScripts'][] + = BASE_URL . 'libjs/jquery.colorPicker.js'; + + // javascript for the edit schedule page + $GLOBALS['bottomScripts'][] + = BASE_URL . 'Toolkit/Schedule/js/editSchedule.js'; + $scheduleId = filter_input( + INPUT_GET, + 'id', + FILTER_SANITIZE_NUMBER_INT + ); + $tpl = new HTML_Template_Flexy($registry->flexyOptions); + $tpl->compile('editSchedule.html'); + $page = new stdClass(); + $page->appBase = GLM_APP_BASE_URL; + $page->baseUrl = BASE_URL; + $page->scheduleId = $scheduleId; + if ($scheduleId) { + $page->departures = $this->getDepartures($registry, $scheduleId); + } + $page->colors = $this->colors; + $page->timesChx = $this->timesChx; + $page->timesBvi = $this->timesBvi; + $scheduleData = $this->getSheduleData($registry->dbh, $scheduleId); + $page->name = $scheduleData['name']; + $page->year = $scheduleData['schedule_year']; + $page->backUrl = BASE_URL . 'admin/schedules.php'; + $page->monthsHeight = (int)$registry->config->months->height; + $page->monthsWidth = (int)$registry->config->months->width; + $elements = $tpl->getElements(); + $startingYear = 2011; + $endingYear = $startingYear + 5; + $years = array(); + for ($i = $startingYear; $i <= $endingYear; ++$i) { + $years[$i] = $i; + } + $elements['schedule_year']->setOptions($years); + $elements['schedule_year']->setValue($scheduleData['schedule_year']); + $html .= $tpl->bufferedOutputObject($page, $elements); + return $html; + } +} diff --git a/Toolkit/Schedule/IndexController.php b/Toolkit/Schedule/IndexController.php new file mode 100644 index 0000000..2d6768c --- /dev/null +++ b/Toolkit/Schedule/IndexController.php @@ -0,0 +1,34 @@ +toHtml($this->registry); + return $html; + } + + /** + * editAction + * + * edit action if set as ac=edit + * + * @return type + */ + public function editAction() + { + $schedule = new Toolkit_Schedule_EditSchedule(); + $html = $schedule->toHtml($this->registry); + return $html; + } +} diff --git a/Toolkit/Schedule/ListSchedules.php b/Toolkit/Schedule/ListSchedules.php new file mode 100644 index 0000000..f9bd659 --- /dev/null +++ b/Toolkit/Schedule/ListSchedules.php @@ -0,0 +1,39 @@ +flexyOptions); + $page = new stdClass(); + $page->baseUrl = BASE_URL; + $page->editLinkUrlBase + = BASE_URL . 'admin/schedules.php?rt=Edit&id='; + $whichActiveSql = " + SELECT id + FROM schedules + WHERE active = true"; + $page->active = $registry->dbh + ->query($whichActiveSql) + ->fetchColumn(); + $sql = " + SELECT * + FROM schedules + ORDER BY id"; + $page->schedules = $registry->dbh + ->query($sql) + ->fetchAll(PDO::FETCH_ASSOC); + $tpl->compile('listSchedules.html'); + return $tpl->bufferedOutputObject($page); + } +} diff --git a/Toolkit/Schedule/application.ini b/Toolkit/Schedule/application.ini new file mode 100644 index 0000000..21966c0 --- /dev/null +++ b/Toolkit/Schedule/application.ini @@ -0,0 +1,34 @@ +; Production server configuration data +[production] +; name of the application +applicationName = "Boat Schedule" + +; flexy options for all the templates used in this application +; based on the GLOBALS['flexyOptions'] +flexy.options.templateDir = BASE "Toolkit/Schedule/templates/" +flexy.options.compileDir = BASE "Toolkit/Schedule/templates/compiled/" + +; the starting month to use in the multiple date picker +months.start = 4 +; the ending month to use in the multiple date picker +months.end = 12 +; controls the width of the dialog box for the multiple date picker +months.width = 500 +; controls the height of the dialog box for the multiple date picker +months.height = 580 + +; development server configuration data inherits from production and +; overrides values as necessary +[development : production] + +; chuck's server configuration data inherits from development +; and overrides values as necessary +[chuck : development] + +; john's server configuration data inherits from development +; and overrides values as necessary +[john : development] + +; steve's server configuration data inherits from development +; and overrides values as necessary +[steve : development] diff --git a/Toolkit/Schedule/js/dateSearch.js b/Toolkit/Schedule/js/dateSearch.js new file mode 100644 index 0000000..a30b967 --- /dev/null +++ b/Toolkit/Schedule/js/dateSearch.js @@ -0,0 +1,29 @@ + +$(document).ready(function(){ +// $("#dateSearch").datepicker({ +// altField: '#departDate' +// }); + $("#departDate").datepicker({ + showOn: "button", + buttonImage: "http://app.gaslightmedia.com/assets/icons/calendar.png", + buttonImageOnly: true, + minDate: new Date(minDateYear, minDateMonth -1, minDateDay), + maxDate: new Date(maxDateYear, maxDateMonth -1, maxDateDay), + beforeShowDay: function(date){ + var dateString = new String; + if (date.getMonth() + 1 < 10) { + dateString += '0'; + } + dateString += date.getMonth() + 1; + dateString += '/'; + if (date.getDate() < 10) { + dateString += '0'; + } + dateString += date.getDate(); + dateString += '/'; + dateString += date.getFullYear(); + + return [$.inArray(dateString, scheduleDates) > -1, ""]; + } + }); +}); \ No newline at end of file diff --git a/Toolkit/Schedule/js/editSchedule.js b/Toolkit/Schedule/js/editSchedule.js new file mode 100644 index 0000000..2ff108e --- /dev/null +++ b/Toolkit/Schedule/js/editSchedule.js @@ -0,0 +1,346 @@ +var EditSchedule = +{ + baseUrl: null, + init: function() + { + // setup a class to add to all input field to disable the enter submit + $('.noEnterSubmit').keypress(function(e){ + if ( e.which == 13 ) e.preventDefault(); + }); + + // setup on change event for schedule_year + // we want to update the schedule with new name if updated + $('#schedule_year').change(function(){ + var newYear = $(this).val(); + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/updateScheduleYear/", + data: "id=" + glm_scheduleId + + "&year=" + newYear, + statusCode: { + 404: function() { + alert('page not found'); + } + }, + success: function(){ + glm_scheduleYear = newYear; + } + }); + }); + // set loading animation to display while ajax + $('#loading').ajaxSend(function(){ + $('#loading').show(); + }); + // set loading animation to hide when stopped + $('#loading').ajaxStop(function(){ + $('#loading').hide(); + }); + // set loading animation to hide when successfull + $('#loading').ajaxSuccess(function(){ + $('#loading').hide(); + }); + // set loading animation to hide when error + $('#loading').ajaxError(function(){ + $('#loading').hide(); + }); + // set loading animation to hide when complete + $('#loading').ajaxComplete(function(){ + $('#loading').hide(); + }); + // setup onclick event for all future clicks on addTime + $('.chxTime.addTime').live('click', function(){ + $("#dialog-form").dialog( "open" ); + $("#id").val(''); + $("#depart_time").val(''); + $("#dock").val('1'); + $("#departure_id").val($(this).attr('rel')); + }); + // setup onclick event for all future clicks on addTime + $('.bviTime.addTime').live('click', function(){ + $("#dialog-form").dialog( "open" ); + $("#id").val(''); + $("#depart_time").val(''); + $("#dock").val('2'); + $("#departure_id").val($(this).attr('rel')); + }); + // setup addDepartureSet click event + $('#addDepartureSet').click(function(){ + $.ajax({ + cache: false, + dataType: 'json', + url: glm_baseUrl + "schedules/Edit/addDepartureSet/", + data: "id=" + $(this).attr('rel'), + statusCode: { + 404: function() { + alert('page not found'); + } + }, + success: function(data){ + $('#loading').before(data.html); + var departureId = data.id; + EditSchedule.setupDepartureById(departureId); + } + }); + }); + // set up removedepartureSet click event + $('.removeDepartureSet').live('click', function(){ + var go = confirm('This will delete the entire Set!\nAre you sure?'); + if (go) { + $(this).parent().remove(); + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/removeDepartureSet/", + data: "id=" + $(this).attr('rel'), + statusCode: { + 404: function() { + alert('page not found'); + } + }, + success: function(){ + } + }); + } + }); + // setup removeTime click for all future events + $('.removeTime').live('click', function(){ + $(this).parent().remove(); + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/removeTime/", + data: "id=" + $(this).attr('rel'), + statusCode: { + 404: function() { + alert('page not found'); + } + }, + success: function(){ + } + }); + }); + // setup commentSvae for all furture events + $('.commentSave').live('click', function(){ + var departureId = $(this).attr('rel'); + var comments = $('#comments' + departureId).val(); + + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/updateComment/", + data: "id=" + departureId + + "&comments=" + encodeURIComponent(comments), + statusCode: { + 404: function() { + alert('page not found'); + } + }, + success: function(){ + $('#commentSave' + glm_departures[i]); + } + }); + }); + // setup nameSave click for all future events + $('.nameSave').live('click', function(){ + var scheduleId = $(this).attr('rel'); + var name = $('#scheduleNameText').val(); + + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/updateName/", + data: "id=" + scheduleId + + "&name=" + encodeURIComponent(name), + 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]); + } + // setup forn-element click for all future events + $(".form-element").live('click', function () { + var formId = $(this).attr('rel'); + $.ajax({ + cache: false, + type: 'get', + dataType: 'json', + url: glm_baseUrl + "schedules/Edit/getTime/?id=" + formId, + success: function (data){ + // can now load the data into the form + $("#id").val(data.id); + $("#depart_time").val(data.departure_time); + $("#dock").val(data.dock); + $("#departure_id").val(data.departure_id); + }, + statusCode: { + 404: function() { + alert('Error: 404 Page Not Found!'); + } + } + }); + $( "#dialog-form" ).dialog( "open" ); + }); + var depart_time = $("#depart_time"), + id = $("#id"), + departure_id = $("#departure_id"), + dock = $("#dock"), + allFields = $([]) + .add(id) + .add(depart_time) + .add(departure_id) + .add(dock), + tips = $( ".validateTips" ); + + function updateTips( t ) { + tips + .text( t ) + .addClass( "ui-state-highlight" ); + setTimeout(function() { + tips.removeClass( "ui-state-highlight", 1500 ); + }, 500 ); + } + + function checkLength( o, n, min) { + if ( o.val().length < min ) { + o.addClass( "ui-state-error" ); + updateTips( "Length of " + n + " must be " + min + "." ); + return false; + } else { + return true; + } + } + + function checkRegexp( o, regexp, n ) { + if ( !( regexp.test( o.val() ) ) ) { + o.addClass( "ui-state-error" ); + updateTips( n ); + return false; + } else { + return true; + } + } + // for the time edit form + $( "#dialog-form" ).dialog({ + autoOpen: false, + height: 200, + width: 350, + modal: true, + buttons: { + "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" ); + } + + if ( bValid ) { + // need to send the data to a php page to save it + var dataVars = "id=" + id.val(); + dataVars += "&depart_time=" + depart_time.val(); + if (id.val()) { + $.ajax({ + cache: false, + type: 'post', + dataType: 'json', + url: glm_baseUrl + "schedules/Edit/saveTime/?id=" + id.val(), + data: allFields.serialize(), + success: function (data){ + $('span[class="form-element"][rel="' + data.id + '"]').html(data.time); + }, + statusCode: { + 404: function() { + alert('Error: 404 Page Not Found!'); + } + } + }); + } else { + $.ajax({ + cache: false, + type: 'post', + dataType: 'json', + url: glm_baseUrl + "schedules/Edit/saveTime/", + data: allFields.serialize(), + success: function (data){ + if (data.dock == 1) { + $('.chxTime.addTime[rel="'+data.departure_id+'"]').before( + '' + ); + } else if (data.dock == 2) { + $('.bviTime.addTime[rel="'+data.departure_id+'"]').before( + '' + ); + } + }, + statusCode: { + 404: function() { + alert('Error: 404 Page Not Found!'); + } + } + }); + } + + $( this ).dialog( "close" ); + } + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + }, + close: function() { + allFields.val( "" ).removeClass( "ui-state-error" ); + } + }); + + }, + // setup the departures by id + setupDepartureById: function(id){ + $('#color' + id).colorPicker(); + $('#color' + id).change(function(){ + var colorCode = $(this).val(); + var departureId = $(this).attr('rel'); + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/updateColor/", + data: "id=" + departureId + '&color=' + encodeURIComponent(colorCode), + statusCode: { + 404: function() { + alert('page not found'); + } + } + }); + }); + + $('#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 + + "&year=" + glm_scheduleYear + + "&_=" + timeDate.getTime(); + $('#departure' + departureId).load(ajaxUrl).dialog({ + title: 'Gaslight Media Multiple Date Picker', + autoOpen: true, + height: glm_monthsHeight, + width: glm_monthsWidth, + position: 'center', + modal:true, + beforeClose: function(){ + $('#departure' + departureId).html('loading...'); + } + }); + }); + } +}; + +$(document).ready(EditSchedule.init); \ No newline at end of file diff --git a/Toolkit/Schedule/js/listSchedule.js b/Toolkit/Schedule/js/listSchedule.js new file mode 100644 index 0000000..a73da67 --- /dev/null +++ b/Toolkit/Schedule/js/listSchedule.js @@ -0,0 +1,41 @@ +var Schedule = +{ + init: function() + { + Schedule.setActive(); + $('input[name="active"]').click(function(){ + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/updateActive/", + data: "id=" + $(this).val(), + statusCode: { + 404: function() { + alert('page not found'); + } + }, + success: function(){ +// alert('active stat saved!'); + } + }); + }); + $('#addSchedule').click(function(){ + $.ajax({ + cache: false, + url: glm_baseUrl + "schedules/Edit/addSchedule/", + success: function(newId){ + location.href=glm_baseUrl + 'admin/schedules.php?ac=Edit&id=' + newId; + } + }); + }); + }, + setActive: function() + { + if (glm_active) { + $('input[name="active"][value="' + glm_active + '"]').attr('checked', 'checked'); + } else { + $('input[name="active"][value="0"]').attr('checked', 'checked'); + } + } +}; + +$(document).ready(Schedule.init); \ No newline at end of file diff --git a/Toolkit/Schedule/templates/departureRow.html b/Toolkit/Schedule/templates/departureRow.html new file mode 100644 index 0000000..0c429b8 --- /dev/null +++ b/Toolkit/Schedule/templates/departureRow.html @@ -0,0 +1,33 @@ +
+
+ +
+
+ times: + + +
+
+ times: + + +
+
+ Calendar Dates + + +
+
+ + +
+ +
\ No newline at end of file diff --git a/Toolkit/Schedule/templates/departuresScheduleCalendar.html b/Toolkit/Schedule/templates/departuresScheduleCalendar.html new file mode 100644 index 0000000..3152893 --- /dev/null +++ b/Toolkit/Schedule/templates/departuresScheduleCalendar.html @@ -0,0 +1,100 @@ + +
+

+

+ Note: {departByDate[comments]:h} +

+ {departByDate[date]:h} Departures from {departByDate[dock]:h}: + +

+
+

{scheduleName:h}

+
+{calendarsHtml:h} +
+

Departures

+ + + + + + + + + + + +
Departing CharlevoixCommentsDeparting Beaver Island
+ {foreach:depart[cTimes],time} +

{time[departure_time]:h}

+ {end:} +
+ + + {foreach:depart[bTimes],time} +

{time[departure_time]:h}

+ {end:} +
diff --git a/Toolkit/Schedule/templates/editSchedule.html b/Toolkit/Schedule/templates/editSchedule.html new file mode 100644 index 0000000..64a5849 --- /dev/null +++ b/Toolkit/Schedule/templates/editSchedule.html @@ -0,0 +1,80 @@ + + + +
+ +
+
+ + +
+ + + + +
+

Must enter in date format. hh:mm AM or PM

+
+
+ + + + + +
+
+
\ No newline at end of file diff --git a/Toolkit/Schedule/templates/listSchedules.html b/Toolkit/Schedule/templates/listSchedules.html new file mode 100644 index 0000000..153ece7 --- /dev/null +++ b/Toolkit/Schedule/templates/listSchedules.html @@ -0,0 +1,22 @@ + + +
+ Boat Schedules +
+ +
+
+ + Edit +
+
\ No newline at end of file diff --git a/Toolkit/Schedule/templates/scheduleCalendar.html b/Toolkit/Schedule/templates/scheduleCalendar.html new file mode 100644 index 0000000..a0c30d9 --- /dev/null +++ b/Toolkit/Schedule/templates/scheduleCalendar.html @@ -0,0 +1,36 @@ + + + +{calendarsHtml:h} diff --git a/admin/nav.phtml b/admin/nav.phtml index 2f5d44e..96ca504 100644 --- a/admin/nav.phtml +++ b/admin/nav.phtml @@ -130,6 +130,14 @@ if (defined('PHOTO_GALLERY') && PHOTO_GALLERY) { if (defined('VIDEOS') && VIDEOS) { $nav['Video Gallery'] = MEDIA_BASE_URL.'admin/videos.php'; } +if (defined('SCHEDULES') && SCHEDULES) { + $scheduleConfig = new Zend_Config_Ini( + BASE . 'Toolkit/Schedule/application.ini', + strtolower($_ENV['GLM_HOST_ID']) + ); + $nav[$scheduleConfig->applicationName] + = MEDIA_BASE_URL . 'admin/schedules.php'; +} if (defined('PRESS_DB') && PRESS_DB) { $nav['Press'] = MEDIA_BASE_URL.'admin/Press/'; } diff --git a/admin/schedules.php b/admin/schedules.php new file mode 100644 index 0000000..7378dc1 --- /dev/null +++ b/admin/schedules.php @@ -0,0 +1,32 @@ +dbh = Toolkit_Database::getInstance(); +$registry->logger = Toolkit_Logger::getLogger(); +$registry->router = new Toolkit_Router($registry); +$registry->router->setPath(BASE . 'Toolkit/Schedule'); +$registry->router->setApplication('Schedule'); + +// use ZendConfig instead +$config = new Zend_Config_Ini( + BASE . 'Toolkit/Schedule/application.ini', + strtolower($_ENV['GLM_HOST_ID']) +); +$flexyOptions = $GLOBALS['flexyOptions']; +$flexyOptions['templateDir'] = $config->flexy->options->templateDir; +$flexyOptions['compileDir'] = $config->flexy->options->compileDir; + +$registry->config = $config; +$registry->flexyOptions = $flexyOptions; + +$html = $registry->router->loader(); + +$appName = $config->applicationName; + +//if (!empty($_GET)) { +// var_dump($_GET); +// exit; +//} +GLM_TOOLBOX::top($appName, ''); +echo $html; +GLM_TOOLBOX::footer(); \ No newline at end of file diff --git a/config/application.ini b/config/application.ini index 927ba78..74a1a62 100644 --- a/config/application.ini +++ b/config/application.ini @@ -125,6 +125,7 @@ ticketing.cat_seo = Off employment.application = Off videos.application = On +schedules.application = On seasons.application = Off blocks.application = On ; development server configuration data inherits from production and diff --git a/setup.phtml b/setup.phtml index e06f691..7f06f98 100644 --- a/setup.phtml +++ b/setup.phtml @@ -476,6 +476,7 @@ define('ROTATING_IMAGES', $applicationConfig->rotating_images->application); define('WEATHER', $applicationConfig->weather->application); define('EMPLOYMENT', $applicationConfig->employment->application); define('VIDEOS', $applicationConfig->videos->application); +define('SCHEDULES', $applicationConfig->schedules->application); define('SEASONS', $applicationConfig->seasons->application); define('GLM_BLOCKS', $applicationConfig->blocks->application); /**