Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Clientes_Controller
- *
- * @uses Template
- * @uses _Controller
- * @package
- * @version $id$
- * @copyright 1997-2009 The SPACEONLINE Group
- * @author Márcio Dias <suporte@spaceonline.com.br>
- * @license PHP Version 5.3
- */
- class Clientes_Controller extends Template_Controller {
- // Do not allow to run in production
- const ALLOW_PRODUCTION = FALSE;
- // Use the default Kohana template
- public $template = 'themes/base_page';
- // Currently logged in user
- protected $user;
- /**
- * __construct
- *
- * @access public
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- // Load sessions, to support logins
- $this->session = Session::instance();
- if (Auth::instance()->logged_in("admin"))
- {
- // Set the current user
- $this->user = $_SESSION['auth_user'];
- } else {
- url::redirect('auth/login');
- }
- }
- /**
- * index
- *
- * @access public
- * @return void
- */
- public function index()
- {
- //Pagination configuration
- $tot = ORM::factory('cliente')->orderby('nome_compl', 'ASC')->count_all();
- $num_per_page = 150;
- //Setup pagination
- $pagination = new Pagination(array(
- 'base_url' => 'clientes/index',
- 'uri_segment' => 'page',
- 'total_items'=> $tot,
- 'style' => "digg",
- 'items_per_page' => $num_per_page,
- 'auto_hide' => true
- ));
- $offset = $pagination->sql_offset;
- $clientes = ORM::factory('cliente')
- ->orderby('nome_compl','ASC')
- ->find_all($num_per_page,$offset);
- // Variables view
- $this->template->pagination = $pagination;
- $this->template->clientes = $clientes;
- $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
- $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
- $this->template->content = new View("clientes/index");
- }
- /**
- * busca_nome
- *
- * @access public
- * @return void
- */
- public function busca_nome()
- {
- if ($_POST) {
- //Pagination configuration
- $tot = ORM::factory('cliente')->where('nome_compl', "$_POST[inputString]")->orderby('nome_compl', 'ASC')->count_all();
- $num_per_page = 150;
- //Setup pagination
- $pagination = new Pagination(array(
- 'base_url' => 'clientes/index',
- 'uri_segment' => 'page',
- 'total_items'=> $tot,
- 'style' => "digg",
- 'items_per_page' => $num_per_page,
- 'auto_hide' => true
- ));
- $offset = $pagination->sql_offset;
- $clientes = ORM::factory('cliente')
- ->where('nome_compl', "$_POST[inputString]")
- ->orderby('nome_compl','ASC')
- ->find_all($num_per_page,$offset);
- // Variables view
- $this->template->pagination = $pagination;
- $this->template->clientes = $clientes;
- $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
- $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
- $this->template->content = new View("clientes/index");
- }
- }
- /**
- * busca_ra
- *
- * @access public
- * @return void
- */
- public function busca_ra()
- {
- if ($_POST) {
- //Pagination configuration
- $tot = ORM::factory('cliente')->where('nome_compl', "$_POST[inputString_ra]")->orderby('aluno', 'ASC')->count_all();
- $num_per_page = 150;
- //Setup pagination
- $pagination = new Pagination(array(
- 'base_url' => 'clientes/index',
- 'uri_segment' => 'page',
- 'total_items'=> $tot,
- 'style' => "digg",
- 'items_per_page' => $num_per_page,
- 'auto_hide' => true
- ));
- $offset = $pagination->sql_offset;
- $clientes = ORM::factory('cliente')
- ->where('aluno', "$_POST[inputString_ra]")
- ->orderby('nome_compl','ASC')
- ->find_all($num_per_page,$offset);
- // Variables view
- $this->template->pagination = $pagination;
- $this->template->clientes = $clientes;
- $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
- $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
- $this->template->content = new View("clientes/index");
- }
- }
- /**
- * busca_filtro
- *
- * @access public
- * @return void
- */
- public function busca_filtro()
- {
- if ($_POST) {
- $post = $_POST;
- $tot_tmp = ORM::factory('cliente');
- if ($post['mes']) { foreach($post['mes'] as $mes) { $tot_tmp->where('mes_ref', $mes); } }
- if ($post['ano']) { foreach($post['ano'] as $ano) { $tot_tmp->where('ano_ref', $ano); } }
- if ($post['nome_curso']) { foreach($post['curso'] as $curso) { $tot_tmp->where('nome_curso', $curso); } }
- $tot = $tot_tmp->orderby('nome_compl', 'ASC')->count_all();
- //Pagination configuration
- $num_per_page = 150;
- //Setup pagination
- $pagination = new Pagination(array(
- 'base_url' => 'clientes/index',
- 'uri_segment' => 'page',
- 'total_items'=> $tot,
- 'style' => "digg",
- 'items_per_page' => $num_per_page,
- 'auto_hide' => true
- ));
- $offset = $pagination->sql_offset;
- $clientes = ORM::factory('cliente');
- if ($post['mes']) { foreach($post['mes'] as $mes) { $clientes->where('mes_ref', $mes); } }
- if ($post['ano']) { foreach($post['ano'] as $ano) { $clientes->where('ano_ref', $ano); } }
- if ($post['nome_curso']) { foreach($post['curso'] as $curso) { $clientes->where('nome_curso', $curso); } }
- $clientes->orderby('nome_compl','ASC');
- $clientes->find_all($num_per_page,$offset);
- // Variables view
- $this->template->pagination = $pagination;
- $this->template->clientes = $clientes;
- $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
- $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
- $this->template->content = new View("clientes/index");
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment