PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.6
VikBooking Hotel Booking Engine & PMS v1.6.6
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 / manageroom / view.html.php

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

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