/** * @param int|bool $reservationId * @return array */ public function getSendReceipt($reservationId = false, $customEmail = null) { /** * @var Logger $logger */ $logger = $this->getServiceLocator()->get('ActionLogger'); $result = ['status' => 'error', 'msg' => TextConstants::ERROR_SEND_MAIL]; try { if ($reservationId) { $bookingTicketDao = new \DDD\Dao\Booking\Booking($this->getServiceLocator(), '\\ArrayObject'); $ticketResult = $bookingTicketDao->fetchOne(['id' => $reservationId], ['guest_first_name', 'guest_last_name', 'guest_email']); if ($ticketResult) { $guestEmail = !empty($customEmail) ? $customEmail : $ticketResult['guest_email']; $output = shell_exec('ginosole reservation-email send-receipt --id=' . $reservationId . ' --email=' . $guestEmail . ' -v'); if (!strstr(strtolower($output), 'error')) { $guestName = $ticketResult['guest_first_name'] . ' ' . $ticketResult['guest_last_name']; $logger->save(Logger::MODULE_BOOKING, $reservationId, Logger::ACTION_RESERVATION_EMAIL_RECEIPT, "Receipt has been sent to {$guestName} <{$guestEmail}>"); $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_SEND_MAIL]; } } } } catch (\Exception $ex) { // do nothing } return $result; }