From 8204bf0855cc79a0e916f54a3a8973c7e575506e Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 24 Oct 2023 15:00:21 +0200 Subject: [PATCH 1/3] WIP new Preorder list --- Layout/default/Preorder/Index.php | 43 +++++++++++++++++++++++++++++-- Layout/default/menu.php | 4 +-- application/Preorder/Preorder.php | 2 ++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index 84eaad700..57c7942c1 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -228,6 +228,9 @@ + is(["Admin", "netowner"])): ?> + + is("preorderfront")): ?> @@ -244,7 +247,12 @@ - + + is(["Admin", "netowner"])): ?> + + is("preorderfront")): ?> + is(["Admin","netowner"])): ?> + + + + + +
Kampagne Bestelltyp
Bestellcode
Status
+ + campaign->name?> type, "preorder")?>
@@ -294,11 +302,20 @@
is("preorderfront")): ?> - $preorder->id])?>"> + $preorder->id])?>"> $preorder->id, "filter" => $filter])?>" class="text-danger" onclick="if(!confirm('Vorbestellung wirklich löschen?')) return false;" title="Vorbestellung Löschen">
@@ -557,5 +574,27 @@ //refreshMap(); + + + function togglePreorder(id) { + $('#preorder-detail-' + id).toggle(); + if($('#preorder-detail-' + id).is(":hidden")) { + $('#preorder-' + id).removeClass("bg-lightblue"); + $('#preorder-' + id).removeClass("text-info"); + } else { + $('#preorder-' + id).addClass("text-info"); + $('#preorder-' + id).addClass("bg-lightblue"); + } + } + + // navigation + var preorder; + var hash = window.location.hash.substr(1); + var match = hash.match(/preorder=(\d+)/); + if(match && match[1]) { + preorder = match[1] + togglePreorder(preorder); + //$('body').scrollTop($('#preorder-' + preorder).offset() - 150); + } diff --git a/Layout/default/menu.php b/Layout/default/menu.php index 7673c12bb..edb139d32 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -87,8 +87,8 @@ Netzbetrieb
diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 570cee685..5d9ec027a 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -10,6 +10,8 @@ class Preorder extends mfBaseModel { private $building; private $adb_hausnummer; private $adb_wohneinheit; + private $creator; + private $editor; private $attribute = []; From 06b51d56dff3e8ca5b1e4f20de287f3898301e9d Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 24 Oct 2023 15:32:27 +0200 Subject: [PATCH 2/3] Added new preorder-detail template --- .../Preorder/include/preorder-detail.php | 152 ++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 Layout/default/Preorder/include/preorder-detail.php diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php new file mode 100644 index 000000000..824477615 --- /dev/null +++ b/Layout/default/Preorder/include/preorder-detail.php @@ -0,0 +1,152 @@ +
+
+
+
+ + +
+ +
+ +
+
+
+
+ +
+
+
Details
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Kampagne:campaign->name?>
Status:status->code?> - status->name?>
Bestellcode:ucode?>
OAID:oaid?>
Bestelltyp:type, "preorder")?>
Partner:partner->getCompanyOrName()?>
Erstellt:create)?> (creator->name?>)
Zuletzt bearbeitet:edit)?> (editor->name?>)
+
+
+
+
+
+ +
+
+
+
+
+
+
+
Anschlussadresse
+ + + + + + + + + + + + + + +
Straße Hausnummeradb_hausnummer->strasse->name?> adb_hausnummer->hausnummer?>
PLZadb_hausnummer->plz->plz?>
Ortadb_hausnummer->ortschaft->name?>
Gemeindeadb_hausnummer->strasse->gemeinde->name?>
+ +
Nutzungseinheit
+ + + + + + + + +
IDadb_wohneinheit_id) ? $preorder->adb_wohneinheit_id : ""?>
Bezeichneradb_wohneinheit?>
+
+ +
+
Kontakt
+
+ +
+
+
+
+
+
+ +
+
+
+ +
+ +
+
RIMO
+ + +
+
+
+
+
+ + + + +
+
+
+
+
+ Files +
+
+
+
+
+ +
+
+
+
+
+ + +
+
+
+
+
+ +
+ +
+
\ No newline at end of file From 90f65abd6f5c5fcb83427883624c7b37cc6ba51f Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 31 Oct 2023 13:54:00 +0100 Subject: [PATCH 3/3] Added foldable details in Preorder Index --- Layout/default/Preorder/Index.php | 15 +- .../Preorder/include/preorder-detail.php | 334 ++++++++++++++---- application/ADBHausnummer/ADBHausnummer.php | 10 +- application/ADBStatus/ADBStatus.php | 9 + application/ADBStatus/ADBStatusModel.php | 136 +++++++ application/ADBWohneinheit/ADBWohneinheit.php | 74 ++-- application/Api/v1/PreorderApicontroller.php | 1 + application/Preorder/Preorder.php | 35 +- .../Preorderstatus/PreorderstatusModel.php | 8 +- 9 files changed, 502 insertions(+), 120 deletions(-) create mode 100644 application/ADBStatus/ADBStatus.php create mode 100644 application/ADBStatus/ADBStatusModel.php diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index 57c7942c1..c09dbb25e 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -249,7 +249,7 @@ is(["Admin", "netowner"])): ?> - + @@ -309,7 +309,7 @@ is(["Admin","netowner"])): ?> - + @@ -581,20 +581,23 @@ if($('#preorder-detail-' + id).is(":hidden")) { $('#preorder-' + id).removeClass("bg-lightblue"); $('#preorder-' + id).removeClass("text-info"); + history.replaceState(null, null, ' '); } else { $('#preorder-' + id).addClass("text-info"); $('#preorder-' + id).addClass("bg-lightblue"); + location.hash = "preorder=" + id; + return false; } } // navigation - var preorder; + var preorder_id; var hash = window.location.hash.substr(1); var match = hash.match(/preorder=(\d+)/); if(match && match[1]) { - preorder = match[1] - togglePreorder(preorder); - //$('body').scrollTop($('#preorder-' + preorder).offset() - 150); + preorder_id = match[1] + togglePreorder(preorder_id); + $('html, body').animate( {scrollTop: $('#preorder-' + preorder_id).offset().top - 230}, 200); } diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php index 824477615..94f3537c4 100644 --- a/Layout/default/Preorder/include/preorder-detail.php +++ b/Layout/default/Preorder/include/preorder-detail.php @@ -1,98 +1,254 @@
-
-
+
-
+
Details
- - - - - - - - - - - - - - - - - - - - - - - - - - +
+
+

