Guest User

Untitled

a guest
Jun 21st, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.66 KB | None | 0 0
  1. <?php
  2. /**
  3. * Clientes_Controller
  4. *
  5. * @uses Template
  6. * @uses _Controller
  7. * @package
  8. * @version $id$
  9. * @copyright 1997-2009 The SPACEONLINE Group
  10. * @author Márcio Dias <suporte@spaceonline.com.br>
  11. * @license PHP Version 5.3
  12. */
  13. class Clientes_Controller extends Template_Controller {
  14.  
  15. // Do not allow to run in production
  16. const ALLOW_PRODUCTION = FALSE;
  17.  
  18. // Use the default Kohana template
  19. public $template = 'themes/base_page';
  20.  
  21. // Currently logged in user
  22. protected $user;
  23.  
  24. /**
  25. * __construct
  26. *
  27. * @access public
  28. * @return void
  29. */
  30. public function __construct()
  31. {
  32. parent::__construct();
  33.  
  34. // Load sessions, to support logins
  35. $this->session = Session::instance();
  36.  
  37. if (Auth::instance()->logged_in("admin"))
  38. {
  39. // Set the current user
  40. $this->user = $_SESSION['auth_user'];
  41. } else {
  42. url::redirect('auth/login');
  43. }
  44. }
  45.  
  46. /**
  47. * index
  48. *
  49. * @access public
  50. * @return void
  51. */
  52. public function index()
  53. {
  54. //Pagination configuration
  55. $tot = ORM::factory('cliente')->orderby('nome_compl', 'ASC')->count_all();
  56. $num_per_page = 150;
  57.  
  58. //Setup pagination
  59. $pagination = new Pagination(array(
  60. 'base_url' => 'clientes/index',
  61. 'uri_segment' => 'page',
  62. 'total_items'=> $tot,
  63. 'style' => "digg",
  64. 'items_per_page' => $num_per_page,
  65. 'auto_hide' => true
  66. ));
  67.  
  68. $offset = $pagination->sql_offset;
  69.  
  70. $clientes = ORM::factory('cliente')
  71. ->orderby('nome_compl','ASC')
  72. ->find_all($num_per_page,$offset);
  73.  
  74. // Variables view
  75. $this->template->pagination = $pagination;
  76. $this->template->clientes = $clientes;
  77.  
  78. $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
  79. $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
  80. $this->template->content = new View("clientes/index");
  81. }
  82.  
  83. /**
  84. * busca_nome
  85. *
  86. * @access public
  87. * @return void
  88. */
  89. public function busca_nome()
  90. {
  91. if ($_POST) {
  92. //Pagination configuration
  93. $tot = ORM::factory('cliente')->where('nome_compl', "$_POST[inputString]")->orderby('nome_compl', 'ASC')->count_all();
  94. $num_per_page = 150;
  95.  
  96. //Setup pagination
  97. $pagination = new Pagination(array(
  98. 'base_url' => 'clientes/index',
  99. 'uri_segment' => 'page',
  100. 'total_items'=> $tot,
  101. 'style' => "digg",
  102. 'items_per_page' => $num_per_page,
  103. 'auto_hide' => true
  104. ));
  105.  
  106. $offset = $pagination->sql_offset;
  107.  
  108. $clientes = ORM::factory('cliente')
  109. ->where('nome_compl', "$_POST[inputString]")
  110. ->orderby('nome_compl','ASC')
  111. ->find_all($num_per_page,$offset);
  112.  
  113. // Variables view
  114. $this->template->pagination = $pagination;
  115. $this->template->clientes = $clientes;
  116.  
  117. $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
  118. $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
  119. $this->template->content = new View("clientes/index");
  120.  
  121. }
  122. }
  123.  
  124. /**
  125. * busca_ra
  126. *
  127. * @access public
  128. * @return void
  129. */
  130. public function busca_ra()
  131. {
  132. if ($_POST) {
  133. //Pagination configuration
  134. $tot = ORM::factory('cliente')->where('nome_compl', "$_POST[inputString_ra]")->orderby('aluno', 'ASC')->count_all();
  135. $num_per_page = 150;
  136.  
  137. //Setup pagination
  138. $pagination = new Pagination(array(
  139. 'base_url' => 'clientes/index',
  140. 'uri_segment' => 'page',
  141. 'total_items'=> $tot,
  142. 'style' => "digg",
  143. 'items_per_page' => $num_per_page,
  144. 'auto_hide' => true
  145. ));
  146.  
  147. $offset = $pagination->sql_offset;
  148.  
  149. $clientes = ORM::factory('cliente')
  150. ->where('aluno', "$_POST[inputString_ra]")
  151. ->orderby('nome_compl','ASC')
  152. ->find_all($num_per_page,$offset);
  153.  
  154. // Variables view
  155. $this->template->pagination = $pagination;
  156. $this->template->clientes = $clientes;
  157.  
  158. $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
  159. $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
  160. $this->template->content = new View("clientes/index");
  161.  
  162. }
  163. }
  164.  
  165. /**
  166. * busca_filtro
  167. *
  168. * @access public
  169. * @return void
  170. */
  171. public function busca_filtro()
  172. {
  173.  
  174. if ($_POST) {
  175.  
  176. $post = $_POST;
  177.  
  178. $tot_tmp = ORM::factory('cliente');
  179.  
  180. if ($post['mes']) { foreach($post['mes'] as $mes) { $tot_tmp->where('mes_ref', $mes); } }
  181. if ($post['ano']) { foreach($post['ano'] as $ano) { $tot_tmp->where('ano_ref', $ano); } }
  182. if ($post['nome_curso']) { foreach($post['curso'] as $curso) { $tot_tmp->where('nome_curso', $curso); } }
  183.  
  184. $tot = $tot_tmp->orderby('nome_compl', 'ASC')->count_all();
  185.  
  186.  
  187. //Pagination configuration
  188. $num_per_page = 150;
  189.  
  190. //Setup pagination
  191. $pagination = new Pagination(array(
  192. 'base_url' => 'clientes/index',
  193. 'uri_segment' => 'page',
  194. 'total_items'=> $tot,
  195. 'style' => "digg",
  196. 'items_per_page' => $num_per_page,
  197. 'auto_hide' => true
  198. ));
  199.  
  200. $offset = $pagination->sql_offset;
  201.  
  202. $clientes = ORM::factory('cliente');
  203. if ($post['mes']) { foreach($post['mes'] as $mes) { $clientes->where('mes_ref', $mes); } }
  204. if ($post['ano']) { foreach($post['ano'] as $ano) { $clientes->where('ano_ref', $ano); } }
  205. if ($post['nome_curso']) { foreach($post['curso'] as $curso) { $clientes->where('nome_curso', $curso); } }
  206. $clientes->orderby('nome_compl','ASC');
  207. $clientes->find_all($num_per_page,$offset);
  208.  
  209. // Variables view
  210. $this->template->pagination = $pagination;
  211. $this->template->clientes = $clientes;
  212.  
  213. $this->template->filtro_ano = ORM::factory('cliente')->select('DISTINCT ano_ref')->orderby('ano_ref', 'DESC')->select_list('ano_ref', 'ano_ref');
  214. $this->template->filtro_curso = ORM::factory('cliente')->select('DISTINCT nome_curso')->orderby('nome_curso', 'DESC')->select_list('nome_curso', 'nome_curso');
  215. $this->template->content = new View("clientes/index");
  216.  
  217. }
  218.  
  219. }
  220.  
  221. }
  222. ?>
Add Comment
Please, Sign In to add comment