From: Steve Sutton Date: Tue, 28 Oct 2014 15:55:49 +0000 (-0400) Subject: update form X-Git-Tag: v1.0.5^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=652db2a5180bf35280beaac7b882488790872335;p=web%2FSooLocks.git update form have one button to save the form data allow selected year for display on page. --- diff --git a/Toolkit/Schedule/EditController.php b/Toolkit/Schedule/EditController.php index c884934..cbed552 100644 --- a/Toolkit/Schedule/EditController.php +++ b/Toolkit/Schedule/EditController.php @@ -78,17 +78,17 @@ class Toolkit_Schedule_EditController } } $selected = $cals->getDepartureDates($scheduleId); - $year - = ($year) - ? $year - : date('Y'); + $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); + $page->calendars = array(); + for ($yearInterval = $year; $yearInterval <= $year + 5; $yearInterval++) { + for ($i = $startingMonth; $i <= $endingMonth; ++$i) { + $page->calendars[$yearInterval] .= $cals->buildCalendar($i, $yearInterval, $selected); + } } - $tpl = new HTML_Template_Flexy( + $tpl = new HTML_Template_Flexy( $this->registry->flexyOptions ); $page->prevYear = $year - 1; @@ -501,10 +501,6 @@ class Toolkit_Schedule_EditController FILTER_SANITIZE_STRING ); if (!$scheduleId || !$depatureId || !$date) { -// var_dump($scheduleId); -// var_dump($depatureId); -// var_dump($date); -// echo 'hi no vars'; echo 0; exit; } @@ -655,6 +651,87 @@ class Toolkit_Schedule_EditController exit; } + public function updateScheduleAction() + { +// echo '
'.print_r($_REQUEST, true).'
';//exit; + $schedule = filter_var_array( + $_REQUEST, + array( + 'schedule_id' => FILTER_VALIDATE_INT, + 'schedule_year' => FILTER_VALIDATE_INT, + 'scheduleName' => FILTER_SANITIZE_STRING, + 'page' => FILTER_VALIDATE_INT + ) + ); + if (!$schedule['schedule_id']) { + echo 0; + exit; + } + try { + $dbh = Toolkit_Database::getInstance(); + $sql = " + UPDATE schedules + SET page = :page, + schedule_year = :schedule_year, + name = :name + WHERE id = :id"; + $update = $dbh->prepare($sql); + $update->bindParam( + ':id', + $schedule['schedule_id'], + PDO::PARAM_INT + ); + $update->bindParam( + ':schedule_year', + $schedule['schedule_year'], + PDO::PARAM_INT + ); + $update->bindParam( + ':page', + $schedule['page'], + PDO::PARAM_INT + ); + $update->bindParam( + ':name', + $schedule['scheduleName'] + ); + $update->execute(); + // update comments and colors + foreach ($_REQUEST as $key => $value) { + if (preg_match('/comments([0-9]*)/', $key, $matches)) { + + $departureId = filter_var($matches[1], FILTER_VALIDATE_INT); + $comment = filter_var( + $_REQUEST['comments' . $departureId], + FILTER_SANITIZE_STRING + ); + $color = filter_var( + $_REQUEST['color' . $departureId], + FILTER_SANITIZE_STRING + ); + if ($departureId) { + $sql = " + UPDATE departures + SET comments = :comments, + color = :color + WHERE id = :id"; + $stmt = $dbh->prepare($sql); + $stmt->bindParam(':comments', $comment); + $stmt->bindParam(':color', $color); + $stmt->bindParam(':id', $departureId); + $stmt->execute(); + } + } + } +// die('stopped'); + header('Location: schedules.php?ac=Edit&id=' . $schedule['schedule_id']. '&saved=1'); + exit; + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + exit; + } + public function updatePageAction() { $scheduleId = filter_input( diff --git a/Toolkit/Schedule/templates/editSchedule.html b/Toolkit/Schedule/templates/editSchedule.html index 0d7cd4e..3eb9437 100644 --- a/Toolkit/Schedule/templates/editSchedule.html +++ b/Toolkit/Schedule/templates/editSchedule.html @@ -14,6 +14,7 @@ .simpleColorDisplay {float:left;} .simpleColorChooser {float:left;position:absolute;top:0;left: 0;background-color: white;} .simpleColorContainer {z-index: 1;float:left;position:relative;top:0;left: 0;background-color: white;} + .hide {display:none;} -
+
+
+ Schedule data is saved! + x +
+
+ + +
+
-
+
+ +
+
-
+
-
+
-
+
-
+
+ +
+
@@ -83,18 +106,5 @@
-
-

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

- -
- - - - - -
- -
- -
\ No newline at end of file +
+ \ No newline at end of file