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 / admin / views / rooms / view.html.php

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

140 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 // import Joomla view library
14 jimport('joomla.application.component.view');
15
16 class VikBookingViewRooms extends JViewVikBooking {
17
18 function display($tpl = null) {
19 // Set the toolbar
20 $this->addToolBar();
21
22 $rows = "";
23 $navbut = "";
24 $mainframe = JFactory::getApplication();
25 $pmodtar = VikRequest::getString('modtar', '', 'request');
26 //to fix js issues
27 $ptarmod = VikRequest::getString('tarmod', '', 'request');
28 //
29 $proomid = VikRequest::getString('roomid', '', 'request');
30 $dbo = JFactory::getDBO();
31 if ((!empty($pmodtar) || !empty($ptarmod)) && !empty($proomid)) {
32 $q = "SELECT * FROM `#__vikbooking_dispcost` WHERE `idroom`=".$dbo->quote($proomid).";";
33 $dbo->setQuery($q);
34 $dbo->execute();
35 if ($dbo->getNumRows() > 0) {
36 $tars = $dbo->loadAssocList();
37 foreach ($tars as $tt) {
38 $tmpcost = VikRequest::getString('cost'.$tt['id'], '', 'request');
39 $tmpattr = VikRequest::getString('attr'.$tt['id'], '', 'request');
40 if (strlen($tmpcost)) {
41 $q = "UPDATE `#__vikbooking_dispcost` SET `cost`='".$tmpcost."'".(strlen($tmpattr) ? ", `attrdata`=".$dbo->quote($tmpattr)."" : "")." WHERE `id`='".$tt['id']."';";
42 $dbo->setQuery($q);
43 $dbo->execute();
44 }
45 }
46 }
47 $lim0 = VikRequest::getVar('limitstart', 0, '', 'int');
48 $mainframe->redirect("index.php?option=com_vikbooking&task=tariffs&cid[]=".$proomid."&limitstart=".$lim0);
49 exit;
50 }
51 $lim = $mainframe->getUserStateFromRequest("com_vikbooking.limit", 'limit', $mainframe->get('list_limit'), 'int');
52 $lim0 = VikRequest::getVar('limitstart', 0, '', 'int');
53 $session = JFactory::getSession();
54 $pvborderby = VikRequest::getString('vborderby', '', 'request');
55 $pvbordersort = VikRequest::getString('vbordersort', '', 'request');
56 $validorderby = array('name', 'toadult', 'tochild', 'totpeople', 'units');
57 $orderby = $session->get('vbViewRoomsOrderby', 'name');
58 $ordersort = $session->get('vbViewRoomsOrdersort', 'ASC');
59 if (!empty($pvborderby) && in_array($pvborderby, $validorderby)) {
60 $orderby = $pvborderby;
61 $session->set('vbViewRoomsOrderby', $orderby);
62 if (!empty($pvbordersort) && in_array($pvbordersort, array('ASC', 'DESC'))) {
63 $ordersort = $pvbordersort;
64 $session->set('vbViewRoomsOrdersort', $ordersort);
65 }
66 }
67
68 // filters
69 $prname = $mainframe->getUserStateFromRequest("vbo.rooms.rname", 'rname', '', 'string');
70 $pidcat = $mainframe->getUserStateFromRequest("vbo.rooms.idcat", 'idcat', 0, 'int');
71 $q = "SELECT `id`, `name` FROM `#__vikbooking_categories` ORDER BY `name` ASC;";
72 $dbo->setQuery($q);
73 $dbo->execute();
74 $allcats = $dbo->getNumRows() ? $dbo->loadAssocList() : array();
75 $clauses = array();
76 if (!empty($prname)) {
77 array_push($clauses, "`r`.`name` LIKE " . $dbo->quote("%{$prname}%"));
78 }
79 if (!empty($pidcat)) {
80 array_push($clauses, "(`r`.`idcat`='" . $pidcat . ";' OR `r`.`idcat` LIKE '" . $pidcat . ";%' OR `r`.`idcat` LIKE '%;" . $pidcat . ";%' OR `r`.`idcat` LIKE '%;" . $pidcat . ";')");
81 }
82 //
83
84 $q = "SELECT SQL_CALC_FOUND_ROWS `r`.*, (SELECT 1 FROM `#__vikbooking_calendars_xref` AS `x` WHERE `x`.`mainroom`=`r`.`id` OR `x`.`childroom`=`r`.`id` LIMIT 1) AS `sharedcals` FROM `#__vikbooking_rooms` AS `r`" . (count($clauses) ? ' WHERE ' . implode(' AND ', $clauses) : '') . " ORDER BY `r`.`".$orderby."` ".$ordersort;
85 $dbo->setQuery($q, $lim0, $lim);
86 $dbo->execute();
87
88 /**
89 * Call assertListQuery() from the View class to make sure the filters set
90 * do not produce an empty result. This would reset the page in this case.
91 *
92 * @since 1.3.0
93 */
94 $this->assertListQuery($lim0, $lim);
95 //
96
97 if ($dbo->getNumRows() > 0) {
98 $rows = $dbo->loadAssocList();
99 $dbo->setQuery('SELECT FOUND_ROWS();');
100 jimport('joomla.html.pagination');
101 $pageNav = new JPagination( $dbo->loadResult(), $lim0, $lim );
102 $navbut = "<table align=\"center\"><tr><td>".$pageNav->getListFooter()."</td></tr></table>";
103 }
104
105 $this->rows = $rows;
106 $this->lim0 = $lim0;
107 $this->navbut = $navbut;
108 $this->orderby = $orderby;
109 $this->ordersort = $ordersort;
110 $this->allcats = $allcats;
111
112 // Display the template
113 parent::display($tpl);
114 }
115
116 /**
117 * Sets the toolbar
118 */
119 protected function addToolBar() {
120 JToolBarHelper::title(JText::translate('VBMAINDEAFULTTITLE'), 'vikbooking');
121 if (JFactory::getUser()->authorise('core.create', 'com_vikbooking')) {
122 JToolBarHelper::addNew('newroom', JText::translate('VBMAINDEFAULTNEW'));
123 JToolBarHelper::spacer();
124 }
125 if (JFactory::getUser()->authorise('core.edit', 'com_vikbooking')) {
126 JToolBarHelper::editList('editroom', JText::translate('VBMAINDEFAULTEDITC'));
127 JToolBarHelper::spacer();
128 JToolBarHelper::editList('tariffs', JText::translate('VBMAINDEFAULTEDITT'));
129 JToolBarHelper::spacer();
130 JToolBarHelper::custom( 'calendar', 'calendar', 'calendar', JText::translate('VBMAINDEFAULTCAL'), true, false);
131 JToolBarHelper::spacer();
132 }
133 if (JFactory::getUser()->authorise('core.delete', 'com_vikbooking')) {
134 JToolBarHelper::deleteList(JText::translate('VBDELCONFIRM'), 'removeroom', JText::translate('VBMAINDEFAULTDEL'));
135 JToolBarHelper::spacer();
136 }
137 }
138
139 }
140