Updated OpenAccessId::exportToRimoAndAssignFtu()

This commit is contained in:
Frank Schubert
2024-01-24 13:36:36 +01:00
parent ec9ccf1830
commit 808c846d88
4 changed files with 56 additions and 80 deletions

View File

@@ -115,10 +115,15 @@ class OpenAccessId extends mfBaseModel {
*/
$existing_rimo_export_data = $this->getExportData("rimo");
if(!is_object($existing_rimo_export_data) || (!isset($existing_rimo_export_data->oaid_id) || !$existing_rimo_export_data->oaid_id) || (!isset($existing_rimo_export_data->name) || !$existing_rimo_export_data->name)) {
//if(!is_object($existing_rimo_export_data) || (!isset($existing_rimo_export_data->oaid_id) || !$existing_rimo_export_data->oaid_id) || (!isset($existing_rimo_export_data->name) || !$existing_rimo_export_data->name)) {
$oaid_data = $rimo->getOaid();
// try to create, if it fails, it already exists
if(!$oaid_data) {
$this->createInRimo();
} else {
$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already created in RIMO");
}
//$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already created in RIMO");
/*************************************************************************
* get OAID from rimo and check if it's the same FTU as our Wohneinheit
@@ -131,7 +136,8 @@ class OpenAccessId extends mfBaseModel {
if(!$resp_data) {
// oaid was not found in rimo, try creating it
$resp_data = $this->createInRimo();
$this->createInRimo();
$resp_data = $rimo->getOaid();
}
$assign_oaid = false;
@@ -162,7 +168,7 @@ class OpenAccessId extends mfBaseModel {
$this->save();
}
}
}
//}
@@ -172,39 +178,10 @@ class OpenAccessId extends mfBaseModel {
* assign OAID to FTU - POST /v1/oaid-management/oaids/{oaidName}/ftu/{ftuExternalId}
*/
/*
// check if we assigned the OAID to a RIMO FTU already
$existing_rimo_export_data = $this->getExportData("rimo");
if(!is_object($existing_rimo_export_data) || !isset($existing_rimo_export_data->oaid_id) || !isset($existing_rimo_export_data->ftu_id)) {
/*
$params = [];
$params['apiKey'] = RIMO_API_JSON_APIKEY;
$ctx_opts = [
'http' => [
'method' => 'POST',
'header' => 'accept: application/json'
]
];
$qs = http_build_query($params);
//echo $qs."\n";
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_ASSIGN_OAID_TO_FTU;
$createOrderEp = str_replace("{oaidName}", $this->oaid, $createOrderEp);
$createOrderEp = str_replace("{ftuExternalId}", $unit_extdata->rimo->ftu->id, $createOrderEp);
$post_url = $createOrderEp."?".$qs;
$ctx = stream_context_create($ctx_opts);
$this->log->debug(__METHOD__.": Assigning OAID to FTU in Rimo: $post_url");
$response = file_get_contents($post_url, false, $ctx);
if($response === false) {
$this->log->error("Fehler beim Zuweisen der OAID '".$this->oaid."' zu RIMO FTU '".$unit_extdata->rimo->ftu->id."'\n");
$workorders_failed++;
return false;
}
*/
$resp_data = $rimo->assignOaid($unit_extdata->rimo->ftu->id);
// add FTU id to external_data
@@ -227,7 +204,7 @@ class OpenAccessId extends mfBaseModel {
} else {
$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already assigned to FTU in Rimo");
}
*/
return true;
}

View File

@@ -32,7 +32,7 @@ class OpenAccessId_Helper_Rimo {
$response = file_get_contents($get_url, false, $ctx);
if($response === false) {
$this->log->error("Fehler beim auslesen der FTU ".$this->oaid."\n");
$this->log->error("Fehler beim auslesen der FTU ".$this->oaid);
return false;
}
@@ -67,7 +67,7 @@ class OpenAccessId_Helper_Rimo {
$response = file_get_contents($get_url, false, $ctx);
//var_dump($response);exit;
if($response === false) {
$this->log->error("Fehler beim abfragen der OAID in RIMO ".$this->oaid."\n");
$this->log->error("Fehler beim abfragen der OAID in RIMO ".$this->oaid);
return false;
}
@@ -102,7 +102,7 @@ class OpenAccessId_Helper_Rimo {
$response = file_get_contents($post_url, false, $ctx);
//var_dump($response);exit;
if($response === false) {
$this->log->error("Fehler beim Erstellen der OAID in RIMO ".$this->oaid."\n");
$this->log->error("Fehler beim Erstellen der OAID in RIMO ".$this->oaid);
return false;
}
@@ -138,7 +138,7 @@ class OpenAccessId_Helper_Rimo {
$response = file_get_contents($delete_url, false, $ctx);
if($response === false) {
$this->log->error("Fehler beim Unassignen der OAID in RIMO ".$this->oaid.": $delete_url\n");
$this->log->error("Fehler beim Unassignen der OAID in RIMO ".$this->oaid.": $delete_url");
return false;
}
@@ -169,7 +169,7 @@ class OpenAccessId_Helper_Rimo {
$response = file_get_contents($post_url, false, $ctx);
if($response === false) {
$this->log->error("Fehler beim Assignen der OAID ".$this->oaid." in RIMO ".$this->oaid."\n");
$this->log->error("Fehler beim Assignen der OAID ".$this->oaid." in RIMO ".$this->oaid);
return false;
}

View File

@@ -529,7 +529,7 @@ class PreordercampaignController extends mfBaseController {
$assigned_oaids = 0;
$multiple_unit = 0;
foreach(PreorderModel::search(["preordercampaign_id" => $id, "oaid" => null, 'deleted' => 0]) as $preorder) {
foreach(PreorderModel::search(["preordercampaign_id" => $id, "oaid" => null, "connection_count" => 1, 'deleted' => 0]) as $preorder) {
if($preorder->type == "interest") {
continue;
}
@@ -608,7 +608,7 @@ class PreordercampaignController extends mfBaseController {
$workorders_created = 0;
$workorders_failed = 0;
foreach(PreorderModel::search(["preordercampaign_id" => $id, "rimo_workorder" => false, 'deleted' => 0]) as $preorder) {
foreach(PreorderModel::search(["preordercampaign_id" => $id, "rimo_workorder" => false, "connection_count" => 1, 'deleted' => 0]) as $preorder) {
if($preorder->workorder_export_date) {
$this->log->warning(__METHOD__.": workorder_export_date not null");
}
@@ -754,7 +754,7 @@ class PreordercampaignController extends mfBaseController {
$missing_extrefs = 0;
$missing_oaid = 0;
foreach(PreorderModel::search(["preordercampaign_id" => $id, 'deleted' => 0]) as $preorder) {
foreach(PreorderModel::search(["preordercampaign_id" => $id, "connection_count" => 1, 'deleted' => 0]) as $preorder) {
if($preorder->type == "interest") {
$this->log->debug(__METHOD__.": Ignoring Preorder ".$preorder->id.": is interest");
continue;

View File

@@ -1 +0,0 @@
,fronk,fronk-nb,23.01.2024 21:03,file:///home/fronk/.config/libreoffice/4;