PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.7
VikBooking Hotel Booking Engine & PMS v1.8.7
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / views / rooms / tmpl / default.php

default.php in VikBooking Hotel Booking Engine & PMS 1.8.7, at admin/views/rooms/tmpl/default.php

516 lines 22.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 JText::script('VBO_CREATE_LISTING_ON_OTA');
22 JText::script('VBOCHECKINSTATUSUPDATED');
23 JText::script('VBO_OTA_ACCOUNT_ID');
24 JText::script('VBO_OTA_LISTING_ID');
25 JText::script('VBANNULLA');
26 JText::script('VBSAVE');
27
28 $rows = $this->rows;
29 $lim0 = $this->lim0;
30 $navbut = $this->navbut;
31 $orderby = $this->orderby;
32 $ordersort = $this->ordersort;
33
34 $prname = $app->getUserStateFromRequest("vbo.rooms.rname", 'rname', '', 'string');
35 $pidcat = $app->getUserStateFromRequest("vbo.rooms.idcat", 'idcat', 0, 'int');
36 ?>
37 <div class="vbo-list-form-filters vbo-btn-toolbar">
38 <form action="index.php?option=com_vikbooking&amp;task=rooms" method="post" name="roomsform">
39 <div style="width: 100%; display: inline-block;" class="btn-toolbar" id="filter-bar">
40 <div class="btn-group pull-left">
41 <select name="idcat" id="idcat" onchange="document.roomsform.submit();">
42 <option value=""><?php echo JText::translate('VBOCATEGORYFILTER'); ?></option>
43 <?php
44 foreach ($this->allcats as $cat) {
45 ?>
46 <option value="<?php echo $cat['id']; ?>"<?php echo $cat['id'] == $pidcat ? ' selected="selected"' : ''; ?>><?php echo $cat['name']; ?></option>
47 <?php
48 }
49 ?>
50 </select>
51 </div>
52 <div class="btn-group pull-left input-append btn-group-right-el">
53 <input type="text" name="rname" id="rname" value="<?php echo $prname; ?>" size="40" placeholder="<?php echo JText::translate('VBPVIEWROOMONE'); ?>"/>
54 <button type="button" class="btn btn-secondary" onclick="document.roomsform.submit();"><i class="icon-search"></i></button>
55 </div>
56 <div class="btn-group pull-left">
57 <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>
58 </div>
59 </div>
60 <input type="hidden" name="task" value="rooms" />
61 <input type="hidden" name="option" value="com_vikbooking" />
62 </form>
63 </div>
64 <script type="text/javascript">
65 jQuery(function() {
66 jQuery('#idcat').select2();
67 });
68 </script>
69 <?php
70 if (empty($rows)) {
71 ?>
72 <p class="warn"><?php echo JText::translate('VBNOROOMSFOUND'); ?></p>
73 <form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm">
74 <input type="hidden" name="task" value="" />
75 <input type="hidden" name="option" value="com_vikbooking" />
76 </form>
77 <?php
78 } else {
79 ?>
80 <form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm" class="vbo-list-form">
81 <div class="table-responsive">
82 <table cellpadding="4" cellspacing="0" border="0" width="100%" class="table table-striped vbo-list-table">
83 <thead>
84 <tr>
85 <th width="20">
86 <input type="checkbox" onclick="Joomla.checkAll(this)" value="" name="checkall-toggle">
87 </th>
88 <th class="title left" width="150">
89 <a href="index.php?option=com_vikbooking&amp;task=rooms&amp;vborderby=name&amp;vbordersort=<?php echo ($orderby == "name" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "name" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "name" ? "vbo-list-activesort" : "")); ?>">
90 <?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>')); ?>
91 </a>
92 </th>
93 <th class="title center" align="center" width="75">
94 <a href="index.php?option=com_vikbooking&amp;task=rooms&amp;vborderby=toadult&amp;vbordersort=<?php echo ($orderby == "toadult" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "toadult" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "toadult" ? "vbo-list-activesort" : "")); ?>">
95 <?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>')); ?>
96 </a>
97 </th>
98 <th class="title center" align="center" width="75">
99 <a href="index.php?option=com_vikbooking&amp;task=rooms&amp;vborderby=tochild&amp;vbordersort=<?php echo ($orderby == "tochild" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "tochild" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "tochild" ? "vbo-list-activesort" : "")); ?>">
100 <?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>')); ?>
101 </a>
102 </th>
103 <th class="title center" align="center" width="75">
104 <a href="index.php?option=com_vikbooking&amp;task=rooms&amp;vborderby=totpeople&amp;vbordersort=<?php echo ($orderby == "totpeople" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "totpeople" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "totpeople" ? "vbo-list-activesort" : "")); ?>">
105 <?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>')); ?>
106 </a>
107 </th>
108 <th class="title center" width="75"><?php echo JText::translate( 'VBPVIEWROOMTWO' ); ?></th>
109 <th class="title center" align="center" width="75"><?php echo JText::translate( 'VBPVIEWROOMTHREE' ); ?></th>
110 <th class="title center" align="center" width="75"><?php echo JText::translate( 'VBPVIEWROOMFOUR' ); ?></th>
111 <th class="title center" align="center" width="100"><?php echo JText::translate( 'VBOCHANNELS' ); ?></th>
112 <th class="title center" align="center" width="75">
113 <a href="index.php?option=com_vikbooking&amp;task=rooms&amp;vborderby=units&amp;vbordersort=<?php echo ($orderby == "units" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "units" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "units" ? "vbo-list-activesort" : "")); ?>">
114 <?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>')); ?>
115 </a>
116 </th>
117 <th class="title center" align="center" width="100">
118 <a href="index.php?option=com_vikbooking&amp;task=rooms&amp;vborderby=avail&amp;vbordersort=<?php echo ($orderby == "avail" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "avail" && $ordersort == "ASC" ? "vbo-list-activesort" : ($orderby == "avail" ? "vbo-list-activesort" : "")); ?>">
119 <?php echo JText::translate('VBPVIEWROOMSIX').($orderby == "avail" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "avail" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?>
120 </a>
121 </th>
122 </tr>
123 </thead>
124 <?php
125 $vcm_logos = VikBooking::getVcmChannelsLogo('', true);
126 $website_source_lbl = JText::translate('VBORDFROMSITE');
127 $kk = 0;
128 $i = 0;
129 for ($i = 0, $n = count($rows); $i < $n; $i++) {
130 $row = $rows[$i];
131 $categories = [];
132 if (strlen(trim(str_replace(";", "", (string)$row['idcat']))) > 0) {
133 $cat = explode(";", $row['idcat']);
134 $catsfound = false;
135 $q = "SELECT `name` FROM `#__vikbooking_categories` WHERE ";
136 foreach ($cat as $k => $cc) {
137 if (!empty($cc)) {
138 $q .= "`id`=".$dbo->quote($cc)." ";
139 if ($cc != end($cat) && !empty($cat[($k + 1)])) {
140 $q .= "OR ";
141 }
142 $catsfound = true;
143 }
144 }
145 $q .= ";";
146 if ($catsfound) {
147 $dbo->setQuery($q);
148 $lines = $dbo->loadAssocList();
149 foreach ($lines as $ll) {
150 $categories[] = $ll['name'];
151 }
152 }
153 }
154
155 $caratteristiche = '<span class="label">0</span>';
156 if (!empty($row['idcarat'])) {
157 $tmpcarat = explode(";", $row['idcarat']);
158 $caratteristiche = '<span class="label">' . VikBooking::totElements($tmpcarat) . '</span>';
159 }
160
161 $optionals = '<span class="label">0</span>';
162 if (!empty($row['idopt'])) {
163 $tmpopt = explode(";", $row['idopt']);
164 $optionals = '<span class="label">' . VikBooking::totElements($tmpopt) . '</span>';
165 }
166
167 if ($row['fromadult'] == $row['toadult']) {
168 $stradult = $row['fromadult'];
169 } else {
170 $stradult = $row['fromadult'].' - '.$row['toadult'];
171 }
172 if ($row['fromchild'] == $row['tochild']) {
173 $strchild = $row['fromchild'];
174 } else {
175 $strchild = $row['fromchild'].' - '.$row['tochild'];
176 }
177
178 // shared calendar icon
179 $sharedcal = '';
180 if (!empty($row['sharedcals'])) {
181 $sharedcal = '<span class="vbo-room-sharedcalendar" title="' . $this->escape(JText::translate('VBOROOMCALENDARSHARED')) . '"><i class="' . VikBookingIcons::i('calendar-check') . '"></i></span> ';
182 }
183
184 // VCM room's channels mapped
185 $website_source_lbl_short = substr($website_source_lbl, 0, 1);
186 if (function_exists('mb_substr')) {
187 $website_source_lbl_short = mb_substr($website_source_lbl, 0, 1, 'UTF-8');
188 }
189 $roomchannels = array($website_source_lbl => strtoupper($website_source_lbl_short));
190 $otachannels = is_object($vcm_logos) && method_exists($vcm_logos, 'getVboRoomLogosMapped') ? $vcm_logos->getVboRoomLogosMapped($row['id']) : array();
191 $roomchannels = count($otachannels) ? array() : $roomchannels;
192 $roomchannels = array_merge($roomchannels, $otachannels);
193
194 // VCM room onboardable OTAs
195 $onboardable_otas = [];
196 $room_ota_accounts = [];
197 if (is_object($vcm_logos) && method_exists($vcm_logos, 'getRoomOnboardableChannels')) {
198 $onboardable_otas = $vcm_logos->getRoomOnboardableChannels($row['id']);
199 $room_ota_accounts = $vcm_logos->getRoomOtaAccounts();
200 $room_ota_accounts = $room_ota_accounts[$row['id']] ?? [];
201 }
202
203 // room upgrade option
204 $room_upgrade_options = $config->getArray('room_upgrade_options_' . $row['id'], []);
205 $room_upgrade_enabled = (!empty($room_upgrade_options['rooms']) && $room_upgrade_options['rooms']);
206 ?>
207 <tr class="row<?php echo $kk; ?>">
208 <td><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onclick="Joomla.isChecked(this.checked);"></td>
209 <td class="vbo-highlighted-td"><a href="index.php?option=com_vikbooking&amp;task=editroom&amp;cid[]=<?php echo $row['id']; ?>"><?php echo $row['name']; ?></a></td>
210 <td class="center"><?php echo $stradult; ?></td>
211 <td class="center"><?php echo $strchild; ?></td>
212 <td class="center"><?php echo $row['mintotpeople'].' - '.$row['totpeople']; ?></td>
213 <td class="center"><?php
214 if ($categories && count($categories) < 4) {
215 echo implode(', ', $categories);
216 } else if ($categories) {
217 ?>
218 <span class="label" title="<?php echo $this->escape(implode(', ', $categories)); ?>"><?php echo count($categories); ?></span>
219 <?php
220 } else {
221 echo '----' ;
222 }
223 ?></td>
224 <td class="center">
225 <?php
226 if (strpos((string)$row['params'], 'geo":{"enabled":1') !== false) {
227 ?>
228 <span class="vbo-room-sharedcalendar" title="<?php echo $this->escape(JText::translate('VBO_GEO_INFO')); ?>"><?php VikBookingIcons::e('map-marked-alt'); ?></span>
229 <?php
230 }
231 if ($room_upgrade_enabled) {
232 ?>
233 <span class="vbo-room-sharedcalendar" title="<?php echo $this->escape(JText::translate('VBO_ROOM_UPGRADE')); ?>"><?php VikBookingIcons::e('gem'); ?></span>
234 <?php
235 }
236 echo $caratteristiche;
237 ?>
238 </td>
239 <td class="center"><?php echo $optionals; ?></td>
240 <td class="center">
241 <div class="vbo-room-channels-mapped-wrap">
242 <?php
243 $ch_counter = 0;
244 foreach ($roomchannels as $source => $churi) {
245 if (in_array(preg_replace("/api$/", '', $source), $onboardable_otas)) {
246 // the room is mapped with the current channel, but we have a pending onboarding
247 $ch_counter++;
248 continue;
249 }
250
251 $is_img = (strpos($churi, 'http') !== false);
252 // build readable channel name
253 $raw_ch_name = $source;
254 $lower_name = strtolower($raw_ch_name);
255 $lower_name = preg_replace("/(hotel|vr)$/", ' $1', $lower_name);
256 $channel_name = ucwords(preg_replace("/api$/", '', $lower_name));
257 // build OTA account attributes
258 $ota_account_attributes = [];
259 if (!strcasecmp(($room_ota_accounts[$ch_counter]['channel'] ?? ''), $source)) {
260 $ota_account_attributes = [
261 'data-ota-name="' . $this->escape($channel_name) . '"',
262 'data-ota-idroom="' . $this->escape(($room_ota_accounts[$ch_counter]['idroomota'] ?? '')) . '"',
263 'data-ota-account-name="' . $this->escape(($room_ota_accounts[$ch_counter]['account_name'] ?? '')) . '"',
264 'data-ota-account-id="' . $this->escape(($room_ota_accounts[$ch_counter]['host_main_id'] ?? '')) . '"',
265 ];
266 }
267 ?>
268 <div class="vbo-tooltip vbo-tooltip-top vbo-room-channels-mapped-ch" data-tooltiptext="<?php echo $this->escape($channel_name); ?>"<?php echo $ota_account_attributes ? ' ' . implode(' ', $ota_account_attributes) : ''; ?>>
269 <span class="vbo-room-channels-mapped-ch-lbl">
270 <?php
271 if ($is_img) {
272 ?>
273 <img src="<?php echo $churi; ?>" alt="<?php echo $source; ?>" />
274 <?php
275 } else {
276 ?>
277 <span><?php echo $churi; ?></span>
278 <?php
279 }
280 ?>
281 </span>
282 </div>
283 <?php
284 $ch_counter++;
285 }
286 foreach ($onboardable_otas as $ch_id => $ch_name) {
287 $ch_logo_url = $vcm_logos ? $vcm_logos->setProvenience($ch_name, $ch_name)->getTinyLogoURL() : '';
288 if (!$ch_logo_url || strpos($ch_logo_url, 'http') === false) {
289 continue;
290 }
291 ?>
292 <div
293 class="vbo-tooltip vbo-tooltip-top vbo-room-channels-onboard-ch"
294 data-chid="<?php echo $ch_id; ?>"
295 data-chname="<?php echo $this->escape($ch_name); ?>"
296 data-roomid="<?php echo $row['id']; ?>"
297 data-tooltiptext="<?php echo $this->escape(JText::sprintf('VBO_CREATE_LISTING_ON_OTA', $ch_name)); ?>"
298 >
299 <span class="vbo-room-channels-onboard-ch-lbl">
300 <?php VikBookingIcons::e('plus'); ?>
301 <img src="<?php echo $ch_logo_url; ?>" alt="<?php echo $ch_name; ?>" />
302 </span>
303 </div>
304 <?php
305 }
306 ?>
307 </div>
308 </td>
309 <td class="center"><?php echo $sharedcal . '<span class="label label-info">' . $row['units'] . '</span>'; ?></td>
310 <td class="center">
311 <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>
312 </td>
313 </tr>
314 <?php
315 $kk = 1 - $kk;
316 }
317 ?>
318 </table>
319 </div>
320 <input type="hidden" name="option" value="com_vikbooking" />
321 <input type="hidden" name="task" value="rooms" />
322 <input type="hidden" name="boxchecked" value="0" />
323 <input type="hidden" name="rname" value="<?php echo $prname; ?>" />
324 <input type="hidden" name="idcat" value="<?php echo $pidcat; ?>" />
325 <?php echo JHtml::fetch('form.token'); ?>
326 <?php echo $navbut; ?>
327 </form>
328
329 <script type="text/javascript">
330 jQuery(function() {
331
332 jQuery('.vbo-room-channels-onboard-ch').on('click', function() {
333 let channel_id = jQuery(this).attr('data-chid');
334 let channel_name = jQuery(this).attr('data-chname');
335 let room_id = jQuery(this).attr('data-roomid');
336 let room_name = jQuery(this).closest('tr').find('td.vbo-highlighted-td').text();
337
338 let cancel_btn = jQuery('<button></button>')
339 .attr('type', 'button')
340 .addClass('btn')
341 .text(Joomla.JText._('VBANNULLA'))
342 .on('click', function() {
343 VBOCore.emitEvent('vbo-ota-onboard-listing-dismiss');
344 });
345
346 let save_btn = jQuery('<button></button>')
347 .attr('type', 'button')
348 .addClass('btn btn-success')
349 .text(Joomla.JText._('VBSAVE'))
350 .on('click', function() {
351 // start loading
352 VBOCore.emitEvent('vbo-ota-onboard-listing-loading');
353
354 try {
355 // prepare toast message container
356 VBOToast.create(VBOToast.POSITION_TOP_CENTER);
357 VBOToast.changePosition(VBOToast.POSITION_TOP_CENTER);
358 } catch(err) {
359 // do nothing
360 }
361
362 // get form values
363 let formValues = jQuery('#vbo-vcm-onboard-listing-form').serialize();
364
365 // perform the request
366 VBOCore.doAjax(
367 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=otaonboarding.create'); ?>",
368 formValues,
369 (resp) => {
370 // dispatch toast success message
371 VBOToast.enqueue(new VBOToastMessage({
372 body: Joomla.JText._('VBOCHECKINSTATUSUPDATED'),
373 icon: 'fas fa-check-circle',
374 status: VBOToast.SUCCESS_STATUS,
375 action: () => {
376 VBOToast.dispose(true);
377 },
378 }));
379
380 // dismiss the modal on success
381 VBOCore.emitEvent('vbo-ota-onboard-listing-dismiss');
382
383 // reload the current page
384 window.location.reload();
385 },
386 (error) => {
387 // stop loading
388 VBOCore.emitEvent('vbo-ota-onboard-listing-loading');
389
390 // attempt to decode the possible JSON erroneous response
391 try {
392 let errorData = JSON.parse(error.responseText);
393
394 // dispatch the event to display the current progress
395 VBOCore.emitEvent('vbo-vcm-onboard-progress-updated', errorData);
396
397 // display a delayed error
398 setTimeout(() => {
399 alert(errorData.error);
400 }, 100);
401 } catch(err) {
402 // display the raw error as it was not a JSON-encoded string
403 alert(error.responseText);
404 }
405 }
406 );
407 });
408
409 let modal_body = VBOCore.displayModal({
410 suffix: 'ota-onboard-listing',
411 extra_class: 'vbo-modal-rounded vbo-modal-tall',
412 title: Joomla.JText._('VBO_CREATE_LISTING_ON_OTA').replace('%s', channel_name) + ' - ' + room_name,
413 footer_left: cancel_btn,
414 footer_right: save_btn,
415 dismiss_event: 'vbo-ota-onboard-listing-dismiss',
416 loading_event: 'vbo-ota-onboard-listing-loading',
417 });
418
419 // start loading
420 VBOCore.emitEvent('vbo-ota-onboard-listing-loading');
421
422 // perform the request
423 VBOCore.doAjax(
424 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=otaonboarding.new'); ?>",
425 {
426 channel_id: channel_id,
427 channel_name: channel_name,
428 room_id: room_id,
429 },
430 (resp) => {
431 // stop loading
432 VBOCore.emitEvent('vbo-ota-onboard-listing-loading');
433 try {
434 let obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp;
435 modal_body.append(obj_res['html']);
436 } catch (err) {
437 console.error('Error decoding the response', err, resp);
438 }
439 },
440 (error) => {
441 alert(error.responseText);
442 // dismiss the modal
443 VBOCore.emitEvent('vbo-ota-onboard-listing-dismiss');
444 }
445 );
446 });
447
448 jQuery('.vbo-room-channels-mapped-ch[data-ota-idroom]').on('click', function() {
449 let room_name = jQuery(this).closest('tr').find('td.vbo-highlighted-td').text();
450 let channel_img = jQuery(this).find('img').attr('src');
451 let ota_name = jQuery(this).attr('data-ota-name');
452 let ota_idroom = jQuery(this).attr('data-ota-idroom');
453 let ota_account_name = jQuery(this).attr('data-ota-account-name');
454 let ota_account_id = jQuery(this).attr('data-ota-account-id');
455
456 if (!ota_name || !ota_idroom || !ota_account_id) {
457 return;
458 }
459
460 let listing_details_html = '';
461 listing_details_html += '<div class="vbo-admin-container vbo-admin-container-full vbo-admin-container-compact">';
462 listing_details_html += ' <div class="vbo-params-wrap">';
463 listing_details_html += ' <div class="vbo-params-container">';
464 listing_details_html += ' <div class="vbo-params-block">';
465
466 listing_details_html += ' <div class="vbo-param-container">';
467 listing_details_html += ' <div class="vbo-param-label"><img class="vbo-room-ota-listing-details" src="' + channel_img + '" title="' + ota_name + '" /></div>';
468 listing_details_html += ' <div class="vbo-param-setting"><strong>' + ota_account_name + '</strong></div>';
469 listing_details_html += ' </div>';
470
471 listing_details_html += ' <div class="vbo-param-container">';
472 listing_details_html += ' <div class="vbo-param-label"><strong>' + Joomla.JText._('VBO_OTA_ACCOUNT_ID') + '</strong></div>';
473 listing_details_html += ' <div class="vbo-param-setting"><span class="label label-info">' + ota_account_id + '</span></div>';
474 listing_details_html += ' </div>';
475
476 listing_details_html += ' <div class="vbo-param-container">';
477 listing_details_html += ' <div class="vbo-param-label"><strong>' + Joomla.JText._('VBO_OTA_LISTING_ID') + '</strong></div>';
478 listing_details_html += ' <div class="vbo-param-setting"><span class="label label-info">' + ota_idroom + '</span></div>';
479 listing_details_html += ' </div>';
480
481 listing_details_html += ' </div>';
482 listing_details_html += ' </div>';
483 listing_details_html += ' </div>';
484 listing_details_html += '</div>';
485
486 VBOCore.displayModal({
487 suffix: 'ota-listing-details',
488 extra_class: 'vbo-modal-rounded vbo-modal-dialog vbo-modal-nofooter',
489 title: room_name,
490 body: listing_details_html,
491 });
492 });
493
494 /**
495 * Mini thumbnails background generation.
496 */
497 setTimeout(() => {
498 VBOCore.doAjax(
499 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=listings.check_mini_thumbnails'); ?>",
500 {},
501 (result) => {
502 if (typeof result === 'object') {
503 console.info('Mini thumbnails processed (' + result.processed + ') and generated (' + result.generated + ').');
504 }
505 },
506 (error) => {
507 console.error(error);
508 }
509 );
510 }, 1000);
511
512 });
513 </script>
514 <?php
515 }
516