From a866c9e7c38c1053c25575d11c6c21370d24078e Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 25 Nov 2021 21:48:35 +0100 Subject: [PATCH] modifications to use nne/nbe from OrderProduct instead of Product --- .../Emailtemplates/order/int_billing_info.php | 2 +- Layout/default/Order/Form.php | 4 ++ application/Order/OrderController.php | 13 ++++++- scripts/update_orderproduct_nne_nbe.php | 39 +++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 scripts/update_orderproduct_nne_nbe.php diff --git a/Layout/default/Emailtemplates/order/int_billing_info.php b/Layout/default/Emailtemplates/order/int_billing_info.php index 5b4de4b45..01542247a 100644 --- a/Layout/default/Emailtemplates/order/int_billing_info.php +++ b/Layout/default/Emailtemplates/order/int_billing_info.php @@ -41,7 +41,7 @@ Gutschriften Anzahl | Produktname | Verrechungsperiode | Bauabschnitt | NNE ----------------------------------------------------------------------------------------------------------------------- -amount,0,12))?> | product->name,0,42))))?> | billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")) ))?> | termination->building->networksection_id) ? $op->termination->building->networksection->name : "",0,24))?> | EUR product->price_nne?> +amount,0,12))?> | product->name,0,42))))?> | billing_period == 12) ? "Jährlich " : (($op->billing_period == 1) ? "Monatlich" : $op->billing_period."-monatlich")) ))?> | termination->building->networksection_id) ? $op->termination->building->networksection->name : "",0,24))?> | EUR price_nne?> ----------------------------------------------------------------------------------------------------------------------- diff --git a/Layout/default/Order/Form.php b/Layout/default/Order/Form.php index 12208031e..87539939f 100644 --- a/Layout/default/Order/Form.php +++ b/Layout/default/Order/Form.php @@ -447,6 +447,7 @@ Max. 6 Monate + is("Admin")): ?>
@@ -455,6 +456,7 @@
+ @@ -536,6 +538,7 @@ Max. 6 Monate + is("Admin")): ?>
@@ -544,6 +547,7 @@
+ diff --git a/application/Order/OrderController.php b/application/Order/OrderController.php index d5bf06143..bc9aad1c6 100644 --- a/application/Order/OrderController.php +++ b/application/Order/OrderController.php @@ -544,8 +544,17 @@ class OrderController extends mfBaseController { $product_data["description"] = $p["description"]; $product_data["price"] = Layout::commaToDot($p["price"]); $product_data["price_setup"] = Layout::commaToDot($p["price_setup"]); - $product_data["price_nne"] = Layout::commaToDot($p["price_nne"]); - $product_data["price_nbe"] = Layout::commaToDot($p["price_nbe"]); + + if($this->me->is("Admin") && $p["price_nne"]) { + $product_data["price_nne"] = Layout::commaToDot($p["price_nne"]); + } else { + $product_data["price_nne"] = $prod->price_nne; + } + if($this->me->is("Admin") && $p["price_nbe"]) { + $product_data["price_nbe"] = Layout::commaToDot($p["price_nbe"]); + } else { + $product_data["price_nbe"] = $prod->price_nbe; + } $product_data["billing_delay"] = ($p["billing_delay"]) ? $p["billing_delay"] : 0; if($product_data["billing_delay"] > 6) { diff --git a/scripts/update_orderproduct_nne_nbe.php b/scripts/update_orderproduct_nne_nbe.php new file mode 100644 index 000000000..a5f2cf99b --- /dev/null +++ b/scripts/update_orderproduct_nne_nbe.php @@ -0,0 +1,39 @@ +#!/usr/bin/php +select("OrderProduct", "id", "price_nne = 0 AND price_nbe = 0"); +if(!$db->num_rows($res)) { + exit; +} + +while($data = $db->fetch_object($res)) { + $op = new OrderProduct($data->id); + + + + if(!($op->product->price_nne > 0) && !($op->product->price_nbe > 0)) { + //echo "nope\n"; + continue; + } + + echo $op->product->name."\n ".$op->price_nne. " ".$op->price_nbe." -> ".$op->product->price_nne." ".$op->product->price_nbe."\n"; + + //continue; + $op->price_nne = $op->product->price_nne; + $op->price_nbe = $op->product->price_nbe; + $op->save(); +}