| @@ -1202,9 +1202,9 @@ | ||
| 1202 | 1202 | try { |
| 1203 | 1203 | // let the room re-assignment operations start |
| 1204 | 1204 | $moveset = VBOBookingRelocator::getInstance($options) |
| 1205 | 1205 | ->findRelocation(); |
| 1206 | - } catch (Exception $e) { | |
| 1206 | + } catch (Throwable $e) { | |
| 1207 | 1207 | // propagate the error |
| 1208 | 1208 | VBOHttpDocument::getInstance($app)->close($e->getCode(), $e->getMessage()); |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| @@ -1287,6 +1287,56 @@ | ||
| 1287 | 1287 | // process completed |
| 1288 | 1288 | VBOHttpDocument::getInstance($app)->json([ |
| 1289 | 1289 | 'success' => true, |
| 1290 | 1290 | ]); |
| 1291 | + } | |
| 1292 | + | |
| 1293 | + /** | |
| 1294 | + * Regular task to create passcodes for a booking that should have had them. | |
| 1295 | + * | |
| 1296 | + * @since 1.18.16 (J) - 1.8.16 (WP) | |
| 1297 | + */ | |
| 1298 | + public function generatePasscodes() | |
| 1299 | + { | |
| 1300 | + $app = JFactory::getApplication(); | |
| 1301 | + | |
| 1302 | + $bookingId = $app->input->getUInt('bid', 0); | |
| 1303 | + | |
| 1304 | + if (!$bookingId) { | |
| 1305 | + $app->enqueueMessage('Missing booking ID.', 'error'); | |
| 1306 | + $app->redirect('index.php?option=com_vikbooking'); | |
| 1307 | + $app->close(); | |
| 1308 | + } | |
| 1309 | + | |
| 1310 | + if (!JSession::checkToken() && !JSession::checkToken('get')) { | |
| 1311 | + $app->enqueueMessage(JText::translate('JINVALID_TOKEN'), 'error'); | |
| 1312 | + $app->redirect('index.php?option=com_vikbooking&task=editorder&cid[]=' . $bookingId); | |
| 1313 | + $app->close(); | |
| 1314 | + } | |
| 1315 | + | |
| 1316 | + try { | |
| 1317 | + // access booking registry | |
| 1318 | + $registry = VBOBookingRegistry::getInstance(['id' => $bookingId]); | |
| 1319 | + } catch (Exception $e) { | |
| 1320 | + $app->enqueueMessage($e->getMessage(), 'error'); | |
| 1321 | + $app->redirect('index.php?option=com_vikbooking'); | |
| 1322 | + $app->close(); | |
| 1323 | + } | |
| 1324 | + | |
| 1325 | + // do not check the history to see if previous passcode generation events occurred | |
| 1326 | + // always simulate the creation of this booking | |
| 1327 | + $generated = VBOFactory::getDoorAccessControl()->processBookingConfirmation($registry->getData(), $registry->getRooms()); | |
| 1328 | + | |
| 1329 | + if ($registry->hasPreCheckedIn()) { | |
| 1330 | + // simulate the pre-check-in completion of the booking | |
| 1331 | + $generatedTwo = VBOFactory::getDoorAccessControl()->processPrecheckinCompleted($registry->getData(), $registry->getRooms()); | |
| 1332 | + } | |
| 1333 | + | |
| 1334 | + // evaluate result | |
| 1335 | + $generated = $generated || $generatedTwo; | |
| 1336 | + | |
| 1337 | + // complete with a successful message | |
| 1338 | + $app->enqueueMessage(JText::translate('VBO_W_DOORACCESSCONTROL_TITLE'), ($generated ? 'success' : 'warning')); | |
| 1339 | + $app->redirect('index.php?option=com_vikbooking&task=editorder&cid[]=' . $bookingId); | |
| 1340 | + $app->close(); | |
| 1291 | 1341 | } |
| 1292 | 1342 | } |