Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') or die('No direct script access.');
- class Controller_Admin_Cruds_Tours extends Controller {
- function before() {
- $this -> model = Model::factory('admin_cruds_tours');
- }
- function action_index() {
- $view = View::factory('admin/cruds/tours/list');
- if (isset($_POST["activestatus"]) && isset($_POST['rowid'])) {
- $action = db::update('c_tours', array('is_active' => $_POST['activestatus']), array('id' => $_POST['rowid']));
- if ($action) {
- die('true');
- } else {
- die('false');
- }
- }
- }
- function action_new() {
- if (isset($_POST["var0"])) {
- $action = $this->model->save($_POST);
- if (!$action) {
- Message::error(Kohana::message('crud', 'error.entrycreated'));
- $this->request->redirect('cruds/tours');
- } else {
- Message::success(Kohana::message('crud', 'success.entrycreated'));
- $this->request->redirect('cruds/tours'.(isset($_POST["saveandedit"]) ? "/edit/" . mysql_insert_id() : ""));
- }
- }
- $view = View::factory('admin/cruds/tours/new');
- $this->response->body($view);
- }
- function action_edit() {
- $id = (int) $this->request->param('id');
- if (isset($_POST["var0"])) {
- $action = $this->model->update($id, $_POST);
- if (!action) {
- Message::error(Kohana::message('crud', 'error.entrycreated'));
- $this->request->redirect('cruds/tours');
- } else {
- Message::success(Kohana::message('crud', 'success.entrycreated'));
- $this->request->redirect('cruds/tours'.(isset($_POST["saveandedit"]) ? "/edit/" . mysql_insert_id() : ""));
- }
- $view = View::factory('admin/cruds/tours/edit');
- $view->row = db::fetchone("SELECT * FROM $table WHERE id={$id}");
- $this->response->body($view);
- }
- function action_delete() {
- /*
- if(isset($this->request->param('id')) && is_numeric($this->request->param('id'))) {
- $id = $this->request->param('id');
- }
- */
- if (isset($id)) {
- $action = db::delete("c_tours", array("id" => $_GET["del"]));
- if ($action) {
- Message::success(Kohana::message('crud', 'success.entrydeleted'));
- $this->request->redirect('cruds/tours');
- } else {
- Message::error(Kohana::message('crud', 'error.entrydeleted'));
- $this->request->redirect('cruds/tours');
- }
- }else
- if (isset($_POST["tableitems"])) {
- foreach ($_POST["tableitems"] as $id) {
- $action = db::delete("c_tours", array("id" => $id));
- if (!$action) {
- Message::error(Kohana::message('crud', 'error.entrydeleted'));
- $this->request->redirect('cruds/tours');
- }
- }
- Message::success(Kohana::message('crud', 'success.entrydeleted'));
- $this->request->redirect('cruds/tours');
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement