/vidcamara/controller/vid_camara_axispresetpos.control.php

https://gitlab.com/talueses/SIPVE · PHP · 221 lines · 104 code · 22 blank · 95 comment · 18 complexity · 99040438ea7d191fcbd3e2f47decbfc5 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 "../model/vid_camara_axispresetpos.model.php"; // Class MODEL VidCamaraAxispresetpos()
  40. require_once "../../inicio/controller/controller.php";// Class CONTROL Controller()
  41. /**
  42. * Description
  43. * @author David Concepcion
  44. */
  45. class ControlVidCamaraAxispresetpos extends Controller{
  46. /**
  47. * @var string mensaje de exito o error
  48. */
  49. var $mensaje = null;
  50. /**
  51. * @var string accion agregar, modificar o eliminar dato
  52. */
  53. var $accion = null;
  54. /**
  55. * @var array nombre de campos campos
  56. */
  57. var $campos = null;
  58. /**
  59. * @var string nombre de la entidad
  60. */
  61. var $entidad = null;
  62. /**
  63. * Establece la acción
  64. * @param string $accion Acción
  65. */
  66. public function setAccion($accion){
  67. $this->accion = $accion;
  68. }
  69. /**
  70. * @return string Devuelve la accion establecida
  71. */
  72. public function getAccion(){
  73. return $this->accion;
  74. }
  75. /**
  76. * Establece el nombre de los campos
  77. * @param string $name Nombre de la posicion del vector
  78. * @param string $value Valor de la posicion del vector
  79. */
  80. public function setCampos($name,$value){
  81. $this->campos[$name] = $value;
  82. }
  83. /**
  84. * @return array Devuelve el nombre de los campos establecido
  85. */
  86. public function getCampos($name){
  87. return $this->campos[$name];
  88. }
  89. /**
  90. * Establece la Entidad
  91. * @param string $entidad Entidad
  92. */
  93. public function setEntidad($entidad){
  94. $this->entidad = $entidad;
  95. }
  96. /**
  97. * @return string Devuelve la Entidad establecida
  98. */
  99. public function getEntidad(){
  100. return $this->entidad;
  101. }
  102. /**
  103. * Agregar o modificar un VidCamaraAxispresetpos
  104. * @return boolean Devuelve verdadero si se registra o actualiza correctamente
  105. */
  106. function setVidCamaraAxispresetpos(){
  107. //------------------ VALIDACION DE CAMPOS -----------------//
  108. if(!$this->sonValidosDatos()) return false;
  109. $obj = new VidCamaraAxispresetpos();
  110. //--------------------- DATOS --------------------------//
  111. $obj->setIdcamaraaxispresetpos($_REQUEST["idcamaraaxispresetpos"]);
  112. $obj->setIdcamara($_REQUEST["idcamara"]);
  113. $obj->setPresetnbr($_REQUEST["presetnbr"]);
  114. $obj->setPresetname($_REQUEST["presetname"]);
  115. if ($this->getAccion()=="agregar"){
  116. $exito = $obj->insertarRegistro();
  117. }
  118. if ($this->getAccion()=="modificar"){
  119. $exito = $obj->modificarRegistro($obj->getIdcamaraaxispresetpos($_REQUEST["idcamaraaxispresetpos"]));
  120. }
  121. // ------------------------------- MENSAJE ERROR --------------------------------//
  122. if(!$exito){
  123. if ($this->getAccion()=="agregar"){
  124. $this->mensaje = "El registro de ".$this->getEntidad()." no pudo ser creado: ".$obj->getMensaje();
  125. }
  126. if ($this->getAccion()=="modificar"){
  127. $this->mensaje = "El registro de ".$this->getEntidad()." no pudo ser modificado: ".$obj->getMensaje();
  128. }
  129. return false;
  130. }
  131. // ------------------------------- MENSAJE EXITO --------------------------------//
  132. if ($this->getAccion()=="agregar"){
  133. $this->mensaje = "El registro de ".$this->getEntidad()." fu&eacute; creado exitosamente...";
  134. }
  135. if ($this->getAccion()=="modificar"){
  136. $this->mensaje = "El registro de ".$this->getEntidad()." fu&eacute; modificado exitosamente...";
  137. }
  138. return true;
  139. }
  140. /**
  141. * === Eliminar VidCamaraAxispresetpos ===
  142. * @return boolean Devuelve verdadero si el proseco de eliminar se ejecuta exitosamente
  143. */
  144. function eliminarVidCamaraAxispresetpos(){
  145. // -------------------- ELIMINAR LECTORA ----------------------//
  146. $obj = new VidCamaraAxispresetpos();
  147. //--------------------- DATOS --------------------------//
  148. $obj->setIdcamaraaxispresetpos($_REQUEST["idcamaraaxispresetpos"]);
  149. $exito = $obj->eliminarRegistro($obj->getIdcamaraaxispresetpos($_REQUEST["idcamaraaxispresetpos"]));
  150. if(!$exito){
  151. $this->mensaje = "El registro de ".$this->getEntidad()." no pudo ser eliminado: ".$obj->getMensaje();
  152. return false;
  153. }
  154. $this->mensaje = "El registro de ".$this->getEntidad()." fu&eacute; eliminado exitosamente...";
  155. return true;
  156. }
  157. /**
  158. * === Validacion Datos ===
  159. * @return boolean Devuelve verdadero si los datos estan correctos
  160. */
  161. function sonValidosDatos(){
  162. //------------------------------------------------------------------------------------------------------------//
  163. $datoName = "idcamara";
  164. $dato = (isset($_REQUEST[$datoName]) && trim($_REQUEST[$datoName])!=='')? trim($_REQUEST[$datoName]) : null;
  165. if($dato===null){
  166. $this->mensaje = "Falta introducir el campo ".$this->getCampos($datoName)." ";
  167. return false;
  168. }
  169. if(!$this->esNumerico($dato)){
  170. $this->mensaje = "El campo ".$this->getCampos($datoName)." introducido no es v&aacute;lido";
  171. return false;
  172. }
  173. //------------------------------------------------------------------------------------------------------------//
  174. $datoName = "presetnbr";
  175. $dato = (isset($_REQUEST[$datoName]) && trim($_REQUEST[$datoName])!=='')? trim($_REQUEST[$datoName]) : null;
  176. if($dato===null){
  177. $this->mensaje = "Falta introducir el campo ".$this->getCampos($datoName)." ";
  178. return false;
  179. }
  180. if(!$this->esNumerico($dato)){
  181. $this->mensaje = "El campo ".$this->getCampos($datoName)." introducido no es v&aacute;lido";
  182. return false;
  183. }
  184. //------------------------------------------------------------------------------------------------------------//
  185. $datoName = "presetname";
  186. $dato = (isset($_REQUEST[$datoName]) && trim($_REQUEST[$datoName])!=='')? trim($_REQUEST[$datoName]) : null;
  187. if($dato===null){
  188. $this->mensaje = "Falta introducir el campo ".$this->getCampos($datoName)." ";
  189. return false;
  190. }
  191. if(!$this->esAlfaNumerico($dato)){
  192. $this->mensaje = "El campo ".$this->getCampos($datoName)." introducido no es v&aacute;lido";
  193. return false;
  194. }
  195. //------------------------------------------------------------------------------------------------------------//
  196. return true;
  197. }
  198. }
  199. ?>