From 4d4bf81e2a9ca3179e77980b6b33f5cfffe9cbe8 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 31 May 2022 15:38:48 +0200 Subject: [PATCH] Filter and pagination is still set after saving Order --- Layout/default/Contract/Index.php | 2 +- Layout/default/Contractconfig/Index.php | 12 +++- Layout/default/Order/Form.php | 15 ++++- Layout/default/Order/Index.php | 32 +++++++--- application/Contract/Contract.php | 18 +++++- application/Order/OrderController.php | 78 +++++++++++++++---------- public/assets/css/thetool.css | 13 +++++ 7 files changed, 121 insertions(+), 49 deletions(-) diff --git a/Layout/default/Contract/Index.php b/Layout/default/Contract/Index.php index eff3e0e99..4365f42ad 100644 --- a/Layout/default/Contract/Index.php +++ b/Layout/default/Contract/Index.php @@ -51,7 +51,7 @@ $contract->owner_id])?>" target="_blank">owner->getCompanyOrName()?> - product->name?> + product->product->name?> termination_id): ?> termination->building->street?>
diff --git a/Layout/default/Contractconfig/Index.php b/Layout/default/Contractconfig/Index.php index b8de1b705..7847ae08e 100644 --- a/Layout/default/Contractconfig/Index.php +++ b/Layout/default/Contractconfig/Index.php @@ -32,7 +32,11 @@
"> items) && count($group->items)): ?> - items as $item): ?> + items as $item): ?> + + + + - + diff --git a/Layout/default/Order/Form.php b/Layout/default/Order/Form.php index e955574bf..0d658aa44 100644 --- a/Layout/default/Order/Form.php +++ b/Layout/default/Order/Form.php @@ -1,6 +1,17 @@ @@ -34,7 +45,7 @@

id) ? "Bestellung bearbeiten" : "Neue Bestellung"?>

