Ejemplo n.º 1
0
 /**
  * 
  */
 public function informationAction()
 {
     if ($this->getRequest()->isXMLHttpRequest()) {
         $this->_helper->layout()->disableLayout();
     }
     // Form Information
     $formInformation = $this->_initForm('information');
     $data = array();
     $data['fk_id_dec'] = Zend_Auth::getInstance()->getIdentity()->fk_id_dec;
     $id = $this->_getParam('id');
     if (!empty($id)) {
         $row = $this->_mapper->fetchRow($id);
         $data = $row->toArray();
         $data['birth_date'] = $data['birth_date_format'];
         $data['date_registration'] = $data['date_registration_format'];
         $data['age'] = App_General_Date::getAge(new Zend_Date($data['birth_date']));
         // Disable the fields
         $formInformation->getElement('date_registration')->setAttrib('disabled', true);
         $formInformation->getElement('fk_id_adddistrict')->setAttrib('disabled', true);
         // Search the district by acronym
         $mapperDistrict = new Register_Model_Mapper_AddDistrict();
         $district = $mapperDistrict->fetchByAcronym($data['num_district']);
         $data['fk_id_adddistrict'] = $district->id_adddistrict;
         $mapperSubDistrict = new Register_Model_Mapper_AddSubDistrict();
         $rows = $mapperSubDistrict->listAll($district->id_adddistrict);
         $optsSub[''] = '';
         foreach ($rows as $row) {
             $optsSub[$row->acronym] = $row->sub_district;
         }
         $formInformation->getElement('num_subdistrict')->setAttrib('disabled', true)->addMultiOptions($optsSub);
     }
     $formInformation->populate($data);
     $this->view->form = $formInformation;
 }