| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client1/web16/web/scripts/ |
Upload File : |
<?php
declare(strict_types=1);
/**
* AIDA-Buchungslisten importieren.
*
* AIDA liefert pro Anlauf MEHRERE Dateien (eine pro Produktcode). Der Importer
* gruppiert diese Dateien zu BATCHES (= ein Anlauf) anhand cruise_id + Dateiname-Datum,
* importiert alle Dateien des Batches, sammelt die external_uids ÜBER alle Dateien hinweg
* und führt erst danach (und nur bei list_type = "final") einen einzigen Storno-Pass aus.
*
* Aufruf:
* php scripts/import-aida-bookings.php
*/
if (PHP_SAPI !== 'cli') {
fwrite(STDERR, "Bitte nur über die Kommandozeile aufrufen.\n");
exit(1);
}
$root = dirname(__DIR__);
require_once $root . '/app/core/Database.php';
require_once $root . '/app/services/AidaBookingImporter.php';
$db = new Database();
$importer = AidaBookingImporter::fromDatabase($db, $root . '/data');
$summary = $importer->processInbox();
$batches = $summary['batches'] ?? [];
$skipped = $summary['skipped_duplicate'] ?? [];
printf("Batches: %d, Created: %d, Updated: %d, Unchanged: %d, Cancelled: %d, Duplikat-Skip: %d, Errors: %d\n\n",
count($batches),
$summary['created'], $summary['updated'],
$summary['unchanged'], $summary['cancelled'],
count($skipped), count($summary['errors'] ?? [])
);
foreach ($batches as $b) {
printf("Batch AIDA %s %s %s %s\n",
$b['cruise'] ?? '?',
$b['ship'] ?? '?',
$b['departure_date'] ?? '?',
strtoupper((string)($b['list_type'] ?? '?'))
);
printf(" Files: %d\n", (int)($b['files'] ?? 0));
printf(" Product codes: %s\n", implode(', ', $b['product_codes'] ?? []) ?: '–');
printf(" Created: %d\n", (int)($b['created'] ?? 0));
printf(" Updated: %d\n", (int)($b['updated'] ?? 0));
printf(" Unchanged: %d\n", (int)($b['unchanged'] ?? 0));
printf(" Cancelled: %d%s\n",
(int)($b['cancelled'] ?? 0),
!empty($b['cancel_skipped_reason']) ? " [skipped: {$b['cancel_skipped_reason']}]" : ''
);
if (!empty($b['uid_mismatches'])) {
printf(" UID Mismatches: %d (NICHT storniert — selbe legacy_booking_no, alte UID auf neue migriert)\n",
count($b['uid_mismatches']));
foreach ($b['uid_mismatches'] as $m) {
printf(" • id=%d legacy=%s booking_no=%s customer=%s %s\n",
(int)($m['id'] ?? 0),
(string)($m['legacy_booking_no'] ?? ''),
(string)($m['booking_no'] ?? ''),
(string)($m['first_name'] ?? ''),
(string)($m['last_name'] ?? '')
);
}
}
if (!empty($b['cross_event_skipped'])) {
printf(" Cross-Event Umbuchungen: %d (NICHT storniert — Buchung lebt in einem anderen Anlauf)\n",
count($b['cross_event_skipped']));
foreach ($b['cross_event_skipped'] as $m) {
printf(" • id=%d legacy=%s booking_no=%s customer=%s %s\n",
(int)($m['id'] ?? 0),
(string)($m['legacy_booking_no'] ?? ''),
(string)($m['booking_no'] ?? ''),
(string)($m['first_name'] ?? ''),
(string)($m['last_name'] ?? '')
);
}
}
if (!empty($b['errors'])) {
printf(" Errors: %d\n", count($b['errors']));
foreach ($b['errors'] as $err) {
printf(" • %s\n", $err);
}
}
print "\n";
}
if (!empty($skipped)) {
print "Skipped (duplicate filename):\n";
foreach ($skipped as $name) print " • $name\n";
}