/** * zwraca obiekt Iterator\Transactions jezeli w requescie jest parametr transaction_id => id lub [id, id, ...] * * @return Transactions */ public function getTransactions() { $transaction_id = $this->getRequest()->getPost('transaction_id'); $iterator = new Transactions(); if (is_numeric($transaction_id)) { $iterator->append($this->getTransaction()); } else { if (count($data = json_decode($transaction_id, true))) { foreach ($data as $transaction_id) { $iterator->append($this->getService('StatementMapper')->getTransactionById($transaction_id)); } } } return $iterator; }
/** * * @param \Vindication\BankStatement\Entity\Statement $statement * @param closure $closure * @return \Vindication\BankStatement\Iterator\Transactions */ public function getTransactions(Entity\Statement $statement, $closure = null) { $select = $this->getAdapter()->select()->from(array('o' => 'wyciag_bankowy_operacja', 's.*'))->joinLeft(array('d' => 'dluznicy'), 'd.PK_dluznicy = o.kontrahent_id', array('d.*'))->where('s.id =?', $statement->getID()); $this->addFilters($select); if (null === $this->getRequestData()->getSort()) { $select->order(array('o.id ASC')); } if (is_callable($closure)) { $closure($select); } $iterator = new Iterator\Transactions(); $iterator->setPaginator($paginator = $this->getPaginator($select)); foreach ($paginator as $result) { $iterator->append($transaction = new Entity\Transaction($result)); if ($transaction->get('kontrahent_id')) { $transaction->setContractor(new Contractor($result)); } } return $iterator; }