Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once APPLICATION_PATH . '/helpers/Functions.php';
- include_once APPLICATION_PATH . '/helpers/Config.php';
- class ReportesSos_Form extends Zend_Form
- {
- private $_ReportesModel;
- public function init()
- {
- $config = Config::getIni();
- $numVehicles = $config->suspectVehicles;
- $numPersons = $config->suspectPersons;
- $this->getView()->setEscape('stripslashes');
- $this->setMethod("post");
- $hiddenIdReport = new Zend_Form_Element_Hidden("idReport");
- $hiddenIdReport = $this->delDecorators($hiddenIdReport);
- $this->addElement($hiddenIdReport);
- $hiddenFolio = new Zend_Form_Element_Hidden("Folio");
- $hiddenFolio = $this->delDecorators($hiddenFolio);
- $this->addElement($hiddenFolio);
- $hiddenAgente = new Zend_Form_Element_Hidden("Agente");
- $hiddenAgente = $this->delDecorators($hiddenAgente);
- $this->addElement($hiddenAgente);
- $hiddenSucursal = new Zend_Form_Element_Hidden("Sucursal");
- $hiddenSucursal = $this->delDecorators($hiddenSucursal);
- $this->addElement($hiddenSucursal);
- $hiddenStatus = new Zend_Form_Element_Hidden("StatusSos");
- $hiddenStatus = $this->delDecorators($hiddenStatus);
- $this->addElement($hiddenStatus);
- $hiddenFecha = new Zend_Form_Element_Hidden("Fecha");
- $hiddenFecha = $this->delDecorators($hiddenFecha);
- $this->addElement($hiddenFecha);
- $hiddenFFecha = new Zend_Form_Element_Hidden("FFecha");
- $hiddenFFecha = $this->delDecorators($hiddenFFecha);
- $this->addElement($hiddenFFecha);
- $hiddenReportePara = new Zend_Form_Element_Hidden("ReportePara");
- $hiddenReportePara = $this->delDecorators($hiddenReportePara);
- $this->addElement($hiddenReportePara);
- $hiddenNumVehicles = new Zend_Form_Element_Hidden("numVehicles");
- $hiddenNumVehicles->setValue($numVehicles);
- $hiddenNumVehicles = $this->delDecorators($hiddenNumVehicles);
- $this->addElement($hiddenNumVehicles);
- # Array for types of activities
- $actividadOptions = Functions::arrayToSimpleSel(array("", "Correlacion", "Incompatibilidad", "Vagabundeo", "Titubeos", "Paranoia", "Comunicacion", "Tecnico"));
- $fechaSubForm = new Zend_Form_SubForm();
- $fechaSubForm->setLegend("Fecha del reporte");
- $fechaSubForm = $this->delDecorators($fechaSubForm);
- $fdate = new Zend_Form_Element_Text("newFecha");
- $fdate->setLabel("Día");
- $fdate->setAttrib("readonly", "readonly");
- $fdate->setAttrib("onclick","new Calendar('', '', {disable_after: 'today', beforeCreate: 'checkDisableDate', dateFormat: 'd/m/Y'}, this);");
- $fhour = new Zend_Form_Element_Text("newHour");
- $fhour->setLabel("Hora");
- $fechaSubForm->addElements(array($fdate, $fhour));
- $actividad = new Zend_Form_SubForm();
- $actividad->setLegend("Actividad");
- $actividad = $this->delDecorators($actividad);
- $ubicacion = new Zend_Form_SubForm();
- $ubicacion->setLegend("Ubicacion");
- $ubicacion = $this->delDecorators($ubicacion);
- # We generate the vehicle forms according to the settings in our config file
- $cars = array();
- for($i = 1; $i <= $numVehicles; $i ++)
- {
- $cars[$i] = $this->generateVehicleForm($i);
- $cars[$i] = $this->delDecorators($cars[$i]);
- }
- # We generate the person forms according to the settings in our config file
- $persons = array();
- for($i = 1; $i <= $numPersons; $i ++)
- {
- $persons[$i] = $this->generatePersonForm($i);
- $persons[$i] = $this->delDecorators($persons[$i]);
- }
- $metodo = new Zend_Form_SubForm();
- $metodo->setLegend("Método");
- $metodo = $this->delDecorators($metodo);
- $blanco = new Zend_Form_SubForm();
- $blanco->setLegend("Blanco Probable");
- $blanco = $this->delDecorators($blanco);
- $narrativo = new Zend_Form_SubForm("narrativo");
- $narrativo->setLegend("Texto Narrativo");
- $narrativo = $this->delDecorators($narrativo);
- $file = new Zend_Form_SubForm();
- $file->setLegend("Adjuntar Fotos");
- $file = $this->delDecorators($file);
- $chkActividad = new Zend_Form_Element_MultiCheckbox("Actividad");
- $chkActividad->addMultiOptions(array
- (
- 'Correlacion' => 'Correlacion',
- 'Incompatibilidad' => 'Incompatibilidad',
- 'Vagabundeo' => 'Vagabundeo',
- 'Titubeos' => 'Titubeos',
- 'Paranoia' => 'Paranoia',
- 'Comunicacion' => 'Comunicacion',
- 'Tecnico' => 'Tecnico'
- )
- );
- $chkActividad = $this->delDecorators($chkActividad);
- $actividad->addElement($chkActividad);
- $chokePoints = $this->getChokePoints();
- $chokePoints = Functions::arrayToSelect($chokePoints, "idChokeP", "Lugar", true);
- $ubicacion->AddElement("select", "ChokePoint", array(
- 'label' => 'Choke Point',
- 'MultiOptions' => $chokePoints
- )
- );
- $lugares = $this->getClaveLugares();
- $lugares = Functions::escapeArray($lugares);
- $lugares = Functions::arrayToSelect($lugares, "ClaveLugar", "ClaveLugar", true);
- $ubicacion->addElement("select", "ClaveLugar", array(
- 'label' => 'Clave Lugar',
- 'MultiOptions' => $lugares,
- 'onchange' => 'manageClaveLugar(this)'
- )
- );
- $sectores = $this->getSectoresSucursal();
- $sectores= Functions::escapeArray($sectores);
- $sectores= Functions::arrayToSelect($sectores, "idSector", "Sector", true);
- $ubicacion->addElement("select", "Sector", array(
- 'label' => 'Sector',
- 'MultiOptions' => $sectores,
- 'onchange' => 'manageSectorZona(this)',
- 'required' => true
- )
- );
- $ubicacion->addElement("select", "Zona", array(
- 'label' => 'Zona',
- 'required' => true
- ))
- ->setRegisterInArrayValidator(false);
- $ubicacion->addElement("text", "Colonia", array(
- 'label' => 'Colonia',
- 'filters' => array('StringToUpper', 'StringTrim'),
- 'uppercase' => true,
- 'size' => 25,
- 'required' => true,
- 'errorMessages' => array('isEmpty' => 'Campo Requerido')
- )
- );
- $ubicacion->addElement("text", "CalleNum", array(
- 'label' => 'Calle y Numero',
- 'filters' => array('StringToUpper', 'StringTrim'),
- 'uppercase' => true,
- 'size' => 25,
- 'required' => true,
- 'errorMessages' => array('isEmpty' => 'Campo Requerido')
- )
- );
- $ubicacion->addElement("text", "Entre", array(
- 'label' => 'Calles Aledañas',
- 'filters' => array('StringToUpper', 'StringTrim'),
- 'uppercase' => true,
- 'size' => 25,
- )
- );
- $chkMetodo = new Zend_Form_element_MultiCheckbox ("Metodo");
- $chkMetodo->setLabel("Metodo");
- $chkMetodo->addMultiOptions(array(
- 'progresivo' => 'Progresivo',
- 'movil' => 'Móvil',
- 'fijo' => 'Fijo',
- 'tecnico' => 'Técnico'
- )
- );
- $chkMetodo = $this->delDecorators($chkMetodo);
- $metodo->addElement($chkMetodo);
- $hiddenBlanco = new Zend_Form_Element_Hidden("Objetivos");
- $hiddenBlanco = $this->delDecorators($hiddenBlanco);
- $hiddenBlanco->setAttribs(array
- (
- 'required' => true,
- 'errorMessages' => array('isEmpty' => 'Se requiere agregar por lo menos un Principal')
- )
- );
- $this->addElement($hiddenBlanco);
- $blanco->addElement("radio", "tipoBlanco", array(
- 'MultiOptions' => array(
- //'colonia' => 'Por Colonia',
- //'calle' => 'Por Calle',
- 'lugar' => 'Por Lugar',
- 'listado' => 'Por Listado'
- )
- )
- );
- $narrativo->addElement("checkbox", "Prioridad", array(
- 'label' => 'Prioritario',
- 'onclick' => 'prioritizeReport(this)'
- )
- );
- $narrativo->addElement("textarea", "Observaciones", array(
- 'cols' => 45,
- 'rows' => 6
- )
- );
- //$element->addValidator('Extension', false, 'jpg,png,gif');
- $file->addElement("file", "file1", array
- (
- 'ValueDisabled' => true,
- 'size' => 60,
- 'Validators' => array
- (
- array ('Size', 'false', 1024000),
- array ('Extension', 'false', 'jpg,png,gif,bmp'),
- ),
- )
- );
- $file->addElement("file", "file2", array
- (
- 'ValueDisabled' => true,
- 'size' => 60,
- 'Validators' => array
- (
- array ('Size', 'false', 1024000),
- array ('Extension', 'false', 'jpg,png,gif,bmp'),
- ),
- )
- );
- /**/
- $file->addElement("file", "file3", array
- (
- 'ValueDisabled' => true,
- 'size' => 60,
- 'Validators' => array
- (
- array ('Size', 'false', 1024000),
- array ('Extension', 'false', 'jpg,png,gif,bmp'),
- ),
- )
- );
- /**/
- /*
- $f3 = $file->file3;
- $tmpFolio = $this->Folio->getValue();
- $f3->addDecorator('Description', array('escape' => 'false', 'placement' => 'append'));
- $f3->setDescription("<div class=\"editFormImg\">$tmpFolio | ". $this->putThumbnail($tmpFolio, 1) .
- $this->putThumbnail($tmpFolio, 2) . $this->putThumbnail($tmpFolio, 3) . "</div>");
- /**/
- $file->addDecorator('Description', array ('escape' => 'false', 'placement' => 'append'));
- $file->setDescription("<div class=\"separatorDiv\"></div>");
- $subformArray = array
- (
- 'LaFecha' => $fechaSubForm,
- 'Actividad' => $actividad,
- 'Metodo' => $metodo,
- 'Blanco' => $blanco,
- 'Ubicacion' => $ubicacion,
- 'Narrativo' => $narrativo
- );
- $subformArray = $this->buildSubformArray($subformArray, $cars, $persons);
- $subformArray["File"] = $file;
- $this->addSubForms($subformArray);
- $busquedaPlacas = $this->getFoliosBusquedaPlacas();
- $idBusquedaPlacas = new Zend_Form_Element_Select("idBusquedaPlacas");
- $idBusquedaPlacas->setLabel("Folio de Busqueda de Placas")
- ->setRegisterInArrayValidator(false)
- ->addMultiOptions($busquedaPlacas);
- $this->addElement($idBusquedaPlacas);
- $this->addDisplayGroup(array
- (
- 'idBusquedaPlacas',
- ),
- 'DGB'
- );
- $this->DGB->setLegend("Consulta de Placas Folio");
- $submit = new Zend_Form_Element_Button("Guardar");
- $submit->setLabel("Guardar");
- $submit->setAttrib("class", "centeredButton");
- $submit->setAttrib("onclick", "verifyRPSOSForm(this.form)");
- $submit = $this->delDecorators($submit);
- $submit->setDecorators(array(
- 'ViewHelper',
- array
- (
- array
- (
- 'data' => 'HtmlTag'
- ),
- array
- (
- 'tag' => 'div',
- 'class' => 'botonContainer'
- )
- )
- )
- );
- $this->addElement($submit);
- $cancel = new Zend_Form_Element_Button("cancelar");
- $cancel->setLabel("Cancelar");
- $cancel->setAttrib("class", "centeredButton");
- $cancel->setAttrib("onclick", "window.location=\"/reportes\"");
- $cancel = $this->delDecorators($cancel);
- $cancel->setDecorators(array(
- 'ViewHelper',
- array
- (
- array
- (
- 'data'=>'HtmlTag'
- ),
- array
- (
- 'tag'=>'div',
- 'class'=>'botonContainer'
- )
- )
- ));
- $this->addElement($cancel);
- $this->setDecorators(array(
- 'FormElements',
- array
- (
- array
- (
- 'data'=>'HtmlTag'
- ),
- array
- (
- 'tag'=>'div',
- 'class'=>'ReportesForm'
- )
- )
- ,'Form'
- ));
- }
- public function generateVehicleForm($number)
- {
- include_once APPLICATION_PATH . '/forms/ReporteSos/Vehicle.php';
- $form = new VehicleForm();
- $vehicleForm = $form->generateVehicleForm($number);
- return $vehicleForm;
- }
- public function generatePersonForm($number)
- {
- include_once APPLICATION_PATH . '/forms/ReporteSos/Person.php';
- $form = new PersonForm();
- $personForm = $form->generatePersonForm($number);
- return $personForm;
- }
- public function getChokePoints()
- {
- require_once APPLICATION_PATH . '/helpers/Authentication.php';
- $auth = new Authentication();
- $sucursal = $auth->getSessionVar("UserSuc");
- $model = $this->getReportesModel();
- $data = $model->fetchChokePoints($sucursal);
- return $data;
- }
- public function getClaveLugares()
- {
- require_once APPLICATION_PATH . '/helpers/Authentication.php';
- $auth = new Authentication();
- $sucursal = $auth->getSessionVar("UserSuc");
- $model = $this->getReportesModel();
- $data = $model->fetchClaveLugares($sucursal);
- return $data;
- }
- public function getFoliosBusquedaPlacas()
- {
- require_once APPLICATION_PATH . '/helpers/Authentication.php';
- $auth = new Authentication();
- $model = $this->getReportesModel();
- $uid = $auth->getSessionVar("UserID");
- $data = $model->getPlacaBusquedaFolio($uid);
- $array = array();
- $array[0] = "";
- foreach ($data as $reg)
- {
- $array[$reg["idBusquedaPlacas"]] = "Folio {$reg["idBusquedaPlacas"]} - {$reg["placas"]}";
- }
- return $array;
- }
- public function getReportesModel()
- {
- if (null == $this->_ReportesModel)
- {
- include_once APPLICATION_PATH . '/models/ReportesSos.php';
- $this->_ReportesModel = new Model_Reportes();
- }
- return $this->_ReportesModel;
- }
- public function delDecorators($formElement)
- {
- $formElement->removeDecorator('Label');
- $formElement->removeDecorator('HtmlTag');
- $formElement->removeDecorator('DtDdWrapper');
- return $formElement;
- }
- public function buildSubformArray($array, $cars, $persons)
- {
- for ($i = 1; $i <= count($cars); $i ++)
- {
- $array["Vehiculos$i"] = $cars[$i];
- }
- for ($i = 1; $i <= count($persons); $i ++)
- {
- $array["Persona$i"] = $persons[$i];
- }
- return $array;
- }
- public function putThumbnail($folio, $number)
- {
- require_once APPLICATION_PATH . '/helpers/ImageHelper.php';
- $output = $number;
- $output = ImageHelper::outputImage($folio, $number, TRUE);
- return $output;
- }
- public function getSectoresSucursal()
- {
- require_once APPLICATION_PATH . '/helpers/Authentication.php';
- $auth = new Authentication();
- $sucursal = $auth->getSessionVar("UserSuc");
- $model = $this->getReportesModel();
- $data = $model->fetchSectores($sucursal);
- return $data;
- }
- }
Add Comment
Please, Sign In to add comment