Fixed statusflags only set on Adddresses with Preorder and added snopp
connected api
This commit is contained in:
@@ -14,6 +14,7 @@ class ADBHausnummer extends mfBaseModel {
|
||||
protected function init() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->table = "Hausnummer";
|
||||
mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, 0);
|
||||
}
|
||||
|
||||
public function afterSave() {
|
||||
|
||||
@@ -78,17 +78,27 @@ class AddressDB {
|
||||
//echo "in handleRimoStatusUpdate\n";
|
||||
|
||||
$wohneinheit = new ADBWohneinheit($wohneinheit_id);
|
||||
if(!$wohneinheit->id) return false;
|
||||
if(!$wohneinheit->id) {
|
||||
//echo "no wohneinheit\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
$hausnummer = $wohneinheit->hausnummer;
|
||||
if(!$hausnummer->netzgebiet->getOption("statuschange")) {
|
||||
//echo "no option statuschange\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
$order_type = false;
|
||||
|
||||
$preorder = PreorderModel::getFirstActive(["adb_wohneinheit_id" => $wohneinheit->id]);
|
||||
if(!$preorder) {
|
||||
return true;
|
||||
if($preorder) {
|
||||
$order_type = $preorder->type;
|
||||
}
|
||||
/*if(!$preorder) {
|
||||
echo "no preorder\n";
|
||||
return true;
|
||||
}*/
|
||||
|
||||
$b_ex_state = strtolower($hausnummer->rimo_ex_state);
|
||||
$b_op_state = strtolower($hausnummer->rimo_op_state);
|
||||
@@ -103,7 +113,7 @@ class AddressDB {
|
||||
}
|
||||
|
||||
|
||||
$order_type = $preorder->type;
|
||||
|
||||
|
||||
$status_matrix = array_reverse(TT_PREORDER_RIMO_STATUS_MATRIX);
|
||||
|
||||
@@ -130,19 +140,19 @@ class AddressDB {
|
||||
|
||||
if($matrix["rwo"] && (!$workorder || $matrix["rwo"] != $wo_state)) continue;
|
||||
|
||||
if($matrix["pt"] && $matrix["pt"] != $order_type) continue;
|
||||
if($matrix["pt"] && $order_type && $matrix["pt"] != $order_type) continue;
|
||||
// seems all criteria match => set new status
|
||||
|
||||
$log->debug(__METHOD__.": new Preorder Status: ".$matrix["p"]);
|
||||
|
||||
$preorderstatus = $matrix["p"];
|
||||
if(!$preorderstatus) {
|
||||
continue;
|
||||
if($preorder) {
|
||||
$preorderstatus = $matrix["p"];
|
||||
if($preorderstatus) {
|
||||
$preorder->setNewStatusCode($preorderstatus);
|
||||
$preorder->save();
|
||||
}
|
||||
}
|
||||
|
||||
$preorder->setNewStatusCode($preorderstatus);
|
||||
$preorder->save();
|
||||
|
||||
$hausnummer_status = $matrix["h"];
|
||||
if($hausnummer_status) {
|
||||
$log->debug(__METHOD__.": new Hausnummer (".$hausnummer->id.") status: ".$matrix["h"]);
|
||||
|
||||
@@ -43,4 +43,32 @@ class Snopp extends Modules\ApiControllerModule
|
||||
|
||||
return \mfResponse::Ok(["message" => "OK"]);
|
||||
}
|
||||
|
||||
public function setPreorderActive($id) {
|
||||
if(!$id || !is_numeric($id)) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
}
|
||||
|
||||
$wohneinheit = new \ADBWohneinheit($id);
|
||||
if(!$wohneinheit->id) {
|
||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||
}
|
||||
|
||||
$preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $id]);
|
||||
if(!$preorder) {
|
||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||
}
|
||||
|
||||
$new_status = \PreorderstatusModel::getFirst(["code" => 500]);
|
||||
if(!$new_status) {
|
||||
return \mfResponse::InternalServerError();
|
||||
}
|
||||
|
||||
if($preorder->status->code < $new_status->code) {
|
||||
$preorder->status_id = $new_status->id;
|
||||
$preorder->save();
|
||||
}
|
||||
|
||||
return \mfResponse::Ok(["message" => "OK"]);
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ class OperationaldataApicontroller extends mfBaseApicontroller
|
||||
$this->addRoute("/operationaldata/buildings", "getBuildingsByCampaign", "GET");
|
||||
|
||||
$this->addRoute("/operationaldata/home/:id/connected", [$modules["Snopp"], "setPreorderConnected"], "POST");
|
||||
$this->addRoute("/operationaldata/home/:id/active", [$modules["Snopp"], "setPreorderActive"], "POST");
|
||||
|
||||
/*$this->addRoute("/preorder/open", "getOpenPreorders", "GET");
|
||||
$this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "getCifData"], "GET");
|
||||
|
||||
@@ -48,7 +48,7 @@ class PreorderHistory extends mfBaseModel {
|
||||
if(array_key_exists(1, $m)) {
|
||||
$id = $m[1];
|
||||
$psf = new Preorderstatusflag($id);
|
||||
return "Status Flag ".$psf->name;
|
||||
return "Status Flag ".$psf->code." - ".$psf->name;
|
||||
}
|
||||
}
|
||||
return $key;
|
||||
|
||||
@@ -258,11 +258,15 @@ foreach ($clusters as $cluster_data) {
|
||||
if($b_executionstate_label != $hausnummer->rimo_ex_state) {
|
||||
$hausnummer->rimo_ex_state = $b_executionstate_label;
|
||||
$hausnummer->save();
|
||||
//echo "saved executionstate\n";
|
||||
\mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$hausnummer->id, 0);
|
||||
$hausnummer = new \ADBHausnummer($hausnummer_id);
|
||||
}
|
||||
if($b_operationalstate_label != $hausnummer->rimo_op_state) {
|
||||
$hausnummer->rimo_op_state = $b_operationalstate_label;
|
||||
$hausnummer->save();
|
||||
//echo "saved operationalstate\n";
|
||||
\mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$hausnummer->id, 0);
|
||||
$hausnummer = new \ADBHausnummer($hausnummer_id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user