| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - e4j - Extensionsforjoomla.com |
| 6 |
* @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
$vat_included = VikBooking::ivaInclusa(); |
| 14 |
$tax_summary = !$vat_included && VikBooking::showTaxOnSummaryOnly() ? true : false; |
| 15 |
|
| 16 |
$currencysymb = VikBooking::getCurrencySymb(); |
| 17 |
$pitemid = VikRequest::getInt('Itemid', '', 'request'); |
| 18 |
|
| 19 |
/** |
| 20 |
* Interactive map booking. Only for classic booking layout. |
| 21 |
* |
| 22 |
* @since 1.14 (J) - 1.4.0 (WP) |
| 23 |
*/ |
| 24 |
if (VikBooking::interactiveMapEnabled()) { |
| 25 |
echo $this->loadTemplate('interactive_map'); |
| 26 |
} |
| 27 |
// |
| 28 |
|
| 29 |
?> |
| 30 |
<div class="vbo-searchresults-classic-wrap"> |
| 31 |
<?php |
| 32 |
$writeroomnum = array(); |
| 33 |
foreach ($this->res as $indroom => $rooms) { |
| 34 |
foreach ($rooms as $room) { |
| 35 |
if ($this->roomsnum > 1 && !in_array($indroom, $writeroomnum)) { |
| 36 |
$writeroomnum[] = $indroom; |
| 37 |
?> |
| 38 |
<div id="vbpositionroom<?php echo $indroom; ?>"></div> |
| 39 |
<div class="vbsearchproominfo"> |
| 40 |
<span class="vbsearchnroom"><?php echo JText::translate('VBSEARCHROOMNUM'); ?> <?php echo $indroom; ?></span> |
| 41 |
<span class="vbsearchroomparty"><?php VikBookingIcons::e('users', 'vbo-pref-color-text'); ?> <?php echo $this->arrpeople[$indroom]['adults']; ?> <?php echo ($this->arrpeople[$indroom]['adults'] == 1 ? JText::translate('VBSEARCHRESADULT') : JText::translate('VBSEARCHRESADULTS')); ?> <?php echo ($this->showchildren && $this->arrpeople[$indroom]['children'] > 0 ? ", ".$this->arrpeople[$indroom]['children']." ".($this->arrpeople[$indroom]['children'] == 1 ? JText::translate('VBSEARCHRESCHILD') : JText::translate('VBSEARCHRESCHILDREN')) : ""); ?></span> |
| 42 |
</div> |
| 43 |
<?php |
| 44 |
} |
| 45 |
//set a different class to the main div in case the rooms usage is for less people than the capacity |
| 46 |
$rdiffusage = array_key_exists('diffusage', $room[0]) && $this->arrpeople[$indroom]['adults'] < $room[0]['toadult'] ? true : false; |
| 47 |
$has_promotion = array_key_exists('promotion', $room[0]) ? true : false; |
| 48 |
$maindivclass = $rdiffusage ? "room_resultdiffusage" : "room_result"; |
| 49 |
$carats = VikBooking::getRoomCaratOriz($room[0]['idcarat'], $this->vbo_tn); |
| 50 |
/** |
| 51 |
* @wponly we try to parse any shortcode inside the short description of the room |
| 52 |
*/ |
| 53 |
$room[0]['smalldesc'] = do_shortcode($room[0]['smalldesc']); |
| 54 |
// |
| 55 |
$saylastavail = false; |
| 56 |
$showlastavail = (int)VikBooking::getRoomParam('lastavail', $room[0]['params']); |
| 57 |
if (!empty($showlastavail) && $showlastavail > 0) { |
| 58 |
if ($room[0]['unitsavail'] <= $showlastavail) { |
| 59 |
$saylastavail = true; |
| 60 |
} |
| 61 |
} |
| 62 |
$searchdet_link = JRoute::rewrite('index.php?option=com_vikbooking&view=searchdetails&roomid='.$room[0]['idroom'].'&checkin='.$this->checkin.'&checkout='.$this->checkout.'&adults='.$this->arrpeople[$indroom]['adults'].'&children='.$this->arrpeople[$indroom]['children'].'&tmpl=component'.(!empty($pitemid) ? '&Itemid='.$pitemid : '')); |
| 63 |
|
| 64 |
/** |
| 65 |
* Build image gallery, if available |
| 66 |
* |
| 67 |
* @since 1.14 (J) - 1.4.0 (WP) |
| 68 |
*/ |
| 69 |
$gallery_data = array(); |
| 70 |
if (!empty($room[0]['moreimgs'])) { |
| 71 |
$moreimages = explode(';;', $room[0]['moreimgs']); |
| 72 |
foreach ($moreimages as $mimg) { |
| 73 |
if (empty($mimg)) { |
| 74 |
continue; |
| 75 |
} |
| 76 |
// push thumb URL |
| 77 |
array_push($gallery_data, $mimg); |
| 78 |
} |
| 79 |
} |
| 80 |
// |
| 81 |
?> |
| 82 |
<div class="room_item <?php echo $maindivclass; ?><?php echo $has_promotion === true ? ' vbo-promotion-price' : ''; ?>" id="vbcontainer<?php echo $indroom.'_'.$room[0]['idroom']; ?>"> |
| 83 |
<div class="vblistroomblock"> |
| 84 |
<div class="vbimglistdiv"> |
| 85 |
<div class="vbo-dots-slider-selector"> |
| 86 |
<a href="<?php echo $searchdet_link; ?>" class="vbmodalframe" target="_blank" data-gallery="<?php echo implode('|', $gallery_data); ?>"> |
| 87 |
<?php |
| 88 |
if (!empty($room[0]['img']) && is_file(VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $room[0]['img'])) { |
| 89 |
?> |
| 90 |
<img class="vblistimg" alt="<?php echo htmlspecialchars($room[0]['name']); ?>" id="vbroomimg<?php echo $indroom.'_'.$room[0]['idroom']; ?>" src="<?php echo VBO_SITE_URI; ?>resources/uploads/<?php echo $room[0]['img']; ?>"/> |
| 91 |
<?php |
| 92 |
} |
| 93 |
?> |
| 94 |
</a> |
| 95 |
</div> |
| 96 |
<div class="vbmodalrdetails"> |
| 97 |
<a href="<?php echo $searchdet_link; ?>" class="vbmodalframe" target="_blank"><?php VikBookingIcons::e('plus'); ?></a> |
| 98 |
</div> |
| 99 |
</div> |
| 100 |
<div class="vbo-info-room"> |
| 101 |
<div class="vbdescrlistdiv"> |
| 102 |
<h4 class="vbrowcname" id="vbroomname<?php echo $indroom.'_'.$room[0]['idroom']; ?>"><?php echo $room[0]['name']; ?></h4> |
| 103 |
<div class="vbrowcdescr"><?php echo $room[0]['smalldesc']; ?></div> |
| 104 |
</div> |
| 105 |
<?php |
| 106 |
if (!empty($carats)) { |
| 107 |
?> |
| 108 |
<div class="roomlist_carats"> |
| 109 |
<?php echo $carats; ?> |
| 110 |
</div> |
| 111 |
<?php |
| 112 |
} |
| 113 |
?> |
| 114 |
<?php |
| 115 |
if ($has_promotion === true && !empty($room[0]['promotion']['promotxt'])) { |
| 116 |
?> |
| 117 |
<div class="vbo-promotion-block"> |
| 118 |
<div class="vbo-promotion-icon"><?php VikBookingIcons::e('percentage'); ?></div> |
| 119 |
<div class="vbo-promotion-description"> |
| 120 |
<?php echo $room[0]['promotion']['promotxt']; ?> |
| 121 |
</div> |
| 122 |
</div> |
| 123 |
<?php |
| 124 |
} |
| 125 |
?> |
| 126 |
</div> |
| 127 |
</div> |
| 128 |
<div class="vbcontdivtot"> |
| 129 |
<div class="vbdivtot"> |
| 130 |
<div class="vbdivtotinline"> |
| 131 |
<div class="vbsrowprice"> |
| 132 |
<div class="vbrowroomcapacity"> |
| 133 |
<?php |
| 134 |
for ($i = 1; $i <= $room[0]['toadult']; $i++) { |
| 135 |
if ($i <= $this->arrpeople[$indroom]['adults']) { |
| 136 |
VikBookingIcons::e('male', 'vbo-pref-color-text'); |
| 137 |
} else { |
| 138 |
VikBookingIcons::e('male', 'vbo-empty-personicn'); |
| 139 |
} |
| 140 |
} |
| 141 |
$raw_roomcost = $tax_summary ? $room[0]['cost'] : VikBooking::sayCostPlusIva($room[0]['cost'], $room[0]['idprice']); |
| 142 |
?> |
| 143 |
</div> |
| 144 |
<div class="vbsrowpricediv"> |
| 145 |
<span class="room_cost"> |
| 146 |
<span class="vbo_currency"><?php echo $currencysymb; ?></span> |
| 147 |
<span class="vbo_price"><?php echo VikBooking::numberFormat($raw_roomcost); ?></span> |
| 148 |
</span> |
| 149 |
<?php |
| 150 |
if (isset($room[0]['promotion']) && isset($room[0]['promotion']['discount'])) { |
| 151 |
if ($room[0]['promotion']['discount']['pcent']) { |
| 152 |
/** |
| 153 |
* Do not make an upper-cent operation, but rather calculate the original price proportionally: |
| 154 |
* final price : (100 - discount amount) = x : 100 |
| 155 |
* |
| 156 |
* @since 1.13.5 |
| 157 |
*/ |
| 158 |
$prev_amount = $raw_roomcost * 100 / (100 - $room[0]['promotion']['discount']['amount']); |
| 159 |
} else { |
| 160 |
$prev_amount = $raw_roomcost + $room[0]['promotion']['discount']['amount']; |
| 161 |
} |
| 162 |
if ($prev_amount > 0) { |
| 163 |
?> |
| 164 |
<div class="vbo-room-result-price-before-discount"> |
| 165 |
<span class="room_cost"> |
| 166 |
<span class="vbo_currency"><?php echo $currencysymb; ?></span> |
| 167 |
<span class="vbo_price"><?php echo VikBooking::numberFormat($prev_amount); ?></span> |
| 168 |
</span> |
| 169 |
</div> |
| 170 |
<?php |
| 171 |
if ($room[0]['promotion']['discount']['pcent']) { |
| 172 |
// hide by default the DIV containing the percent of discount |
| 173 |
?> |
| 174 |
<div class="vbo-room-result-price-before-discount-percent" style="display: none;"> |
| 175 |
<span class="room_cost"> |
| 176 |
<span><?php echo '-' . (float)$room[0]['promotion']['discount']['amount'] . ' %'; ?></span> |
| 177 |
</span> |
| 178 |
</div> |
| 179 |
<?php |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
?> |
| 184 |
</div> |
| 185 |
<?php |
| 186 |
if ($saylastavail === true) { |
| 187 |
?> |
| 188 |
<span class="vblastavail"><?php echo JText::sprintf('VBLASTUNITSAVAIL', $room[0]['unitsavail']); ?></span> |
| 189 |
<?php |
| 190 |
} |
| 191 |
?> |
| 192 |
</div> |
| 193 |
<div class="vbselectordiv"> |
| 194 |
<button type="button" id="vbselector<?php echo $indroom.'_'.$room[0]['idroom']; ?>" class="btn vbselectr-result vbo-pref-color-btn" onclick="vbSelectRoom('<?php echo $indroom; ?>', '<?php echo $room[0]['idroom']; ?>');"><?php echo JText::translate('VBSELECTR'); ?></button> |
| 195 |
</div> |
| 196 |
</div> |
| 197 |
</div> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
<?php |
| 201 |
} |
| 202 |
} |
| 203 |
?> |
| 204 |
</div> |
| 205 |
|
| 206 |
<script type="text/javascript"> |
| 207 |
jQuery(document).ready(function() { |
| 208 |
jQuery('.vbo-dots-slider-selector').each(function() { |
| 209 |
var sliderLink = jQuery(this).find('a').first(); |
| 210 |
if (!sliderLink.length) { |
| 211 |
return; |
| 212 |
} |
| 213 |
var gallery = sliderLink.data('gallery'); |
| 214 |
if (!gallery || !gallery.length) { |
| 215 |
return; |
| 216 |
} |
| 217 |
var thumbs_base_uri = '<?php echo VBO_SITE_URI . 'resources/uploads/thumb_'; ?>'; |
| 218 |
var gallery_data = gallery.split('|'); |
| 219 |
var images = []; |
| 220 |
for (var i = 0; i < gallery_data.length; i++) { |
| 221 |
if (!gallery_data[i].length) { |
| 222 |
continue; |
| 223 |
} |
| 224 |
images.push(thumbs_base_uri + gallery_data[i]); |
| 225 |
} |
| 226 |
if (!images.length) { |
| 227 |
return; |
| 228 |
} |
| 229 |
// move original main photo and make it hidden so that the dialog will keep showing it |
| 230 |
var room_main_photo = jQuery(this).find('img.vblistimg'); |
| 231 |
if (room_main_photo.length) { |
| 232 |
room_main_photo.hide().appendTo(jQuery(this).parent()); |
| 233 |
} |
| 234 |
// render slider |
| 235 |
var slideWrap = sliderLink.clone(); |
| 236 |
jQuery(this).html('').vikDotsSlider({ |
| 237 |
images: images, |
| 238 |
navButPrevContent: '<?php VikBookingIcons::e('chevron-left'); ?>', |
| 239 |
navButNextContent: '<?php VikBookingIcons::e('chevron-right'); ?>', |
| 240 |
onDisplaySlide: function() { |
| 241 |
var content = jQuery(this).children().clone(true, true); |
| 242 |
/** |
| 243 |
* @wponly In order to avoid delays with Fancybox, we do not re-construct the A tag. |
| 244 |
* We just append the slide image. |
| 245 |
* var link = jQuery('<a target="_blank"></a>').attr('href', slideWrap.attr('href')).attr('class', slideWrap.attr('class')).append(content); |
| 246 |
* jQuery(this).html('').append(link); |
| 247 |
*/ |
| 248 |
jQuery(this).html('').append(content); |
| 249 |
} |
| 250 |
}); |
| 251 |
}); |
| 252 |
}); |
| 253 |
</script> |
| 254 |
|