PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
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 1.7.3 All 36 releases
vikbooking / site / views / availability / view.html.php

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

110 lines 3.9 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 VikbookingViewAvailability extends JViewVikBooking
16 {
17 public function display($tpl = null)
18 {
19 $room_ids = array_filter((array)VikRequest::getVar('room_ids', array(), 'request', 'int'));
20 $psortby = VikRequest::getString('sortby', '', 'request');
21 $psortby = !in_array($psortby, array('adults', 'name', 'id')) ? 'adults' : $psortby;
22 $psorttype = VikRequest::getString('sorttype', '', 'request');
23 $psorttype = $psorttype == 'desc' ? 'DESC' : 'ASC';
24
25 $oclause = "`#__vikbooking_rooms`.`toadult` ".$psorttype.", `#__vikbooking_rooms`.`totpeople` ".$psorttype.", `#__vikbooking_rooms`.`name` ".$psorttype;
26 if ($psortby == 'name') {
27 $oclause = "`#__vikbooking_rooms`.`name` ".$psorttype;
28 } elseif ($psortby == 'id') {
29 $oclause = "`#__vikbooking_rooms`.`id` ".$psorttype;
30 }
31
32 $dbo = JFactory::getDBO();
33 $vbo_tn = VikBooking::getTranslator();
34
35 $q = "SELECT * FROM `#__vikbooking_rooms` WHERE ".(count($room_ids) > 0 ? "`id` IN (".implode(',', $room_ids).") AND " : "")."`avail`='1' ORDER BY ".$oclause.";";
36 $dbo->setQuery($q);
37 $dbo->execute();
38 if (!$dbo->getNumRows()) {
39 $app = JFactory::getApplication();
40 $app->redirect("index.php");
41 $app->close();
42 }
43 $rooms=$dbo->loadAssocList();
44 $vbo_tn->translateContents($rooms, '#__vikbooking_rooms');
45
46 $pmonth = VikRequest::getInt('month', '', 'request');
47 if (!empty($pmonth)) {
48 $tsstart=$pmonth;
49 } else {
50 $oggid = getdate();
51 $tsstart = mktime(0, 0, 0, $oggid['mon'], 1, $oggid['year']);
52 }
53 $oggid = getdate($tsstart);
54 if ($oggid['mon'] == 12) {
55 $nextmon = 1;
56 $year = $oggid['year'] + 1;
57 } else {
58 $nextmon = $oggid['mon'] + 1;
59 $year = $oggid['year'];
60 }
61 $tsend = mktime(0, 0, 0, $nextmon, 1, $year);
62 $today = getdate();
63 $firstmonth = mktime(0, 0, 0, $today['mon'], 1, $today['year']);
64 $wmonthsel = "<select name=\"month\" onchange=\"document.vbmonths.submit();\">\n";
65 $wmonthsel .= "<option value=\"".$firstmonth."\"".($firstmonth==$tsstart ? " selected=\"selected\"" : "").">".VikBooking::sayMonth($today['mon'])." ".$today['year']."</option>\n";
66 $futuremonths = 12;
67 for ($i = 1; $i <= $futuremonths; $i++) {
68 $newts = getdate($firstmonth);
69 if ($newts['mon'] == 12) {
70 $nextmon = 1;
71 $year = $newts['year'] + 1;
72 } else {
73 $nextmon = $newts['mon'] + 1;
74 $year = $newts['year'];
75 }
76 $firstmonth = mktime(0, 0, 0, $nextmon, 1, $year);
77 $newts = getdate($firstmonth);
78 $wmonthsel .= "<option value=\"".$firstmonth."\"".($firstmonth==$tsstart ? " selected=\"selected\"" : "").">".VikBooking::sayMonth($newts['mon'])." ".$newts['year']."</option>\n";
79 }
80 $wmonthsel .= "</select>\n";
81
82 $busy = array();
83 $q = "SELECT * FROM `#__vikbooking_busy` WHERE ".(count($room_ids) > 0 ? "`idroom` IN (".implode(',', $room_ids).") AND " : "")."(`checkin`>=".$tsstart." OR `checkout`>=".$tsstart.");";
84 $dbo->setQuery($q);
85 $dbo->execute();
86 if ($dbo->getNumRows()) {
87 $all_busy = $dbo->loadAssocList();
88 foreach ($all_busy as $brecord) {
89 $busy[$brecord['idroom']][] = $brecord;
90 }
91 }
92
93 $this->rooms = $rooms;
94 $this->tsstart = $tsstart;
95 $this->wmonthsel = $wmonthsel;
96 $this->busy = $busy;
97 $this->vbo_tn = $vbo_tn;
98 //theme
99 $theme = VikBooking::getTheme();
100 if ($theme != 'default') {
101 $thdir = VBO_SITE_PATH . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'availability';
102 if (is_dir($thdir)) {
103 $this->_setPath('template', $thdir . DIRECTORY_SEPARATOR);
104 }
105 }
106 //
107 parent::display($tpl);
108 }
109 }
110