public function indexAction()
 {
     $storage = new Zend_Auth_Storage_Session();
     $data = $storage->read();
     if (!$data) {
         $this->_redirect('index/login');
     }
     $this->view->title = "Ledger";
     $this->view->searchLink = 1;
     $ledger = new Ledger_Model_Ledger();
     $ledgerselect = $ledger->fetchAllLedger1();
     $this->view->ledger = $ledger->fetchAllLedger1();
     //fetch all glcode details
     $subledger = new Ledger_Model_Ledger();
     $subledgerselect = $subledger->fetchAllSubLedger();
     $this->view->subledger = $subledger->fetchAllSubLedger();
     //fetch all glsubcode details
     $paginator = Zend_Paginator::factory($this->view->ledger);
     $paginator->setCurrentPageNumber($this->_getParam("page"));
     $paginator->setItemCountPerPage(5);
     $paginator->setPageRange(6);
     $this->view->page = $this->_request->getParam('page');
     $this->view->paginator = $paginator;
     $form = new Management_Form_Search();
     $this->view->form1 = $form;
     $office = $this->view->adm->viewRecord("ourbank_office", "id", "DESC");
     foreach ($office as $office1) {
         $form->field5->addMultiOption($office1->id, $office1->name);
     }
     if ($this->_request->isPost() && $this->_request->getPost('Search')) {
         $glcode = $this->_request->getParam('field6');
         $glsubcode = $this->_request->getParam('field2');
         $accountHeader = $this->_request->getParam('field3');
         $subheader = $this->_request->getParam('field4');
         $officeid = $this->_request->getParam('field5');
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             $first = new Ledger_Model_Ledger();
             $arrayledger = $first->ledgerSearch($glcode, $accountHeader);
             $arraysubledger = $first->subledgerSearch($glsubcode, $subheader, $officeid);
             $this->view->subledger = $arraysubledger;
             $this->view->ledger1 = $arrayledger;
             $paginator = Zend_Paginator::factory($this->view->ledger1);
             $paginator->setCurrentPageNumber($this->_getParam("page"));
             $paginator->setItemCountPerPage(5);
             $paginator->setPageRange(6);
             $this->view->paginator = $paginator;
         }
     }
 }
 public function indexAction()
 {
     $storage = new Zend_Auth_Storage_Session();
     $data = $storage->read();
     if (!$data) {
         $this->_redirect('index/login');
     }
     $this->view->title = $this->view->translate('Loans');
     $searchForm = new Management_Form_Search();
     $this->view->form = $searchForm;
     $loan = new Loans_Model_Loan();
     $result = $loan->getLoan();
     $page = $this->_getParam('page', 1);
     $paginator = Zend_Paginator::factory($result);
     $paginator->setItemCountPerPage(5);
     $paginator->setCurrentPageNumber($page);
     $this->view->paginator = $paginator;
     if ($this->_request->isPost() && $this->_request->getPost('Search')) {
         $formData = $this->_request->getPost();
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($searchForm->isValid($formData)) {
                 $loan = new Loans_Model_Loan();
                 $result = $loan->searchLoan($searchForm->getValues());
                 $page = $this->_getParam('page', 1);
                 $paginator = Zend_Paginator::factory($result);
                 $paginator->setItemCountPerPage(5);
                 $paginator->setCurrentPageNumber($page);
                 $this->view->paginator = $paginator;
             }
         }
     }
 }