new OAID type "other" / added adrcd to preorderreporting api
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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'];
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user