PageRenderTime 40ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/bk/app/Controller/AtualizacaoExternaPlsController.php

https://gitlab.com/digaotinfo/agendaLegislativa
PHP | 168 lines | 56 code | 17 blank | 95 comment | 3 complexity | b4c9f4c97e198dc71741282d70a7a835 MD5 | raw file
  1. <?php
  2. App::import('Vendor', 'receiveMail/receiveMail');
  3. class AtualizacaoExternaPlsController extends AppController{
  4. var $name = "AtualizacaoExternaPl";
  5. public $helpers = array('Html', 'Session', 'Form', 'Paginator');
  6. public $uses = array('AtualizacaoExternaPl', 'PlType');
  7. var $scaffold = 'admin';
  8. //var $transformUrl = array('url_amigavel' => 'titulo_ptbr');
  9. var $paginate = array(
  10. 'limit' => 10,
  11. );
  12. //// Nescessário ter o beforeFilter
  13. function beforeFilter() {
  14. parent::beforeFilter();
  15. /// Descomentar verificação abaixo apenas quando utilizar Scaffold
  16. /*
  17. if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
  18. $showThisFields = array(
  19. 'campo' => 'Nome do Campo',
  20. ...
  21. );
  22. $showImage = array(
  23. ''
  24. );
  25. $this->set('showFields', $showThisFields);
  26. $this->set('fieldToImg', $showImage);
  27. $this->set('schemaTable', $this->Empresa->schema());
  28. }
  29. */
  30. }
  31. public function admin_index(){
  32. $model = 'AtualizacaoExternaPl';
  33. $this->set('model' , $model);
  34. $this->paginate = array(
  35. 'order' => array(
  36. 'id' => 'DESC'
  37. )
  38. );
  39. // >>> FILTRO
  40. $conditions = array();
  41. if( $this->request->is('post') || $this->request->is('put') ){
  42. $buscar = $this->request->data[$model]['search'];
  43. if( !empty($buscar) ):
  44. $conditions = array(
  45. "OR" => array(
  46. $model.'.remetente Like' => '%'.$buscar.'%',
  47. $model.'.corpo Like' => '%'.$buscar.'%',
  48. $model.'.assunto Like' => '%'.$buscar.'%',
  49. )
  50. );
  51. $this->paginate['conditions'] = array($conditions);
  52. endif;
  53. }
  54. $this->paginate['conditions'] = array($conditions);
  55. $this->set('registros', $this->paginate($model));
  56. }
  57. public function admin_atualizacoesEmail(){
  58. $this->autoRender = false;
  59. $this->receiveMail();
  60. }
  61. public function admin_verAtualizacao( $id=null ){
  62. $model = 'AtualizacaoExternaPl';
  63. $this->set('model', $model);
  64. $registro = $this->$model->find('first', array(
  65. 'conditions' => array(
  66. 'AtualizacaoExternaPl.id' => $id
  67. )
  68. ));
  69. $this->set('registro', $registro);
  70. $this->$model->id = $id;
  71. $this->$model->saveField('lido', true);
  72. }
  73. // public function admin_atualizacaoCamara(){
  74. // $this->autoRender = false;
  75. // // die('teste');
  76. // $corpo = $this->request->data['txt'];
  77. //
  78. // $tipo = '';
  79. // $tipoID = '';
  80. // $tiposId = '';
  81. // $tiposName = '';
  82. // $numero_da_pl = '';
  83. // $ano = '';
  84. // $pl_id = '';
  85. // $jaExiste = '';
  86. // $anoPl = '';
  87. // $acheiTipo = 0;
  88. // $propCompleta = '';
  89. // $txt = '';
  90. //
  91. // $tipos = $this->PlType->find('all', array(
  92. // 'fields' => array(
  93. // 'PlType.id',
  94. // 'PlType.tipo',
  95. // ),
  96. // 'recursive' => -2
  97. // ));
  98. // foreach( $tipos as $index => $tipo ){
  99. // $index++;
  100. // if( count($tipos) == $index ){
  101. // $tiposName = $tiposName.$tipo['PlType']['tipo'];
  102. // $tiposId = $tiposId.$tipo['PlType']['id'];
  103. // }else{
  104. // $tiposName = $tiposName.$tipo['PlType']['tipo'].',';
  105. // $tiposId = $tiposId.$tipo['PlType']['id'].',';
  106. // }
  107. // }
  108. //
  109. // $a_prop = array();
  110. // $a_propNew = array();
  111. // $tipo = '';
  112. // $acheiTipo = '';
  113. // $acheiTipo = '';
  114. // $explodeType = '';
  115. // foreach(explode(',', $tiposName) as $tipo){
  116. // $tipo = $tipo.'-';
  117. // $acheiTipo = strripos( $corpo, $tipo );
  118. // $acheiTipo = intval($acheiTipo);
  119. // $explodeType = '';
  120. //
  121. // if( $acheiTipo > 0 ){
  122. // $tratarStr = substr($corpo, $acheiTipo);
  123. // $explodeType = explode('/', $tratarStr);
  124. // $tipo = str_Replace('-', '', $tipo);
  125. // // $tipoFindId = $this->PlType->find('first', array(
  126. // // 'fields' => array(
  127. // // 'PlType.id',
  128. // // 'PlType.tipo'
  129. // // ),
  130. // // 'conditions' => array(
  131. // // 'PlType.tipo' => $tipo
  132. // // ),
  133. // // 'recursive' => -2
  134. // // ));
  135. // $a = array(
  136. // 'tipo' => $tipo
  137. // );
  138. // array_push($a_prop, $a);
  139. // }
  140. // echo "<pre>";
  141. // print_r( $explodeType );
  142. // echo "</pre>";
  143. // }
  144. //
  145. // die();
  146. // // }
  147. }
  148. ?>