Exemplo n.º 1
0
 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;
             }
         }
     }
 }