From e9937f2df8fdfdf300012d1f909a5d5b6f59ff3c Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 6 Feb 2024 20:46:05 +0100 Subject: [PATCH] Added contract_term to Order/Product/Contract --- Layout/default/Order/Form.php | 55 ++++++++++++++++--- Layout/default/Product/Form.php | 14 +++++ application/Order/OrderController.php | 24 +++++++- application/Order/OrderModel.php | 14 +++++ .../OrderProduct/OrderProductModel.php | 1 + application/Product/ProductController.php | 3 +- application/Product/ProductModel.php | 37 +++++++------ 7 files changed, 119 insertions(+), 29 deletions(-) diff --git a/Layout/default/Order/Form.php b/Layout/default/Order/Form.php index cf9f9274a..5d598095c 100644 --- a/Layout/default/Order/Form.php +++ b/Layout/default/Order/Form.php @@ -8,7 +8,7 @@ if($noTermProducts) { $urlfilter['noTermProducts'] = 1; } - if(is_array($filter) && count($filter)) { + if(isset($filter) && is_array($filter) && count($filter)) { $urlfilter["filter"] = $filter; } $posturl = self::getUrl("Order", "save", $urlfilter); @@ -589,8 +589,8 @@ " placeholder="Anzahl/Menge" />
- - @@ -649,10 +649,22 @@
-
+
+
+ + +
@@ -718,7 +730,7 @@
- @@ -757,10 +769,22 @@
-
+
+
+ + +
@@ -1195,12 +1219,13 @@ form_id: id }, function (success) { - //console.log(success); + console.log(success); p = success.result.product; id = success.result.form_id; $('#billing_delay-' + id).val(p.billing_delay); $('#billing_period-' + id).val(p.billing_period); + $('#contract_term-' + id).val(p.contract_term); $('#price-' + id).val(p.price); $('#price_setup-' + id).val(p.price_setup); $('#price_nne-' + id).val(p.price_nne); @@ -1576,7 +1601,7 @@
\
\ \ - \ \ \ \ @@ -1616,10 +1641,22 @@ \
\ \ -
\ +
\ \ \
\ +
\ + \ + \ +
\
\ \ \ diff --git a/Layout/default/Product/Form.php b/Layout/default/Product/Form.php index c0b4577d5..ef3fb6f26 100644 --- a/Layout/default/Product/Form.php +++ b/Layout/default/Product/Form.php @@ -210,7 +210,21 @@
+
+ +
+ +
+
diff --git a/application/Order/OrderController.php b/application/Order/OrderController.php index b98869fc5..dcb836a34 100644 --- a/application/Order/OrderController.php +++ b/application/Order/OrderController.php @@ -498,6 +498,10 @@ class OrderController extends mfBaseController { $mode = "add"; } + /* + * Contacts/Addresses and Billing data + */ + // validate owner $owner = false; $owner_new = false; @@ -642,6 +646,7 @@ class OrderController extends mfBaseController { if($billingaddress_new) { if($r->billing_type == "sepa") { $billing_data['billing_type'] = "sepa"; + $billing_data['sepa_date'] = date("U"); } else { $billing_data['billing_type'] = "invoice"; } @@ -659,6 +664,7 @@ class OrderController extends mfBaseController { } elseif($owner_new) { if($r->billing_type == "sepa") { $owner_data['billing_type'] = "sepa"; + $owner_data['sepa_date'] = date("U"); } else { $owner_data['billing_type'] = "invoice"; } @@ -685,6 +691,20 @@ class OrderController extends mfBaseController { $techcontact = AddressModel::create($techcontact_data); } + // set sepa date if not yet set and sepa is active + if($billingaddress) { + if($billingaddress->billing_type == "sepa" && !$billingaddress->sepa_date) { + $billingaddress->sepa_date = date("U"); + $billingaddress->save(); + } + } else { + if($owner->billing_type == "sepa" && !$owner->sepa_date) { + $owner->sepa_date = date("U"); + $owner->save(); + } + } + + // create or save Order object $order_data = []; @@ -703,7 +723,7 @@ class OrderController extends mfBaseController { $order_data['allow_spin'] = ($r->allow_spin) ? 1 : 0; $order_data['note'] = $r->note; - $order_data['order_date'] = Layout::dateToInt($r->order_date); + $order_data['order_date'] = ($order_data['order_date']) ? Layout::dateToInt($r->order_date) : null; if($r->finish_after) { $order_data['finish_after'] = Layout::dateToInt($r->finish_after); @@ -876,6 +896,7 @@ class OrderController extends mfBaseController { $product_data["billing_delay"] = 6; } $product_data["billing_period"] = $p["billing_period"]; + $product_data["contract_term"] = $p["contract_term"]; $product_data['upgrade'] = $order_data['upgrade']; @@ -912,6 +933,7 @@ class OrderController extends mfBaseController { $product_data['voicenumber'] = null; } + $product_data['edit_by'] = $this->me->id; if(!$orderproduct_id) { $product = OrderProductModel::create($product_data); diff --git a/application/Order/OrderModel.php b/application/Order/OrderModel.php index 724bb3787..ea8cd61e0 100644 --- a/application/Order/OrderModel.php +++ b/application/Order/OrderModel.php @@ -284,6 +284,20 @@ class OrderModel { } } + if(array_key_exists("finish_date>", $filter)) { + $finish_date = $filter['finish_date>']; + if($finish_date) { + $where .= " AND `Order`.finish_date > $finish_date"; + } + } + + if(array_key_exists("finish_date<", $filter)) { + $finish_date = $filter['finish_date<']; + if($finish_date) { + $where .= " AND `Order`.finish_date < $finish_date"; + } + } + if(array_key_exists("upgrade", $filter)) { if($filter['upgrade'] == 1) { $where .= " AND `Order`.upgrade = 1"; diff --git a/application/OrderProduct/OrderProductModel.php b/application/OrderProduct/OrderProductModel.php index a1a2c395a..0af892007 100644 --- a/application/OrderProduct/OrderProductModel.php +++ b/application/OrderProduct/OrderProductModel.php @@ -15,6 +15,7 @@ class OrderProductModel public $price_nbe; public $billing_delay; public $billing_period; + public $contract_term; public $note; public $create_by = null; diff --git a/application/Product/ProductController.php b/application/Product/ProductController.php index 82e53042b..745cda09b 100644 --- a/application/Product/ProductController.php +++ b/application/Product/ProductController.php @@ -156,6 +156,7 @@ class ProductController extends mfBaseController { $data['price_setup'] = ($r->price_setup) ? Layout::commaToDot($r->price_setup) : 0; $data['billing_period'] = $r->billing_period; $data['billing_delay'] = ($r->billing_delay) ? $r->billing_delay : 0; + $data['contract_term'] = $r->contract_term; $data['ivt_id'] = ($r->ivt_id) ? $r->ivt_id : null; $data['note'] = $r->note; @@ -316,7 +317,7 @@ class ProductController extends mfBaseController { if(!$product->id) { return false; } - + if(is_array($product->attributes) && count($product->attributes)) { $attributes = $product->attributes; $product->data->attributes = []; diff --git a/application/Product/ProductModel.php b/application/Product/ProductModel.php index b7ccc17a1..bb2638e8d 100644 --- a/application/Product/ProductModel.php +++ b/application/Product/ProductModel.php @@ -1,26 +1,27 @@