From 21655c5ff4a63bbfdf6abc5af666e78bde9c92da Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Sat, 29 Mar 2025 20:51:44 +0100 Subject: [PATCH] added magenta activation date import script --- .../import-magenta-activation-dates.php | 109 +++++++++++ .../rml-billing/import/25_MagentaKunden.csv | 175 ++++++++++++++++++ 2 files changed, 284 insertions(+) create mode 100644 scripts/rml-billing/import-magenta-activation-dates.php create mode 100644 scripts/rml-billing/import/25_MagentaKunden.csv diff --git a/scripts/rml-billing/import-magenta-activation-dates.php b/scripts/rml-billing/import-magenta-activation-dates.php new file mode 100644 index 000000000..12ec83297 --- /dev/null +++ b/scripts/rml-billing/import-magenta-activation-dates.php @@ -0,0 +1,109 @@ +#!/usr/bin/php +id); +define("INTERNAL_USER_USERNAME", $me->username); +define("MFBASE_BYPASS_LOGIN", true); + +$folder = __DIR__."/import/"; +$filename = "25_MagentaKunden.csv"; + +$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); +$log = mfLoghandler::singleton(); + +$start = date("U"); +$last_ts = $start; + +$input = fopen($folder.$filename, "r"); + +$bom = "\xef\xbb\xbf"; +if(fgets($input, 4) !== $bom) { + // BOM not found - rewind pointer to start of file. + rewind($input); +} + +$headers = []; +$import_date = false; + +$status_500 = PreorderstatusModel::getFirst(["code" => 500]); +if(!$status_500) { + die("No status 500"); +} + +//$c = 0; +$i = 0; +while($csv = fgetcsv($input, 0)) { + $i++; + + if ($i == 1) { + foreach ($csv as $key => $name) { + $headers[$name] = $key; + } + continue; + } + + if (!trim($csv[0])) { + continue; + } + + $oaid = trim($csv[$headers["OAID HOME"]]); + $input_date = trim($csv[$headers["ISP Service aktiv"]]); + + if(!$oaid || !$input_date) { + break; + } + + $activation_date = new DateTime($input_date); + $activation_date->setTime(4, 0, 0); + + if(PreorderModel::countActive(["oaid" => $oaid]) > 1) { + die("OAID $oaid more than 1 active Preorder!"); + } + $preorder = PreorderModel::getFirstActive(["oaid" => $oaid]); + + if(!$preorder) { + die("Preorder $oaid not Found!"); + } + + if($preorder->status->code < 500) { + echo "$oaid -> status ".$preorder->status->code."\n"; + } + + + + $active_change = PreorderHistoryModel::getLastStatusChangeTo($preorder->id, 500); + /*echo "$oaid: $input_date\n"; + echo "$oaid: ".$activation_date->format("Y-m-d")."\n"; + + if($input_date != $activation_date->format("Y-m-d")) { + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; + } + continue;*/ + + if(!$active_change) { + + $active_change = PreorderHistoryModel::create([ + "preorder_id" => $preorder->id, + "key" => "status_id", + "old_value" => 1, + "new_value" => $status_500->id, + ]); + $active_change->save(); + } + + $active_change->changed = $activation_date->getTimestamp(); + $active_change->save(); +} + +echo "$i\n"; \ No newline at end of file diff --git a/scripts/rml-billing/import/25_MagentaKunden.csv b/scripts/rml-billing/import/25_MagentaKunden.csv new file mode 100644 index 000000000..a98324bee --- /dev/null +++ b/scripts/rml-billing/import/25_MagentaKunden.csv @@ -0,0 +1,175 @@ +OAID HOME,ISP Service aktiv +AT-8952-b92fcb7d.001,2023-10-17 +AT-8952-0923e13a.001,2023-12-07 +AT-8952-d5efb0c5.001,2024-04-24 +AT-8952-20559f13.001,2023-12-07 +AT-8952-18354d50.001,2024-04-24 +AT-8952-f15a2ca7.001,2024-01-12 +AT-8952-e2aac412.001,2024-04-24 +AT-8952-d150720b.001,2024-01-10 +AT-8952-03e9c108.001,2024-01-15 +AT-8952-a9ef64c5.001,2023-12-07 +AT-8952-5dfb7093.001,2023-12-07 +AT-8952-e41153d0.001,2024-04-24 +AT-8952-4e7fa84f.001,2024-09-12 +AT-8952-46bb7fff.001,2024-04-23 +AT-8952-49928eab.001,2024-01-10 +AT-8952-fc73db80.001,2024-05-15 +AT-8943-2a911dab.001,2024-07-25 +AT-8952-544d23e8.001,2024-04-23 +AT-8952-a0784e8d.001,2024-07-11 +AT-8982-a415bb94.001,2024-08-14 +AT-8952-1629b7f4.001,2024-05-15 +AT-8952-2ce0dc06.001,2024-05-17 +AT-8943-65b57745.001,2024-09-03 +AT-8943-40c99c0d.002,2024-08-12 +AT-8943-40c99c0d.004,2024-08-12 +AT-8943-40c99c0d.001,2024-08-12 +AT-8943-40c99c0d.003,2024-08-12 +AT-8952-db66a8b5.001,2024-09-12 +AT-8952-a2959a59.001,2024-09-10 +AT-8952-d82544fa.001,2024-09-11 +AT-8943-dcab7caf.001,2024-09-12 +AT-8943-cf48ccef.001,2024-09-02 +AT-8943-2c01ac8d.001,2024-09-03 +AT-8952-eb1f181f.001,2024-09-30 +AT-8952-ab64ee00.001,2024-09-10 +AT-8943-3f07dd46.001,2024-09-30 +AT-8943-f2c2ae10.002,2024-09-10 +AT-8943-fa78f417.001,2024-09-04 +AT-8952-9298eb35.001,2024-09-10 +AT-8943-05505f1e.001,2024-09-04 +AT-8943-b8e526a2.002,2024-09-03 +AT-8943-b8e526a2.001,2024-09-03 +AT-8943-54e2caa3.001,2024-09-11 +AT-8952-907f3e5b.001,2024-09-12 +AT-8943-91b15e79.001,2024-09-11 +AT-8952-e3ead452.001,2024-09-11 +AT-8943-a28e1bce.001,2024-09-10 +AT-8952-6825d3ae.001,2024-09-11 +AT-8943-e29b3cd4.001,2024-09-11 +AT-8952-5badd1cd.001,2024-09-09 +AT-8943-1277b7eb.001,2024-09-11 +AT-8943-5d391327.001,2024-09-09 +AT-8943-b4c1b606.001,2024-09-09 +AT-8943-6e424945.001,2024-09-05 +AT-8943-339cdc17.001,2024-09-05 +AT-8943-a443cbe2.001,2024-09-05 +AT-8943-dd7e2b71.005,2024-10-08 +AT-8952-d63f3b4a.001,2024-11-11 +AT-8943-9389a188.002,2024-11-07 +AT-8952-730c7315.001,2024-11-04 +AT-8943-9389a188.001,2024-11-05 +AT-8943-090108fa.001,2024-11-04 +AT-8952-56809ead.001,2024-11-05 +AT-8952-0f09116b.001,2024-11-05 +AT-8952-7a957a9e.001,2024-11-04 +AT-8943-ad0ba787.001,2024-11-05 +AT-8952-8ff3a2c9.001,2024-11-05 +AT-8952-fccc732a.001,2024-11-04 +AT-8952-8307773c.001,2024-11-04 +AT-8943-8bde59fc.004,2024-11-11 +AT-8952-d510b7aa.001,2024-11-07 +AT-8952-39b3f98f.001,2024-11-07 +AT-8952-f2a0a99d.001,2024-11-06 +AT-8952-cfd374ef.001,2024-11-11 +AT-8952-84e38d21.001,2024-11-06 +AT-8952-a95bda77.001,2024-11-06 +AT-8952-5df56224.001,2024-11-04 +AT-8952-047a8d82.001,2024-11-06 +AT-8952-174a11aa.001,2024-11-06 +AT-8943-ac155257.001,2024-11-04 +AT-8943-ad0ba787.004,2024-11-05 +AT-8943-d906ff07.001,2024-10-30 +AT-8952-be7a0660.001,2024-10-28 +AT-8952-4bffce63.001,2024-10-28 +AT-8952-aed7e5ed.001,2024-10-29 +AT-8952-cd78c3e5.001,2024-10-29 +AT-8952-af85f1e0.001,2024-10-29 +AT-8952-b9749ec9.001,2024-10-29 +AT-8952-f63e9d2c.001,2024-10-30 +AT-8952-affe64f2.001,2024-10-30 +AT-8952-f4468002.001,2024-10-30 +AT-8952-e80422e6.001,2024-10-31 +AT-8943-13e70f36.001,2024-10-30 +AT-8943-426cda48.002,2024-10-18 +AT-8943-0281f0db.003,2024-10-28 +AT-8943-426cda48.001,2024-10-28 +AT-8943-5565dba0.001,2024-10-30 +AT-8952-a7c37d89.001,2024-10-31 +AT-8952-a8bd4bd9.001,2024-11-13 +AT-8952-d4fb7422.001,2024-11-13 +AT-8952-8ea45971.001,2024-11-13 +AT-8943-a464c429.001,2024-12-12 +AT-8943-fffb3d90.006,2024-12-11 +AT-8943-ad6205f0.001,2024-12-18 +AT-8982-6a510a7a.001,2024-12-20 +AT-8982-66f307a0.001,2024-12-20 +AT-8982-dbab4714.002,2024-12-19 +AT-8943-dd7e2b71.003,2024-12-19 +AT-8982-2827d3aa.001,2024-12-19 +AT-8982-a1ada847.001,2024-12-20 +AT-8943-fce5a31f.003,2024-12-18 +AT-8943-49b0c91c.001,2024-12-12 +AT-8982-0208e8be.001,2024-12-20 +AT-8943-fffb3d90.003,2024-12-10 +AT-8943-fffb3d90.004,2024-12-10 +AT-8943-c964421e.001,2024-12-12 +AT-8982-580833dd.001,2024-12-20 +AT-8943-77d4537b.001,2024-12-18 +AT-8943-820efe44.001,2024-12-12 +AT-8943-3c8f8152.003,2024-12-10 +AT-8982-614920ab.001,2024-12-20 +AT-8943-9c8937e8.001,2024-12-02 +AT-8982-af3a8d63.001,2024-12-19 +AT-8943-3c8f8152.002,2024-12-18 +AT-8982-d798cd99.001,2024-12-19 +AT-8943-3c8f8152.001,2024-12-11 +AT-8982-c6d7e4f2.001,2024-12-19 +AT-8982-9641fb2e.001,2024-12-19 +AT-8943-6e670739.001,2024-12-12 +AT-8943-ed3620c0.001,2024-10-15 +AT-8943-399bd714.001,2024-09-04 +AT-8943-69ae30fb.001,2024-09-05 +AT-8943-a1116acf.001,2024-12-12 +AT-8952-5eea3a46.001,2024-12-10 +AT-8952-3083a5c1.001,2025-01-28 +AT-8943-46ec6651.001,2025-01-28 +AT-8982-aded99c2.001,2025-01-21 +AT-8982-abd61a0b.001,2025-01-21 +AT-8952-64e40186.003,2025-01-13 +AT-8983-2bf3214f.001,2025-01-14 +AT-8952-c291163a.003,2025-01-29 +AT-8952-47e52775.003,2025-01-29 +AT-8943-d61452be.002,2025-01-21 +AT-8943-c10d87c7.002,2025-01-28 +AT-8943-fffb3d90.002,2024-12-11 +AT-8982-451c1eb1.001,2024-12-19 +AT-8982-3126a5dc.001,2024-12-19 +AT-8982-06484e3f.001,2024-12-19 +AT-8943-fffb3d90.001,2024-12-11 +AT-8982-63977aa7.001,2024-12-20 +AT-8982-7edf2184.001,2024-12-19 +AT-8982-edc6a443.001,2024-12-20 +AT-8952-64e40186.002,2025-01-13 +AT-8982-bce86ac9.001,2024-12-19 +AT-8982-d448ba70.001,2024-12-20 +AT-8943-fce5a31f.002,2024-12-10 +AT-8952-64e40186.001,2025-01-13 +AT-8982-be11d84d.001,2024-12-20 +AT-8952-ec0bd13d.001,2025-02-18 +AT-8952-2c5c1a88.001,2025-02-18 +AT-8943-9db3a055.002,2025-02-25 +AT-8982-8ecff7fc.001,2025-02-05 +AT-8952-ad79e49e.003,2025-02-27 +AT-8943-9db3a055.001,2025-02-25 +AT-8952-ad79e49e.002,2025-02-26 +AT-8943-122f171a.001,2025-02-25 +AT-8943-a72c5637.002,2025-02-05 +AT-8982-f02e6c7d.002,2025-02-05 +AT-8952-8e408a37.002,2025-02-27 +AT-8982-f02e6c7d.001,2025-02-05 +AT-8952-91880329.001,2025-02-11 +AT-8943-bba3a3bc.001,2025-02-25 +AT-8952-51989893.003,2025-03-11 +AT-8943-f92eb5f7.001,2025-03-11