Exemple #1
0
 /**
  * Get data to display check out form
  *
  * @return object
  */
 public function getItem()
 {
     $app = JFactory::getApplication();
     $reservationAssetModel = JModelLegacy::getInstance('ReservationAsset', 'SolidresModel', array('ignore_request' => true));
     $currencyModel = JModelLegacy::getInstance('Currency', 'SolidresModel', array('ignore_request' => true));
     // TODO replace this manual call with autoloading later
     JLoader::register('SRCurrency', SRPATH_LIBRARY . '/currency/currency.php');
     $modelName = $this->getName();
     $reservationAssetId = $this->getState($modelName . '.reservationAssetId');
     $reservationAsset = $reservationAssetModel->getItem($reservationAssetId);
     $currency = $currencyModel->getItem($reservationAsset->currency_id);
     $app->setUserState($this->context . '.countryId', $reservationAsset->country_id);
     $app->setUserState($this->context . '.currency_id', $currency->id);
     $reservation = new stdClass();
     $reservation->room_types = $this->getRoomType();
     $reservation->extras = $this->getExtra();
     $cost = $app->getUserState($this->context . '.cost');
     $currency = new SRCurrency($cost['total_price_tax_excl'], $currency->id);
     $reservation->total_price_tax_excl_formatted = $currency->format();
     return $reservation;
 }
Exemple #2
0
 static function info($config, $item, $num = 1)
 {
     // %AUTHOR %DATE %HITS %CATEGORY
     $news_info = '';
     //
     if ($num == 1) {
         if ($config['news_content_info_pos'] != 'disabled') {
             $class = 'nspInfo1 t' . $config['news_content_info_pos'] . ' f' . $config['news_content_info_float'];
         }
     } else {
         if ($config['news_content_info2_pos'] != 'disabled') {
             $class = 'nspInfo2 t' . $config['news_content_info2_pos'] . ' f' . $config['news_content_info2_float'];
         }
     }
     //
     if ($config['news_content_info_pos'] != 'disabled' && $num == 1 || $config['news_content_info2_pos'] != 'disabled' && $num == 2) {
         $news_info = '<div class="nspInfo ' . $class . '"> ' . $config['info' . ($num == 2 ? '2' : '') . '_format'] . ' </div>';
         // Featured label
         $info_featured = '';
         if (stripos($news_info, '%FEATURED') !== FALSE && $item['frontpage'] == '1') {
             $info_featured = '<strong class="is-featured">' . JText::_('MOD_NEWS_PRO_GK5_FEATURED') . '</strong>';
         }
         // Price
         $info_price = '';
         if (!($config['data_source'] == 'com_solidres_all_hotels' || $config['data_source'] == 'com_solidres_hotels' || $config['data_source'] == 'com_solidres_hotel_categories')) {
             JLoader::register('SRCurrency', SRPATH_LIBRARY . '/currency/currency.php');
             $currency = new SRCurrency(0, $item['currency_id']);
             $info_price = NSP_GK5_com_solidres_Model::getPrice($item['id'], date("w"));
             $info_price = '<strong class="gk-solidres-price">' . $currency->getCode() . ' ' . $info_price . '</strong>';
         }
         $news_info = str_replace('%PRICE', $info_price, $news_info);
         $news_info = str_replace('%FEATURED', $info_featured, $news_info);
         //
         return $news_info;
     } else {
         return '';
     }
 }
    /**
     * 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);
    }
                    if (!empty($roomType->complexTariff)) {
                        $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;