public function officeeditAction()
 {
     $this->view->title = $this->view->translate("New Office");
     $storage = new Zend_Auth_Storage_Session();
     //redirect if not a session
     $data = $storage->read();
     if (!$data) {
         $this->_redirect('index/login');
     }
     $path = $this->view->baseUrl();
     //sent url to model
     $officeForm = new Officedefault_Form_officedefault($path, $this->view->createdby);
     $this->view->form = $officeForm;
     $office = new Officedefault_Model_officedefault();
     // $this->view->officeDetails = $office->getOffice();
     //  $this->view->officehierarchyselect = $office->officehierarchyselect();
     $this->view->id = $office_id = $this->_getParam('id');
     //         $officehierarchy = $office->getOfficehierarchyDetails();
     // 	//load office hierarchy drop down
     //         foreach($officehierarchy as $officehierarchy) {
     //           $officeForm->officetype_id->addMultiOption($officehierarchy->id,$officehierarchy->type);
     //         }
     $edit_office = $this->view->adm->editRecord("ourbank_office", $office_id);
     $officetype_id = $edit_office[0]['parentoffice_id'];
     $typeid = $edit_office[0]['officetype_id'];
     $office_typeid = $edit_office[0]['officetype_id'];
     $officetypename = $office->getofficetypename($office_typeid);
     $this->view->form->officetypename->setValue($officetypename[0]['type']);
     $parentid = $office->subofficeFromUrledit($officetype_id);
     $maxid = $office->findlastlevel();
     foreach ($maxid as $maxid1) {
         $villagelastid = $maxid1->lastid;
     }
     if ($villagelastid == $edit_office[0]['officetype_id']) {
         $this->view->villagelastid = $maxid;
         $villagename = $edit_office[0]['id'];
         $address = $office->getvillageaddress($villagename);
         $district = $this->view->adm->viewRecord("ourbank_master_districtlist", "id", "DESC");
         foreach ($district as $district1) {
             $officeForm->district->addMultiOption($district1['id'], $district1['name']);
         }
         $taluque = $office->gettaluklist($address[0]['district_id']);
         foreach ($taluque as $taluque1) {
             $officeForm->taluque->addMultiOption($taluque1['id'], $taluque1['name']);
         }
         $hoblilist = $office->gethoblilist($address[0]['taluk_id']);
         foreach ($hoblilist as $hoblilist1) {
             $officeForm->hobli->addMultiOption($hoblilist1['id'], $hoblilist1['name']);
         }
         $panchayath = $office->getpanchayathlist($address[0]['taluk_id']);
         foreach ($panchayath as $panchayath1) {
             $officeForm->panchayath->addMultiOption($panchayath1['id'], $panchayath1['name']);
         }
         $village_id = $address[0]['villageid'];
         $villageaddressid = $address[0]['id'];
         $this->view->form->district->setValue($address[0]['district_id']);
         $this->view->form->taluque->setValue($address[0]['taluk_id']);
         $this->view->form->hobli->setValue($address[0]['hobli_id']);
         $this->view->form->panchayath->setValue($address[0]['panchayath_id']);
     }
     //load parent office dropdown
     foreach ($parentid as $parentid1) {
         $officeForm->parentoffice_id->addMultiOption($parentid1->id, $parentid1->name);
     }
     $officeForm->populate($edit_office[0]);
     $officeForm->name->removeValidator('Db_NoRecordExists');
     $officeForm->officetype_id->setRequired(false);
     //check and load poster data
     if ($this->_request->isPost() && $this->_request->getPost('Submit')) {
         $formData = $this->_request->getPost();
         if ($officeForm->isValid($formData)) {
             //assign poster values to variable and send to model
             $parentofficeid = $this->_request->getParam('parentoffice_id');
             $name = $this->_request->getParam('name');
             $shortname = $this->_request->getParam('short_name');
             $createdate = $this->_request->getParam('createddate');
             if ($parentofficeid) {
                 $lastid = $this->view->adm->updateRecord("ourbank_office", $office_id, array('id' => $office_id, 'name' => $name, 'short_name' => $shortname, 'parentoffice_id' => $parentofficeid, 'createddate' => $createdate, 'createdby' => $this->view->createdby));
                 echo $typeid;
                 $maxid = $office->findlastlevel();
                 foreach ($maxid as $maxid1) {
                     echo $villagelastid = $maxid1->lastid;
                 }
                 if ($villagelastid == $typeid) {
                     $villageid = $this->view->adm->updateRecord("ourbank_master_villagelist", $village_id, array('name' => $name, 'name_regional' => $name, 'village_id' => $office_id, 'created_date' => $createdate, 'created_by' => $this->view->createdby));
                     $office->updatevillage($office_id, array('taluk_id' => $this->_request->getParam('taluque'), 'district_id' => $this->_request->getParam('district'), 'panchayath_id' => $this->_request->getParam('panchayath'), 'hobli_id' => $this->_request->getParam('hobli'), 'created_date' => $createdate, 'created_by' => $this->view->createdby));
                 }
                 //	update and redirect if valid data
                 $this->_redirect('/officecommonview/index/commonview/id/' . $office_id);
             }
         }
     }
 }