2014-01-10 10:27:37 +02:00
|
|
|
<?php defined('SYSPATH') or die('No direct script access.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client controller.
|
|
|
|
**/
|
|
|
|
class Controller_Client extends Controller_Layout {
|
2014-02-02 05:25:58 +02:00
|
|
|
protected $secure_actions = array(
|
2016-10-07 08:38:43 +03:00
|
|
|
'index',
|
|
|
|
'group',
|
|
|
|
'create',
|
|
|
|
'edit',
|
|
|
|
'delete',
|
|
|
|
'view',
|
|
|
|
'search',
|
2014-02-02 05:25:58 +02:00
|
|
|
);
|
2014-02-02 05:43:51 +02:00
|
|
|
protected $controls = array(
|
|
|
|
'name' => 'input',
|
|
|
|
'email' => 'input',
|
|
|
|
);
|
2014-02-02 05:25:58 +02:00
|
|
|
public function action_index()
|
|
|
|
{
|
|
|
|
$this->template = new View_Client_Index;
|
|
|
|
$this->template->title = __('Clients');
|
|
|
|
$this->template->items = ORM::factory('Client')
|
|
|
|
->filter_by_page($this->request->param('page'))
|
|
|
|
->find_all();
|
|
|
|
}
|
|
|
|
|
2016-10-07 08:38:43 +03:00
|
|
|
public function action_group()
|
|
|
|
{
|
|
|
|
$this->template = new View_Client_Index;
|
|
|
|
$this->template->title = __('Clients');
|
|
|
|
$this->template->items = ORM::factory('Client')
|
|
|
|
->filter_by_page($this->request->param('page'))
|
|
|
|
->find_by_group($this->request->param('group_id'));
|
|
|
|
}
|
|
|
|
|
2014-01-16 14:01:14 +02:00
|
|
|
/**
|
|
|
|
* Manually add a client.
|
|
|
|
**/
|
2014-02-02 05:25:58 +02:00
|
|
|
public function action_create()
|
2014-01-16 14:01:14 +02:00
|
|
|
{
|
2014-02-02 05:43:51 +02:00
|
|
|
$this->template = new View_Edit;
|
|
|
|
$this->template->model = ORM::factory('Client');
|
|
|
|
$this->template->title = __('New client');
|
|
|
|
$this->_edit($this->template->model);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function action_edit()
|
|
|
|
{
|
|
|
|
$this->template = new View_Edit;
|
|
|
|
$this->template->title = __('Edit client info');
|
|
|
|
$id = $this->request->param('id');
|
|
|
|
$model = ORM::factory('Client', $id);
|
|
|
|
if (!$model->loaded())
|
|
|
|
{
|
|
|
|
$this->redirect('error/404');
|
|
|
|
}
|
|
|
|
$this->_edit($model);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function action_delete()
|
|
|
|
{
|
|
|
|
$this->template = new View_Delete;
|
|
|
|
$id = $this->request->param('id');
|
|
|
|
$model = ORM::factory('Client', $id);
|
|
|
|
if (!$model->loaded())
|
|
|
|
{
|
|
|
|
$this->redirect('error/404');
|
|
|
|
}
|
|
|
|
$this->template->title = __('Delete client');
|
|
|
|
$this->template->content_title = $model->name;
|
|
|
|
$this->template->content = $model->email;
|
|
|
|
|
|
|
|
$confirmation = $this->request->post('confirmation');
|
|
|
|
if ($confirmation === 'yes') {
|
|
|
|
$post->delete();
|
|
|
|
$this->redirect('/');
|
|
|
|
}
|
2014-01-16 14:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search a client.
|
|
|
|
**/
|
|
|
|
public function action_search()
|
|
|
|
{
|
2014-02-02 05:43:51 +02:00
|
|
|
$this->template = new View_Client_Index;
|
|
|
|
$this->template->show_create = FALSE;
|
|
|
|
$this->template->title = __('Clients');
|
|
|
|
$query = $this->request->post('query');
|
|
|
|
$this->template->items = ORM::factory('Client')
|
|
|
|
->search($query)
|
|
|
|
->filter_by_page($this->request->param('page'))
|
|
|
|
->find_all();
|
2014-01-17 09:37:23 +02:00
|
|
|
}
|
2016-10-07 08:38:43 +03:00
|
|
|
|
2014-02-02 05:43:51 +02:00
|
|
|
/**
|
|
|
|
* Unsubscription link action.
|
|
|
|
**/
|
2014-01-17 09:37:23 +02:00
|
|
|
public function action_unsubscribe()
|
|
|
|
{
|
|
|
|
}
|
2014-01-10 10:27:37 +02:00
|
|
|
}
|