Allgemein

+
Kampagne:campaign->name?>
Status:status->code?> - status->name?>
Bestellcode:ucode?>
OAID:oaid?>
Bestelltyp:type, "preorder")?>
Partner:partner->getCompanyOrName()?>
Erstellt:create)?> (creator->name?>)
Zuletzt bearbeitet:edit)?> (editor->name?>)
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID:id?>
Bestellcode:ucode?>
Kampagne:campaign->name?>
Status:status->code?> - status->name?>
OAID:oaid?>
Bestelltyp:type, "preorder")?>
Anschlusstyp:connection_type, "preorder")?>
Ist Zusatzbestellung:is_additional_order) ? "Ja" : "Nein"?>
Partner:partner->getCompanyOrName()?>
Erstellt:create)?> (creator->name?>)
Zuletzt bearbeitet:edit)?> (editor->name?>)
+
+
+ +

Zustimmungen

+ + + + + + + + + + + + + + + + + +
Zustimmung AGB:accept_agb) ? '' : ''?>
Zustimmung DSGVO:accept_dsgvo) ? '' : ''?>
Zustimmung Rücktrittsrecht:accept_withdrawal) ? '' : ''?>
Zustimmung Datenweitergabe:accept_marketing) ? '' : ''?>
Zustimmung Grabungsarbeiten:accept_digging) ? '' : ''?>
+ + +
+
+ + +
+
+

Bestelldaten

+ + + + + + + + + + + +
Extref:extref)?>
Adressinfo:address_info))?>
Versand an:address_info == "address") ? "Anschlussadresse" : "Kontaktadresse"?>
+
- +
+ ordered_services): ?> +

