Merge branch 'fronkdev' into 'master'
Updated OpenAccessId::exportToRimoAndAssignFtu() See merge request fronk/thetool!197
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
$thetime = microtime(true);
|
||||
|
||||
$additionalJS = ["plugins/chart.js/Chart.min.js"];
|
||||
|
||||
@@ -432,4 +434,8 @@ $chartColors = [
|
||||
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
<?php
|
||||
$thetime = microtime(true) - $thetime;
|
||||
$this->log->debug("Rendering Dashboard page took $thetime microseconds");
|
||||
?>
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="col-lg-10">
|
||||
<?php if($oaid->adb_wohneinheit_id && is_object($oaid->adb_wohneinheit)): ?>
|
||||
<input type="text" class="form-control" disabled="disabled"
|
||||
value="[<?=$oaid->adb_wohneinheit->hausnummer->strasse->gemeinde->name?>] <?=$oaid->adb_wohneinheit->hausnummer->plz->plz?><?=$oaid->adb_wohneinheit->hausnummer->ortschaft->name?>, <?=$oaid->adb_wohneinheit->hausnummer->strasse->name?><?=$oaid->adb_wohneinheit->hausnummer->hausnummer?><?=((string)$oaid->adb_wohneinheit) ? " - ".(string)$oaid->adb_wohneinheit : ""?>"
|
||||
value="[<?=$oaid->adb_wohneinheit->hausnummer->strasse->gemeinde->name?>] <?=$oaid->adb_wohneinheit->hausnummer->plz->plz?><?=$oaid->adb_wohneinheit->hausnummer->ortschaft->name?>, <?=$oaid->adb_wohneinheit->hausnummer->strasse->name?> <?=$oaid->adb_wohneinheit->hausnummer->hausnummer?><?=((string)$oaid->adb_wohneinheit) ? " - ".(string)$oaid->adb_wohneinheit : ""?>"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -11,8 +11,6 @@ class DashboardController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
|
||||
|
||||
if($this->me->is("preorderfront")) {
|
||||
$this->redirect("Preorder");
|
||||
}
|
||||
@@ -82,8 +80,8 @@ class DashboardController extends mfBaseController {
|
||||
$status_connected = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 500]);
|
||||
|
||||
$partner_orders = $this->getPartnerOrderCount($campaign_ids);
|
||||
$partner_orders_by_status = $this->getPartnerOrdersByStatus($campaign_ids);
|
||||
|
||||
$partner_orders_by_status = $this->getPartnerOrdersByStatus($campaign_ids);
|
||||
|
||||
$total_orders = $partner_orders["total"];
|
||||
unset($partner_orders["total"]);
|
||||
|
||||
@@ -187,10 +185,10 @@ class DashboardController extends mfBaseController {
|
||||
$orders[$name] = [];
|
||||
$orders[$name]["total"] = 0;
|
||||
}
|
||||
if(!array_key_exists($preorder->status_id, $orders[$name])) {
|
||||
$orders[$name][$preorder->status_id] = 0;
|
||||
if(!array_key_exists($preorder->status->id, $orders[$name])) {
|
||||
$orders[$name][$preorder->status->id] = 0;
|
||||
}
|
||||
$orders[$name][$preorder->status_id]++;
|
||||
$orders[$name][$preorder->status->id]++;
|
||||
$orders[$name]["total"]++;
|
||||
}
|
||||
//var_dump($orders);exit;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once APPDIR."/OpenAccessId/helper/rimo.php";
|
||||
|
||||
class OpenAccessId extends mfBaseModel {
|
||||
private $owner;
|
||||
private $adb_wohneinheit;
|
||||
@@ -46,6 +48,8 @@ class OpenAccessId extends mfBaseModel {
|
||||
|
||||
|
||||
public function exportToRimoAndAssignFtu() {
|
||||
$rimo = new OpenAccessId_Helper_Rimo($this->oaid);
|
||||
|
||||
// XXX for now only support ADB Addresses
|
||||
if(!$this->adb_wohneinheit_id) {
|
||||
return true;
|
||||
@@ -68,7 +72,10 @@ class OpenAccessId extends mfBaseModel {
|
||||
$unit_extdata = new StdClass();
|
||||
|
||||
if($wohneinheit->external_data) {
|
||||
$extdata = json_decode($wohneinheit->external_data);
|
||||
$json_data = json_decode($wohneinheit->external_data);
|
||||
if(is_object($json_data)) {
|
||||
$extdata = $json_data;
|
||||
}
|
||||
|
||||
if(is_object($extdata)) {
|
||||
$unit_extdata = $extdata;
|
||||
@@ -81,39 +88,7 @@ class OpenAccessId extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($fetch_ftu) {
|
||||
// query Home to get FTU data from RIMO - GET /queryHomeWithId
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params["homeId"] = $wohneinheit->extref;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$queryHomeEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_QUERY_HOME;
|
||||
$get_url = $queryHomeEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Getting Home to fetch FTU: $get_url");
|
||||
//exit;
|
||||
$response = file_get_contents($get_url, false, $ctx);
|
||||
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim auslesen der FTU ".$this->oaid."\n");
|
||||
return false;
|
||||
}
|
||||
//$preorder->workorder_export_date = date('U');
|
||||
//$preorder->workorder_export_data = $response;
|
||||
//$preorder->save();
|
||||
$resp_data = json_decode($response);
|
||||
if(!is_object($resp_data)) {
|
||||
$this->log->error(__METHOD__.": OAID ".$this->oaid.": Cannot fetch Home from RIMO! Invalid Response!");
|
||||
return false;
|
||||
}
|
||||
$resp_data = $rimo->getFtuData($wohneinheit->extref);
|
||||
|
||||
if(!is_array($resp_data->ftus->item) || !count($resp_data->ftus->item)) {
|
||||
$this->log->warning(__METHOD__.": Homes ftus object has no items ".$this->oaid);
|
||||
@@ -140,129 +115,60 @@ 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) || !isset($existing_rimo_export_data->name)) {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params['oaidName'] = $this->oaid;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
//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->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']) {
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
$resp_data = $rimo->getOaid();
|
||||
|
||||
$createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_CREATE_OAID;
|
||||
$post_url = $createOrderEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Creating OAID in Rimo: $post_url");
|
||||
$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");
|
||||
$workorders_failed++;
|
||||
return false;
|
||||
if(!$resp_data) {
|
||||
// oaid was not found in rimo, try creating it
|
||||
$this->createInRimo();
|
||||
$resp_data = $rimo->getOaid();
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!$resp_data->id || !$resp_data->name) {
|
||||
$this->log->warning(__METHOD__.": Create OAID returned no ID or oaid name ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
$assign_oaid = false;
|
||||
|
||||
// mark OAID as exported
|
||||
$oaid_export_data = new StdClass();
|
||||
if($this->export_data) {
|
||||
$oaid_export_data = json_decode($this->export_data);
|
||||
}
|
||||
if(!isset($oaid_export_data->rimo)) {
|
||||
$oaid_export_data->rimo = new StdClass();
|
||||
}
|
||||
$oaid_export_data->rimo->oaid_id = $resp_data->id;
|
||||
$oaid_export_data->rimo->name = $resp_data->name;
|
||||
$oaid_export_data->rimo->ftu_id = null;
|
||||
$this->exported_to = "rimo";
|
||||
$this->exported = date('U');
|
||||
$this->export_data = json_encode($oaid_export_data);
|
||||
$this->save();
|
||||
} else {
|
||||
$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']) {
|
||||
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$getOaidEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_GET_OAID;
|
||||
$getOaidEp .= "/".$this->oaid;
|
||||
$get_url = $getOaidEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Getting OAID from Rimo: $get_url");
|
||||
$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");
|
||||
return false;
|
||||
if($resp_data && $resp_data->terminiationUnit && $resp_data->terminiationUnit->id) {
|
||||
if($ftu_data['id'] != $resp_data->terminiationUnit->id) {
|
||||
$old_ftu_id = $resp_data->terminiationUnit->id;
|
||||
|
||||
// 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']);
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if($resp_data->terminiationUnit && $resp_data->terminiationUnit->id) {
|
||||
if($ftu_data['id'] != $resp_data->terminiationUnit->id) {
|
||||
$old_ftu_id = $resp_data->terminiationUnit->id;
|
||||
|
||||
|
||||
// unassign oaid from FTU
|
||||
$ctx_opts["http"]["method"] = "DELETE";
|
||||
$unassignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_UNASSIGN_OAID_TO_FTU;
|
||||
$unassignEp = str_replace("{oaidName}", $this->oaid, $unassignEp);
|
||||
$unassignEp = str_replace("{ftuExternalId}", $old_ftu_id, $unassignEp);
|
||||
|
||||
$delete_url = $unassignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Unassigning OAID from FTU $old_ftu_id: $delete_url");
|
||||
$response = file_get_contents($delete_url, false, $ctx);
|
||||
|
||||
|
||||
// assign oaid to Wohneinheit FTU
|
||||
$ctx_opts["http"]["method"] = "POST";
|
||||
$assignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_ASSIGN_OAID_TO_FTU;
|
||||
$assignEp = str_replace("{oaidName}", $this->oaid, $assignEp);
|
||||
$assignEp = str_replace("{ftuExternalId}", $ftu_data['id'], $assignEp);
|
||||
|
||||
$post_url = $assignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Assigning OAID to current FTU ".$ftu_data['id'].": $post_url");
|
||||
$response = file_get_contents($post_url, false, $ctx);
|
||||
|
||||
// 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($ext_data_update);
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -272,42 +178,19 @@ 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
|
||||
$oaid_export_data = new StdClass();
|
||||
if($this->export_data) {
|
||||
$oaid_export_data = json_decode($this->export_data);
|
||||
$json_data = json_decode($this->export_data);
|
||||
if(is_object($json_data)) {
|
||||
$oaid_export_data = $json_data;
|
||||
}
|
||||
}
|
||||
if(!isset($oaid_export_data->rimo)) {
|
||||
$oaid_export_data->rimo = new StdClass();
|
||||
@@ -321,6 +204,36 @@ class OpenAccessId extends mfBaseModel {
|
||||
} else {
|
||||
$this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already assigned to FTU in Rimo");
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createInRimo() {
|
||||
$rimo = new OpenAccessId_Helper_Rimo($this->oaid);
|
||||
|
||||
$resp_data = $rimo->createOaid();
|
||||
if(!$resp_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// mark OAID as exported
|
||||
$oaid_export_data = new StdClass();
|
||||
if($this->export_data) {
|
||||
$json_data = json_decode($this->export_data);
|
||||
if(is_object($json_data)) {
|
||||
$oaid_export_data = $json_data;
|
||||
}
|
||||
}
|
||||
if(!isset($oaid_export_data->rimo)) {
|
||||
$oaid_export_data->rimo = new StdClass();
|
||||
}
|
||||
$oaid_export_data->rimo->oaid_id = $resp_data->id;
|
||||
$oaid_export_data->rimo->name = $resp_data->name;
|
||||
$oaid_export_data->rimo->ftu_id = null;
|
||||
$this->exported_to = "rimo";
|
||||
$this->exported = date('U');
|
||||
$this->export_data = json_encode($oaid_export_data);
|
||||
$this->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,9 @@ class OpenAccessIdController extends mfBaseController {
|
||||
// get old and new unit_id
|
||||
$old_unit = ADBWohneinheitModel::getFirst(["oaid" => $oaid->oaid]);
|
||||
$new_unit = new ADBWohneinheit($this->request->new_unit_id);
|
||||
|
||||
if(!$new_unit->id) {
|
||||
$new_unit = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
179
application/OpenAccessId/helper/rimo.php
Normal file
179
application/OpenAccessId/helper/rimo.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
class OpenAccessId_Helper_Rimo {
|
||||
private $log;
|
||||
public $oaid;
|
||||
|
||||
public function __construct($oaid) {
|
||||
$this->oaid = $oaid;
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
public function getFtuData($home_external_id) {
|
||||
// query Home to get FTU data from RIMO - GET /queryHomeWithId
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params["homeId"] = $home_external_id;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$queryHomeEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_QUERY_HOME;
|
||||
$get_url = $queryHomeEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Getting Home to fetch FTU: $get_url");
|
||||
$response = file_get_contents($get_url, false, $ctx);
|
||||
|
||||
if($response === false) {
|
||||
$this->log->error("Fehler beim auslesen der FTU ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!is_object($resp_data)) {
|
||||
$this->log->error(__METHOD__.": OAID ".$this->oaid.": Cannot fetch Home from RIMO! Invalid Response!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function getOaid() {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'GET',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
//echo $qs."\n";
|
||||
|
||||
$getOaidEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_GET_OAID;
|
||||
$getOaidEp .= "/".$this->oaid;
|
||||
$get_url = $getOaidEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Getting OAID from Rimo: $get_url");
|
||||
$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);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!is_object($resp_data)) {
|
||||
$this->log->error(__METHOD__.": OAID ".$this->oaid.": Cannot fetch OAID from RIMO! Invalid Response!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function createOaid() {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
$params['oaidName'] = $this->oaid;
|
||||
|
||||
$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_CREATE_OAID;
|
||||
$post_url = $createOrderEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Creating OAID in Rimo: $post_url");
|
||||
$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);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
if(!$resp_data->id || !$resp_data->name) {
|
||||
$this->log->warning(__METHOD__.": Create OAID returned no ID or oaid name ".$this->oaid);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function unassignOaid($ftu_external_id) {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'DELETE',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$unassignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_UNASSIGN_OAID_TO_FTU;
|
||||
$unassignEp = str_replace("{oaidName}", $this->oaid, $unassignEp);
|
||||
$unassignEp = str_replace("{ftuExternalId}", $ftu_external_id, $unassignEp);
|
||||
|
||||
$delete_url = $unassignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Unassigning OAID from FTU $ftu_external_id: $delete_url");
|
||||
$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");
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
return $resp_data;
|
||||
}
|
||||
|
||||
public function assignOaid($ftu_external_id) {
|
||||
$params = [];
|
||||
$params['apiKey'] = RIMO_API_JSON_APIKEY;
|
||||
|
||||
$ctx_opts = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'header' => 'accept: application/json'
|
||||
]
|
||||
];
|
||||
|
||||
$qs = http_build_query($params);
|
||||
|
||||
$assignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_ASSIGN_OAID_TO_FTU;
|
||||
$assignEp = str_replace("{oaidName}", $this->oaid, $assignEp);
|
||||
$assignEp = str_replace("{ftuExternalId}", $ftu_external_id, $assignEp);
|
||||
|
||||
$post_url = $assignEp."?".$qs;
|
||||
$ctx = stream_context_create($ctx_opts);
|
||||
$this->log->debug(__METHOD__.": Assigning OAID to current FTU $ftu_external_id: $post_url");
|
||||
$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);
|
||||
return false;
|
||||
}
|
||||
|
||||
$resp_data = json_decode($response);
|
||||
return $resp_data;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
,fronk,fronk-nb,23.01.2024 21:03,file:///home/fronk/.config/libreoffice/4;
|
||||
Reference in New Issue
Block a user