From 8a9e29087a057e96d9ce9dc0b2ca6112c5d171fc Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 23 Sep 2021 21:14:42 +0200 Subject: [PATCH] Keep filter after saving patching --- Layout/default/Patching/Index.php | 15 ++++++++--- application/Patching/Patching.php | 24 ++++++++++++++++++ application/Patching/PatchingController.php | 28 +++++++++++++++++++-- application/Patching/PatchingModel.php | 8 +++--- 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/Layout/default/Patching/Index.php b/Layout/default/Patching/Index.php index 748786db5..6cce58d46 100644 --- a/Layout/default/Patching/Index.php +++ b/Layout/default/Patching/Index.php @@ -108,7 +108,7 @@ Standort ODF - Abschluss/Device + Abschluss/Device @@ -119,9 +119,10 @@ Patchposition ODF ODF Port Typ - Gerät + Splitte / Gerät Port Gepatched + Von @@ -156,11 +157,17 @@ - + patching->patched == 1) ? "checked='checked'" : ""?> /> + patching->patched == 1 && $term->patching->patched_by) ? "title='Gepatched: ".date("d.m.Y H:i",$term->patching->patched_date)." von ".$term->patching->patcher->name." (".$term->patching->patcher->address->getCompanyOrName(true).")'" : ""?>> + + patching->patched == 1 && $term->patching->patched_by): ?> + patching->patcher) ? $term->patching->patcher->getAbbrName() : ""?> + + -
"> + $pagination['start'], "filter" => $filter])?>">
diff --git a/application/Patching/Patching.php b/application/Patching/Patching.php index 7025ded6f..7662e99a0 100644 --- a/application/Patching/Patching.php +++ b/application/Patching/Patching.php @@ -1,5 +1,29 @@ $name == null) { + + if($name == "patcher") { + $this->patcher = new User($this->patched_by); + return $this->patcher; + } + + + $classname = ucfirst($name); + $idfield = $name."_id"; + $this->$name = new $classname($this->$idfield); + + if($this->$name->id) { + return $this->$name; + } else { + return null; + } + } + + return $this->$name; + } } \ No newline at end of file diff --git a/application/Patching/PatchingController.php b/application/Patching/PatchingController.php index cba5a59be..7d0194177 100644 --- a/application/Patching/PatchingController.php +++ b/application/Patching/PatchingController.php @@ -157,15 +157,28 @@ class PatchingController extends mfBaseController { $patch_data["linework_port"] = $r->linework_port; - $patch_data["device_type"] = $r->device_type; $patch_data["device_name"] = $r->device_name; $patch_data["device_port"] = $r->device_port; $patch_data["patched"] = ($r->patched == "1") ? 1 : 0; + if(strlen($patch_data["device_type"])) { + $patch_data["device_type"] = $r->device_type; + } else { + $patch_data["device_type"] = null; + } + if($mode == "add") { $patch_data['create_by'] = 1; $patching = PatchingModel::create($patch_data); + if($patch_data["patched"]) { + $patch_data["patched_by"] = $this->me->id; + $patch_data["patched_date"] = date("U"); + } } else { + if($patch_data["patched"] && !$patchind->patched) { + $patch_data["patched_by"] = $this->me->id; + $patch_data["patched_date"] = date("U"); + } $patching->update($patch_data); } @@ -175,8 +188,19 @@ class PatchingController extends mfBaseController { return $this->indexAction(); } + $sq = ""; + $query = []; + if(is_numeric($this->request->s) && $this->request->s > 0) { + $query["s"] = $this->request->s; + } + if (is_array($this->request->filter)) { + $query["filter"] = $this->request->filter; + } + + $qs = http_build_query($query); + $this->layout()->setFlash("Patchung erfolgreich gespeichert.", "success"); - $this->redirect("Patching", "Index"); + $this->redirect("Patching","Index", $qs); } diff --git a/application/Patching/PatchingModel.php b/application/Patching/PatchingModel.php index 1811926aa..669a4520a 100644 --- a/application/Patching/PatchingModel.php +++ b/application/Patching/PatchingModel.php @@ -89,7 +89,7 @@ class PatchingModel { $where = self::getSqlFilter($filter); - $sql = "SELECT COUNT(Termination.id) as cnd FROM `Order` + $sql = "SELECT COUNT(Termination.id) as cnt FROM `Order` LEFT JOIN OrderProduct ON (OrderProduct.order_id = `Order`.id) LEFT JOIN Product ON (Product.id = OrderProduct.product_id) LEFT JOIN Termination ON (Termination.id = OrderProduct.termination_id) @@ -106,7 +106,7 @@ class PatchingModel { GROUP BY Termination.id ORDER BY Termination.id ASC LIMIT 1"; - //mfLoghandler::singleton()->debug($sql); + mfLoghandler::singleton()->debug($sql); $res = $db->query($sql); if($db->num_rows($res)) { @@ -118,7 +118,7 @@ class PatchingModel { return 0; } - public static function searchByTermination($filter = false) { + public static function searchByTermination($filter = false, $limit = false) { $items = []; $db = FronkDB::singleton(); @@ -163,7 +163,7 @@ class PatchingModel { return $items; } - public static function search($filter = false) { + public static function search($filter = false, $limit = false) { $items = []; $db = FronkDB::singleton();