- send User-Agent "OrderApp/1.4.0 (linux) QloApps-CasposBridge/1.0" and version 1.4.0: CASPOS classifies non-OrderApp clients as "Orderman", which cannot be activated in the Order-App device manager - fixed prices for open-price articles: ARTICLE@12.50 / @12,50 (cents) - live test (docker/test-casposbridge-live.php) booked one night on table 101: 1 x 301 @ 145.00 + 2 x 101 @ 12.50, bookedAmount 17000, lines committed -> enteredPrice is in cents - README: device activation, waiter key, per-area table number ranges ("Ungültige Tischnummer"), results - docker/reset-admin-password.php: set a back-office password from the CLI (asked interactively, not echoed) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
3.6 KiB
PHP
70 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* Live check of modules/casposbridge against a real (test!) CASPOS POS.
|
|
* Uses the connection settings saved in the module (host, port, waiter, password) and
|
|
* books ONE throw-away checked-in stay on table T-<room> so the result can be inspected
|
|
* at the POS. Only run it against a test POS: lines are committed with finalizeOrder.
|
|
*
|
|
* docker compose ... exec -u www-data app php docker/test-casposbridge-live.php "301@preis, 101*erwachsene@12.50" [room]
|
|
*/
|
|
if (PHP_SAPI !== 'cli') {
|
|
exit;
|
|
}
|
|
define('_PS_ADMIN_DIR_', __DIR__);
|
|
require __DIR__.'/../config/config.inc.php';
|
|
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
|
require_once _PS_MODULE_DIR_.'casposbridge/classes/CasposBridgeService.php';
|
|
|
|
$rule = isset($argv[1]) ? $argv[1] : '';
|
|
$room = isset($argv[2]) ? $argv[2] : 'T-1001';
|
|
if ($rule === '') {
|
|
fwrite(STDERR, "Usage: php docker/test-casposbridge-live.php \"<article rule>\" [room]\n");
|
|
exit(1);
|
|
}
|
|
CasposBridgeService::parseRule($rule);
|
|
|
|
$cfg = CasposBridgeService::clientConfig();
|
|
printf("Kasse %s:%s, Kellner %s, Bereich %s, Tisch %s\n", $cfg['host'], $cfg['port'], $cfg['waiter_id'],
|
|
Configuration::get('CASPOSBRIDGE_SERVICE_AREA'), $room);
|
|
|
|
$db = Db::getInstance();
|
|
$oldMapping = Configuration::get('CASPOSBRIDGE_MAPPING');
|
|
$oldEnabled = Configuration::get('CASPOSBRIDGE_ENABLED');
|
|
$map = CasposBridgeService::getMapping();
|
|
$map[2] = $rule;
|
|
Configuration::updateValue('CASPOSBRIDGE_MAPPING', json_encode($map));
|
|
Configuration::updateValue('CASPOSBRIDGE_ENABLED', 1);
|
|
|
|
$from = date('Y-m-d');
|
|
$to = date('Y-m-d', strtotime('+2 day'));
|
|
$db->insert('htl_booking_detail', array(
|
|
'id_product' => 2, 'id_order' => 999002, 'id_order_detail' => 1, 'id_cart' => 1, 'id_room' => 6, 'id_hotel' => 1,
|
|
'id_customer' => 1, 'booking_type' => 1, 'id_status' => HotelBookingDetail::STATUS_ASSIGNED,
|
|
'check_in' => '0000-00-00 00:00:00', 'check_out' => '0000-00-00 00:00:00', 'planned_check_out' => $to.' 11:00:00',
|
|
'date_from' => $from.' 00:00:00', 'date_to' => $to.' 00:00:00',
|
|
'total_price_tax_excl' => 271.03, 'total_price_tax_incl' => 290, 'total_paid_amount' => 0, 'is_back_order' => 0,
|
|
'hotel_name' => 'Test', 'room_type_name' => 'Doppelzimmer', 'room_num' => $room, 'adults' => 2, 'children' => 0,
|
|
'city' => 'Annweiler', 'country' => 'Deutschland', 'zipcode' => '76855', 'phone' => '0000', 'email' => 'test@hotel.test',
|
|
'check_in_time' => '15:00', 'check_out_time' => '11:00',
|
|
'date_add' => date('Y-m-d H:i:s'), 'date_upd' => date('Y-m-d H:i:s'),
|
|
));
|
|
$id = (int)$db->Insert_ID();
|
|
|
|
try {
|
|
$b = new HotelBookingDetail($id);
|
|
$b->changeStatus(HotelBookingDetail::STATUS_CHECKED_IN);
|
|
foreach ($db->executeS('SELECT * FROM `'._DB_PREFIX_.'casposbridge_job` WHERE id_htl_booking = '.$id) as $j) {
|
|
printf("Nacht %s -> Tisch %s: %s (Versuche %d) %s\n", $j['night'], $j['table_name'], $j['status'], $j['attempts'], $j['last_error']);
|
|
foreach ((array)json_decode((string)$j['lines_json'], true) as $l) {
|
|
printf(" %d x %s%s\n", $l['quantity'], $l['article'], $l['enteredPrice'] !== null ? ' @ '.number_format($l['enteredPrice'] / 100, 2, ',', '.').' €' : '');
|
|
}
|
|
}
|
|
} finally {
|
|
$db->delete('casposbridge_job', 'id_htl_booking = '.$id);
|
|
$db->delete('htl_booking_status_history', 'id_htl_booking = '.$id);
|
|
$db->delete('htl_booking_detail', 'id = '.$id);
|
|
Configuration::updateValue('CASPOSBRIDGE_MAPPING', $oldMapping);
|
|
Configuration::updateValue('CASPOSBRIDGE_ENABLED', $oldEnabled);
|
|
}
|
|
echo "Testbuchung in QloApps wieder entfernt; der Tisch an der Kasse bleibt zur Kontrolle offen.\n";
|