diff --git a/Layout/default/Building/Index.php b/Layout/default/Building/Index.php index 0ef681c28..d38976c79 100644 --- a/Layout/default/Building/Index.php +++ b/Layout/default/Building/Index.php @@ -165,7 +165,7 @@ units?> status->name."-b")?> - + create)?> (creator->name?>)
edit)?> (editor->name?>) diff --git a/Layout/default/Preordercampaign/Form.php b/Layout/default/Preordercampaign/Form.php index 30479998d..8db2ea694 100644 --- a/Layout/default/Preordercampaign/Form.php +++ b/Layout/default/Preordercampaign/Form.php @@ -158,6 +158,9 @@ + @@ -377,73 +380,81 @@

Emailbenachrichtigungen

-
-
-

Absender

-
- -
- -
-
-
- -
- -
-
- -

Emailtemplates

- -
"> - - + +
+
+

Absender

+
+
-
-
-
-
- code?> + +
+
+
+ +
+ +
+
+ +

Emailtemplates

+ +
"> + + +
+
+
+
+
+ code?> +
+
-
-
-
-
-
- @ -
- -
- +
+
+
+ @ +
+ +
+ +
-
-
-
-
- +
+
+
+ +
+
-
- - + +
-
+ +
+
+ Verfügbar nach Speichern... +
+
+

API-User

