public function addAction() { $form = new TransactionForm($this->getEntityManager()); $form->get('submit')->setValue('Add'); $request = $this->getRequest(); if ($request->isPost()) { $transaction = new Transaction(); $form->setInputFilter($transaction->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $transaction->exchangeArray($form->getData()); $transaction->source = $this->getEntityManager()->find('Application\\Entity\\Source', $form->getData()['source']); $this->getEntityManager()->persist($transaction); $this->getEntityManager()->flush(); // Redirect to list of products return $this->redirect()->toRoute('trans'); } } return array('form' => $form); }
public function unassociateTransaction($id) { $transaction = $this->getOneObjectByField(Transaction::getClass(), 'id', $id); /* @var $transaction \Application\Entity\Transaction */ $invoice = $transaction->getDocument(); /* @var $invoice \Application\Entity\Document\Invoice */ $transaction->setStatus(Transaction::STATUS_PENDING); $transaction->setDocument(null); $this->saveObject($transaction); $this->isInvoicePaid($invoice); return $transaction; }