File manager - Edit - /home/verseaumee/ptitsanes/plugins/solidres/invoice/components/com_solidres/controllers/invoicefrontend.php
Back
<?php /*------------------------------------------------------------------------ Solidres - Hotel booking extension for Joomla ------------------------------------------------------------------------ @Author Solidres Team @Website http://www.solidres.com @Copyright Copyright (C) 2013 - 2016 Solidres. All Rights Reserved. @License GNU General Public License version 3, or later ------------------------------------------------------------------------*/ defined('_JEXEC') or die; JLoader::register('SolidresControllerInvoice', SRPlugin::getAdminPath('invoice') . '/controllers/invoice.php'); /** * Invoice controller class for front end usage * * @package Solidres * @subpackage Invoice * @since 0.6.0 */ class SolidresControllerInvoiceFrontEnd extends SolidresControllerInvoice { protected function getReservationTable() { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_solidres/tables'); $resId = (int) $this->input->getUint('reservationId', 0); $resTable = JTable::getInstance('Reservation', 'SolidresTable'); if ($resId > 0 && $resTable->load($resId) && $resTable->reservation_asset_id) { return $resTable; } return false; } public function loadPaymentsForm() { $app = JFactory::getApplication(); $response = null; try { $resTable = $this->getReservationTable(); if (!$resTable) { throw new RuntimeException('Invalid Reservation.'); } $invoice = trim($app->input->getString('invoice')); if (empty($invoice)) { throw new RuntimeException('Invalid Invoice Number.'); } $model = $this->getModel('CustomerInvoices', 'SolidresModel', array('ignore_request' => true)); if ($payments = $model->getPayments($resTable->reservation_asset_id)) { SRLayoutHelper::addIncludePath(SRPlugin::getPluginPath('invoice') . '/layouts'); $response = SRLayoutHelper::render('payment.form', array( 'payments' => $payments, 'reservation' => $resTable, 'invoice' => $invoice, 'return' => $app->input->getBase64('return'), )); } } catch (RuntimeException $e) { $response = $e; } echo new JResponseJson($response); $app->close(); } public function payInvoice() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $element = strtolower($app->input->get('element')); $resTable = $this->getReservationTable(); $model = $this->getModel('CustomerInvoices', 'SolidresModel', array('ignore_request' => true)); $redirect = base64_decode($app->input->getBase64('return')); $invoice = trim($this->input->getString('invoice')); $results = false; if (!$redirect || !JUri::isInternal($redirect)) { $redirect = JRoute::_('index.php?option=com_solidres&view=customerinvoices', false); } if (!empty($invoice) && $resTable && ($payments = $model->getPayments($resTable->reservation_asset_id)) ) { foreach ($payments as $payment) { if (strcasecmp($payment->element, $element) === 0) { try { $cardData = $app->input->post->get('jform', [], 'array'); $payment->card = isset($cardData[$element]) ? $cardData[$element] : []; $payment->invoice = $invoice; $payment->amount = $model->getPaymentAmount($resTable); $payment->redirect = $redirect; $results = $app->triggerEvent('onSolidrespayment' . $element . 'PayInvoice', array($resTable, $payment)); if (!empty($payment->success)) { $app->enqueueMessage(JText::sprintf('SR_INVOICE_PAY_INVOICE_SUCCESS_FORMAT', $payment->invoice, $resTable->code, 'success')); } } catch (RuntimeException $e) { $app->enqueueMessage($e->getMessage(), 'warning'); } break; } } } if (false === $results) { $app->enqueueMessage(JText::_('SR_INVOICE_PAY_NO_RESPONSE_MSG'), 'warning'); } else { $response = trim(join(PHP_EOL, $results)); ob_start(); $this->paymentReturnMessage($response, $redirect); $display = ob_get_clean(); if (!empty($display)) { $redirect = null; echo $display; } } if (null !== $redirect) { $app->redirect($redirect); } } public function paymentReturnMessage($message = null) { $app = JFactory::getApplication(); if (empty($message)) { $message = $app->getUserState('com_solidres.invoice.paymentReturnMessage'); $app->setUserState('com_solidres.invoice.paymentReturnMessage', null); } if (!empty($message)) { $redirect = null; $basePath = SRPlugin::getSitePath('invoice') . '/views'; JLoader::register('SolidresViewCustomerInvoices', $basePath . '/customerinvoices/view.html.php'); $view = new SolidresViewCustomerInvoices(array('base_path' => $basePath, 'layout' => 'paymentredirect')); $view->set('paymentRedirectMessage', $message); $view->display(); } } }
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings