PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/ctrlpuerta/controller/ctrl_sincronizar.control.op.php

https://gitlab.com/talueses/SIPVE
PHP | 171 lines | 80 code | 21 blank | 70 comment | 14 complexity | 71740507831f9ef418eac969b832d144 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. require_once "../../ctrlsincronizar/controller/ctrl_sincronizar.control.php";// Class CONTROL ControlCtrlSincronizar()
  40. /**
  41. * Description
  42. * @author David Concepcion
  43. */
  44. class ControlOpCtrlSincronizar extends ControlCtrlSincronizar{
  45. /**
  46. * Proceso de registrar o actualizar registro
  47. * @return boolean Devuelve verdadero si se registra o actualiza correctamente
  48. */
  49. function setOpCtrlSincronizar(){
  50. // ---------- Set Nombres de Campos ---------------//
  51. $this->setNombres();
  52. //echo "<div align='left'><pre>".print_r($_REQUEST,true)."</pre></div>";
  53. $this->setAccion("agregar");
  54. $_REQUEST["item"] = "Puertas"; // Etiqueta de registro en el proceso de sincronizacion para accionar puerta
  55. if ($_REQUEST["accion"]=="abrir"){
  56. $_REQUEST["accion"] = "Abrir Por Numero de Puerta";
  57. if ($_REQUEST["all"]==""){
  58. $_REQUEST["codigoaccion"] = "2"; // Codigo de abrir puerta en la controladora
  59. }elseif($_REQUEST["all"]=="true"){
  60. $_REQUEST["accion"] = "Abrir Todas Las Puertas";
  61. $_REQUEST["codigoaccion"] = "1"; // Codigo de abrir todas las puertas en la controladora
  62. }
  63. }
  64. if ($_REQUEST["accion"]=="cerrar"){
  65. $_REQUEST["accion"] = "Cerrar Por Numero de Puerta";
  66. if ($_REQUEST["all"]==""){
  67. $_REQUEST["codigoaccion"] = "16"; // Codigo de cerrar puerta en la controladora
  68. }elseif($_REQUEST["all"]=="true"){
  69. $_REQUEST["accion"] = "Cerrar Todas Las Puertas";
  70. $_REQUEST["codigoaccion"] = "15"; // Codigo de cerrar todas las puertas en la controladora
  71. }
  72. }
  73. $_REQUEST["prioridad"] = "100"; // Prioridad del proceso de sincronizacion para accionar puerta
  74. // Consulta de todas las controladoras a sincronizar las puertas
  75. if ($_REQUEST["all"]=="" && $_REQUEST["idpuerta"] != ""){
  76. $data = CtrlSincronizars::getControladorasPuertas($_REQUEST["idpuerta"]);
  77. }
  78. if($_REQUEST["all"]=="true"){
  79. $data = CtrlSincronizars::getControladoras();
  80. }
  81. if (count($data) > 0){
  82. //echo "<div align='left'><pre>".print_r($data,true)."</pre></div>";
  83. foreach ($data as $key => $row){
  84. $_REQUEST["nodo"] = $row->nodo;
  85. $_REQUEST["ipv4"] = $row->ipv4;
  86. $_REQUEST["puerto"] = $row->puerto;
  87. if($_REQUEST["all"] ==""){
  88. $_REQUEST["param1"] = $row->numero_puerta; // Numero de la camara
  89. }
  90. //------------------ Metodo Set -----------------//
  91. if(!$this->setCtrlSincronizar()) return false;
  92. }
  93. }
  94. return true;
  95. }
  96. /**
  97. * Proceso de eliminar registro
  98. * @return boolean Devuelve verdadero si el proseco de eliminar se ejecuta exitosamente
  99. */
  100. function eliminarOpCtrlSincronizar(){
  101. // ---------- Set Nombres de Campos ---------------//
  102. $this->setNombres();
  103. //------------------ Metodo Set -----------------//
  104. if(!$this->eliminarCtrlSincronizar()) return false;
  105. return true;
  106. }
  107. /**
  108. * Establece los nombres de la Entidad y los campos
  109. */
  110. function setNombres(){
  111. $this->setEntidad("Sincronizacion");
  112. $this->setCampos("item","Item");
  113. $this->setCampos("accion","Accion");
  114. $this->setCampos("codigoaccion","Codigoaccion");
  115. $this->setCampos("nodo","Nodo");
  116. $this->setCampos("ipv4","Ipv4");
  117. $this->setCampos("puerto","Puerto");
  118. $this->setCampos("prioridad","Prioridad");
  119. $this->setCampos("param1","Param1");
  120. }
  121. /**
  122. * === Validacion Datos ===
  123. * @return boolean Devuelve verdadero si los datos estan correctos
  124. */
  125. function sonValidosDatos(){
  126. $datos = array();
  127. //------------------------------------------------------------------------------------------------------------//
  128. $datos[] = array("isRequired"=>true,"datoName"=>"item","tipoDato"=>"esAlfaNumericoConEspacios");
  129. //------------------------------------------------------------------------------------------------------------//
  130. $datos[] = array("isRequired"=>true,"datoName"=>"accion","tipoDato"=>"esAlfaNumericoConEspacios");
  131. //------------------------------------------------------------------------------------------------------------//
  132. $datos[] = array("isRequired"=>true,"datoName"=>"codigoaccion","tipoDato"=>"");
  133. //------------------------------------------------------------------------------------------------------------//
  134. $datos[] = array("isRequired"=>true,"datoName"=>"nodo","tipoDato"=>"esNumerico");
  135. //------------------------------------------------------------------------------------------------------------//
  136. $datos[] = array("isRequired"=>true,"datoName"=>"ipv4","tipoDato"=>"esValidaIP");
  137. //------------------------------------------------------------------------------------------------------------//
  138. $datos[] = array("isRequired"=>true,"datoName"=>"puerto","tipoDato"=>"");
  139. //------------------------------------------------------------------------------------------------------------//
  140. $datos[] = array("isRequired"=>true,"datoName"=>"prioridad","tipoDato"=>"esNumerico");
  141. //------------------------------------------------------------------------------------------------------------//
  142. if($_REQUEST["all"] ==""){
  143. $datos[] = array("isRequired"=>true,"datoName"=>"param1","tipoDato"=>"esAlfaNumericoConEspacios");
  144. }
  145. //------------------------------------------------------------------------------------------------------------//
  146. if (!$this->validarDatos($datos))return false;
  147. return true;
  148. }
  149. }
  150. ?>