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

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

141 lines 4.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 // import Joomla view library
14 jimport('joomla.application.component.view');
15
16 class VikBookingViewManageroom extends JViewVikBooking
17 {
18 public function display($tpl = null)
19 {
20 // Set the toolbar
21 $this->addToolBar();
22
23 if (!JFactory::getUser()->authorise('core.vbo.rooms', 'com_vikbooking')) {
24 VBOHttpDocument::getInstance()->close(403, JText::translate('JERROR_ALERTNOAUTHOR'));
25 }
26
27 $cid = VikRequest::getVar('cid', array(0));
28 if (!empty($cid[0])) {
29 $id = (int)$cid[0];
30 }
31
32 $row = array();
33 $adultsdiff = "";
34 $dbo = JFactory::getDbo();
35 if (!empty($cid[0])) {
36 $q = "SELECT * FROM `#__vikbooking_rooms` WHERE `id`={$id};";
37 $dbo->setQuery($q);
38 $dbo->execute();
39 if ($dbo->getNumRows() == 1) {
40 $row = $dbo->loadAssoc();
41 } else {
42 VikError::raiseWarning('', 'Room not found.');
43 $mainframe = JFactory::getApplication();
44 $mainframe->redirect("index.php?option=com_vikbooking&task=rooms");
45 }
46 }
47
48 $q = "SELECT * FROM `#__vikbooking_categories`;";
49 $dbo->setQuery($q);
50 $dbo->execute();
51 $cats = $dbo->getNumRows() > 0 ? $dbo->loadAssocList() : "";
52 $q = "SELECT * FROM `#__vikbooking_characteristics`;";
53 $dbo->setQuery($q);
54 $dbo->execute();
55 $carats = $dbo->getNumRows() > 0 ? $dbo->loadAssocList() : "";
56 $q = "SELECT * FROM `#__vikbooking_optionals` ORDER BY `#__vikbooking_optionals`.`ordering` ASC;";
57 $dbo->setQuery($q);
58 $dbo->execute();
59 $optionals = $dbo->getNumRows() > 0 ? $dbo->loadAssocList() : "";
60 if (!empty($cid[0])) {
61 $q = "SELECT * FROM `#__vikbooking_adultsdiff` WHERE `idroom`={$id};";
62 $dbo->setQuery($q);
63 $dbo->execute();
64 $adultsdiff = $dbo->getNumRows() > 0 ? $dbo->loadAssocList() : "";
65 }
66
67 // rooms map and calendar relations (used also for room-upgrade)
68 $rooms_map = array();
69 $q = "SELECT `id`, `name` FROM `#__vikbooking_rooms`" . (!empty($cid[0]) ? " WHERE `id`!={$id}" : '') . " ORDER BY `name` ASC;";
70 $dbo->setQuery($q);
71 $dbo->execute();
72 if ($dbo->getNumRows()) {
73 $rooms = $dbo->loadAssocList();
74 foreach ($rooms as $r) {
75 $rooms_map[$r['id']] = $r['name'];
76 }
77 }
78 $cal_xref = array(
79 'shared_with' => array(),
80 'shared_by' => array(),
81 );
82 if (!empty($cid[0])) {
83 $q = "SELECT * FROM `#__vikbooking_calendars_xref` WHERE `mainroom`={$id} OR `childroom`={$id};";
84 $dbo->setQuery($q);
85 $dbo->execute();
86 if ($dbo->getNumRows()) {
87 $xref = $dbo->loadAssocList();
88 foreach ($xref as $r) {
89 if ((int)$r['mainroom'] == $id) {
90 array_push($cal_xref['shared_with'], $r['childroom']);
91 } elseif ((int)$r['childroom'] == $id) {
92 array_push($cal_xref['shared_by'], $r['mainroom']);
93 }
94 }
95 }
96 }
97 //
98
99 $this->row = $row;
100 $this->cats = $cats;
101 $this->carats = $carats;
102 $this->optionals = $optionals;
103 $this->adultsdiff = $adultsdiff;
104 $this->rooms_map = $rooms_map;
105 $this->cal_xref = $cal_xref;
106
107 // Display the template
108 parent::display($tpl);
109 }
110
111 /**
112 * Sets the toolbar
113 */
114 protected function addToolBar()
115 {
116 $cid = VikRequest::getVar('cid', array(0));
117
118 if (!empty($cid[0])) {
119 //edit
120 JToolBarHelper::title(JText::translate('VBMAINROOMTITLEEDIT'), 'vikbooking');
121 if (JFactory::getUser()->authorise('core.edit', 'com_vikbooking')) {
122 JToolBarHelper::apply( 'updateroomstay', JText::translate('VBSAVE'));
123 JToolBarHelper::save( 'updateroom', JText::translate('VBSAVECLOSE'));
124 JToolBarHelper::spacer();
125 }
126 JToolBarHelper::cancel( 'cancel', JText::translate('VBANNULLA'));
127 JToolBarHelper::spacer();
128 } else {
129 //new
130 JToolBarHelper::title(JText::translate('VBMAINROOMTITLENEW'), 'vikbooking');
131 if (JFactory::getUser()->authorise('core.create', 'com_vikbooking')) {
132 JToolBarHelper::save( 'createroom', JText::translate('VBSAVECLOSE'));
133 JToolBarHelper::apply( 'createroomstay', JText::translate('VBSAVE'));
134 JToolBarHelper::spacer();
135 }
136 JToolBarHelper::cancel( 'cancel', JText::translate('VBANNULLA'));
137 JToolBarHelper::spacer();
138 }
139 }
140 }
141