Added status to Adressdb export; added loading indicator in Preorder
detail view
This commit is contained in:
@@ -50,6 +50,8 @@ class Preorder extends mfBaseModel {
|
||||
|
||||
// Cascade status changes down to adb_hausnummer and adb_wohneinheit
|
||||
$this->cascadeStatus();
|
||||
// Cascade status changes down all active preorders with the same hausnummer
|
||||
$this->cascadeStatusToPreorders();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -138,6 +140,31 @@ class Preorder extends mfBaseModel {
|
||||
|
||||
}
|
||||
|
||||
private function cascadeStatusToPreorders() {
|
||||
$status = new Preorderstatus($this->status_id);
|
||||
if(!$status->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->adb_hausnummer_id) {
|
||||
foreach(PreorderModel::search(["deleted" => 0, "adb_hausnummer_id" => $this->adb_hausnummer_id, "<status_code" => $status->code]) as $preorder) {
|
||||
if($preorder->id == $this->id) continue;
|
||||
|
||||
/*if(!$preorder->status->code || !$status->code) {
|
||||
$this->log->debug("Preorder->status->code". print_r($preorder->status, true));
|
||||
$this->log->debug("Status->code". print_r($status->code, true));
|
||||
}*/
|
||||
|
||||
if($preorder->status->code < $status->code && $status->code <= 244) {
|
||||
$preorder->status_id = $this->status_id;
|
||||
$preorder->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setOrCreateOaid($oaid_attributes = false) {
|
||||
$campaign = new Preordercampaign($this->preordercampaign_id);
|
||||
//var_dump($campaign);exit;
|
||||
|
||||
@@ -966,8 +966,26 @@ class PreorderController extends mfBaseController {
|
||||
$preorder->status_id = $status_id;
|
||||
$preorder->save();
|
||||
|
||||
$update = [];
|
||||
|
||||
$update = [
|
||||
foreach(PreorderModel::search(["deleted" => 0, "adb_hausnummer_id" => $preorder->adb_hausnummer_id]) as $affected_preorder) {
|
||||
$up = [
|
||||
"id" => $affected_preorder->id,
|
||||
"sid" => $affected_preorder->status_id,
|
||||
"code" => $affected_preorder->status->code,
|
||||
"text" => $affected_preorder->status->name,
|
||||
"bcode" => $affected_preorder->adb_hausnummer->status->code,
|
||||
"btext" => $affected_preorder->adb_hausnummer->status->name,
|
||||
];
|
||||
if($preorder->adb_wohneinheit_id) {
|
||||
$up["ucode"] = $affected_preorder->adb_wohneinheit->status->code;
|
||||
$up["utext"] = $affected_preorder->adb_wohneinheit->status->name;
|
||||
}
|
||||
|
||||
$update[] = $up;
|
||||
}
|
||||
|
||||
/* $update = [
|
||||
"preorder" => [
|
||||
"status" => [
|
||||
"id" => $status->id,
|
||||
@@ -996,8 +1014,8 @@ class PreorderController extends mfBaseController {
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return ["message" => "Status saved successfully", "id" => $preorder_id, "update" => $update];
|
||||
*/
|
||||
return ["message" => "Status saved successfully", "id" => $preorder_id, "updates" => $update];
|
||||
}
|
||||
|
||||
private function deleteWorkorderApi() {
|
||||
|
||||
Reference in New Issue
Block a user