Bestellte Zusatzdienste

+ + + + + + + ordered_services as $service): ?> + + + + + + +
DienstBestelltDaten
service?>ordered == true || $service->ordered == 1) ? "Ja" : "Nein"?> + data): ?> + data as $data): ?> + name?>: value?>
+ + +
+ +
+ +
-
+
-
+
+ +
Addressdetails
+
-
Anschlussadresse
- + +

Anschlussadresse

+
- + + + + + + + + + + + + + - - - - - + +
Straße HausnummerIDadb_hausnummer_id?>
OAIDadb_hausnummer->oaid?>
Statusadb_hausnummer->status->code?> - adb_hausnummer->status->name?>
Extrefadb_hausnummer->extref?>
Straße/Hausnummer adb_hausnummer->strasse->name?> adb_hausnummer->hausnummer?>
PLZadb_hausnummer->plz->plz?>
Ortadb_hausnummer->ortschaft->name?>PLZ Ortadb_hausnummer->plz->plz?> adb_hausnummer->ortschaft->name?>
Gemeinde adb_hausnummer->strasse->gemeinde->name?>
-
Nutzungseinheit
- +

Nutzungseinheit

+
- + + + + + + + + + + + + + + + + + + + + + + + + + - +
IDadb_wohneinheit_id) ? $preorder->adb_wohneinheit_id : ""?>adb_wohneinheit_id) ? $preorder->adb_wohneinheit_id : ""?>
Statusadb_wohneinheit->status->code?> - adb_wohneinheit->status->name?>
OAIDadb_wohneinheit->oaid?>
Extrefadb_wohneinheit->extref?>
Blockadb_wohneinheit->block?>
Stiegeadb_wohneinheit->stiege?>
Stockadb_wohneinheit->stock?>
Türadb_wohneinheit->tuer?>
Zusatzadb_wohneinheit->zusatz?>
Bezeichneradb_wohneinheit?>adb_wohneinheit->bezeichner?>
-
Kontakt
+

Kontaktadresse

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Firmacompany?>
UIDuidy?>
Vornamefirstname?>
Nachnamelastname?>
Straße + street?> housenumber?> + block) ? "/".$preorder->block : ""?> + stiege) ? "/".$preorder->stiege : ""?> + stock) ? "/".$preorder->stock : ""?> + tuer) ? "/".$preorder->tuer : ""?> +
PLZzip?>
Ortcity?>
Telefonphone?>
Emailemail?>
@@ -102,16 +258,66 @@
-
+
-
+
RIMO
- +
+
+

Metadaten

+ + + + + + +
Building Name:adb_hausnummer->extref?> +
Home External ID:adb_wohneinheit->extref?> +
+
+ +
+

FTU

+ + + + + + +
FTU Name:adb_wohneinheit->ftu_data["name"]?> +
FTU External ID:adb_wohneinheit->ftu_data["id"]?> +
+
+ +
+
+ +
+

Workorder

