Files
thetool/scripts/preorder/citycom/order-mgmt-services.php
2025-11-20 14:49:29 +01:00

57 lines
2.0 KiB
PHP

#!/usr/bin/php
<?php
//require 'vendor/autoload.php';
require("../../../config/config.php");
define('FRONKDB_SQLDEBUG', false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR . "/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseController.php");
$me = new User(1);
define("INTERNAL_USER_ID", $me->id);
define("INTERNAL_USER_USERNAME", $me->username);
define("MFBASE_BYPASS_LOGIN", true);
$log = mfLoghandler::singleton();
$cc = new Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
$cc_helper = new Citycom_OanApiHelper($cc);
foreach(PreordercampaignModel::search(["fulfillment" => "citycom_oan"]) as $campaign) {
foreach($campaign->active_preorders as $preorder) {
if(!$preorder->adb_wohneinheit_id) continue;
$has_inet_service = false;
$has_mgmt_service = false;
if(is_array($preorder->ctags) && count($preorder->ctags)) {
foreach ($preorder->ctags as $ctag) {
if ($ctag->network != "citycom-oan") continue;
if ($ctag->service_type == "inet") $has_inet_service = true;
if ($ctag->service_type == "mgmt") $has_mgmt_service = true;
}
}
if($has_inet_service || $has_mgmt_service) continue;
$sublocation_id = \Citycom_OanApiHelper::hausnummerExtrefToCitycomId($preorder->adb_wohneinheit->extref);
$data = [
"down" => 100,
"up" => 100,
"product_name" => "Estmk Greenstream OAN Mgmt",
"execution_date" => false,
"services" => [CITYCOM_OAN_API_SERVICES_FOR_RESERVATION],
];
$log->info(__METHOD__.": Ordering mgmt service for preorder ".$preorder->id);
if(!$cc_helper->orderServices($preorder, $sublocation_id, $data)) {
$log->error(__METHOD__.": Error ordering mgmt service for preorder ".$preorder->id);
}
}
}