PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.4
VikBooking Hotel Booking Engine & PMS v1.6.4
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 / site / views / roomslist / view.html.php

view.html.php in VikBooking Hotel Booking Engine & PMS 1.6.4, at site/views/roomslist/view.html.php

154 lines 5.4 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 jimport('joomla.application.component.view');
14
15 class VikbookingViewRoomslist extends JViewVikBooking {
16 function display($tpl = null) {
17 VikBooking::prepareViewContent();
18 $dbo = JFactory::getDbo();
19 $vbo_tn = VikBooking::getTranslator();
20 $pcategory_id = VikRequest::getInt('category_id', '', 'request');
21 $psortby = VikRequest::getString('sortby', '', 'request');
22 $psortby = !in_array($psortby, array('price', 'name', 'id', 'random')) ? 'price' : $psortby;
23 $psorttype = VikRequest::getString('sorttype', '', 'request');
24 $psorttype = $psorttype == 'desc' ? 'DESC' : 'ASC';
25 $preslim = VikRequest::getInt('reslim', '', 'request');
26 $preslim = empty($preslim) || $preslim < 1 ? 20 : $preslim;
27 $category = "";
28 if ($pcategory_id > 0) {
29 $q = "SELECT * FROM `#__vikbooking_categories` WHERE `id`='".$pcategory_id."';";
30 $dbo->setQuery($q);
31 $dbo->execute();
32 if($dbo->getNumRows() == 1) {
33 $category = $dbo->loadAssocList();
34 $category = $category[0];
35 $vbo_tn->translateContents($category, '#__vikbooking_categories');
36 }
37 }
38 $ordbyclause = '';
39 if ($psortby == 'name') {
40 $ordbyclause = ' ORDER BY `#__vikbooking_rooms`.`name` '.$psorttype;
41 } elseif ($psortby == 'id') {
42 $ordbyclause = ' ORDER BY `#__vikbooking_rooms`.`id` '.$psorttype;
43 }
44 if (is_array($category)) {
45 $q = "SELECT * FROM `#__vikbooking_rooms` WHERE `avail`='1' AND (`idcat`='".$category['id'].";' OR `idcat` LIKE '".$category['id'].";%' OR `idcat` LIKE '%;".$category['id'].";%' OR `idcat` LIKE '%;".$category['id'].";')".$ordbyclause.";";
46 } else {
47 $q = "SELECT * FROM `#__vikbooking_rooms` WHERE `avail`='1'".$ordbyclause.";";
48 }
49 $dbo->setQuery($q);
50 $dbo->execute();
51 if ($dbo->getNumRows() > 0) {
52 $rooms = $dbo->loadAssocList();
53 $vbo_tn->translateContents($rooms, '#__vikbooking_rooms');
54 if ($vbo_tn->default_lang != $vbo_tn->current_lang && $psortby == 'name') {
55 //VBO 1.9 - resort rooms by name after the translations have been applied
56 $resort_map = array();
57 foreach ($rooms as $k => $v) {
58 $resort_map[$k] = $v['name'];
59 }
60 asort($resort_map);
61 $resorted = array();
62 foreach ($resort_map as $k => $v) {
63 $resorted[$k] = $rooms[$k];
64 }
65 $rooms = $resorted;
66 unset($resorted);
67 }
68 /**
69 * We calculate the default timestamps for check-in of today and check-out for tomorrow.
70 * Useful to apply the today's rate by default for one night of stay.
71 *
72 * @since 1.13.5
73 */
74 $vbo_df = VikBooking::getDateFormat();
75 $vbo_df = $vbo_df == "%d/%m/%Y" ? 'd/m/Y' : ($vbo_df == "%m/%d/%Y" ? 'm/d/Y' : 'Y/m/d');
76 $checkinh = 0;
77 $checkinm = 0;
78 $checkouth = 0;
79 $checkoutm = 0;
80 $timeopst = VikBooking::getTimeOpenStore();
81 if (is_array($timeopst)) {
82 $opent = VikBooking::getHoursMinutes($timeopst[0]);
83 $closet = VikBooking::getHoursMinutes($timeopst[1]);
84 $checkinh = $opent[0];
85 $checkinm = $opent[1];
86 $checkouth = $closet[0];
87 $checkoutm = $closet[1];
88 }
89 $checkin_today_ts = VikBooking::getDateTimestamp(date($vbo_df), $checkinh, $checkinm);
90 $checkout_tomorrow_ts = VikBooking::getDateTimestamp(date($vbo_df, strtotime('tomorrow')), $checkouth, $checkoutm);
91 //
92 foreach ($rooms as $k => $c) {
93 $custprice = VikBooking::getRoomParam('custprice', $c['params']);
94 if (!empty($custprice)) {
95 $rooms[$k]['cost'] = floatval($custprice);
96 } else {
97 $rooms[$k]['cost'] = 0;
98 $q = "SELECT * FROM `#__vikbooking_dispcost` WHERE `idroom`=".$dbo->quote($c['id'])." ORDER BY `#__vikbooking_dispcost`.`days` ASC, `#__vikbooking_dispcost`.`cost` ASC";
99 $dbo->setQuery($q, 0, 1);
100 $dbo->execute();
101 if ($dbo->getNumRows()) {
102 $tar = $dbo->loadAssocList();
103 /**
104 * We apply the today's rate by default for one night of stay.
105 *
106 * @since 1.13.5
107 */
108 $tar = VikBooking::applySeasonsRoom($tar, $checkin_today_ts, $checkout_tomorrow_ts);
109 //
110 $rooms[$k]['cost'] = $tar[0]['cost'] / ($tar[0]['days'] > 1 ? $tar[0]['days'] : 1);
111 }
112 }
113 }
114 if ($psortby == 'random') {
115 $keys = array_keys($rooms);
116 shuffle($keys);
117 $new = array();
118 foreach ($keys as $key) {
119 $new[$key] = $rooms[$key];
120 }
121 $rooms = $new;
122 } elseif ($psortby == 'price') {
123 $rooms = VikBooking::sortRoomPrices($rooms);
124 if ($psorttype == 'DESC') {
125 $rooms = array_reverse($rooms, true);
126 }
127 }
128 //pagination
129 $lim = $preslim; //results limit
130 $lim0 = VikRequest::getVar('limitstart', 0, '', 'int');
131 jimport('joomla.html.pagination');
132 $pageNav = new JPagination(count($rooms), $lim0, $lim);
133 $navig = $pageNav->getPagesLinks();
134 $this->navig = $navig;
135 $rooms = array_slice($rooms, $lim0, $lim, true);
136 //
137
138 $this->rooms = $rooms;
139 $this->category = $category;
140 $this->vbo_tn = $vbo_tn;
141 //theme
142 $theme = VikBooking::getTheme();
143 if($theme != 'default') {
144 $thdir = VBO_SITE_PATH.DS.'themes'.DS.$theme.DS.'roomslist';
145 if(is_dir($thdir)) {
146 $this->_setPath('template', $thdir.DS);
147 }
148 }
149 //
150 parent::display($tpl);
151 }
152 }
153 }
154