From c95311d528c2b59def3fa6184d29132dd7e23cbd Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 10 Oct 2024 14:16:31 +0200 Subject: [PATCH 1/3] added skel of RimoWorkorder Contact update in Preorder.php --- application/Preorder/Preorder.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 2439cd9c9..c60f62d0f 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -68,6 +68,7 @@ class Preorder extends mfBaseModel { $this->createHistoryEntry(); //} + $this->updateRimoWorkorderContact(); // run triggers based on new status $this->runStatusTrigger(); // Cascade status changes down to adb_hausnummer and adb_wohneinheit @@ -80,6 +81,10 @@ class Preorder extends mfBaseModel { mfValuecache::singleton()->delete("preorder-save-nesting-level-" . $this->id); } + public function updateRimoWorkorderContact() { + + } + public function createHistoryEntry() { if(!$this->id) return true; From 396e26c0a1d5b1c81fe567e5990883e8724b5ad7 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 10 Oct 2024 14:17:11 +0200 Subject: [PATCH 2/3] WIP Preorder readonly user (meridiam) --- Layout/default/User/Form.php | 10 ++++- Layout/default/User/Index.php | 6 --- application/Api/v1/PreorderApicontroller.php | 40 +++++++++++++++++-- .../PreordercampaignController.php | 6 +-- application/User/UserController.php | 24 ++++++++--- .../WorkerPermission/WorkerPermission.php | 4 ++ ...03659_add_preorder_readonly_permission.php | 31 ++++++++++++++ 7 files changed, 102 insertions(+), 19 deletions(-) create mode 100644 db/migrations/20241007103659_add_preorder_readonly_permission.php diff --git a/Layout/default/User/Form.php b/Layout/default/User/Form.php index 48e1d99c5..3845dbb8c 100644 --- a/Layout/default/User/Form.php +++ b/Layout/default/User/Form.php @@ -146,7 +146,15 @@ Beschränkt Benutzer auf Netzgebiete. Überschreibt Netzgebiete der Firma. Wenn leer werden Netzgebiete der Firma angezeigt - + +
+ + +
+

Modulberechtigungen

diff --git a/Layout/default/User/Index.php b/Layout/default/User/Index.php index 90329031b..0ac80a500 100644 --- a/Layout/default/User/Index.php +++ b/Layout/default/User/Index.php @@ -117,12 +117,6 @@ $pagination_entity_name = "Benutzer"; style="text-align: left; letter-spacing: 4px; font-size: 1.1em;"> $user->id]) ?>" title="User bearbeiten"> - id > 1): ?> - $user->id]) ?>" - class="text-danger" title="User löschen" - onclick="if(!confirm('Benutzer wirklich löschen?')) return false;"> - diff --git a/application/Api/v1/PreorderApicontroller.php b/application/Api/v1/PreorderApicontroller.php index 8197f78a1..2d5ae6447 100644 --- a/application/Api/v1/PreorderApicontroller.php +++ b/application/Api/v1/PreorderApicontroller.php @@ -46,6 +46,7 @@ class PreorderApicontroller extends mfBaseApicontroller { $this->addRoute("/preorder", "submitPreorder", "POST"); $this->addRoute("/preorder/open", "getOpenPreorders", "GET"); + $this->addRoute("/preorder/all", "getAllPreorders", "GET"); $this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "getCifData"], "GET"); $this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "userSetCif"], "POST"); $this->addRoute("/preorder/fullexport", "exportPreorders", "GET"); @@ -189,9 +190,12 @@ class PreorderApicontroller extends mfBaseApicontroller { if(count($this->filter_salescluster_ids)) { $preorder_search['netzgebiet_id'] = $this->filter_salescluster_ids; }*/ - + $preorder_search = []; - $preorder_search['partner_id'] = $this->me->address_id; + if(!$this->me->preorderaddressreporting) { + $preorder_search['partner_id'] = $this->me->address_id; + } + if($update_ts) { $preorder_search['add-where'] = "AND tt_preorder.`edit` > $update_ts"; } else { @@ -204,10 +208,40 @@ class PreorderApicontroller extends mfBaseApicontroller { foreach(PreorderModel::searchActive($preorder_search) as $preorder) { $return[] = $preorder->getApiArray(); } + $this->requestLog->debug(print_r($return, true)); return mfResponse::Ok(["preorders" => $return]); - } + + protected function getAllPreorders() { + + // nicht auf cluster einschränken, sondern auf partner_id + /* + $preorder_search = []; + if(count($this->filter_salescluster_ids)) { + $preorder_search['netzgebiet_id'] = $this->filter_salescluster_ids; + }*/ + + $preorder_search = []; + if($this->me->preorderaddressreporting) { + + } else { + // providers see their own orders + $preorder_search['partner_id'] = $this->me->address_id; + } + + // if no timestamp, return only open orders (500 == finished) + $preorder_search['getApiArray(); + } + + $this->requestLog->debug(print_r($return, true)); + return mfResponse::Ok(["preorders" => $return]); + } protected function getPreorder($code) { $code = trim($code); diff --git a/application/Preordercampaign/PreordercampaignController.php b/application/Preordercampaign/PreordercampaignController.php index 00efa6ebc..1c9240943 100644 --- a/application/Preordercampaign/PreordercampaignController.php +++ b/application/Preordercampaign/PreordercampaignController.php @@ -988,7 +988,7 @@ class PreordercampaignController extends mfBaseController { if($oaid->adb_wohneinheit_id != $wohneinheit->id) { - $rimo = new OpenAccessId_Helper_Rimo($oaid->oaid); + //$rimo = new OpenAccessId_Helper_Rimo($oaid->oaid); $unit_ftu_data = $wohneinheit->ftu_data; //var_dump($unit_ftu_data); @@ -999,8 +999,8 @@ class PreordercampaignController extends mfBaseController { $oaid_ftu = $oaid->getExportData("rimo"); //var_dump($oaid_ftu); if($oaid_ftu->ftu_id) { - $rimo->unassignOaid($oaid_ftu->ftu_id); - $rimo->assignOaid($unit_ftu_data["id"]); + Rimoapi::unassignOaid($oaid->oaid, $oaid_ftu->ftu_id); + Rimoapi::assignOaid($oaid->oaid, $unit_ftu_data["id"]); $oaid->updateExportData("rimo", "ftu_id", $unit_ftu_data["id"]); $oaid->updateExportData("rimo", "ftu_name", $unit_ftu_data["name"]); diff --git a/application/User/UserController.php b/application/User/UserController.php index bc65ba9bb..b73f05bbb 100644 --- a/application/User/UserController.php +++ b/application/User/UserController.php @@ -80,7 +80,7 @@ class UserController extends mfBaseController $this->layout()->set("addresses", $addresses); } - protected function generateApikey($request) + protected function generateApikeyAction($request) { if (!$this->isAdmin()) { $this->redirect("Dashboard"); @@ -219,7 +219,18 @@ class UserController extends mfBaseController } else { $user->permissions->preorderlogistics = "false"; } - + + if ($r->preorderaddressreporting == "true") { + $user->permissions->preorderaddressreporting = "true"; + } else { + $user->permissions->preorderaddressreporting = "false"; + } + + if ($r->preorderreadonly == "true") { + $user->permissions->preorderreadonly = "true"; + } else { + $user->permissions->preorderreadonly = "false"; + } // set can permissions $user->permissions->canBuilding = "false"; @@ -271,9 +282,7 @@ class UserController extends mfBaseController } else { $enum->delete(); } - - - + } $this->layout()->setFlash("Benutzer gespeichert.", "success"); @@ -282,8 +291,11 @@ class UserController extends mfBaseController protected function deleteAction($request) { + $this->layout()->setFlash("nope"); + $this->redirect("User"); + if (!$this->isAdmin()) { - $this->redirect("Bridge"); + $this->redirect("Dashboard"); } $id = $request['id']; diff --git a/application/WorkerPermission/WorkerPermission.php b/application/WorkerPermission/WorkerPermission.php index 4fa25500a..f8b8a9543 100644 --- a/application/WorkerPermission/WorkerPermission.php +++ b/application/WorkerPermission/WorkerPermission.php @@ -7,6 +7,7 @@ class WorkerPermission extends mfBaseModel { public $isPreorderfront = false; public $isPreorderaddressreporting = false; public $isPreorderlogistics = false; + public $isPreorderreadonly = false; public function loadByUserId($userid) { $res = $this->db->select($this->table,"*","worker_id=$userid"); @@ -41,6 +42,9 @@ class WorkerPermission extends mfBaseModel { if($this->preorderlogistics == 'true') { $this->isPreorderlogistics = true; } + if($this->preorderreadonly == 'true') { + $this->isPreorderreadonly = true; + } } } \ No newline at end of file diff --git a/db/migrations/20241007103659_add_preorder_readonly_permission.php b/db/migrations/20241007103659_add_preorder_readonly_permission.php new file mode 100644 index 000000000..347b98c03 --- /dev/null +++ b/db/migrations/20241007103659_add_preorder_readonly_permission.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $table = $this->table ("WorkerPermission"); + $table->addColumn("preorderreadonly", "enum", ["null" => false, "values" => 'false,true', "default" => "false", "after" => "preorderlogistics"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table ("WorkerPermission")->removeColumn("preorderreadonly"); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} From a0b5c9cc6e277996b5f8275fa2fc4f3c0d807c4a Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 10 Oct 2024 16:42:22 +0200 Subject: [PATCH 3/3] Now showing all Workorders in Preorder detail --- Layout/default/Preorder/Index.php | 15 ++++-- .../Preorder/include/preorder-detail.php | 51 ++++++++++--------- application/ADBWohneinheit/ADBWohneinheit.php | 11 +++- application/Preorder/PreorderController.php | 19 +++++-- 4 files changed, 61 insertions(+), 35 deletions(-) diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index 3af5dd407..7d90a4174 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -292,7 +292,7 @@ is(["Admin", "netowner"])): ?> - adb_wohneinheit_id && is_object($preorder->adb_wohneinheit->rimo_workorder)):?> + adb_wohneinheit_id && is_array($preorder->adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)):?> is("preorderfront")): ?> @@ -907,24 +907,29 @@ 'json'); } - function deleteWorkorder(pid) { - console.log("in delete workorder"); + function deleteWorkorder(pid, wid) { + //console.log("in delete workorder"); if(!Number.isInteger(pid) || pid < 1) { return false; } + if(!Number.isInteger(wid) || wid < 1) { + return false; + } + $.post("", { 'do': "deleteWorkorder", id: pid, + wid: wid }, function(success) { if(success.status == "OK") { - $("#preorder-detail-" + success.result.id + "-workorder td").each(function() { + $("#preorder-detail-" + success.result.id + "-workorder-" + success.result.wid + " td").each(function() { $(this).html("--gelöscht--"); }); - $("#preorder-detail-" + success.result.id + "-workorder-del").remove(); + $("#preorder-detail-" + success.result.id + "-workorder-" + success.result.wid + "-del").remove(); } }, 'json'); diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php index 5228fe1f3..99a9bb384 100644 --- a/Layout/default/Preorder/include/preorder-detail.php +++ b/Layout/default/Preorder/include/preorder-detail.php @@ -397,30 +397,33 @@

Workorder

- adb_wohneinheit->rimo_workorder) && $preorder->adb_wohneinheit->rimo_workorder->id): ?> - Workorder löschen - - - - - - - - - - - - adb_wohneinheit->rimo_workorder->rimo_team_name): ?> - - - - - - - - - -
Nameadb_wohneinheit->rimo_workorder->rimo_name?>
External IDadb_wohneinheit->rimo_workorder->rimo_id?>
Statusadb_wohneinheit->rimo_workorder->rimo_status?>
Zugewiesen an:adb_wohneinheit->rimo_workorder->rimo_team_name?>
Erstelltadb_wohneinheit->rimo_workorder)) ? date("d.m.Y H:i:s", $preorder->adb_wohneinheit->rimo_workorder->create) : ""?>
+ adb_wohneinheit->rimo_workorders) && count($preorder->adb_wohneinheit->rimo_workorders)): ?> + adb_wohneinheit->rimo_workorders as $wo): ?> +

rimo_name?>

+ Workorder löschen + + + + + + + + + + + + rimo_team_name): ?> + + + + + + + + + +
Namerimo_name?>
External IDrimo_id?>
Statusrimo_status?>
Zugewiesen an:rimo_team_name?>
Erstelltcreate)?>
+
diff --git a/application/ADBWohneinheit/ADBWohneinheit.php b/application/ADBWohneinheit/ADBWohneinheit.php index 9fc846ba1..374752b77 100644 --- a/application/ADBWohneinheit/ADBWohneinheit.php +++ b/application/ADBWohneinheit/ADBWohneinheit.php @@ -3,6 +3,7 @@ class ADBWohneinheit extends mfBaseModel { private $hausnummer; private $rimo_workorder; + private $rimo_workorders; private $ftu_data; private $status; @@ -244,7 +245,15 @@ class ADBWohneinheit extends mfBaseModel { } return $this->rimo_workorder; } - + + if($name == "rimo_workorders") { + $this->rimo_workorders = RimoWorkorderModel::search(["adb_wohneinheit_id" => $this->id]); + /*if(count($workorders)) { + $this->rimo_workorders = $workorders; + }*/ + return $this->rimo_workorders; + } + if($name == "ftu_data") { $rimo_data = $this->getExternalRimoData(); diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php index d125e7263..3065fd5d2 100644 --- a/application/Preorder/PreorderController.php +++ b/application/Preorder/PreorderController.php @@ -1264,8 +1264,9 @@ class PreorderController extends mfBaseController { if(!$this->me->is("Admin")) { return false; } - + $preorder_id = $this->request->id; + $wo_id = $this->request->wid; if(!is_numeric($preorder_id) || $preorder_id < 1) { return false; @@ -1279,14 +1280,22 @@ class PreorderController extends mfBaseController { if(!$preorder->adb_wohneinheit_id) { return false; } - - $workorder = RimoWorkorderModel::getFirst(["adb_wohneinheit_id" => $preorder->adb_wohneinheit_id]); - if(!$workorder) { + + if(!is_numeric($wo_id) || $wo_id < 1) { return false; } + $workorder = new RimoWorkorder($wo_id); + if(!$workorder->id) { + return false; + } + + if($preorder->adb_wohneinheit_id != $workorder->adb_wohneinheit_id) { + $this->log->warning(__METHOD__.": wohneinheit_id not equal"); + return false; + } $workorder->delete(); - return ["message" => "Workorder deleted successfully", "id" => $preorder->id]; + return ["message" => "Workorder deleted successfully", "id" => $preorder->id, "wid" => $wo_id]; } } \ No newline at end of file