/** * @return \Zend\Http\Response|ViewModel * @throws \Exception */ public function requestAction() { $helper = new ReceivableHelper($this->receivableTable()); $form = $helper->getForm($this->currencyCombo()); $receivable = new Receivable(); $generateNo = $this->receivableTable()->getVoucherNo(date('Y-m-d', time())); $receivable->setVoucherNo($generateNo); $receivable->setDepositBy($this->staffId); $form->bind($receivable); $request = $this->getRequest(); if ($request->isPost()) { $form->setInputFilter($helper->getInputFilter()); $post_data = $request->getPost()->toArray(); $form->setData($post_data); if ($form->isValid()) { $this->receivableTable()->saveReceivable($receivable); $this->flashMessenger()->addInfoMessage('Requested voucher by ' . $generateNo . '.'); return $this->redirect()->toRoute('account_receivable'); } } return new ViewModel(array('form' => $form, 'staffName' => $this->staffName, 'accountTypes' => $this->accountTypes())); }