Container->get('Database'); $shipments_sql = "SELECT CONCAT(va.id, ';', va.modul) module, vp.id, vp.tracking, vp.status FROM versandpakete vp JOIN versandarten va ON vp.versandart = va.type WHERE status IN ('neu', 'versendet')"; $shipments = $db->fetchGroup($shipments_sql); foreach ($shipments as $module => $vps) { list($moduleId, $moduleName) = explode(';', $module,2); $module = $app->erp->LoadVersandModul($moduleName, intval($moduleId)); foreach ($vps as $vp) { $status = match ($module->GetShipmentStatus($vp['tracking'])) { ShipmentStatus::Announced => 'neu', ShipmentStatus::EnRoute => 'versendet', ShipmentStatus::Delivered => 'abgeschlossen', default => null, }; if ($status === null || $status === $vp['status']) continue; $db->perform('UPDATE versandpakete SET status = :status WHERE id = :id', ['status' => $status, 'id' => $vp['id']]); } }