PageRenderTime 43ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/ctrlusuario/controller/ctrl_usuario.control.op.php

https://gitlab.com/talueses/SIPVE
PHP | 254 lines | 142 code | 26 blank | 86 comment | 20 complexity | 5ea0cc470d392d5b26380139235f3351 MD5 | raw file
  1. <?php
  2. /*******************************************************************************\
  3. * @copyright
  4. *
  5. * === SIPve ===
  6. * Sistema Integrado de Protección con capacidades de Videovigilancia
  7. * Control de Acceso y Carnetización para el resguardo físico de instalaciones.
  8. *
  9. * Copyright (C) 2012 Fundación Centro Nacional de Innovación Tecnológica, Cenit.
  10. * Dirección de Investigación, Desarrollo e Innovación.
  11. * Gilda Ramos.
  12. * José Medina.
  13. * Héctor Reverón.
  14. * David Concepción.
  15. * Ronald Delgado.
  16. * Jenner Fuentes.
  17. *
  18. * This program is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License as published by
  20. * the Free Software Foundation, either VERSION 3 of the License, or
  21. * (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU General Public License
  29. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. *
  31. * Para mas información visite
  32. * @link http://repositorio.softwarelibre.gob.ve/ - RNA
  33. * @link http://sourceforge.net/projects/sipve/ - SourceForge
  34. * @link https://gitlab.com/talueses/SIPVE - Gitlab Repositorio.
  35. *
  36. \*******************************************************************************/
  37. ?>
  38. <?php
  39. define("CATEGORIA", "CTRLUSR"); //Categoria del modulo
  40. require_once "ctrl_usuario.control.php";// Class CONTROL ControlCtrlUsuario()
  41. /**
  42. * Description
  43. * @author David Concepcion
  44. */
  45. class ControlOpCtrlUsuario extends ControlCtrlUsuario{
  46. /**
  47. * Proceso de registrar o actualizar registro
  48. * @return boolean Devuelve verdadero si se registra o actualiza correctamente
  49. */
  50. function setOpCtrlUsuario(){
  51. // ---------- Set Nombres de Campos ---------------//
  52. $this->setNombres();
  53. if (!$_REQUEST["tienefechalimite"]){
  54. $_REQUEST["tienefechalimite"] = "0";
  55. }
  56. if (!$_REQUEST["modificable"]){
  57. $_REQUEST["modificable"] = "0";
  58. }
  59. if (!$_REQUEST["rondasguardias"]){
  60. $_REQUEST["rondasguardias"] = "0";
  61. }
  62. if (!$_REQUEST["skipfpcheck"]){
  63. $_REQUEST["skipfpcheck"] = "0";
  64. }
  65. if (!$_REQUEST["antipassback"]){
  66. $_REQUEST["antipassback"] = "0";
  67. }
  68. if ($row["tipo_tarjeta"]=="empleado"){
  69. $row["numero_visitante"] = "";
  70. }
  71. if ($row["tipo_tarjeta"]=="visitante"){
  72. $row["cedula"] = "";
  73. $row["apellidos"] = "";
  74. $row["iddepartamento"] = "";
  75. $row["sexo"] = "";
  76. $row["fecha_nacimiento"] = "";
  77. $row["telefono"] = "";
  78. $row["telefono_celular"] = "";
  79. $row["email"] = "";
  80. $row["direccion"] = "";
  81. }
  82. //------------------ VALIDACION DE CAMPOS -----------------//
  83. if(!$this->sonValidosDatos()) return false;
  84. //------------------ VALIDACION CODIGOS TARJETA -----------------//
  85. // Concatenacion hexadecimal de codigo sitio y codigo tarjeta para generar el cogido identificador
  86. $codigo_id = sprintf("%02X",$_REQUEST["codigo_sitio"]).sprintf("%02X",$_REQUEST["codigo_tarjeta"]);
  87. // Comparacion de codigo identificador generado, convertido de hexadecimal a decimal
  88. if (sprintf('%010d',hexdec($codigo_id)) != sprintf('%010d',$_REQUEST["codigo_id"])){
  89. $this->mensaje = "Existe un error de codificaci&oacute;n en la tarjeta.";
  90. return false;
  91. }
  92. $_REQUEST["codigo_id"] = sprintf('%010d',$_REQUEST["codigo_id"]);
  93. $_REQUEST["codigo_sitio"] = sprintf('%05d',$_REQUEST["codigo_sitio"]);
  94. $_REQUEST["codigo_tarjeta"] = sprintf('%05d',$_REQUEST["codigo_tarjeta"]);
  95. //------------------ Metodo Set -----------------//
  96. if(!$this->setCtrlUsuario()) return false;
  97. //------------------ Sincronizar -----------------//
  98. $sinc = new ControlOpCtrlSincronizar();
  99. if(!$sinc->setOpCtrlSincronizar()){
  100. $this->mensaje = $sinc->mensaje;
  101. return false;
  102. }
  103. return true;
  104. }
  105. /**
  106. * Proceso de eliminar registro
  107. * @return boolean Devuelve verdadero si el proseco de eliminar se ejecuta exitosamente
  108. */
  109. function eliminarOpCtrlUsuario(){
  110. // ---------- Set Nombres de Campos ---------------//
  111. $this->setNombres();
  112. // Unset usuario en las controladoras
  113. $obj = new CtrlUsuarios();
  114. $data = $obj->getCtrlUsuario($_REQUEST["idusuario"]);
  115. $_REQUEST["idgrupo"] = $data->idgrupo;
  116. $_REQUEST["numero"] = $data->numero;
  117. $_REQUEST["codigo_pin"] = "";
  118. $_REQUEST["codigo_tarjeta"] = "0";
  119. $_REQUEST["codigo_sitio"] = "0";
  120. $_REQUEST["tarjetayopin"] = "0";
  121. $_REQUEST["tienefechalimite"] = "0";
  122. $_REQUEST["modificable"] = "0";
  123. $_REQUEST["rondasguardias"] = "0";
  124. $_REQUEST["skipfpcheck"] = "0";
  125. $_REQUEST["fechahasta"] = "0";
  126. $_REQUEST["idzonadetiempo"] = "0";
  127. $_REQUEST["nivel"] = "0";
  128. $_REQUEST["antipassback"] = "0";
  129. //------------------ Sincronizar -----------------//
  130. $sinc = new ControlOpCtrlSincronizar();
  131. if(!$sinc->setOpCtrlSincronizar()){
  132. $this->mensaje = $sinc->mensaje;
  133. return false;
  134. }
  135. //------------------ Metodo Set -----------------//
  136. if(!$this->eliminarCtrlUsuario()) return false;
  137. return true;
  138. }
  139. /**
  140. * Establece los nombres de la Entidad y los campos
  141. */
  142. function setNombres(){
  143. $this->setEntidad("Usuario / Trajeta");
  144. $this->setCampos("numero","N&uacute;mero de usuario de acceso");
  145. $this->setCampos("idgrupo","Grupo de Puertas");
  146. $this->setCampos("idzonadetiempo","Horarios de Trabajo");
  147. $this->setCampos("codigo_pin","C&oacute;digo Pin");
  148. $this->setCampos("codigo_id","C&oacute;digo Identificador");
  149. $this->setCampos("codigo_sitio","C&oacute;digo Sitio de Tarjeta");
  150. $this->setCampos("codigo_tarjeta","C&oacute;digo Tarjeta");
  151. $this->setCampos("cedula","C&eacute;dula");
  152. $this->setCampos("nombres","Nombre");
  153. $this->setCampos("apellidos","Apellido");
  154. $this->setCampos("iddepartamento","Departamento");
  155. $this->setCampos("sexo","Sexo");
  156. $this->setCampos("fecha_nacimiento","Fecha de Nacimiento");
  157. $this->setCampos("telefono","Tel&eacute;fono");
  158. $this->setCampos("telefono_celular","Tel&eacute;fono Celular");
  159. $this->setCampos("direccion","Direcci&oacute;n");
  160. $this->setCampos("email","eMail");
  161. $this->setCampos("fechahasta","Fecha Limite de Acceso");
  162. }
  163. /**
  164. * === Validacion Datos ===
  165. * @return boolean Devuelve verdadero si los datos estan correctos
  166. */
  167. function sonValidosDatos(){
  168. $datos = array();
  169. $isRequired["empleado"] = false;
  170. $isRequired["visitante"] = false;
  171. if ($_REQUEST["tipo_tarjeta"]=="empleado"){
  172. $isRequired["empleado"]=true;
  173. }
  174. if ($_REQUEST["tipo_tarjeta"]=="visitante"){
  175. $isRequired["visitante"]=true;
  176. }
  177. //------------------------------------------------------------------------------------------------------------//
  178. $datos[] = array("isRequired"=>true,"datoName"=>"numero","tipoDato"=>"esNumerico");
  179. //------------------------------------------------------------------------------------------------------------//
  180. $datos[] = array("isRequired"=>$isRequired["visitante"],"datoName"=>"numero_visitante","tipoDato"=>"esNumerico");
  181. //------------------------------------------------------------------------------------------------------------//
  182. $datos[] = array("isRequired"=>$isRequired["empleado"],"datoName"=>"cedula","tipoDato"=>"esNumerico");
  183. //------------------------------------------------------------------------------------------------------------//
  184. $datos[] = array("isRequired"=>true,"datoName"=>"nombres","tipoDato"=>"esAlfaNumericoConEspacios");
  185. //------------------------------------------------------------------------------------------------------------//
  186. $datos[] = array("isRequired"=>$isRequired["empleado"],"datoName"=>"apellidos","tipoDato"=>"esAlfaNumericoConEspacios");
  187. //------------------------------------------------------------------------------------------------------------//
  188. $datos[] = array("isRequired"=>false,"datoName"=>"iddepartamento","tipoDato"=>"esNumerico");
  189. //------------------------------------------------------------------------------------------------------------//
  190. $datos[] = array("isRequired"=>false,"datoName"=>"sexo","tipoDato"=>"esAlfaNumerico");
  191. //------------------------------------------------------------------------------------------------------------//
  192. $datos[] = array("isRequired"=>false,"datoName"=>"fecha_nacimiento","tipoDato"=>"");
  193. //------------------------------------------------------------------------------------------------------------//
  194. $datos[] = array("isRequired"=>false,"datoName"=>"telefono","tipoDato"=>"esValidoTlf");
  195. //------------------------------------------------------------------------------------------------------------//
  196. $datos[] = array("isRequired"=>false,"datoName"=>"telefono_celular","tipoDato"=>"esValidoTlf");
  197. //------------------------------------------------------------------------------------------------------------//
  198. $datos[] = array("isRequired"=>false,"datoName"=>"email","tipoDato"=>"esValidoEmail");
  199. //------------------------------------------------------------------------------------------------------------//
  200. $datos[] = array("isRequired"=>false,"datoName"=>"direccion","tipoDato"=>"esAlfaNumericoEspecial");
  201. //------------------------------------------------------------------------------------------------------------//
  202. $datos[] = array("isRequired"=>true,"datoName"=>"tarjetayopin","tipoDato"=>"esNumerico");
  203. //------------------------------------------------------------------------------------------------------------//
  204. $datos[] = array("isRequired"=>true,"datoName"=>"codigo_id","tipoDato"=>"esNumerico");
  205. //------------------------------------------------------------------------------------------------------------//
  206. $datos[] = array("isRequired"=>true,"datoName"=>"codigo_sitio","tipoDato"=>"esNumerico");
  207. //------------------------------------------------------------------------------------------------------------//
  208. $datos[] = array("isRequired"=>true,"datoName"=>"codigo_tarjeta","tipoDato"=>"esNumerico");
  209. //------------------------------------------------------------------------------------------------------------//
  210. $chkCodigoPin = false;
  211. if ($_REQUEST["tarjetayopin"]=="2" || $_REQUEST["tarjetayopin"]=="3"){
  212. $chkCodigoPin = true;
  213. }
  214. $datos[] = array("isRequired"=>$chkCodigoPin,"datoName"=>"codigo_pin","tipoDato"=>"esNumerico");
  215. //------------------------------------------------------------------------------------------------------------//
  216. $datos[] = array("isRequired"=>true,"datoName"=>"idgrupo","tipoDato"=>"esNumerico");
  217. //------------------------------------------------------------------------------------------------------------//
  218. $datos[] = array("isRequired"=>true,"datoName"=>"idzonadetiempo","tipoDato"=>"esNumerico");
  219. //------------------------------------------------------------------------------------------------------------//
  220. if ($_REQUEST["tienefechalimite"]=="1"){
  221. $datos[] = array("isRequired"=>true,"datoName"=>"fechahasta","tipoDato"=>"");
  222. }
  223. //------------------------------------------------------------------------------------------------------------//
  224. if (!$this->validarDatos($datos))return false;
  225. return true;
  226. }
  227. }
  228. ?>