From cdae3cd24aa01ac49b0e982b4a161d2c2236b409 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 23 May 2023 16:21:41 +0200 Subject: [PATCH 1/2] Added voicenumber to OrderProduct --- Layout/default/Order/Form.php | 45 +++++++++++++++++++++-- application/Order/OrderController.php | 18 +++++++++ application/OrderProduct/OrderProduct.php | 13 +++++++ 3 files changed, 72 insertions(+), 4 deletions(-) diff --git a/Layout/default/Order/Form.php b/Layout/default/Order/Form.php index 4616147ee..88fcedd59 100644 --- a/Layout/default/Order/Form.php +++ b/Layout/default/Order/Form.php @@ -623,7 +623,23 @@ - + product->attributes) && count($product->product->attributes)) + && (array_key_exists(TT_ATTRIB_VOICENUMBER_REQUIRED_NAME, $product->product->attributes) + && $product->product->attributes[TT_ATTRIB_VOICENUMBER_REQUIRED_NAME]->value == 1) + || $product->voicenumber + ): ?> +
+ +
@@ -709,8 +725,6 @@
- -
- +
@@ -1193,6 +1214,13 @@ $('#termination_id-' + id + '-line').hide(); //$('#termination_id-' + id + '-line').hide(); } + + if(typeof p.attributes === 'object' && "needs_number" in p.attributes && p.attributes.needs_number == 1) { + console.log("needs_number"); + $('#voicenumber-' + id + '-line').show(); + } else { + $('#voicenumber-' + id + '-line').hide(); + } }, 'json'); @@ -1509,6 +1537,15 @@
\ \ \ + \ +\
\ \
\ diff --git a/application/Order/OrderController.php b/application/Order/OrderController.php index f870a3cc8..c20415167 100644 --- a/application/Order/OrderController.php +++ b/application/Order/OrderController.php @@ -894,6 +894,24 @@ class OrderController extends mfBaseController { $product_data['termination_id'] = null; } + if(array_key_exists(TT_ATTRIB_VOICENUMBER_REQUIRED_NAME, $prod->attributes) && $prod->attributes[TT_ATTRIB_VOICENUMBER_REQUIRED_NAME]->value == 1) { + $voicenumbers = []; + foreach(explode("\n", $p['voicenumber']) as $number) { + $number = preg_replace('/\D/', '', trim($number)); + if(substr($number, 0, 2) == "00") $number = "+".substr($number, 2); + if(preg_match('/^0[^0]/', $number)) { + $number = "+43".substr($number, 1); + } + if(substr($number, 0, 1) != "+") $number = "+$number"; + if($number && !in_array($number, $voicenumbers)) $voicenumbers[] = $number; + + } + + $product_data['voicenumber'] = json_encode($voicenumbers); + } else { + $product_data['voicenumber'] = null; + } + if(!$orderproduct_id) { $product = OrderProductModel::create($product_data); diff --git a/application/OrderProduct/OrderProduct.php b/application/OrderProduct/OrderProduct.php index d0aaaaae2..51aeab334 100644 --- a/application/OrderProduct/OrderProduct.php +++ b/application/OrderProduct/OrderProduct.php @@ -6,6 +6,7 @@ class OrderProduct extends mfBaseModel { private $termination; private $cpeprovisioning; private $contract; + private $voicenumbers; private $editor; private $creator; @@ -50,6 +51,18 @@ class OrderProduct extends mfBaseModel { return $this->contract; } + if($name == "voicenumbers") { + $this->voicenumbers = []; + if(!$this->voicenumber) return []; + + $json = json_decode($this->voicenumber); + + if(!is_array($json)) return []; + $this->voicenumbers = $json; + + return $this->voicenumbers; + } + if($name == "creator") { $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); if($this->creator === null) { From 426170a8c18067097bf41745d2377d83203f9291 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 24 May 2023 14:39:50 +0200 Subject: [PATCH 2/2] Added rimo filters to Preorder --- Layout/default/Preorder/Index.php | 19 ++++++++++++++++++ application/Preorder/PreorderController.php | 20 +++++++++++++++++-- application/Preorder/PreorderModel.php | 4 ++++ .../PreordercampaignController.php | 2 +- .../01-addressdb_update_buildings.php | 6 +++--- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index 263879811..537eeb979 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -136,6 +136,25 @@
+ +
+ + +
+ +
+ + +
+ diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php index bb6dec5be..78358d980 100644 --- a/application/Preorder/PreorderController.php +++ b/application/Preorder/PreorderController.php @@ -163,10 +163,26 @@ class PreorderController extends mfBaseController { unset($filter['unit_missing']); } - if(array_key_exists("attributes", $filter) && count($filter['attributes'])) { - + if(array_key_exists("rimo_home_extref", $filter)) { + if($filter['rimo_home_extref'] == "1") { + $new_filter['add-where'] = " AND (adb_wohneinheit.extref IS NOT NULL AND adb_wohneinheit.extref like 'SDIHome_%')"; + } elseif($filter['rimo_home_extref'] == "0") { + $new_filter['add-where'] = " AND (adb_wohneinheit.extref IS NULL OR adb_wohneinheit.extref NOT LIKE 'SDIHome_%')"; + } } + if(array_key_exists("rimo_workorder", $filter)) { + if($filter["rimo_workorder"] == "1") { + $new_filter['workorder_export_date'] = true; + } else { + $new_filter['workorder_export_date'] = false; + } + } + + /*if(array_key_exists("attributes", $filter) && count($filter['attributes'])) { + + }*/ + if(is_array($filter) && count($filter)) { foreach($filter as $name => $value) { $new_filter[$name] = $value; diff --git a/application/Preorder/PreorderModel.php b/application/Preorder/PreorderModel.php index 3f4a1be80..acf6989da 100644 --- a/application/Preorder/PreorderModel.php +++ b/application/Preorder/PreorderModel.php @@ -220,6 +220,7 @@ class PreorderModel { $sql = "SELECT COUNT(*) as cnt FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id) LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id) + LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_hausnummer_id = adb_wohneinheit.hausnummer_id) WHERE $where "; @@ -242,6 +243,7 @@ class PreorderModel { $sql = "SELECT tt_preorder.* FROM `".FRONKDB_DBNAME."`.Preorder tt_preorder LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id) LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id) + LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_hausnummer_id = adb_wohneinheit.hausnummer_id) WHERE $where ORDER BY lastname, firstname "; @@ -445,6 +447,8 @@ class PreorderModel { $workorder_export_date = $filter['workorder_export_date']; if($workorder_export_date === null || $workorder_export_date === false) { $where .= " AND (tt_preorder.workorder_export_date IS NULL OR tt_preorder.workorder_export_date = 0)"; + } elseif($workorder_export_date) { + $where .= " AND tt_preorder.workorder_export_date > 1"; } } diff --git a/application/Preordercampaign/PreordercampaignController.php b/application/Preordercampaign/PreordercampaignController.php index 576804b1e..2a1472fe9 100644 --- a/application/Preordercampaign/PreordercampaignController.php +++ b/application/Preordercampaign/PreordercampaignController.php @@ -447,7 +447,7 @@ class PreordercampaignController extends mfBaseController { $workorders_created = 0; $workorders_failed = 0; - foreach(PreorderModel::search(["preordercampaign_id" => $id, "workorder_export_date" => null]) as $preorder) { + foreach(PreorderModel::search(["preordercampaign_id" => $id, "workorder_export_date" => null, 'deleted' => 0]) as $preorder) { if($preorder->workorder_export_date) { $this->log->warning(__METHOD__.": workorder_export_date not null"); } diff --git a/scripts/addressdb/st-stefan-ob-stainz/01-addressdb_update_buildings.php b/scripts/addressdb/st-stefan-ob-stainz/01-addressdb_update_buildings.php index 756450a31..e6bfcc420 100644 --- a/scripts/addressdb/st-stefan-ob-stainz/01-addressdb_update_buildings.php +++ b/scripts/addressdb/st-stefan-ob-stainz/01-addressdb_update_buildings.php @@ -113,8 +113,8 @@ while($csv = fgetcsv($input, 0, ";")) { if($strasse_name == "Schilcherlandsiedlung") $strasse_name = "Schilcherland Siedlung"; //if($strasse_name == "Bierbaumer Strasse") $strasse_name = "Bierbaumerstrasse"; if(preg_match('/GST(\s+\.)?$/', $strasse_name) && !$adrcd) continue; - if(preg_match('/^L\d+/',$strasse_name)) continue; - if(preg_match('/^BP/',$strasse_name)) continue; + if(preg_match('/^L\d+/',$strasse_name) && !$adrcd) continue; + if(preg_match('/^BP/',$strasse_name) && !$adrcd) continue; if($strasse_name == "Lemsitz GNR") { @@ -209,7 +209,7 @@ while($csv = fgetcsv($input, 0, ";")) { $sql = "SELECT * FROM view_hausnummer WHERE gemeinde_id = $gemeinde_id AND strasse IN ('". implode("', '", $strasse_search)."') AND hausnummer='$hausnummer_name'"; - echo "$sql\n"; + //echo "$sql\n"; /*if(preg_match('/^Tobelbader/i',$strasse_name)) { echo "$sql\n"; }*/