{
/**
* indexAction
- *
+ *
* default action if none found
- *
+ *
* @return type string HTML
*/
public function indexAction()
$html = $schedues->toHtml($this->registry);
return $html;
}
-
+
/**
* editAction
- *
+ *
* edit action if set as ac=edit
- *
- * @return type
+ *
+ * @return type
*/
public function editAction()
{
$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;
+ }
}
$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 = "
<legend>Boat Schedules</legend>
<div flexy:foreach="schedules,schedule" class="panel">
<label>
- {schedule[name]:h}<a class="edit tiny button right" href="{baseUrl:h}admin/schedules.php?ac=Edit&id={schedule[id]:h}">Edit</a>
+ <a
+ onClick="return(confirm('Are you sure you want to Delete This schedule?'));"
+ class="delete tiny button right"
+ href="{deleteUrlBase:h}{schedule[id]:h}">Delete</a>
+ <span style="margin: 0 20px;">{schedule[name]:h}</span>
+ <a
+ class="edit tiny button left"
+ href="{baseUrl:h}admin/schedules.php?ac=Edit&id={schedule[id]:h}">Edit</a>
</label>
</div>