More product related changes in preorder
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Building")?>">Vorbestellung</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordercampaign")?>">Vorbestellung</a></li>
|
||||
<li class="breadcrumb-item active"><?=($campaign->id) ? "bearbeiten" : "Neu" ?></li>
|
||||
</ol>
|
||||
</div>
|
||||
@@ -141,7 +141,7 @@
|
||||
|
||||
<input type="hidden" name="setup_product_id" id="setup_product_id" value="<?=$preorder->setup_product_id?>" />
|
||||
|
||||
<?php if(is_array($campaign->setup_products) && count($campaign->setup_products)): ?>
|
||||
<?php if($campaign->product_type != "no_setup" && is_array($campaign->setup_products) && count($campaign->setup_products)): ?>
|
||||
<?php if(is_array($campaign->setup_products['provision']) && count($campaign->setup_products['provision'])): ?>
|
||||
<div class="form-group row" id="setup-provision">
|
||||
<label class="col-lg-2 col-form-label" for="">Anschlussprodukt (Herstellung) *</label>
|
||||
@@ -177,8 +177,9 @@
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($campaign->product_type != "setup_only"): ?>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="product_id">Internetprodukt *</label>
|
||||
<label class="col-lg-2 col-form-label" for="product_id">Internetprodukt</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="product_id" id="product_id" onchange="updateProduct()">
|
||||
<option value=""></option>
|
||||
@@ -188,6 +189,7 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_setup">Netto Preis Setup *</label>
|
||||
@@ -331,6 +333,9 @@
|
||||
if(!$("#price_setup").val()) {
|
||||
$("#price_setup").val($("#setup-provision input.value").data("price"));
|
||||
}
|
||||
<?php if(count($campaign->setup_products['provision']) == 1): ?>
|
||||
$("#setup_product_id").val($("#setup-provision input.value").val());
|
||||
<?php endif; ?>
|
||||
}
|
||||
|
||||
if($('#type').val() == "order") {
|
||||
@@ -338,6 +343,9 @@
|
||||
if(!$("#price_setup").val()) {
|
||||
$("#price_setup").val($("#setup-provision input.value").data("price"));
|
||||
}
|
||||
<?php if(count($campaign->setup_products['activation']) == 1): ?>
|
||||
$("#setup_product_id").val($("#setup-activation input.value").val());
|
||||
<?php endif; ?>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,9 +26,11 @@
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Liste aller Vorbestellungen<?=($campaign) ? " - ".$campaign->name : ""?></h4>
|
||||
</div>
|
||||
<?php if($filter['campaign_id']): ?>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preorder", "add")?>"><i class="fas fa-plus"></i> Neue Vorbestellung anlegen</a>
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Preorder", "add", ["preordercampaign_id" => $filter['campaign_id']])?>"><i class="fas fa-plus"></i> Neue Vorbestellung anlegen</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user