/** * @param int $ticketId * @return bool * @throws ExpenseCustomException * @throws \Exception */ public function readyTicket($ticketId) { /** * @var BackofficeAuthenticationService $auth * @var Logger $logger */ $expenseDao = new Expenses($this->getServiceLocator(), '\\ArrayObject'); $auth = $this->getServiceLocator()->get('library_backoffice_auth'); $logger = $this->getServiceLocator()->get('ActionLogger'); $expenseExist = $expenseDao->checkForCloseReview($ticketId); if (!$expenseExist) { throw new ExpenseCustomException('Impossible to set ready this ticket'); } else { if ($expenseExist['manager_id'] != $auth->getIdentity()->id) { throw new ExpenseCustomException('You have no premissions to set as rendered this purchase order.'); } try { $expenseDao->beginTransaction(); $expenseDao->save(['finance_status' => Ticket::FIN_STATUS_READY], ['id' => $ticketId]); $logger->save(Logger::MODULE_EXPENSE, $ticketId, Logger::ACTION_SERVICE_IS_RENDERED); $expenseDao->commitTransaction(); } catch (\Exception $ex) { $expenseDao->rollbackTransaction(); throw new \Exception($ex); } } return true; }