@@ -566,30 +577,32 @@ background: "bg-danger" }); - function sendTestStatusEmail(status_code) { - if(!status_code) return; + + function sendTestStatusEmail(status_code) { + if(!status_code) return; - var template_id = $("#mailtemplate-" + status_code).val(); - var email_to = $("#test-to-" + status_code).val(); + var template_id = $("#mailtemplate-" + status_code).val(); + var email_to = $("#test-to-" + status_code).val(); - $.post("", - { - do: "sendStatusEmail", - campaign_id: id?>, - template_id: template_id, - to_email: email_to - }, - (success) => { - if(success.status == "OK") { - window.notify("success", "Testmail wurde versendet"); - } else { - window.notify("error", "Beim versenden ist ein Fehler aufgetragen."); - } + $.post("", + { + do: "sendStatusEmail", + campaign_id: id?>, + template_id: template_id, + to_email: email_to + }, + (success) => { + if(success.status == "OK") { + window.notify("success", "Testmail wurde versendet"); + } else { + window.notify("error", "Beim versenden ist ein Fehler aufgetragen."); + } - console.log(success); - }, - "json" - ); - } + console.log(success); + }, + "json" + ); + } + \ No newline at end of file diff --git a/application/ADBWohneinheit/ADBWohneinheit.php b/application/ADBWohneinheit/ADBWohneinheit.php index 1dcfe0aad..552ef9c6b 100644 --- a/application/ADBWohneinheit/ADBWohneinheit.php +++ b/application/ADBWohneinheit/ADBWohneinheit.php @@ -8,6 +8,7 @@ class ADBWohneinheit extends mfBaseModel { private $status; private $statusflags; // TODO private $preorders; + private $active_preorders; protected function init() { $this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); @@ -316,6 +317,15 @@ class ADBWohneinheit extends mfBaseModel { return $this->preorders; } + if($name == "active_preorders") { + $preorders = PreorderModel::searchActive(["adb_wohneinheit_id" => $this->id]); + if(!count($preorders)) { + return []; + } + $this->preorders = $preorders; + return $this->preorders; + } + if($name == "ftu_data") { $rimo_data = $this->getExternalRimoData(); diff --git a/application/AddressDB/AddressDBController.php b/application/AddressDB/AddressDBController.php index abb0e9048..409dccfcf 100644 --- a/application/AddressDB/AddressDBController.php +++ b/application/AddressDB/AddressDBController.php @@ -1066,7 +1066,7 @@ class AddressDBController extends mfBaseController { $u['zusatz'] = $unit->zusatz; $u['usage'] = $unit->nutzung; $u['oaid'] = $unit->oaid; - $u['preorder_count'] = count($unit->preorders); + $u['preorder_count'] = count($unit->active_preorders); $results[] = $u; } diff --git a/application/Api/v1/AddressdbApicontroller.php b/application/Api/v1/AddressdbApicontroller.php index 41bfb98e8..bbf447aba 100644 --- a/application/Api/v1/AddressdbApicontroller.php +++ b/application/Api/v1/AddressdbApicontroller.php @@ -447,6 +447,9 @@ class AddressdbApicontroller extends mfBaseApicontroller { 'sort_key' => $sort_key, 'oaid' => $data->hausnummer_oaid, 'cluster_id' => $data->netzgebiet_extref, + 'visibility' => null, + 'adrcd' => null, + 'subcd' => null, 'zip' => $data->plz, 'city' => $data->gemeinde, "municipality" => "", @@ -472,6 +475,15 @@ class AddressdbApicontroller extends mfBaseApicontroller { } else { unset($tmp_addresses[$address_key]['municipality']); } + if($this->me->is("preorderaddressreporting")) { + $tmp_addresses[$address_key]['visibility'] = $data->visibility; + $tmp_addresses[$address_key]['adrcd'] = $data->adrcd; + $tmp_addresses[$address_key]['subcd'] = $data->subcd; + } else { + unset($tmp_addresses[$address_key]["visibility"]); + unset($tmp_addresses[$address_key]["adrcd"]); + unset($tmp_addresses[$address_key]["subcd"]); + } } $unit_data = [ @@ -589,6 +601,9 @@ class AddressdbApicontroller extends mfBaseApicontroller { $new_address['ordered'] = $u['ordered']; $new_address['orderType'] = $u['orderType']; $new_address['ispName'] = $u['ispName']; + $new_address['visibility'] = $ta['visibility']; + $new_address['adrcd'] = $ta['adrcd']; + $new_address['subcd'] = $ta['subcd']; } $new_address['oaid'] = $u['oaid']; $new_address['building_oaid'] = $ta['oaid']; @@ -743,6 +758,9 @@ class AddressdbApicontroller extends mfBaseApicontroller { $tmp_addresses[$address_key] = [ 'oaid' => $data->hausnummer_oaid, 'cluster_id' => $data->netzgebiet_extref, + 'visibility' => null, + 'adrcd' => null, + 'subcd' => null, 'zip' => $data->plz, 'city' => $data->gemeinde, "municipality" => "", @@ -768,7 +786,15 @@ class AddressdbApicontroller extends mfBaseApicontroller { } else { unset($tmp_addresses[$address_key]['municipality']); } - + if($this->me->is("preorderaddressreporting")) { + $tmp_addresses[$address_key]['visibility'] = $data->visibility; + $tmp_addresses[$address_key]['adrcd'] = $data->adrcd; + $tmp_addresses[$address_key]['subcd'] = $data->subcd; + } else { + unset($tmp_addresses[$address_key]["visibility"]); + unset($tmp_addresses[$address_key]["adrcd"]); + unset($tmp_addresses[$address_key]["subcd"]); + } } $unit_data = [ @@ -808,6 +834,9 @@ class AddressdbApicontroller extends mfBaseApicontroller { $new_address['ordered'] = $u['ordered']; $new_address['orderType'] = $u['orderType']; $new_address['ispName'] = $u['ispName']; + $new_address['visibility'] = $ta['visibility']; + $new_address['adrcd'] = $ta['adrcd']; + $new_address['subcd'] = $ta['subcd']; } $new_address['oaid'] = $u['oaid']; $new_address['building_oaid'] = $ta['oaid']; diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 2454c2426..ff7480d07 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -37,6 +37,12 @@ class Preorder extends mfBaseModel { } } + public function beforeSave() { + if(!isset($this->data->status_id)) { + $this->data->status_id = 1; + } + } + public function afterSave() { // reset auto magic properties $this->status = null; @@ -111,6 +117,9 @@ class Preorder extends mfBaseModel { } } + $campaign = $this->getProperty("campaign"); + if($campaign->oaid_origin == "other") return true; + if($this->adb_wohneinheit_id && is_array($this->getProperty("adb_wohneinheit")->rimo_workorders)) { foreach($this->getProperty("adb_wohneinheit")->rimo_workorders as $workorder) { Rimoapi::updateWorkorder($workorder->rimo_id, $update); @@ -425,7 +434,7 @@ class Preorder extends mfBaseModel { $new_status = new Preorderstatus($this->status_id); if(!$new_status->id) { - $this->log->warning(__METHOD__ . ": Preorder has invalid status!"); + $this->log->warning(__METHOD__ . ": Preorder has invalid status! ".print_r($this, true)); return true; } @@ -583,6 +592,23 @@ class Preorder extends mfBaseModel { return true; } + /*if($campaign->oaid_origin == "other") { + // oaid in wohneinheit übernehmen, falls in Preorder schon vorhanden + if($this->oaid) + // oaid aus wohneinheit übernehmen, falls vorhanden + + + $this->log->debug(__METHOD__.": Kampagne unterstützt keine OAIDs"); + return true; + }*/ + + if($campaign->oaid_origin == "other") { + if($wohneinheit->oaid != $this->oaid) { + $this->oaid = $wohneinheit->oaid; + } + return true; + } + if($this->oaid) { // If current OAID is from correct Origin then do nothing if($campaign->oaid_origin == "thetool") { @@ -755,6 +781,13 @@ class Preorder extends mfBaseModel { return false; } + $campaign = new Preordercampaign($this->preordercampaign_id); + + if($campaign->oaid_origin == "other") { + $this->log->debug(__METHOD__.": Kampagne unterstützt keine OAIDs"); + return false; + } + if(!$this->oaid) { $this->setOrCreateOaid(); if(!$this->oaid) { diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php index 9caf363b4..e2588193e 100644 --- a/application/Preorder/PreorderController.php +++ b/application/Preorder/PreorderController.php @@ -399,6 +399,28 @@ class PreorderController extends mfBaseController { $this->redirect("Preordercampaign"); } + $new_status = false; + if($data['adb_wohneinheit_id']) { + $unit = new ADBWohneinheit($data['adb_wohneinheit_id']); + if ($unit->id) { + $new_status = PreorderstatusModel::getFirst(["code" => $unit->status->code]); + if ($unit->hausnummer->status->code > $unit->status->code) { + $new_status = PreorderstatusModel::getFirst(["code" => $unit->hausnummer->status->code]); + } + } + } elseif($data['adb_hausnummer_id']) { + $h = new ADBHausnummer($data['adb_hausnummer_id']); + if($h->id) { + $new_status = PreorderstatusModel::getFirst(["code" => $h->status->code]); + } + } + if($new_status) { + $data["status_id"] = $new_status->id; + } else { + $data["status_id"] = 1; + } + + if($campaign->product_type != "setup_only") { $data['product_id'] = $r->product_id; diff --git a/application/Preordercampaign/PreordercampaignController.php b/application/Preordercampaign/PreordercampaignController.php index 4c606bbcd..fbc8494f0 100644 --- a/application/Preordercampaign/PreordercampaignController.php +++ b/application/Preordercampaign/PreordercampaignController.php @@ -257,8 +257,10 @@ class PreordercampaignController extends mfBaseController { if($r->oaid_origin == "ofaa") { $data['oaid_origin'] = "ofaa"; - } else { + } elseif($r->oaid_origin == "thetool") { $data['oaid_origin'] = "thetool"; + } else { + $data['oaid_origin'] = "other"; } if($r->product_type == "setup_only") { @@ -776,7 +778,7 @@ class PreordercampaignController extends mfBaseController { protected function assignOpenAccessIdsToPreordersAction() { $this->layout()->setTemplate("Preordercampaign/Admin"); - + $id = $this->request->id; if(!is_numeric($id) || !$id) { $this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error"); @@ -788,6 +790,11 @@ class PreordercampaignController extends mfBaseController { $this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error"); $this->redirect("Preordercampaign"); } + + if($campaign->oaid_origin == "other") { + $this->layout()->setFlash("Kampagne unterstützt keine OAIDs", "warning"); + $this->redirect("Preordercampaign", "Admin", ["id" => $id]); + } $assigned_oaids = 0; $multiple_unit = 0; @@ -865,6 +872,11 @@ class PreordercampaignController extends mfBaseController { $this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error"); $this->redirect("Preordercampaign"); } + + if($campaign->oaid_origin == "other") { + $this->layout()->setFlash("Kampagne unterstützt keine OAIDs, somit können keine Workorders erstellt werden", "warning"); + $this->redirect("Preordercampaign", "Admin", ["id" => $id]); + } $missing_units = []; $missing_extrefs = []; @@ -992,6 +1004,11 @@ class PreordercampaignController extends mfBaseController { $this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error"); $this->redirect("Preordercampaign"); } + + if($campaign->oaid_origin == "other") { + $this->layout()->setFlash("Kampagne unterstützt keine OAIDs", "warning"); + $this->redirect("Preordercampaign", "Admin", ["id" => $id]); + } $oaid_assigned = 0; $missing_units = 0; @@ -1058,6 +1075,11 @@ class PreordercampaignController extends mfBaseController { $this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error"); $this->redirect("Preordercampaign"); } + + if($campaign->oaid_origin == "other") { + $this->layout()->setFlash("Kampagne unterstützt keine OAIDs", "warning"); + $this->redirect("Preordercampaign", "Admin", ["id" => $id]); + } $oaid_updated = 0; diff --git a/scripts/adb-rimo-import/rimo-import.php b/scripts/adb-rimo-import/rimo-import.php index 59d850d8e..5f6663bf2 100755 --- a/scripts/adb-rimo-import/rimo-import.php +++ b/scripts/adb-rimo-import/rimo-import.php @@ -45,7 +45,8 @@ if ($argc > 1) { } //$netowners = ["estmk", "rml"]; -$netowners = ["estmk", "rml"]; +//$netowners = ["estmk", "rml"]; +$netowners = ["sbidi"]; //$netowners = ["rml"]; $apiEdition = "prod"; @@ -188,6 +189,11 @@ foreach ($clusters as $cluster_data) { } } + + $preorder_only_oaid = false; + $preorder_only_oaid = $adb_netzgebiet->getOption("preorder_only_oaid"); + $option_wo_ignore_status = $adb_netzgebiet->getOption("wo_ignore_status"); + $AddressHelper = new ADBAddressHelper\AddressHelper(["log" => $log, "db" => $adb, "netzgebiet" => $adb_netzgebiet]); /* @@ -436,7 +442,13 @@ foreach ($clusters as $cluster_data) { $rimo_oaid = $home->ftus->item[0]->oaidObject->name; $oaid = \OpenAccessIdModel::getFirst(["oaid" => $rimo_oaid]); if (!$oaid) { - echo "!!! Home hat fremde OAID: $rimo_oaid (Home " . $unit->id . "\n"; + if($preorder_only_oaid) { + // if campaign oaid handling "other" just import OAID and nothing else + $unit->oaid = $rimo_oaid; + $unit->save(); + } else { + echo "!!! Home hat fremde OAID: $rimo_oaid (Home " . $unit->id . "\n"; + } } else { $unit->oaid = $rimo_oaid; @@ -471,7 +483,7 @@ foreach ($clusters as $cluster_data) { } } else { - // + // TODO maybe check if OAIDs match? } } } @@ -709,6 +721,8 @@ foreach ($clusters as $cluster_data) { continue; } + //if(($option_wo_ignore_status == "Documented" && $workorder_status == "Documented") || $workorder_status == "Cancelled") continue; // dont import status > Executed + \mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$hausnummer->id, 0); \mfValuecache::singleton()->set("adbwohneinheit-save-nesting-level-".$unit->id, 0); //echo "Creating Workorder $rimo_workorder_id ($workorder_home_id)\n";