/** * Return html to display confirmation form in one-page reservation, data is retrieved from user session * * @return string HTML */ public function getHtmlConfirmation() { JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php'); // TODO replace this manual call with autoloading later JLoader::register('SRCurrency', SRPATH_LIBRARY . '/currency/currency.php'); $this->reservationDetails = $this->app->getUserState($this->context); $model = $this->getModel(); $modelName = $model->getName(); $checkin = $this->reservationDetails->room['checkin']; $checkout = $this->reservationDetails->room['checkout']; $raId = $this->reservationDetails->room['raid']; $roomTypeObj = SRFactory::get('solidres.roomtype.roomtype'); $currency = new SRCurrency(0, $this->reservationDetails->currency_id); $totalRoomTypeExtraCost = $this->reservationDetails->room['total_extra_price']; $numberOfNights = $roomTypeObj->calculateDateDiff($checkin, $checkout); $cost = $this->app->getUserState($this->context . '.cost'); $model->setState($modelName . '.roomTypes', $this->reservationDetails->selected_room_types); $model->setState($modelName . '.checkin', $checkin); $model->setState($modelName . '.checkout', $checkout); $model->setState($modelName . '.reservationAssetId', $raId); $task = 'reservation.save'; if ($this->reservationDetails->payment['payment_method'] == 'paypalexpresscheckout') { $task = 'reservationppec.save'; } $roomTypes = $model->getRoomType(); $html = ' <div class="reservation-box-inner"> <form id="sr-reservation-form-confirmation" class="" action="' . JRoute::_("index.php?option=com_solidres&task=" . $task) . '" method="POST"> <p> ' . JText::_("SR_RESERVATION_NOTICE_CONFIRMATION") . ' </p> <div id="reservation-confirmation-box"> <table class="table"> <tbody>'; // Room cost foreach ($roomTypes as $roomTypeId => $roomTypeDetail) { if ($roomTypeDetail["quantity"] > 0) { $tempValue = $roomTypeDetail['currency']['total_price_tax_excl_formatted']->getValue(); $currency->setValue($tempValue * $roomTypeDetail["quantity"]); $html .= ' <tr> <td> ' . $roomTypeDetail["name"] . ' </td> <td> ' . $roomTypeDetail["quantity"] . ' </td> <td> ' . JText::plural("SR_NIGHTS", $numberOfNights) . ' </td> <td class="align-right"> ' . $currency->format() . ' </td> </tr>'; } } // Total room cost $totalRoomCost = new SRCurrency($cost['total_price_tax_excl'], $this->reservationDetails->currency_id); $html .= ' <tr> <td colspan="3"> ' . JText::_("SR_TOTAL_ROOM_COST") . ' </td> <td class="align-right"> ' . $totalRoomCost->format() . ' </td> </tr>'; // Imposed taxes $taxesModel = JModelLegacy::getInstance('Taxes', 'SolidresModel', array('ignore_request' => true)); $taxesModel->setState('filter.reservation_asset_id', $this->reservationDetails->room['raid']); $imposedTaxTypes = $taxesModel->getItems(); $totalImposedTax = 0; foreach ($imposedTaxTypes as $taxType) { $imposedAmount = $taxType->rate * $cost['total_price_tax_excl']; $totalImposedTax += $imposedAmount; $currency->setValue($imposedAmount); $taxItem = new SRCurrency($imposedAmount, $this->reservationDetails->currency_id); $html .= ' <tr> <td colspan="3"> ' . $taxType->name . ' </td> <td class="align-right"> ' . $taxItem->format() . ' </td> </tr>'; } // Extra cost $totalExtraCost = new SRCurrency($totalRoomTypeExtraCost, $this->reservationDetails->currency_id); $html .= ' <tr> <td colspan="3"> ' . JText::_("SR_TOTAL_EXTRA_COST") . ' </td> <td id="total-extra-cost" class="align-right"> ' . $totalExtraCost->format() . ' </td> </tr>'; // Grand total cost $grandTotal = new SRCurrency($cost['total_price_tax_incl'] + $totalRoomTypeExtraCost, $this->reservationDetails->currency_id); $html .= ' <tr> <td colspan="3"> <strong>' . JText::_("SR_GRAND_TOTAL") . '</strong> </td> <td class="align-right gra"> ' . $grandTotal->format() . ' </td> </tr>'; // Terms and conditions $bookingConditionsLink = JRoute::_(ContentHelperRoute::getArticleRoute($this->reservationDetails->booking_conditions)); $privacyPolicyLink = JRoute::_(ContentHelperRoute::getArticleRoute($this->reservationDetails->privacy_policy)); $html .= ' <tr> <td colspan="4"> <p> <input type="checkbox" id="termsandconditions" data-target="finalbutton" /> I agree with the <a target="_blank" href="' . $bookingConditionsLink . '">Booking conditions</a> and <a target="_blank" href="' . $privacyPolicyLink . '">Privacy Policy</a> </p> </td> </tr>'; $button_data = ''; if ($this->reservationDetails->payment["payment_method"] == "chequemoney") { $button_data = "chequemoney"; } elseif ($this->reservationDetails->payment["payment_method"] == "paypal") { $button_data = "paypal"; } $html .= ' </tbody> </table> </div> <input type="hidden" name="id" value="' . $raId . '"/> <button id="finalbutton" data-payment="' . $button_data . '" class="btn btn-large btn-primary" id="" type="submit" disabled="disabled"> <i class="icon-checkmark"></i> ' . JText::_("SR_BUTTON_RESERVATION_FINAL_SUBMIT") . ' </button> ' . JHtml::_("form.token") . ' </form> </div> '; echo $html; die(1); }
$currencyValue = $roomType->complexTariff->getValue(); } else { $currencyValue = $roomType->defaultTariff->getValue(); } ?> <select class="span12" name="rt_<?php echo $this->item->id; ?> _<?php echo $roomType->id; ?> "> <?php for ($i = 0; $i <= $roomType->totalAvailableRoom; $i++) { $temp = new SRCurrency(0, $this->item->currency_id); $temp->setValue($currencyValue * $i); echo '<option value="' . $i . '">' . $i . ($i > 0 ? ' (' . $temp->format() . ')' : '') . '</option>'; } ?> </select> <?php } } } ?> </div> </div> </div> <div class="row-fluid <?php echo $rowCSSClass; ?>