From 0caa0bfac2c6a4eae18c664d0a6dd1fd56c59196 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 6 Aug 2024 12:19:07 +0200 Subject: [PATCH 1/2] Saving edit_by in ContractController --- application/Contract/ContractController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/application/Contract/ContractController.php b/application/Contract/ContractController.php index 08953ff24..7032d1b5e 100644 --- a/application/Contract/ContractController.php +++ b/application/Contract/ContractController.php @@ -197,8 +197,9 @@ class ContractController extends mfBaseController } $contract->cancel_date = $cancel_date->getTimestamp(); + $contract->edit_by = $this->me->id; if(!$contract->save()) { - $this->layout()->setFlash("Verlinkten Vertrag $link_id nicht gefunden", "error"); + $this->layout()->setFlash("Fehler beim Speichern", "error"); $this->redirect("Contract", "cancel", ["contract_id" => $contract->id]); } @@ -214,6 +215,7 @@ class ContractController extends mfBaseController } $link_contract->cancel_date = $cancel_date->getTimestamp(); + $link_contract->edit_by = $this->me->id; if(!$link_contract->save()) { $this->layout()->setFlash("Fehler beim Speichern von verlinktem Vertrag", "warning"); } @@ -465,6 +467,7 @@ class ContractController extends mfBaseController if($contract_cancel_date) { $contract->cancel_date = $contract_cancel_date->getTimestamp(); + $contract->edit_by = $this->me->id; $contract->save(); } From cdf8050a5f15512537221207e33985f8d6287e6f Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 6 Aug 2024 16:08:03 +0200 Subject: [PATCH 2/2] Added invoice number filter to Invoice/Index --- Layout/default/Invoice/Index.php | 5 +++++ application/Invoice/InvoiceController.php | 9 +++++++-- application/Invoice/InvoiceModel.php | 9 ++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Layout/default/Invoice/Index.php b/Layout/default/Invoice/Index.php index af3c9ba0b..03876d014 100644 --- a/Layout/default/Invoice/Index.php +++ b/Layout/default/Invoice/Index.php @@ -35,6 +35,11 @@ $pagination_entity_name = "Rechnungen";
">
+
+ + "/> +
+
"/> diff --git a/application/Invoice/InvoiceController.php b/application/Invoice/InvoiceController.php index 45acad4e3..8712c53a7 100644 --- a/application/Invoice/InvoiceController.php +++ b/application/Invoice/InvoiceController.php @@ -59,7 +59,7 @@ class InvoiceController extends mfBaseController { if (array_key_exists("customer", $filter)) { if (array_key_exists("customer", $filter) && $filter["customer"]) { - $kunde = $this->db()->escape($filter['customer']); + $kunde = $this->db()->escape(trim($filter['customer'])); if (!array_key_exists("add-where", $new_filter)) $new_filter["add-where"] = ""; $new_filter['add-where'] .= " AND (company like '%$kunde%' OR firstname like '%$kunde%' OR lastname like '%$kunde%' OR concat(firstname, ' ', lastname) like '%$kunde%' OR concat(lastname, ' ', firstname) like '%$kunde%')"; } @@ -67,12 +67,17 @@ class InvoiceController extends mfBaseController { if(array_key_exists("address", $filter)) { if($filter["address"]) { - $search = $this->db()->escape($filter['address']); + $search = $this->db()->escape(trim($filter['address'])); if (!array_key_exists("add-where", $new_filter)) $new_filter["add-where"] = ""; $new_filter['add-where'] .= " AND (street like '%$search%' OR zip like '%$search%' OR city like '%$search%' OR country like '%$search%')"; } } + if(array_key_exists("invoice_number", $filter) && $filter["invoice_number"]) { + $new_filter["invoice_number%"] = trim($filter["invoice_number"]); + unset($filter["invoice_number"]); + } + if (is_array($filter) && count($filter)) { foreach ($filter as $name => $value) { $new_filter[$name] = $value; diff --git a/application/Invoice/InvoiceModel.php b/application/Invoice/InvoiceModel.php index 1ca115c31..2afe875c1 100644 --- a/application/Invoice/InvoiceModel.php +++ b/application/Invoice/InvoiceModel.php @@ -245,7 +245,14 @@ class InvoiceModel { $where .= " AND Invoice.invoice_number IS NULL"; } } - + + if(array_key_exists("invoice_number%", $filter)) { + $invoice_number = $filter['invoice_number%']; + if($invoice_number) { + $where .= " AND Invoice.invoice_number LIKE '%$invoice_number%'"; + } + } + if(array_key_exists("invoice_date", $filter)) { $invoice_date = $filter['invoice_date']; if($invoice_date) {