- " name="orderForm" id="orderForm" enctype="multipart/form-data"> +
diff --git a/Layout/default/Order/Index.php b/Layout/default/Order/Index.php index 75f15301d..098a7822c 100644 --- a/Layout/default/Order/Index.php +++ b/Layout/default/Order/Index.php @@ -141,10 +141,16 @@ @@ -234,7 +240,7 @@ $order->id])?>"> $order->id])?>" onclick="if(!confirm('Soll der Service-PIN an den Vertragsinhaber gesendet werden?')) return false;"> - $order->id])?>"> + $order->id, "filter" => $filter, "noTermProducts" => 1])?>"> $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"> @@ -255,7 +261,7 @@
-
@@ -544,11 +550,10 @@
- + - @@ -647,7 +652,7 @@ $order->id])?>"> $order->id])?>" onclick="if(!confirm('Soll der Service-PIN an den Vertragsinhaber gesendet werden?')) return false;"> - $order->id])?>"> + $order->id, "filter" => $filter, "s" => $pagination['start']])?>"> $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"> @@ -677,7 +682,7 @@
-
@@ -996,7 +1004,13 @@ toggleOrder(order); //$('body').scrollTop($('#order-' + order).offset() - 50); scrollToDiv('#order-' + order); + + if(hash.match(/order=(\d+)-details/)) { + $('.order-tab a[href="#order-detail-' + order + '-details"]').tab('show'); + } + } + }); diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php index 155ea8889..b084199a4 100644 --- a/application/Contract/Contract.php +++ b/application/Contract/Contract.php @@ -4,6 +4,7 @@ class Contract extends mfBaseModel { private $owner; private $creator; private $product; + private $orderproduct; private $termination; private $sla; private $editor; @@ -39,16 +40,27 @@ class Contract extends mfBaseModel { } if($name == "product") { - $this->product = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderproduct_id); + $this->product = mfValuecache::singleton()->get("mfObjectmodel-Product-".$this->product_id); if($this->product === null) { - $this->product = new OrderProduct($this->orderproduct_id); + $this->product = new Product($this->product_id); if($this->product->id) { - mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderproduct_id, $this->product); + mfValuecache::singleton()->set("mfObjectmodel-Product-".$this->product_id, $this->product); } } return $this->product; } + if($name == "orderproduct") { + $this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id); + if($this->orderproduct === null) { + $this->orderproduct = new OrderProduct($this->orderorderproduct_id); + if($this->orderproduct->id) { + mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id, $this->orderproduct); + } + } + return $this->orderproduct; + } + if($name == "creator") { $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); if($this->creator === null) { diff --git a/application/Order/OrderController.php b/application/Order/OrderController.php index f93c0fd2c..85aeb1b8e 100644 --- a/application/Order/OrderController.php +++ b/application/Order/OrderController.php @@ -112,7 +112,7 @@ class OrderController extends mfBaseController { } } - if(!$showLonelies) { + //if(!$showLonelies) { //var_dump($order_search);exit; $pagination['maxItems'] = OrderModel::count($order_search); foreach(OrderModel::search($order_search, $pagination) as $order) { @@ -120,9 +120,17 @@ class OrderController extends mfBaseController { $orders[$order->id] = $order; } } + //} + + $showLoneliesCount = false; + foreach(["owner", "owner_address", "partner_number", "finish_date"] as $key) { + if(array_key_exists($key, $filter) && $filter[$key]) { + $showLoneliesCount = true; + break; + } } - - if($showLonelies) { + + if($showLonelies || $showLoneliesCount) { $userIds = $this->me->getAddressOrParent()->getUserIds(); //var_dump($userIds);exit; if(!array_key_exists("network_linked_status", $order_search)) { @@ -265,10 +273,13 @@ class OrderController extends mfBaseController { } protected function addAction() { + //var_dump($this->request->filter);exit; + + // TODO: filter by network permissions $this->layout()->setTemplate("Order/Form"); if($this->me->is("Admin")) { - $this->layout()->set("addresses", AddressModel::search(['parents_only' => 1])); + //$this->layout()->set("addresses", AddressModel::search(['parents_only' => 1])); $this->layout()->set("products", ProductModel::getAll()); $this->layout()->set("terminations", TerminationModel::getAll()); } else { @@ -280,17 +291,18 @@ class OrderController extends mfBaseController { $users = []; foreach($this->me->my_networks as $network) { $network_ids[] = $network->id; - $tmp_users = $network->getAddressUsersByAddresstype("salespartner"); + /*$tmp_users = $network->getAddressUsersByAddresstype("salespartner"); foreach($tmp_users as $user) { if(!in_array($user->id, $users)) { $users[] = $user->id; } - } + }*/ } + /* // get addresses from salespartner address' user ids $addresses = AddressModel::search(["create_by" => $users]); $this->layout()->set("addresses", $addresses); - + */ // get terminations in my networks $terms = TerminationModel::search(["network_id" => $network_ids]); $this->layout()->set("terminations", $terms); @@ -305,6 +317,15 @@ class OrderController extends mfBaseController { } + if($this->request->filter) { + $this->layout()->set("filter", $this->request->filter); + } + if($this->request->noTermProducts) { + $this->layout()->set("noTermProducts", $this->request->noTermProducts); + } + if($this->request->s) { + $this->layout()->set("s", $this->request->s); + } } @@ -366,18 +387,12 @@ class OrderController extends mfBaseController { $this->layout()->setFlash("Bestellung nicht gefunden", "error"); $this->redirect("Order"); } + // refuse to save if there is a contract already - if($order->finish_date && is_array($order->contracts) && count($order->contracts)) { $this->layout()->setFlash("Bestellung kann nicht mehr bearbeitet werden, da sie bereits abgeschlossen und in Verrechnung ist.", "error"); $this->redirect("Order", "edit", ['id' => $order->id]); } - /*foreach($order->products as $p) { - if($p->contract && $p->contract->id) { - $this->layout()->setFlash("Bestellung kann nicht mehr bearbeitet werden, da sie bereits abgeschlossen und in Verrechnung ist.", "error"); - $this->redirect("Order", "edit", ['id' => $order->id]); - } - }*/ } else { $id = false; $mode = "add"; @@ -385,12 +400,6 @@ class OrderController extends mfBaseController { // validate owner $owner = false; - /*if(!$r->owner_id) { - $this->layout()->setFlash("Bitte Vertragsinhaber auswählen oder eintragen.", "error"); - $this->layout()->set("order", $r); - return $this->add(); - }*/ - $owner_new = false; if(is_numeric($r->owner_id) && $r->owner_id > 0) { @@ -415,11 +424,7 @@ class OrderController extends mfBaseController { return $this->add(); } } - }/* else { - $this->layout()->setFlash("Ungültiger Vertragsinhaber."); - $this->layout()->set("order", $r); - return $this->add(); - }*/ + } // validate billindaddress @@ -456,11 +461,7 @@ class OrderController extends mfBaseController { return $this->add(); } } - } /*else { - $this->layout()->setFlash("Ungültiger Rechnungsempfänger."); - $this->layout()->set("order", $r); - return $this->add(); - }*/ + } // validate sepa if(!$r->billing_type) { @@ -873,8 +874,23 @@ class OrderController extends mfBaseController { } } + + $sq = ""; + $query = []; + if($r->s) { + $query['s'] = $r->s; + } + if($r->noTermProducts) { + $query["noTermProducts"] = $r->noTermProducts; + } + if($r->filter) { + $query["filter"] = $r->filter; + } + + $qs = http_build_query($query); + $this->layout()->setFlash("Bestellung erfolgreich gespeichert.", "success"); - $this->redirect("Order", "edit", ["id" => $new_id]); + $this->redirect("Order", "Index", $qs, "order=$new_id-details"); } diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css index 3b9e6007b..98c331638 100644 --- a/public/assets/css/thetool.css +++ b/public/assets/css/thetool.css @@ -404,3 +404,16 @@ td.controls { .pointer { cursor: pointer; } + + +.counter { + vertical-align: super; + font-size: .75em; + color: #fff; + background-color: tomato; + padding-left: 4px; + padding-right: 4px; + padding-top: 1px; + padding-bottom: 1px; + border-radius: 4px; +}