Guest User

Untitled

a guest
Dec 7th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.83 KB | None | 0 0
  1. <?php
  2.  
  3. include_once APPLICATION_PATH . '/helpers/Functions.php';
  4. include_once APPLICATION_PATH . '/helpers/Config.php';
  5.  
  6.  
  7. class ReportesSos_Form extends Zend_Form
  8. {
  9.  
  10. private $_ReportesModel;
  11.  
  12. public function init()
  13. {
  14. $config = Config::getIni();
  15. $numVehicles = $config->suspectVehicles;
  16. $numPersons = $config->suspectPersons;
  17.  
  18. $this->getView()->setEscape('stripslashes');
  19.  
  20. $this->setMethod("post");
  21.  
  22. $hiddenIdReport = new Zend_Form_Element_Hidden("idReport");
  23. $hiddenIdReport = $this->delDecorators($hiddenIdReport);
  24. $this->addElement($hiddenIdReport);
  25.  
  26. $hiddenFolio = new Zend_Form_Element_Hidden("Folio");
  27. $hiddenFolio = $this->delDecorators($hiddenFolio);
  28. $this->addElement($hiddenFolio);
  29.  
  30. $hiddenAgente = new Zend_Form_Element_Hidden("Agente");
  31. $hiddenAgente = $this->delDecorators($hiddenAgente);
  32. $this->addElement($hiddenAgente);
  33.  
  34. $hiddenSucursal = new Zend_Form_Element_Hidden("Sucursal");
  35. $hiddenSucursal = $this->delDecorators($hiddenSucursal);
  36. $this->addElement($hiddenSucursal);
  37.  
  38. $hiddenStatus = new Zend_Form_Element_Hidden("StatusSos");
  39. $hiddenStatus = $this->delDecorators($hiddenStatus);
  40. $this->addElement($hiddenStatus);
  41.  
  42. $hiddenFecha = new Zend_Form_Element_Hidden("Fecha");
  43. $hiddenFecha = $this->delDecorators($hiddenFecha);
  44. $this->addElement($hiddenFecha);
  45.  
  46. $hiddenFFecha = new Zend_Form_Element_Hidden("FFecha");
  47. $hiddenFFecha = $this->delDecorators($hiddenFFecha);
  48. $this->addElement($hiddenFFecha);
  49.  
  50. $hiddenReportePara = new Zend_Form_Element_Hidden("ReportePara");
  51. $hiddenReportePara = $this->delDecorators($hiddenReportePara);
  52. $this->addElement($hiddenReportePara);
  53.  
  54. $hiddenNumVehicles = new Zend_Form_Element_Hidden("numVehicles");
  55. $hiddenNumVehicles->setValue($numVehicles);
  56. $hiddenNumVehicles = $this->delDecorators($hiddenNumVehicles);
  57. $this->addElement($hiddenNumVehicles);
  58.  
  59. # Array for types of activities
  60. $actividadOptions = Functions::arrayToSimpleSel(array("", "Correlacion", "Incompatibilidad", "Vagabundeo", "Titubeos", "Paranoia", "Comunicacion", "Tecnico"));
  61.  
  62. $fechaSubForm = new Zend_Form_SubForm();
  63. $fechaSubForm->setLegend("Fecha del reporte");
  64. $fechaSubForm = $this->delDecorators($fechaSubForm);
  65.  
  66. $fdate = new Zend_Form_Element_Text("newFecha");
  67. $fdate->setLabel("D&iacute;a");
  68. $fdate->setAttrib("readonly", "readonly");
  69. $fdate->setAttrib("onclick","new Calendar('', '', {disable_after: 'today', beforeCreate: 'checkDisableDate', dateFormat: 'd/m/Y'}, this);");
  70.  
  71. $fhour = new Zend_Form_Element_Text("newHour");
  72. $fhour->setLabel("Hora");
  73.  
  74. $fechaSubForm->addElements(array($fdate, $fhour));
  75.  
  76. $actividad = new Zend_Form_SubForm();
  77. $actividad->setLegend("Actividad");
  78. $actividad = $this->delDecorators($actividad);
  79.  
  80. $ubicacion = new Zend_Form_SubForm();
  81. $ubicacion->setLegend("Ubicacion");
  82. $ubicacion = $this->delDecorators($ubicacion);
  83.  
  84. # We generate the vehicle forms according to the settings in our config file
  85. $cars = array();
  86. for($i = 1; $i <= $numVehicles; $i ++)
  87. {
  88. $cars[$i] = $this->generateVehicleForm($i);
  89. $cars[$i] = $this->delDecorators($cars[$i]);
  90. }
  91.  
  92. # We generate the person forms according to the settings in our config file
  93. $persons = array();
  94. for($i = 1; $i <= $numPersons; $i ++)
  95. {
  96. $persons[$i] = $this->generatePersonForm($i);
  97. $persons[$i] = $this->delDecorators($persons[$i]);
  98. }
  99.  
  100. $metodo = new Zend_Form_SubForm();
  101. $metodo->setLegend("M&eacute;todo");
  102. $metodo = $this->delDecorators($metodo);
  103.  
  104. $blanco = new Zend_Form_SubForm();
  105. $blanco->setLegend("Blanco Probable");
  106. $blanco = $this->delDecorators($blanco);
  107.  
  108. $narrativo = new Zend_Form_SubForm("narrativo");
  109. $narrativo->setLegend("Texto Narrativo");
  110. $narrativo = $this->delDecorators($narrativo);
  111.  
  112. $file = new Zend_Form_SubForm();
  113. $file->setLegend("Adjuntar Fotos");
  114. $file = $this->delDecorators($file);
  115.  
  116. $chkActividad = new Zend_Form_Element_MultiCheckbox("Actividad");
  117. $chkActividad->addMultiOptions(array
  118. (
  119. 'Correlacion' => 'Correlacion',
  120. 'Incompatibilidad' => 'Incompatibilidad',
  121. 'Vagabundeo' => 'Vagabundeo',
  122. 'Titubeos' => 'Titubeos',
  123. 'Paranoia' => 'Paranoia',
  124. 'Comunicacion' => 'Comunicacion',
  125. 'Tecnico' => 'Tecnico'
  126. )
  127. );
  128. $chkActividad = $this->delDecorators($chkActividad);
  129. $actividad->addElement($chkActividad);
  130.  
  131. $chokePoints = $this->getChokePoints();
  132. $chokePoints = Functions::arrayToSelect($chokePoints, "idChokeP", "Lugar", true);
  133.  
  134. $ubicacion->AddElement("select", "ChokePoint", array(
  135. 'label' => 'Choke Point',
  136. 'MultiOptions' => $chokePoints
  137. )
  138. );
  139.  
  140. $lugares = $this->getClaveLugares();
  141. $lugares = Functions::escapeArray($lugares);
  142. $lugares = Functions::arrayToSelect($lugares, "ClaveLugar", "ClaveLugar", true);
  143.  
  144. $ubicacion->addElement("select", "ClaveLugar", array(
  145. 'label' => 'Clave Lugar',
  146. 'MultiOptions' => $lugares,
  147. 'onchange' => 'manageClaveLugar(this)'
  148. )
  149. );
  150.  
  151. $sectores = $this->getSectoresSucursal();
  152. $sectores= Functions::escapeArray($sectores);
  153. $sectores= Functions::arrayToSelect($sectores, "idSector", "Sector", true);
  154.  
  155.  
  156. $ubicacion->addElement("select", "Sector", array(
  157. 'label' => 'Sector',
  158. 'MultiOptions' => $sectores,
  159. 'onchange' => 'manageSectorZona(this)',
  160. 'required' => true
  161. )
  162. );
  163.  
  164. $ubicacion->addElement("select", "Zona", array(
  165. 'label' => 'Zona',
  166. 'required' => true
  167. ))
  168. ->setRegisterInArrayValidator(false);
  169.  
  170. $ubicacion->addElement("text", "Colonia", array(
  171. 'label' => 'Colonia',
  172. 'filters' => array('StringToUpper', 'StringTrim'),
  173. 'uppercase' => true,
  174. 'size' => 25,
  175. 'required' => true,
  176. 'errorMessages' => array('isEmpty' => 'Campo Requerido')
  177. )
  178. );
  179.  
  180. $ubicacion->addElement("text", "CalleNum", array(
  181. 'label' => 'Calle y Numero',
  182. 'filters' => array('StringToUpper', 'StringTrim'),
  183. 'uppercase' => true,
  184. 'size' => 25,
  185. 'required' => true,
  186. 'errorMessages' => array('isEmpty' => 'Campo Requerido')
  187. )
  188. );
  189.  
  190. $ubicacion->addElement("text", "Entre", array(
  191. 'label' => 'Calles Aleda&ntilde;as',
  192. 'filters' => array('StringToUpper', 'StringTrim'),
  193. 'uppercase' => true,
  194. 'size' => 25,
  195. )
  196. );
  197.  
  198. $chkMetodo = new Zend_Form_element_MultiCheckbox ("Metodo");
  199. $chkMetodo->setLabel("Metodo");
  200. $chkMetodo->addMultiOptions(array(
  201. 'progresivo' => 'Progresivo',
  202. 'movil' => 'M&oacute;vil',
  203. 'fijo' => 'Fijo',
  204. 'tecnico' => 'T&eacute;cnico'
  205. )
  206. );
  207. $chkMetodo = $this->delDecorators($chkMetodo);
  208. $metodo->addElement($chkMetodo);
  209.  
  210. $hiddenBlanco = new Zend_Form_Element_Hidden("Objetivos");
  211. $hiddenBlanco = $this->delDecorators($hiddenBlanco);
  212. $hiddenBlanco->setAttribs(array
  213. (
  214. 'required' => true,
  215. 'errorMessages' => array('isEmpty' => 'Se requiere agregar por lo menos un Principal')
  216. )
  217. );
  218. $this->addElement($hiddenBlanco);
  219.  
  220. $blanco->addElement("radio", "tipoBlanco", array(
  221. 'MultiOptions' => array(
  222. //'colonia' => 'Por Colonia',
  223. //'calle' => 'Por Calle',
  224. 'lugar' => 'Por Lugar',
  225. 'listado' => 'Por Listado'
  226. )
  227. )
  228. );
  229.  
  230. $narrativo->addElement("checkbox", "Prioridad", array(
  231. 'label' => 'Prioritario',
  232. 'onclick' => 'prioritizeReport(this)'
  233. )
  234. );
  235.  
  236. $narrativo->addElement("textarea", "Observaciones", array(
  237. 'cols' => 45,
  238. 'rows' => 6
  239. )
  240. );
  241.  
  242. //$element->addValidator('Extension', false, 'jpg,png,gif');
  243. $file->addElement("file", "file1", array
  244. (
  245. 'ValueDisabled' => true,
  246. 'size' => 60,
  247. 'Validators' => array
  248. (
  249. array ('Size', 'false', 1024000),
  250. array ('Extension', 'false', 'jpg,png,gif,bmp'),
  251. ),
  252. )
  253. );
  254.  
  255. $file->addElement("file", "file2", array
  256. (
  257. 'ValueDisabled' => true,
  258. 'size' => 60,
  259. 'Validators' => array
  260. (
  261. array ('Size', 'false', 1024000),
  262. array ('Extension', 'false', 'jpg,png,gif,bmp'),
  263. ),
  264. )
  265. );
  266.  
  267. /**/
  268. $file->addElement("file", "file3", array
  269. (
  270. 'ValueDisabled' => true,
  271. 'size' => 60,
  272. 'Validators' => array
  273. (
  274. array ('Size', 'false', 1024000),
  275. array ('Extension', 'false', 'jpg,png,gif,bmp'),
  276. ),
  277. )
  278. );
  279. /**/
  280.  
  281. /*
  282. $f3 = $file->file3;
  283. $tmpFolio = $this->Folio->getValue();
  284. $f3->addDecorator('Description', array('escape' => 'false', 'placement' => 'append'));
  285. $f3->setDescription("<div class=\"editFormImg\">$tmpFolio | ". $this->putThumbnail($tmpFolio, 1) .
  286. $this->putThumbnail($tmpFolio, 2) . $this->putThumbnail($tmpFolio, 3) . "</div>");
  287. /**/
  288. $file->addDecorator('Description', array ('escape' => 'false', 'placement' => 'append'));
  289. $file->setDescription("<div class=\"separatorDiv\"></div>");
  290.  
  291. $subformArray = array
  292. (
  293. 'LaFecha' => $fechaSubForm,
  294. 'Actividad' => $actividad,
  295. 'Metodo' => $metodo,
  296. 'Blanco' => $blanco,
  297. 'Ubicacion' => $ubicacion,
  298. 'Narrativo' => $narrativo
  299. );
  300.  
  301. $subformArray = $this->buildSubformArray($subformArray, $cars, $persons);
  302. $subformArray["File"] = $file;
  303.  
  304. $this->addSubForms($subformArray);
  305.  
  306. $busquedaPlacas = $this->getFoliosBusquedaPlacas();
  307.  
  308. $idBusquedaPlacas = new Zend_Form_Element_Select("idBusquedaPlacas");
  309. $idBusquedaPlacas->setLabel("Folio de Busqueda de Placas")
  310. ->setRegisterInArrayValidator(false)
  311. ->addMultiOptions($busquedaPlacas);
  312. $this->addElement($idBusquedaPlacas);
  313.  
  314. $this->addDisplayGroup(array
  315. (
  316. 'idBusquedaPlacas',
  317. ),
  318. 'DGB'
  319. );
  320.  
  321. $this->DGB->setLegend("Consulta de Placas Folio");
  322.  
  323. $submit = new Zend_Form_Element_Button("Guardar");
  324. $submit->setLabel("Guardar");
  325. $submit->setAttrib("class", "centeredButton");
  326. $submit->setAttrib("onclick", "verifyRPSOSForm(this.form)");
  327. $submit = $this->delDecorators($submit);
  328. $submit->setDecorators(array(
  329. 'ViewHelper',
  330. array
  331. (
  332. array
  333. (
  334. 'data' => 'HtmlTag'
  335. ),
  336. array
  337. (
  338. 'tag' => 'div',
  339. 'class' => 'botonContainer'
  340. )
  341. )
  342. )
  343. );
  344. $this->addElement($submit);
  345.  
  346. $cancel = new Zend_Form_Element_Button("cancelar");
  347. $cancel->setLabel("Cancelar");
  348. $cancel->setAttrib("class", "centeredButton");
  349. $cancel->setAttrib("onclick", "window.location=\"/reportes\"");
  350. $cancel = $this->delDecorators($cancel);
  351.  
  352. $cancel->setDecorators(array(
  353. 'ViewHelper',
  354. array
  355. (
  356. array
  357. (
  358. 'data'=>'HtmlTag'
  359. ),
  360. array
  361. (
  362. 'tag'=>'div',
  363. 'class'=>'botonContainer'
  364. )
  365. )
  366. ));
  367.  
  368.  
  369. $this->addElement($cancel);
  370.  
  371. $this->setDecorators(array(
  372. 'FormElements',
  373. array
  374. (
  375. array
  376. (
  377. 'data'=>'HtmlTag'
  378. ),
  379. array
  380. (
  381. 'tag'=>'div',
  382. 'class'=>'ReportesForm'
  383. )
  384. )
  385. ,'Form'
  386. ));
  387.  
  388. }
  389.  
  390. public function generateVehicleForm($number)
  391. {
  392.  
  393. include_once APPLICATION_PATH . '/forms/ReporteSos/Vehicle.php';
  394. $form = new VehicleForm();
  395. $vehicleForm = $form->generateVehicleForm($number);
  396. return $vehicleForm;
  397. }
  398.  
  399. public function generatePersonForm($number)
  400. {
  401.  
  402. include_once APPLICATION_PATH . '/forms/ReporteSos/Person.php';
  403.  
  404. $form = new PersonForm();
  405. $personForm = $form->generatePersonForm($number);
  406.  
  407. return $personForm;
  408.  
  409. }
  410.  
  411. public function getChokePoints()
  412. {
  413. require_once APPLICATION_PATH . '/helpers/Authentication.php';
  414. $auth = new Authentication();
  415. $sucursal = $auth->getSessionVar("UserSuc");
  416.  
  417. $model = $this->getReportesModel();
  418. $data = $model->fetchChokePoints($sucursal);
  419.  
  420. return $data;
  421. }
  422.  
  423. public function getClaveLugares()
  424. {
  425. require_once APPLICATION_PATH . '/helpers/Authentication.php';
  426. $auth = new Authentication();
  427. $sucursal = $auth->getSessionVar("UserSuc");
  428. $model = $this->getReportesModel();
  429. $data = $model->fetchClaveLugares($sucursal);
  430.  
  431. return $data;
  432. }
  433.  
  434. public function getFoliosBusquedaPlacas()
  435. {
  436. require_once APPLICATION_PATH . '/helpers/Authentication.php';
  437. $auth = new Authentication();
  438. $model = $this->getReportesModel();
  439. $uid = $auth->getSessionVar("UserID");
  440.  
  441. $data = $model->getPlacaBusquedaFolio($uid);
  442. $array = array();
  443. $array[0] = "";
  444. foreach ($data as $reg)
  445. {
  446. $array[$reg["idBusquedaPlacas"]] = "Folio {$reg["idBusquedaPlacas"]} - {$reg["placas"]}";
  447. }
  448.  
  449. return $array;
  450. }
  451.  
  452.  
  453. public function getReportesModel()
  454. {
  455. if (null == $this->_ReportesModel)
  456. {
  457. include_once APPLICATION_PATH . '/models/ReportesSos.php';
  458. $this->_ReportesModel = new Model_Reportes();
  459. }
  460.  
  461. return $this->_ReportesModel;
  462. }
  463.  
  464. public function delDecorators($formElement)
  465. {
  466. $formElement->removeDecorator('Label');
  467. $formElement->removeDecorator('HtmlTag');
  468. $formElement->removeDecorator('DtDdWrapper');
  469.  
  470. return $formElement;
  471. }
  472.  
  473. public function buildSubformArray($array, $cars, $persons)
  474. {
  475.  
  476. for ($i = 1; $i <= count($cars); $i ++)
  477. {
  478. $array["Vehiculos$i"] = $cars[$i];
  479. }
  480.  
  481. for ($i = 1; $i <= count($persons); $i ++)
  482. {
  483. $array["Persona$i"] = $persons[$i];
  484. }
  485.  
  486. return $array;
  487. }
  488.  
  489. public function putThumbnail($folio, $number)
  490. {
  491. require_once APPLICATION_PATH . '/helpers/ImageHelper.php';
  492. $output = $number;
  493. $output = ImageHelper::outputImage($folio, $number, TRUE);
  494. return $output;
  495. }
  496.  
  497.  
  498. public function getSectoresSucursal()
  499. {
  500. require_once APPLICATION_PATH . '/helpers/Authentication.php';
  501. $auth = new Authentication();
  502. $sucursal = $auth->getSessionVar("UserSuc");
  503. $model = $this->getReportesModel();
  504. $data = $model->fetchSectores($sucursal);
  505.  
  506. return $data;
  507. }
  508.  
  509. }
Add Comment
Please, Sign In to add comment