| @@ -19,8 +19,12 @@ | ||
| 19 | 19 | { |
| 20 | 20 | // Set the toolbar |
| 21 | 21 | $this->addToolBar(); |
| 22 | 22 | |
| 23 | + if (!JFactory::getUser()->authorise('core.vbo.availability', 'com_vikbooking') && !JFactory::getUser()->authorise('core.vbo.bookings', 'com_vikbooking')) { | |
| 24 | + VBOHttpDocument::getInstance()->close(403, JText::translate('JERROR_ALERTNOAUTHOR')); | |
| 25 | + } | |
| 26 | + | |
| 23 | 27 | $cid = VikRequest::getVar('cid', array(0)); |
| 24 | 28 | $aid = $cid[0]; |
| 25 | 29 | |
| 26 | 30 | $app = JFactory::getApplication(); |
| @@ -52,18 +56,19 @@ | ||
| 52 | 56 | |
| 53 | 57 | // new reservation ID default status |
| 54 | 58 | $new_res_id = 0; |
| 55 | 59 | |
| 56 | - $q = "SELECT `id`,`name`,`img`,`units` FROM `#__vikbooking_rooms` WHERE `id`=".$dbo->quote($aid); | |
| 60 | + $q = "SELECT * FROM `#__vikbooking_rooms` WHERE `id`=".$dbo->quote($aid); | |
| 57 | 61 | $dbo->setQuery($q, 0, 1); |
| 58 | 62 | $room = $dbo->loadAssoc(); |
| 59 | 63 | if (!$room) { |
| 64 | + $session->set('vbCalRid', ''); | |
| 60 | 65 | VikError::raiseWarning('', 'No Rooms.'); |
| 61 | 66 | $app->redirect("index.php?option=com_vikbooking&task=rooms"); |
| 62 | 67 | $app->close(); |
| 63 | 68 | } |
| 64 | 69 | |
| 65 | - $q = "SELECT `id`,`name`,`units` FROM `#__vikbooking_rooms` ORDER BY `#__vikbooking_rooms`.`name` ASC;"; | |
| 70 | + $q = "SELECT `id`,`name`,`img`,`units` FROM `#__vikbooking_rooms` ORDER BY `#__vikbooking_rooms`.`name` ASC;"; | |
| 66 | 71 | $dbo->setQuery($q); |
| 67 | 72 | $allc = $dbo->loadAssocList(); |
| 68 | 73 | |
| 69 | 74 | $q = "SELECT `id`,`name` FROM `#__vikbooking_gpayments` ORDER BY `#__vikbooking_gpayments`.`name` ASC;"; |
| @@ -90,8 +95,9 @@ | ||
| 90 | 95 | $pcustmail = VikRequest::getString('custmail', '', 'request'); |
| 91 | 96 | $padults = VikRequest::getInt('adults', 0, 'request'); |
| 92 | 97 | $pchildren = VikRequest::getInt('children', 0, 'request'); |
| 93 | 98 | $psetclosed = VikRequest::getInt('setclosed', 0, 'request'); |
| 99 | + $psetunitsclosed = VikRequest::getInt('setunitsclosed', 0, 'request'); | |
| 94 | 100 | $num_rooms = VikRequest::getInt('num_rooms', 0, 'request'); |
| 95 | 101 | $num_rooms = empty($num_rooms) || $num_rooms <= 0 ? 1 : $num_rooms; |
| 96 | 102 | $pordstatus = VikRequest::getString('newstatus', '', 'request'); |
| 97 | 103 | $pordstatus = (empty($pordstatus) || !in_array($pordstatus, array('confirmed', 'standby')) ? 'confirmed' : $pordstatus); |
| @@ -110,8 +116,17 @@ | ||
| 110 | 116 | $ptotalpnight = VikRequest::getString('totalpnight', 'total', 'request'); |
| 111 | 117 | $ptaxid = VikRequest::getInt('taxid', 0, 'request'); |
| 112 | 118 | $pcloseothers = VikRequest::getVar('closeothers', array()); |
| 113 | 119 | |
| 120 | + /** | |
| 121 | + * Mark the units as closed in case of a regular reservation for no customers. | |
| 122 | + * | |
| 123 | + * @since 1.16.6 (J) - 1.6.6 (WP) | |
| 124 | + */ | |
| 125 | + if ($psetunitsclosed && ($psetclosed || $pordstatus != 'confirmed' || $pcustomer_id)) { | |
| 126 | + $psetunitsclosed = 0; | |
| 127 | + } | |
| 128 | + | |
| 114 | 129 | $paymentmeth = ''; |
| 115 | 130 | if (!empty($ppaymentid) && $payments) { |
| 116 | 131 | foreach ($payments as $pay) { |
| 117 | 132 | if (intval($pay['id']) == intval($ppaymentid)) { |
| @@ -170,8 +185,9 @@ | ||
| 170 | 185 | $model_res = VBOModelReservation::getInstance([ |
| 171 | 186 | 'force_booking' => $forcebooking, |
| 172 | 187 | 'split_stay' => $split_stay_data, |
| 173 | 188 | 'set_closed' => $psetclosed, |
| 189 | + 'units_closed' => $psetunitsclosed, | |
| 174 | 190 | 'close_others' => $pcloseothers, |
| 175 | 191 | 'status' => $pordstatus, |
| 176 | 192 | 'checkin' => $first, |
| 177 | 193 | 'checkout' => $second, |
| @@ -212,19 +228,19 @@ | ||
| 212 | 228 | $app->redirect("index.php?option=com_vikbooking&task=calendar"); |
| 213 | 229 | $app->close(); |
| 214 | 230 | } |
| 215 | 231 | |
| 232 | + // check if any action for the Channel Manager should be displayed | |
| 233 | + $vcm_action = $model_res->getChannelManagerAction(); | |
| 234 | + if ($vcm_action) { | |
| 235 | + VikError::raiseNotice('', $vcm_action); | |
| 236 | + } | |
| 237 | + | |
| 216 | 238 | if ($pordstatus == 'standby') { |
| 217 | 239 | // redirect only if the booking status is pending |
| 218 | 240 | $app->enqueueMessage(JText::translate('VBQUICKRESWARNSTANDBY')); |
| 219 | 241 | $app->redirect("index.php?option=com_vikbooking&task=editbusy&cid[]=" . $res_id); |
| 220 | 242 | $app->close(); |
| 221 | - } | |
| 222 | - | |
| 223 | - // check if any action for the Channel Manager should be displayed | |
| 224 | - $vcm_action = $model_res->getChannelManagerAction(); | |
| 225 | - if ($vcm_action) { | |
| 226 | - VikError::raiseNotice('', $vcm_action); | |
| 227 | 243 | } |
| 228 | 244 | |
| 229 | 245 | // set new reservation ID |
| 230 | 246 | $new_res_id = $res_id; |