Files
hotel/modules/casposbridge/cron.php
DanielS b6eebfcb90 Add casposbridge: post hotel nights to CASPOS tables via OrderApp API
On check-in (actionBookingStatusAfter -> checked in) and hourly via the
QloApps Cron Task Manager or modules/casposbridge/cron.php, every night of
a checked-in stay is posted to the CASPOS table named after the room
number: registerClient -> waiter login -> tables/openByName ->
orderLines/add -> tables/finalizeOrder (API derived from the CASPOS
OrderApp client, lib/api/api.dart).

- one job per booking and night; pending -> added -> done, so a retry
  only commits and never books lines twice; half-added lines are
  cancelled; POS offline keeps jobs queued (max 10 attempts)
- mapping per room type: ARTICLE[*qty|erwachsene|kinder|gaeste][@preis]
- optional HTTPS with pinned SHA1 certificate fingerprint, checked
  before credentials are sent
- undoing a check-in drops unsent nights and logs posted ones for a void
- config page with connection test (lists service areas and articles)
  and the last 50 jobs with retry
- docker/caspos-mock: stand-in POS for the used endpoints and error
  codes; docker/test-casposbridge.php: 23 end-to-end checks

Not yet verified against a real CASPOS: enteredPrice unit, auto-creation
of tables, client activation, finalizeOrder/TSE behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 23:07:28 +01:00

29 lines
956 B
PHP

<?php
/**
* Post the nights of checked-in guests to CASPOS (command line only).
* docker compose exec -u www-data app php modules/casposbridge/cron.php
* Use this with Windows Task Scheduler if the QloApps Cron Task Manager is not running.
*/
if (PHP_SAPI !== 'cli') {
header('HTTP/1.1 403 Forbidden');
exit;
}
define('_PS_ADMIN_DIR_', __DIR__);
require dirname(__FILE__).'/../../config/config.inc.php';
$module = Module::getInstanceByName('casposbridge');
if (!$module || !Module::isEnabled('casposbridge')) {
fwrite(STDERR, "Modul casposbridge ist nicht installiert oder deaktiviert.\n");
exit(1);
}
$res = $module->cronPostNights();
if ($res === true) {
echo "Anbindung ist ausgeschaltet.\n";
exit(0);
}
printf("gebucht: %d, erneut versuchen: %d, fehlgeschlagen: %d\n", $res['done'], $res['retry'], $res['failed']);
foreach ($res['errors'] as $e) {
echo ' - '.$e."\n";
}
exit($res['failed'] || $res['retry'] ? 2 : 0);