Updated OpenAccessId::exportToRimoAndAssignFtu()
This commit is contained in:
@@ -115,54 +115,60 @@ class OpenAccessId extends mfBaseModel {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$existing_rimo_export_data = $this->getExportData("rimo");
|
$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();
|
$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
|
||||||
|
*/
|
||||||
|
|
||||||
|
$ftu_data = $wohneinheit->ftu_data;
|
||||||
|
if($ftu_data['id'] && $ftu_data['name']) {
|
||||||
|
|
||||||
/*************************************************************************
|
$resp_data = $rimo->getOaid();
|
||||||
* get OAID from rimo and check if it's the same FTU as our Wohneinheit
|
|
||||||
*/
|
|
||||||
|
|
||||||
$ftu_data = $wohneinheit->ftu_data;
|
if(!$resp_data) {
|
||||||
if($ftu_data['id'] && $ftu_data['name']) {
|
// oaid was not found in rimo, try creating it
|
||||||
|
$this->createInRimo();
|
||||||
$resp_data = $rimo->getOaid();
|
$resp_data = $rimo->getOaid();
|
||||||
|
}
|
||||||
if(!$resp_data) {
|
|
||||||
// oaid was not found in rimo, try creating it
|
$assign_oaid = false;
|
||||||
$resp_data = $this->createInRimo();
|
|
||||||
}
|
if($resp_data && $resp_data->terminiationUnit && $resp_data->terminiationUnit->id) {
|
||||||
|
if($ftu_data['id'] != $resp_data->terminiationUnit->id) {
|
||||||
$assign_oaid = false;
|
$old_ftu_id = $resp_data->terminiationUnit->id;
|
||||||
|
|
||||||
if($resp_data && $resp_data->terminiationUnit && $resp_data->terminiationUnit->id) {
|
// unassign oaid from FTU
|
||||||
if($ftu_data['id'] != $resp_data->terminiationUnit->id) {
|
$resp_data = $rimo->unassignOaid($old_ftu_id);
|
||||||
$old_ftu_id = $resp_data->terminiationUnit->id;
|
$assign_oaid = true;
|
||||||
|
|
||||||
// unassign oaid from FTU
|
|
||||||
$resp_data = $rimo->unassignOaid($old_ftu_id);
|
|
||||||
$assign_oaid = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$assign_oaid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($assign_oaid) {
|
|
||||||
// assign oaid to Wohneinheit FTU
|
|
||||||
$resp_data = $rimo->assignOaid($ftu_data['id']);
|
|
||||||
|
|
||||||
// update OAID export data
|
|
||||||
$exp_data_update = json_decode($this->export_data);
|
|
||||||
$exp_data_update->rimo->ftu_id = $ftu_data['id'];
|
|
||||||
$exp_data_update->rimo->ftu_name = $ftu_data['name'];
|
|
||||||
$exp_data_update->rimo->ftu_assigned_date = date("U");
|
|
||||||
$this->export_data = json_encode($exp_data_update);
|
|
||||||
$this->save();
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$assign_oaid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($assign_oaid) {
|
||||||
|
// assign oaid to Wohneinheit FTU
|
||||||
|
$resp_data = $rimo->assignOaid($ftu_data['id']);
|
||||||
|
|
||||||
|
// update OAID export data
|
||||||
|
$exp_data_update = json_decode($this->export_data);
|
||||||
|
$exp_data_update->rimo->ftu_id = $ftu_data['id'];
|
||||||
|
$exp_data_update->rimo->ftu_name = $ftu_data['name'];
|
||||||
|
$exp_data_update->rimo->ftu_assigned_date = date("U");
|
||||||
|
$this->export_data = json_encode($exp_data_update);
|
||||||
|
$this->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -172,39 +178,10 @@ class OpenAccessId extends mfBaseModel {
|
|||||||
* assign OAID to FTU - POST /v1/oaid-management/oaids/{oaidName}/ftu/{ftuExternalId}
|
* assign OAID to FTU - POST /v1/oaid-management/oaids/{oaidName}/ftu/{ftuExternalId}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
// check if we assigned the OAID to a RIMO FTU already
|
// check if we assigned the OAID to a RIMO FTU already
|
||||||
$existing_rimo_export_data = $this->getExportData("rimo");
|
$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)) {
|
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);
|
$resp_data = $rimo->assignOaid($unit_extdata->rimo->ftu->id);
|
||||||
|
|
||||||
// add FTU id to external_data
|
// add FTU id to external_data
|
||||||
@@ -227,7 +204,7 @@ class OpenAccessId extends mfBaseModel {
|
|||||||
} else {
|
} else {
|
||||||
$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already assigned to FTU in Rimo");
|
$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already assigned to FTU in Rimo");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class OpenAccessId_Helper_Rimo {
|
|||||||
$response = file_get_contents($get_url, false, $ctx);
|
$response = file_get_contents($get_url, false, $ctx);
|
||||||
|
|
||||||
if($response === false) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class OpenAccessId_Helper_Rimo {
|
|||||||
$response = file_get_contents($get_url, false, $ctx);
|
$response = file_get_contents($get_url, false, $ctx);
|
||||||
//var_dump($response);exit;
|
//var_dump($response);exit;
|
||||||
if($response === false) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ class OpenAccessId_Helper_Rimo {
|
|||||||
$response = file_get_contents($post_url, false, $ctx);
|
$response = file_get_contents($post_url, false, $ctx);
|
||||||
//var_dump($response);exit;
|
//var_dump($response);exit;
|
||||||
if($response === false) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ class OpenAccessId_Helper_Rimo {
|
|||||||
$response = file_get_contents($delete_url, false, $ctx);
|
$response = file_get_contents($delete_url, false, $ctx);
|
||||||
|
|
||||||
if($response === false) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ class OpenAccessId_Helper_Rimo {
|
|||||||
$response = file_get_contents($post_url, false, $ctx);
|
$response = file_get_contents($post_url, false, $ctx);
|
||||||
|
|
||||||
if($response === false) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -529,7 +529,7 @@ class PreordercampaignController extends mfBaseController {
|
|||||||
$assigned_oaids = 0;
|
$assigned_oaids = 0;
|
||||||
$multiple_unit = 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") {
|
if($preorder->type == "interest") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -608,7 +608,7 @@ class PreordercampaignController extends mfBaseController {
|
|||||||
$workorders_created = 0;
|
$workorders_created = 0;
|
||||||
$workorders_failed = 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) {
|
if($preorder->workorder_export_date) {
|
||||||
$this->log->warning(__METHOD__.": workorder_export_date not null");
|
$this->log->warning(__METHOD__.": workorder_export_date not null");
|
||||||
}
|
}
|
||||||
@@ -754,7 +754,7 @@ class PreordercampaignController extends mfBaseController {
|
|||||||
$missing_extrefs = 0;
|
$missing_extrefs = 0;
|
||||||
$missing_oaid = 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") {
|
if($preorder->type == "interest") {
|
||||||
$this->log->debug(__METHOD__.": Ignoring Preorder ".$preorder->id.": is interest");
|
$this->log->debug(__METHOD__.": Ignoring Preorder ".$preorder->id.": is interest");
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
,fronk,fronk-nb,23.01.2024 21:03,file:///home/fronk/.config/libreoffice/4;
|
|
||||||
Reference in New Issue
Block a user