| 1 |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 |
|
| 3 |
class Shift_templates_controller extends Backend_controller_crud |
| 4 |
{ |
| 5 |
function __construct() |
| 6 |
{ |
| 7 |
$this->conf = array( |
| 8 |
'model' => 'Shift_template_model', |
| 9 |
'path' => 'admin/shift_templates', |
| 10 |
'entity' => 'shift_template', |
| 11 |
); |
| 12 |
parent::__construct( User_model::LEVEL_ADMIN ); |
| 13 |
} |
| 14 |
|
| 15 |
function save() |
| 16 |
{ |
| 17 |
$args = func_get_args(); |
| 18 |
$id = count($args) ? $args[0] : 0; |
| 19 |
$post = call_user_func_array( array($this, 'save_prepare'), $args ); |
| 20 |
$relations = $this->save_prepare_relations(); |
| 21 |
$this->{$this->model}->weekday = 'mmm'; |
| 22 |
|
| 23 |
if( $this->{$this->model}->save($relations) ) |
| 24 |
{ |
| 25 |
// redirect to list |
| 26 |
$msg = $id ? lang('common_update') : lang('common_add'); |
| 27 |
$this->session->set_flashdata( 'message', $msg . ': ' . lang('common_ok') ); |
| 28 |
|
| 29 |
$redirect_to = method_exists($this, 'after_save') ? $this->after_save() : array($this->conf['path']); |
| 30 |
$this->redirect( $redirect_to ); |
| 31 |
return; |
| 32 |
} |
| 33 |
else |
| 34 |
{ |
| 35 |
$this->hc_form->set_errors( $this->{$this->model}->error->all ); |
| 36 |
$this->hc_form->set_defaults( $post ); |
| 37 |
if( $this->{$this->model}->id ) |
| 38 |
$this->edit( $this->{$this->model}->id ); |
| 39 |
else |
| 40 |
{ |
| 41 |
array_shift( $args ); |
| 42 |
call_user_func_array( array($this, 'add'), $args ); |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
/* End of file customers.php */ |
| 49 |
/* Location: ./application/controllers/admin/categories.php */ |