+ + + + + + + + + + + + + + +
Nameadb_wohneinheit->rimo_workorder->rimo_name?>
External IDadb_wohneinheit->rimo_workorder->rimo_id?>
Statusadb_wohneinheit->rimo_workorder->rimo_status?>
Erstelltadb_wohneinheit->rimo_workorder->id) ? date("d.m.Y H:i:s", $preorder->adb_wohneinheit->rimo_workorder->create) : ""?>
+
+ + +
@@ -119,32 +325,6 @@
- - -
-
-
-
-
- Files -
-
-
-
-
- -
-
-
-
-
- - -
-
-
-
-
diff --git a/application/ADBHausnummer/ADBHausnummer.php b/application/ADBHausnummer/ADBHausnummer.php index 01dae66c4..5bde0b4d8 100644 --- a/application/ADBHausnummer/ADBHausnummer.php +++ b/application/ADBHausnummer/ADBHausnummer.php @@ -6,9 +6,10 @@ class ADBHausnummer extends mfBaseModel { private $ortschaft; private $strasse; private $plz; + private $status; private $freigaben = []; private $wohneinheiten = []; - + protected function init() { $this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $this->table = "Hausnummer"; @@ -126,7 +127,12 @@ class ADBHausnummer extends mfBaseModel { } return $this->wohneinheiten; } - + + if($name == "status") { + $this->status = new ADBStatus($this->status_id); + return $this->status; + } + $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); diff --git a/application/ADBStatus/ADBStatus.php b/application/ADBStatus/ADBStatus.php new file mode 100644 index 000000000..2a39a883c --- /dev/null +++ b/application/ADBStatus/ADBStatus.php @@ -0,0 +1,9 @@ +db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); + $this->table = "Status"; + } +} \ No newline at end of file diff --git a/application/ADBStatus/ADBStatusModel.php b/application/ADBStatus/ADBStatusModel.php new file mode 100644 index 000000000..172a8748b --- /dev/null +++ b/application/ADBStatus/ADBStatusModel.php @@ -0,0 +1,136 @@ + $value) { + if(property_exists(get_called_class(), $field)) { + $model->$field = $value; + } + } + + $me = mfValuecache::singleton()->get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::singleton()->set("me", $me); + } + + if($model->create_by === null) { + $model->create_by = $me->id; + } + if($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("Status", "*"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Status($data); + } + } + return $items; + + } + + public static function getFirst($filter = false) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("Status", "*", "$where ORDER BY code, name"); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Status($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function count($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) as cnt FROM Status + WHERE $where + "; + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + + public static function search($filter, $limit = false) { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + + $sql = "SELECT * FROM Status + WHERE $where + ORDER BY code, name + "; + + if(is_array($limit) && count($limit)) { + if(is_numeric($limit['start']) && is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['start'].", ".$limit['count']; + } elseif(is_numeric($count)) { + $sql .= " LIMIT ".$limit['count']; + } + } + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Status($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + //var_dump($filter);exit; + + if(array_key_exists("code", $filter)) { + $code = $filter['code']; + if(is_numeric($code)) { + $where .= " AND code=$code"; + } + } + + + //var_dump($filter, $where);exit; + return $where; + } + +} diff --git a/application/ADBWohneinheit/ADBWohneinheit.php b/application/ADBWohneinheit/ADBWohneinheit.php index 1fd57cacc..8fa0fcf93 100644 --- a/application/ADBWohneinheit/ADBWohneinheit.php +++ b/application/ADBWohneinheit/ADBWohneinheit.php @@ -3,7 +3,9 @@ class ADBWohneinheit extends mfBaseModel { private $hausnummer; private $rimo_workorder; - + private $ftu_data; + private $status; + protected function init() { $this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $this->table = "Wohneinheit"; @@ -131,37 +133,31 @@ class ADBWohneinheit extends mfBaseModel { return $code; } - public function afterLoad() { - //$this->hausnummer = new ADBHausnummer($this->hausnummer_id); - //$this->loadStatus(); - //$this->loadProvider(); + public function getExternalData() { + if(!$this->external_data) return []; + + $extdata = json_decode($this->external_data, true); + if(is_array($extdata) && count($extdata)) { + return $extdata; + } + return false; } - /* - public function loadStatus() { - if(!$this->id) { + + public function getExternalRimoData() { + $extdata = $this->getExternalData(); + if(!is_array($extdata) || !count($extdata)) { return false; } - $status = HausnummerStatus::singleton(); - $this->status = $status->getObject($this->status_id); - } - - public function loadProvider() { - if(!$this->id) { - return false; - } - - $res = $this->db->select("HausnummerProvider", "*", "hausnummer_id=".$this->id); - if($this->db->num_rows($res)) { - while($data = $this->db->fetch_object($res)) { - $provider = new Provider($data->provider_id); - $this->providerlist[$provider->id] = $provider->name; - $this->providers[] = $provider; + //var_dump($extdata);exit; + if(array_key_exists("rimo", $extdata) && count($extdata['rimo'])) { + $rimo_data = $extdata['rimo']; + if(is_array($extdata['rimo']) && count($extdata['rimo'])) { + return $rimo_data; } } - - return true; - }*/ - + + return false; + } public function getProperty($name) { if($this->$name == null) { @@ -175,7 +171,29 @@ class ADBWohneinheit extends mfBaseModel { $this->rimo_workorder = RimoWorkorderModel::getFirst(['adb_wohneinheit_id' => $this->id]); return $this->rimo_workorder; } - + + if($name == "ftu_data") { + $rimo_data = $this->getExternalRimoData(); + + if(!is_array($rimo_data) || !count($rimo_data)) { + return ['id' => "", 'name' => ""]; + } + + if(array_key_exists("ftu", $rimo_data)) { + $ftu_data = $rimo_data['ftu']; + if($ftu_data['id'] || $ftu_data['name']) { + $this->ftu_data = $ftu_data; + return $this->ftu_data; + } + } + return ['id' => "", 'name' => ""]; + } + + if($name == "status") { + $this->status = new ADBStatus($this->status_id); + return $this->status; + } + $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); diff --git a/application/Api/v1/PreorderApicontroller.php b/application/Api/v1/PreorderApicontroller.php index 5e356378e..388544960 100644 --- a/application/Api/v1/PreorderApicontroller.php +++ b/application/Api/v1/PreorderApicontroller.php @@ -464,6 +464,7 @@ class PreorderApicontroller extends mfBaseApicontroller { $where = "1=1 "; $unit = false; + // We ignore Stock when matching units $unit_search_count_without_stock = count($unit_search); if(array_key_exists("stock", $unit_search) && $unit_search['stock']) { $unit_search_count_without_stock--; diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 5d9ec027a..3f4b35794 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -10,6 +10,8 @@ class Preorder extends mfBaseModel { private $building; private $adb_hausnummer; private $adb_wohneinheit; + private $services; + private $ordered_services; private $creator; private $editor; private $attribute = []; @@ -314,7 +316,7 @@ class Preorder extends mfBaseModel { return $a; } - + public function getProperty($name) { if($this->$name == null) { @@ -366,8 +368,35 @@ class Preorder extends mfBaseModel { return $this->adb_wohneinheit; } - if($name == "addon_services") { - + if($name == "services") { + if(!$this->addon_services) { + return null; + } + $addon_services = json_decode($this->addon_services); + if(json_last_error() === JSON_ERROR_NONE) { + $this->services = $addon_services; + return $this->services; + } + return null; + } + + if($name == "ordered_services") { + if(!$this->addon_services) { + return null; + } + $ordered_services = []; + $addon_services = json_decode($this->addon_services); + if(json_last_error() === JSON_ERROR_NONE) { + foreach($addon_services as $s) { + if($s->ordered) { + $ordered_services[] = $s; + } + } + + $this->ordered_services = $ordered_services; + return $this->ordered_services; + } + return null; } if($name == "attribute") { diff --git a/application/Preorderstatus/PreorderstatusModel.php b/application/Preorderstatus/PreorderstatusModel.php index e2231eaad..01a4fb49d 100644 --- a/application/Preorderstatus/PreorderstatusModel.php +++ b/application/Preorderstatus/PreorderstatusModel.php @@ -44,7 +44,7 @@ class PreorderstatusModel { public static function getAll() { $items = []; - $db = FronkDB::singleton(); + $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $res = $db->select("Preorderstatus", "*"); if($db->num_rows($res)) { @@ -57,7 +57,7 @@ class PreorderstatusModel { } public static function getFirst($filter = false) { - $db = FronkDB::singleton(); + $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $where = self::getSqlFilter($filter); $res = $db->select("Preorderstatus", "*", "$where ORDER BY code, name"); @@ -74,7 +74,7 @@ class PreorderstatusModel { } public static function count($filter) { - $db = FronkDB::singleton(); + $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $where = self::getSqlFilter($filter); $sql = "SELECT COUNT(*) as cnt FROM Preorderstatus @@ -93,7 +93,7 @@ class PreorderstatusModel { public static function search($filter, $limit = false) { $items = []; - $db = FronkDB::singleton(); + $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); $where = self::getSqlFilter($filter);