From: Steve Sutton Date: Tue, 12 Aug 2014 17:12:43 +0000 (-0400) Subject: Add ability to delete schedules X-Git-Tag: v1.0^2~2^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=013b161dd510e5cd025316767b111f8f778601db;p=web%2FSooLocks.git Add ability to delete schedules Adding the ability to delete a schedule. --- diff --git a/Toolkit/Schedule/IndexController.php b/Toolkit/Schedule/IndexController.php index 2d6768c..b9f6e69 100644 --- a/Toolkit/Schedule/IndexController.php +++ b/Toolkit/Schedule/IndexController.php @@ -6,9 +6,9 @@ class Toolkit_Schedule_IndexController { /** * indexAction - * + * * default action if none found - * + * * @return type string HTML */ public function indexAction() @@ -17,13 +17,13 @@ class Toolkit_Schedule_IndexController $html = $schedues->toHtml($this->registry); return $html; } - + /** * editAction - * + * * edit action if set as ac=edit - * - * @return type + * + * @return type */ public function editAction() { @@ -31,4 +31,40 @@ class Toolkit_Schedule_IndexController $html = $schedule->toHtml($this->registry); return $html; } + + public function deleteAction() + { + $scheduleId = filter_var($_REQUEST['id'], FILTER_VALIDATE_INT); + if ($scheduleId) { + try { + $sql = " + DELETE + FROM schedules + WHERE id = :id"; + $stmt = $this->registry->dbh->prepare($sql); + $stmt->bindParam(':id', $scheduleId, PDO::PARAM_INT); + $stmt->execute(); + + $sql = " + DELETE + FROM departures + WHERE schedule_id = :id"; + $stmt = $this->registry->dbh->prepare($sql); + $stmt->bindParam(':id', $scheduleId, PDO::PARAM_INT); + $stmt->execute(); + + $sql = " + DELETE + FROM departure_dates + WHERE schedule_id = :id"; + $stmt = $this->registry->dbh->prepare($sql); + $stmt->bindParam(':id', $scheduleId, PDO::PARAM_INT); + $stmt->execute(); + } catch(PDOException $e) { + Toolkit_Common::handleError($e); + } + } + header('Location: schedules.php'); + exit; + } } diff --git a/Toolkit/Schedule/ListSchedules.php b/Toolkit/Schedule/ListSchedules.php index 4dfceff..18fea0a 100644 --- a/Toolkit/Schedule/ListSchedules.php +++ b/Toolkit/Schedule/ListSchedules.php @@ -23,6 +23,8 @@ class Toolkit_Schedule_ListSchedules $tpl = new HTML_Template_Flexy($registry->flexyOptions); $page = new stdClass(); $page->baseUrl = BASE_URL; + $page->deleteUrlBase + = MEDIA_BASE_URL . 'admin/schedules.php?ac=Delete&id='; $page->editLinkUrlBase = MEDIA_BASE_URL . 'admin/schedules.php?rt=Edit&id='; $whichActiveSql = " diff --git a/Toolkit/Schedule/templates/listSchedules.html b/Toolkit/Schedule/templates/listSchedules.html index 821c7e1..1127cca 100644 --- a/Toolkit/Schedule/templates/listSchedules.html +++ b/Toolkit/Schedule/templates/listSchedules.html @@ -8,7 +8,14 @@ Boat Schedules