| 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 |
$dbo = JFactory::getDbo(); |
| 14 |
$app = JFactory::getApplication(); |
| 15 |
|
| 16 |
$vbo_app = VikBooking::getVboApplication(); |
| 17 |
$vbo_app->loadSelect2(); |
| 18 |
|
| 19 |
$config = VBOFactory::getConfig(); |
| 20 |
|
| 21 |
$rows = $this->rows; |
| 22 |
$lim0 = $this->lim0; |
| 23 |
$navbut = $this->navbut; |
| 24 |
$orderby = $this->orderby; |
| 25 |
$ordersort = $this->ordersort; |
| 26 |
|
| 27 |
$prname = $app->getUserStateFromRequest("vbo.rooms.rname", 'rname', '', 'string'); |
| 28 |
$pidcat = $app->getUserStateFromRequest("vbo.rooms.idcat", 'idcat', 0, 'int'); |
| 29 |
?> |
| 30 |
<div class="vbo-list-form-filters vbo-btn-toolbar"> |
| 31 |
<form action="index.php?option=com_vikbooking&task=rooms" method="post" name="roomsform"> |
| 32 |
<div style="width: 100%; display: inline-block;" class="btn-toolbar" id="filter-bar"> |
| 33 |
<div class="btn-group pull-left"> |
| 34 |
<select name="idcat" id="idcat" onchange="document.roomsform.submit();"> |
| 35 |
<option value=""><?php echo JText::translate('VBOCATEGORYFILTER'); ?></option> |
| 36 |
<?php |
| 37 |
foreach ($this->allcats as $cat) { |
| 38 |
?> |
| 39 |
<option value="<?php echo $cat['id']; ?>"<?php echo $cat['id'] == $pidcat ? ' selected="selected"' : ''; ?>><?php echo $cat['name']; ?></option> |
| 40 |
<?php |
| 41 |
} |
| 42 |
?> |
| 43 |
</select> |
| 44 |
</div> |
| 45 |
<div class="btn-group pull-left input-append"> |
| 46 |
<input type="text" name="rname" id="rname" value="<?php echo $prname; ?>" size="40" placeholder="<?php echo JText::translate('VBPVIEWROOMONE'); ?>"/> |
| 47 |
<button type="button" class="btn btn-secondary" onclick="document.roomsform.submit();"><i class="icon-search"></i></button> |
| 48 |
</div> |
| 49 |
<div class="btn-group pull-left"> |
| 50 |
<button type="button" class="btn btn-secondary" onclick="document.getElementById('rname').value='';document.getElementById('idcat').value='';document.roomsform.submit();"><?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?></button> |
| 51 |
</div> |
| 52 |
</div> |
| 53 |
<input type="hidden" name="task" value="rooms" /> |
| 54 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 55 |
</form> |
| 56 |
</div> |
| 57 |
<script type="text/javascript"> |
| 58 |
jQuery(function() { |
| 59 |
jQuery('#idcat').select2(); |
| 60 |
}); |
| 61 |
</script> |
| 62 |
<?php |
| 63 |
if (empty($rows)) { |
| 64 |
?> |
| 65 |
<p class="warn"><?php echo JText::translate('VBNOROOMSFOUND'); ?></p> |
| 66 |
<form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm"> |
| 67 |
<input type="hidden" name="task" value="" /> |
| 68 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 69 |
</form> |
| 70 |
<?php |
| 71 |
} else { |
| 72 |
?> |
| 73 |
<form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm" class="vbo-list-form"> |
| 74 |
<div class="table-responsive"> |
| 75 |
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="table table-striped vbo-list-table"> |
| 76 |
<thead> |
| 77 |
<tr> |
| 78 |
<th width="20"> |
| 79 |
<input type="checkbox" onclick="Joomla.checkAll(this)" value="" name="checkall-toggle"> |
| 80 |
</th> |
| 81 |
<th class="title left" width="150"> |
| 82 |
<a href="index.php?option=com_vikbooking&task=rooms&vborderby=name&vbordersort=<?php echo ($orderby == "name" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "name" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "name" ? "vbo-list-activesort" : "")); ?>"> |
| 83 |
<?php echo JText::translate('VBPVIEWROOMONE').($orderby == "name" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "name" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 84 |
</a> |
| 85 |
</th> |
| 86 |
<th class="title center" align="center" width="75"> |
| 87 |
<a href="index.php?option=com_vikbooking&task=rooms&vborderby=toadult&vbordersort=<?php echo ($orderby == "toadult" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "toadult" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "toadult" ? "vbo-list-activesort" : "")); ?>"> |
| 88 |
<?php echo JText::translate('VBPVIEWROOMADULTS').($orderby == "toadult" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "toadult" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 89 |
</a> |
| 90 |
</th> |
| 91 |
<th class="title center" align="center" width="75"> |
| 92 |
<a href="index.php?option=com_vikbooking&task=rooms&vborderby=tochild&vbordersort=<?php echo ($orderby == "tochild" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "tochild" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "tochild" ? "vbo-list-activesort" : "")); ?>"> |
| 93 |
<?php echo JText::translate('VBPVIEWROOMCHILDREN').($orderby == "tochild" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "tochild" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 94 |
</a> |
| 95 |
</th> |
| 96 |
<th class="title center" align="center" width="75"> |
| 97 |
<a href="index.php?option=com_vikbooking&task=rooms&vborderby=totpeople&vbordersort=<?php echo ($orderby == "totpeople" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "totpeople" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "totpeople" ? "vbo-list-activesort" : "")); ?>"> |
| 98 |
<?php echo JText::translate('VBPVIEWROOMTOTPEOPLE').($orderby == "totpeople" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "totpeople" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 99 |
</a> |
| 100 |
</th> |
| 101 |
<th class="title center" width="75"><?php echo JText::translate( 'VBPVIEWROOMTWO' ); ?></th> |
| 102 |
<th class="title center" align="center" width="75"><?php echo JText::translate( 'VBPVIEWROOMTHREE' ); ?></th> |
| 103 |
<th class="title center" align="center" width="75"><?php echo JText::translate( 'VBPVIEWROOMFOUR' ); ?></th> |
| 104 |
<th class="title center" align="center" width="100"><?php echo JText::translate( 'VBOCHANNELS' ); ?></th> |
| 105 |
<th class="title center" align="center" width="75"> |
| 106 |
<a href="index.php?option=com_vikbooking&task=rooms&vborderby=units&vbordersort=<?php echo ($orderby == "units" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "units" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "units" ? "vbo-list-activesort" : "")); ?>"> |
| 107 |
<?php echo JText::translate('VBPVIEWROOMSEVEN').($orderby == "units" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "units" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?> |
| 108 |
</a> |
| 109 |
</th> |
| 110 |
<th class="title center" align="center" width="100"><?php echo JText::translate( 'VBPVIEWROOMSIX' ); ?></th> |
| 111 |
</tr> |
| 112 |
</thead> |
| 113 |
<?php |
| 114 |
$vcm_logos = VikBooking::getVcmChannelsLogo('', true); |
| 115 |
$website_source_lbl = JText::translate('VBORDFROMSITE'); |
| 116 |
$kk = 0; |
| 117 |
$i = 0; |
| 118 |
for ($i = 0, $n = count($rows); $i < $n; $i++) { |
| 119 |
$row = $rows[$i]; |
| 120 |
$categories = ""; |
| 121 |
if (strlen(trim(str_replace(";", "", (string)$row['idcat']))) > 0) { |
| 122 |
$cat = explode(";", $row['idcat']); |
| 123 |
$catsfound = false; |
| 124 |
$q = "SELECT `name` FROM `#__vikbooking_categories` WHERE "; |
| 125 |
foreach ($cat as $k => $cc) { |
| 126 |
if (!empty($cc)) { |
| 127 |
$q .= "`id`=".$dbo->quote($cc)." "; |
| 128 |
if ($cc != end($cat) && !empty($cat[($k + 1)])) { |
| 129 |
$q .= "OR "; |
| 130 |
} |
| 131 |
$catsfound = true; |
| 132 |
} |
| 133 |
} |
| 134 |
$q .= ";"; |
| 135 |
if ($catsfound) { |
| 136 |
$dbo->setQuery($q); |
| 137 |
$lines = $dbo->loadAssocList(); |
| 138 |
if ($lines) { |
| 139 |
$categories = array(); |
| 140 |
foreach($lines as $ll) { |
| 141 |
$categories[] = $ll['name']; |
| 142 |
} |
| 143 |
$categories = implode(", ", $categories); |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
$caratteristiche = '<span class="label">0</span>'; |
| 149 |
if (!empty($row['idcarat'])) { |
| 150 |
$tmpcarat = explode(";", $row['idcarat']); |
| 151 |
$caratteristiche = '<span class="label">' . VikBooking::totElements($tmpcarat) . '</span>'; |
| 152 |
} |
| 153 |
|
| 154 |
$optionals = '<span class="label">0</span>'; |
| 155 |
if (!empty($row['idopt'])) { |
| 156 |
$tmpopt = explode(";", $row['idopt']); |
| 157 |
$optionals = '<span class="label">' . VikBooking::totElements($tmpopt) . '</span>'; |
| 158 |
} |
| 159 |
|
| 160 |
if ($row['fromadult'] == $row['toadult']) { |
| 161 |
$stradult = $row['fromadult']; |
| 162 |
} else { |
| 163 |
$stradult = $row['fromadult'].' - '.$row['toadult']; |
| 164 |
} |
| 165 |
if ($row['fromchild'] == $row['tochild']) { |
| 166 |
$strchild = $row['fromchild']; |
| 167 |
} else { |
| 168 |
$strchild = $row['fromchild'].' - '.$row['tochild']; |
| 169 |
} |
| 170 |
|
| 171 |
// shared calendar icon |
| 172 |
$sharedcal = ''; |
| 173 |
if (!empty($row['sharedcals'])) { |
| 174 |
$sharedcal = '<span class="vbo-room-sharedcalendar" title="' . $this->escape(JText::translate('VBOROOMCALENDARSHARED')) . '"><i class="' . VikBookingIcons::i('calendar-check') . '"></i></span> '; |
| 175 |
} |
| 176 |
|
| 177 |
// VCM room's channels mapped |
| 178 |
$website_source_lbl_short = substr($website_source_lbl, 0, 1); |
| 179 |
if (function_exists('mb_substr')) { |
| 180 |
$website_source_lbl_short = mb_substr($website_source_lbl, 0, 1, 'UTF-8'); |
| 181 |
} |
| 182 |
$roomchannels = array($website_source_lbl => strtoupper($website_source_lbl_short)); |
| 183 |
$otachannels = is_object($vcm_logos) && method_exists($vcm_logos, 'getVboRoomLogosMapped') ? $vcm_logos->getVboRoomLogosMapped($row['id']) : array(); |
| 184 |
$roomchannels = count($otachannels) ? array() : $roomchannels; |
| 185 |
$roomchannels = array_merge($roomchannels, $otachannels); |
| 186 |
|
| 187 |
// room upgrade option |
| 188 |
$room_upgrade_options = $config->getArray('room_upgrade_options_' . $row['id'], []); |
| 189 |
$room_upgrade_enabled = (!empty($room_upgrade_options['rooms']) && $room_upgrade_options['rooms']); |
| 190 |
?> |
| 191 |
<tr class="row<?php echo $kk; ?>"> |
| 192 |
<td><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onclick="Joomla.isChecked(this.checked);"></td> |
| 193 |
<td class="vbo-highlighted-td"><a href="index.php?option=com_vikbooking&task=editroom&cid[]=<?php echo $row['id']; ?>"><?php echo $row['name']; ?></a></td> |
| 194 |
<td class="center"><?php echo $stradult; ?></td> |
| 195 |
<td class="center"><?php echo $strchild; ?></td> |
| 196 |
<td class="center"><?php echo $row['mintotpeople'].' - '.$row['totpeople']; ?></td> |
| 197 |
<td class="center"><?php echo $categories ?: '----' ; ?></td> |
| 198 |
<td class="center"> |
| 199 |
<?php |
| 200 |
if (strpos((string)$row['params'], 'geo":{"enabled":1') !== false) { |
| 201 |
?> |
| 202 |
<span class="vbo-room-sharedcalendar" title="<?php echo $this->escape(JText::translate('VBO_GEO_INFO')); ?>"><?php VikBookingIcons::e('map-marked-alt'); ?></span> |
| 203 |
<?php |
| 204 |
} |
| 205 |
if ($room_upgrade_enabled) { |
| 206 |
?> |
| 207 |
<span class="vbo-room-sharedcalendar" title="<?php echo $this->escape(JText::translate('VBO_ROOM_UPGRADE')); ?>"><?php VikBookingIcons::e('gem'); ?></span> |
| 208 |
<?php |
| 209 |
} |
| 210 |
echo $caratteristiche; |
| 211 |
?> |
| 212 |
</td> |
| 213 |
<td class="center"><?php echo $optionals; ?></td> |
| 214 |
<td class="center"> |
| 215 |
<div class="vbo-room-channels-mapped-wrap"> |
| 216 |
<?php |
| 217 |
foreach ($roomchannels as $source => $churi) { |
| 218 |
$is_img = (strpos($churi, 'http') !== false); |
| 219 |
// build readable channel name |
| 220 |
$raw_ch_name = $source; |
| 221 |
$lower_name = strtolower($raw_ch_name); |
| 222 |
$lower_name = preg_replace("/hotel$/", ' hotel', $lower_name); |
| 223 |
$channel_name = ucwords(preg_replace("/api$/", '', $lower_name)); |
| 224 |
?> |
| 225 |
<div class="vbo-tooltip vbo-tooltip-top vbo-room-channels-mapped-ch" data-tooltiptext="<?php echo $this->escape($channel_name); ?>"> |
| 226 |
<span class="vbo-room-channels-mapped-ch-lbl"> |
| 227 |
<?php |
| 228 |
if ($is_img) { |
| 229 |
?> |
| 230 |
<img src="<?php echo $churi ?>" alt="<?php echo $source; ?>" /> |
| 231 |
<?php |
| 232 |
} else { |
| 233 |
?> |
| 234 |
<span><?php echo $churi; ?></span> |
| 235 |
<?php |
| 236 |
} |
| 237 |
?> |
| 238 |
</span> |
| 239 |
</div> |
| 240 |
<?php |
| 241 |
} |
| 242 |
?> |
| 243 |
</div> |
| 244 |
</td> |
| 245 |
<td class="center"><?php echo $sharedcal . '<span class="label label-info">' . $row['units'] . '</span>'; ?></td> |
| 246 |
<td class="center"> |
| 247 |
<a href="<?php echo VBOFactory::getPlatform()->getUri()->addCSRF('index.php?option=com_vikbooking&task=modavail&cid[]=' . $row['id'], true); ?>"><?php echo (intval($row['avail'])=="1" ? "<i class=\"".VikBookingIcons::i('check', 'vbo-icn-img')."\" style=\"color: #099909;\" title=\"".JText::translate('VBMAKENOTAVAIL')."\"></i>" : "<i class=\"".VikBookingIcons::i('times-circle', 'vbo-icn-img')."\" style=\"color: #ff0000;\" title=\"".JText::translate('VBMAKEAVAIL')."\"></i>"); ?></a> |
| 248 |
</td> |
| 249 |
</tr> |
| 250 |
<?php |
| 251 |
$kk = 1 - $kk; |
| 252 |
unset($categories); |
| 253 |
} |
| 254 |
?> |
| 255 |
</table> |
| 256 |
</div> |
| 257 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 258 |
<input type="hidden" name="task" value="rooms" /> |
| 259 |
<input type="hidden" name="boxchecked" value="0" /> |
| 260 |
<input type="hidden" name="rname" value="<?php echo $prname; ?>" /> |
| 261 |
<input type="hidden" name="idcat" value="<?php echo $pidcat; ?>" /> |
| 262 |
<?php echo JHtml::fetch('form.token'); ?> |
| 263 |
<?php echo $navbut; ?> |
| 264 |
</form> |
| 265 |
<?php |
| 266 |
} |
| 267 |
|