public function associateOutgoingTransactionAction() { if ($this->request->isPost() && $this->request->isXmlHttpRequest()) { $transaction = $this->bankService->getTransactionById($this->request->getPost()->transactionId); $invoice = $this->invoiceService->getPurchaseInvoiceById($this->request->getPost()->invoiceId); if ($transaction && $invoice) { /* @var $transaction \Application\Entity\BankTransaction */ $transaction->setDocument($invoice); $transaction->setStatus(BankTransaction::STATUS_ASSOCIATED); $this->bankService->saveTransaction($transaction); $this->bankService->isDocumentPaid($invoice); return new JsonModel(array('OK')); } } return $this->response; }
public function viewPurchaseInvoiceAction() { $invoice = $this->invoiceService->getPurchaseInvoiceById($this->params('id')); $view = new ViewModel(); $auth = $this->getServiceLocator()->get('zfcuser_auth_service'); if ($auth->hasIdentity()) { $user = $auth->getIdentity(); } $form = $this->getServiceLocator()->get('Application\\Form\\Document'); $form->setUser($user); $form->init(); $form->setFormValues($invoice); $form->disableFields(); $invoiceRows = $this->invoiceService->assembleInvoiceRowsArray($invoice); if ($this->request->isPost()) { $form->setData($this->request->getPost()); if ($form->isValid()) { $invoice = $this->invoiceService->saveInvoiceWithParams($invoice, $user, (array) $this->request->getPost(), Document::TYPE_PURCHASE_INVOICE); $translator = $this->serviceLocator->get('MvcTranslator'); $this->flashMessenger()->addMessage($translator->translate('Controller.Document.Add.PurchaseInvoiceSaved')); return $this->redirect()->toRoute('application/default', array('controller' => 'document', 'action' => 'view-purchase-invoice', 'id' => $invoice->getId())); } else { $invoiceRows = $this->invoiceService->assembleInvoiceRowsArrayFromPost((array) $this->request->getPost()); } } $view->form = $form; $view->rows = $invoiceRows; $view->service = $this->getServiceLocator()->get('Application\\Service\\Invoice'); $view->messages = $this->flashMessenger()->getMessages(); $view->user = $user; $view->invoice = $invoice; $view->vats = $this->settingsService->getAllVats($user); $view->uoms = $this->settingsService->getAllUoms($user); $view->page = $this->params('page'); $view->confirmed = true; $view->user = $user; $view->type = Document::TYPE_PURCHASE_INVOICE; return $view; }