More product related changes in preorder

This commit is contained in:
Frank Schubert
2022-05-17 17:55:13 +02:00
parent d9e65c3062
commit 995072178f
4 changed files with 90 additions and 49 deletions
+61 -44
View File
@@ -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;