コード例 #1
0
 public function officeaddAction()
 {
     //language translator
     $this->view->title = $this->view->translate("New Office");
     //session
     $storage = new Zend_Auth_Storage_Session();
     $data = $storage->read();
     //redirect if not a session
     if (!$data) {
         $this->_redirect('index/login');
     }
     $path = $this->view->baseUrl();
     $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();
     //load hierarchy office dropdown
     if ($this->view->officehierarchyselect) {
         $officehierarchyoutid = $office->getOfficehierarchyDetailsout();
         foreach ($officehierarchyoutid as $officehierarchyoutids) {
             $officeForm->officetype_id->addMultiOption($officehierarchyoutids->Hierarchy_level, $officehierarchyoutids->type);
         }
     } else {
         $officehierarchy = new Officedefault_Model_officedefault();
         $officehierarchy = $officehierarchy->getOfficehierarchyDetails();
         foreach ($officehierarchy as $officehierarchy) {
             $officeForm->officetype_id->addMultiOption($officehierarchy->id, $officehierarchy->type);
         }
     }
     //validate poster values
     if ($this->_request->isPost() && $this->_request->getPost('Submit')) {
         $formData = $this->_request->getPost();
         if ($officeForm->isValid($formData)) {
             //variable for form data
             $officeid = $this->_request->getParam('officetype_id');
             $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->addRecord("ourbank_office", array('id' => '', 'name' => $name, 'short_name' => $shortname, 'officetype_id' => $officeid, 'parentoffice_id' => $parentofficeid, 'createddate' => $createdate, 'createdby' => $this->view->createdby));
                 $maxid = $office->findlastlevel();
                 foreach ($maxid as $maxid1) {
                     $villagelastid = $maxid1->lastid;
                 }
                 if ($villagelastid == $officeid) {
                     $this->view->adm->addRecord("ourbank_master_villagelist", array('id' => '', 'village_id' => $lastid, 'name' => $name, 'name_regional' => $name, 'panchayath_id' => $this->_request->getParam('panchayath'), 'created_date' => $createdate, 'created_by' => $this->view->createdby));
                     $this->view->adm->addRecord("ourbank_master_village", array('id' => '', 'village_id' => $lastid, 'taluk_id' => $this->_request->getParam('taluque'), 'panchayath_id' => $this->_request->getParam('panchayath'), 'hobli_id' => $this->_request->getParam('hobli'), 'district_id' => $this->_request->getParam('district'), 'created_date' => $createdate, 'created_by' => $this->view->createdby));
                 }
                 //insert glsubcode
                 for ($j = 1; $j <= 6; $j++) {
                     $fetchglcodedetails = $this->view->adm->editRecord('ourbank_glcode', $j);
                     $ledgertype_id = $fetchglcodedetails[0]['ledgertype_id'];
                     $glcode = $fetchglcodedetails[0]['glcode'];
                     $header = $fetchglcodedetails[0]['header'];
                     $ledger = new Officedefault_Model_officedefault();
                     $genarateGlsub = $ledger->genarateGlsubCode1($ledgertype_id, $j);
                     $glsubcode = $genarateGlsub->id;
                     if ($glsubcode) {
                         $ini = substr($glsubcode, 0, 1);
                         $last = substr($glsubcode, 1, 5);
                         $last += 1;
                         $last = str_pad($last, 5, 0, STR_PAD_LEFT);
                         $glsubcode = $ini . $last;
                         $glsubcode;
                     } else {
                         $glcode1 = $ledger->fetchGlcode($j);
                         $glcode = $glcode1->glcode;
                         $ini = substr($glcode, 0, 1);
                         $last = substr($glcode, 1, 5);
                         $last += 1;
                         $last = str_pad($last, 5, 0, STR_PAD_LEFT);
                         $glsubcode = $ini . $last;
                         $glsubcode;
                     }
                     $headername = array('bank', 'cash', 'loans', 'savings', 'interest', 'fee');
                     $gInsert = $ledger->insertGlsubcode(array('id' => '', 'office_id' => $lastid, 'glsubcode' => $glsubcode, 'glcode_id' => $j, 'subledger_id' => $ledgertype_id, 'header' => $headername[$j - 1] . $lastid, 'description' => $headername[$j - 1] . $lastid, 'created_date' => $createdate, 'created_by' => $this->view->createdby));
                 }
                 $this->_redirect('/officecommonview/index/commonview/id/' . $lastid);
             }
         }
     }
 }