From 995072178f49699ec16e1914fb2aee15c321618f Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 17 May 2022 17:55:13 +0200 Subject: [PATCH] More product related changes in preorder --- Layout/default/Preorder/Form.php | 14 ++- Layout/default/Preorder/Index.php | 4 +- application/Preorder/PreorderController.php | 105 ++++++++++-------- .../Preordercampaign/Preordercampaign.php | 16 ++- 4 files changed, 90 insertions(+), 49 deletions(-) diff --git a/Layout/default/Preorder/Form.php b/Layout/default/Preorder/Form.php index 4a8d02e58..8b350b978 100644 --- a/Layout/default/Preorder/Form.php +++ b/Layout/default/Preorder/Form.php @@ -6,7 +6,7 @@
@@ -141,7 +141,7 @@ - setup_products) && count($campaign->setup_products)): ?> + product_type != "no_setup" && is_array($campaign->setup_products) && count($campaign->setup_products)): ?> setup_products['provision']) && count($campaign->setup_products['provision'])): ?>
@@ -177,8 +177,9 @@ + product_type != "setup_only"): ?>
- +
+
@@ -331,6 +333,9 @@ if(!$("#price_setup").val()) { $("#price_setup").val($("#setup-provision input.value").data("price")); } + setup_products['provision']) == 1): ?> + $("#setup_product_id").val($("#setup-provision input.value").val()); + } if($('#type').val() == "order") { @@ -338,6 +343,9 @@ if(!$("#price_setup").val()) { $("#price_setup").val($("#setup-provision input.value").data("price")); } + setup_products['activation']) == 1): ?> + $("#setup_product_id").val($("#setup-activation input.value").val()); + } diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index abc575d14..c02c790f3 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -26,9 +26,11 @@

Liste aller Vorbestellungenname : ""?>

+ + diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php index ac71119c1..58b561390 100644 --- a/application/Preorder/PreorderController.php +++ b/application/Preorder/PreorderController.php @@ -88,7 +88,9 @@ class PreorderController extends mfBaseController { $products = []; foreach(ProductNetworkModel::search(["network_id" => $campaign->network_id]) as $pn) { if(!array_key_exists($pn->product_id, $products)) { - $products[$pn->product_id] = $pn->product; + if(is_array($pn->product->attributes) && !array_key_exists("presales", $pn->product->attributes)) { + $products[$pn->product_id] = $pn->product; + } } } //var_dump($products);exit; @@ -147,8 +149,20 @@ class PreorderController extends mfBaseController { $data['preordercampaign_id'] = $r->campaign_id; $data['building_id'] = $r->building_id; $data['termination_id'] = ($r->termination_id) ? $r->termination_id : null; - $data['product_id'] = $r->product_id; - $data['setup_product_id'] = $r->setup_product_id; + + if($campaign->product_type != "setup_only") { + $data['product_id'] = $r->product_id; + } + if(!$r->product_id) { + $data['product_id'] = null; + } + + if($campaign->product_type != "no_setup") { + $data['setup_product_id'] = $r->setup_product_id; + } + if(!$r->setup_product_id) { + $data['setup_product_id'] = null; + } switch($r->type) { case "interest": @@ -162,11 +176,11 @@ class PreorderController extends mfBaseController { break; } - $data['price'] = $r->price; - $data['price_setup'] = $r->price_setup; - $data['price_nne'] = $r->price_nne; - $data['price_nbe'] = $r->price_nbe; - $data['billing_delay'] = $r->billing_delay; + $data['price'] = ($r->price) ? $r->price : 0; + $data['price_setup'] = ($r->price_setup) ? $r->price_setup : 0; + $data['price_nne'] = ($r->price_nne) ? $r->price_nne : 0; + $data['price_nbe'] = ($r->price_nbe) ? $r->price_nbe : 0; + $data['billing_delay'] = ($r->billing_delay) ? $r->billing_delay : 0; if($r->partner_id) { $data['partner_id'] = $r->partner_id; @@ -211,43 +225,46 @@ class PreorderController extends mfBaseController { return $this->addAction(); } - $product = new Product($data['product_id']); - if(!$product->id) { - $this->layout()->setFlash("Bitte Produkt auswählen!", "error"); - $this->layout()->set("preorder", $preorder); - $this->layout()->set("campaign", $campaign); - return $this->addAction(); + if($data['product_id']) { + $product = new Product($data['product_id']); + if(!$product->id) { + $this->layout()->setFlash("Bitte Produkt auswählen!", "error"); + $this->layout()->set("preorder", $preorder); + $this->layout()->set("campaign", $campaign); + return $this->addAction(); + } + + $preorder->billing_period = $product->billing_period; + + if(!$this->me->isAdmin()) { + $preorder->price_nne = $product->price_nne; + $preorder->price_nbe = $product->price_nbe; + } + + if(!strlen($preorder->price) + || !strlen($preorder->price_setup) + || !strlen($preorder->price_nne) + || !strlen($preorder->price_nbe) + || !strlen($preorder->price_nne)) { + $this->layout()->setFlash("Bitte alle benötigten Produktdaten ausfüllen!", "error"); + $this->layout()->set("preorder", $preorder); + $this->layout()->set("campaign", $campaign); + return $this->addAction(); + } + + if(!strlen($preorder->firstname) + || !strlen($preorder->lastname) + || !strlen($preorder->street) + || !strlen($preorder->zip) + || !strlen($preorder->city)) { + $this->layout()->setFlash("Bitte alle benötigten Kundendaten ausfüllen!", "error"); + $this->layout()->set("preorder", $preorder); + $this->layout()->set("campaign", $campaign); + return $this->addAction(); + } + } else { + $preorder->billing_period = 0; } - $preorder->billing_period = $product->billing_period; - if(!$this->me->isAdmin()) { - $preorder->price_nne = $product->price_nne; - $preorder->price_nbe = $product->price_nbe; - } - - - if(!strlen($preorder->price) - || !strlen($preorder->price_setup) - || !strlen($preorder->price_nne) - || !strlen($preorder->price_nbe) - || !strlen($preorder->price_nne)) { - $this->layout()->setFlash("Bitte alle benötigten Produktdaten ausfüllen!", "error"); - $this->layout()->set("preorder", $preorder); - $this->layout()->set("campaign", $campaign); - return $this->addAction(); - } - - if(!strlen($preorder->firstname) - || !strlen($preorder->lastname) - || !strlen($preorder->street) - || !strlen($preorder->zip) - || !strlen($preorder->city)) { - $this->layout()->setFlash("Bitte alle benötigten Kundendaten ausfüllen!", "error"); - $this->layout()->set("preorder", $preorder); - $this->layout()->set("campaign", $campaign); - return $this->addAction(); - } - - //var_dump($preorder);exit; diff --git a/application/Preordercampaign/Preordercampaign.php b/application/Preordercampaign/Preordercampaign.php index 6c1babfa8..eb2ccb217 100644 --- a/application/Preordercampaign/Preordercampaign.php +++ b/application/Preordercampaign/Preordercampaign.php @@ -43,10 +43,24 @@ class Preordercampaign extends mfBaseModel { } public function getSetupProducts() { + $provision_products = []; + $activation_products = []; + $provisions = ProductModel::search(["attributename" => "presales", "attributevalue" => "provision"]); $activations = ProductModel::search(["attributename" => "presales", "attributevalue" => "activation"]); - return ['activation' => $activations, 'provision' => $provisions]; + foreach($provisions as $p) { + if(ProductNetworkModel::search(['product_id' => $p->id, "network_id" => $this->network_id])) { + $provision_products[] = $p; + } + } + foreach($activations as $p) { + if(ProductNetworkModel::search(['product_id' => $p->id, "network_id" => $this->network_id])) { + $activation_products[] = $p; + } + } + + return ['activation' => $activation_products, 'provision' => $provision_products]; } public function getProperty($name) {