WIP PreorderPrice 2025-02-21

This commit is contained in:
Frank Schubert
2025-02-24 12:37:33 +01:00
parent fdd6ed7ebb
commit 99bdbd3b39
12 changed files with 1329 additions and 135 deletions

View File

@@ -1,5 +0,0 @@
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -30,36 +30,61 @@
</div>
</div>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-4">
<form class="form-inline" type="get" action="<?=self::getUrl("PreorderProduct")?>">
<div class="form-group mx-sm-3 mb-2">
<label for="view_date">Ansichtsdatum:</label>
<input type="text" class="form-control datepicker-sys ml-2" name="view_date" placeholder="Datum..." value="<?=$today_date?>" />
</div>
<button type="submit" class="btn btn-primary mb-2">Anzeigen</button>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<?php foreach($netoperators as $netoperator): // TODO: Netoperators als Tabs anzeigen ?>
<h4><span class="text-pink"><?=$netoperator->getCompanyOrName()?> (<?=$netoperator->id?>)</span></h4>
<?php //foreach([new Address(5668), new Address(4803)] as $netoperator): // TODO: Netoperators als Tabs anzeigen ?>
<h4><?=$netoperator->getCompanyOrName()?> (<?=$netoperator->id?>)</h4>
<div class="card">
<div class="card-body mb-3">
<form method="post" action="<?=self::getUrl("PreorderProduct", "save")?>">
<h4>Produkte</h4>
<?php foreach($products as $product): ?>
<?php $product->setNetoperatorId($netoperator->id) ?>
<?php $prices = (array_key_exists($netoperator->id, $product->prices)) ? $product->prices[$netoperator->id] : false; ?>
<?php //var_dump($prices); ?>
<?php $product->setNetoperatorId($netoperator->id) ?>
<?php $product->setTodayDate($today_date); ?>
<?php //$prices = (array_key_exists($netoperator->id, $product->prices)) ? $product->prices[$netoperator->id] : false; ?>
<div class="card">
<div class="card-body mb-3">
<h4>Preiseinstellungen für <?=$product->name?></h4>
<div class="card-header" >
<h4 class="pointer"
data-toggle="collapse" data-target="#price-detail-<?=$netoperator->id?>-<?=$product->id?>"
id="price-detail-<?=$netoperator->id?>-<?=$product->id?>-collapse" data-collapse-indicator="fa-chevron" onclick="toggleCollapseIndicator(this)"
>
<i class="fas fa-fw fa-chevron-right collapse-indicator"></i> Preiseinstellungen für <span class="text-pink"><?=$product->name?></span>
</h4>
</div>
<div class="card-body mb-3 collapse" id="price-detail-<?=$netoperator->id?>-<?=$product->id?>">
<?php if($product->type == "operator_setup"): ?>
<?php include(__DIR__."/include/netoperator-prices-setup.php"); ?>
<?php include(__DIR__."/include/prices-setup.php"); ?>
<?php elseif($product->type == "enduser_setup"): ?>
<?php include(__DIR__."/include/enduser-prices-setup.php"); ?>
<?php elseif($product->type == "operatr_usage"): ?>
<?php include(__DIR__."/include/prices-setup.php"); ?>
<?php elseif($product->type == "operator_usage"): ?>
<?php include(__DIR__."/include/netoperator-prices-usage.php"); ?>
<?php endif; ?>
</div>
</div>
<hr />
<?php endforeach; ?>
<input type="submit" class="btn btn-primary mt-2" value="Speichern" />
</form>
</div>
</div>
<?php endforeach; ?>
@@ -83,5 +108,40 @@
todayBtn: 'linked',
autoclose: true
});
$('.datepicker-sys').datepicker({
language: 'de',
format: "yyyy-mm-dd",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
$(".select2").select2({
allowClear: true,
placeholder: "",
closeOnSelect: true
});
$(".select2-nc").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
function toggleCollapseIndicator(elem) {
var selector = "#" + $(elem).attr("id");
var itype = $(elem).data("collapse-indicator");
//console.log("selector: " + selector);
if($(selector + " i.collapse-indicator").hasClass(itype + "-right")) {
$(selector + " i.collapse-indicator").removeClass(itype + "-right").addClass(itype + "-down");
} else {
$(selector + " i.collapse-indicator").removeClass(itype + "-down").addClass(itype + "-right");
}
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -1,82 +0,0 @@
<div class="row">
<div class="col-6">
<div class="form-group">
Derzeit gültiger Preis: <strong><?=$product->current_price->price_setup?></strong>
<?php if($product->current_price->end_date): ?>
(bis <?=(new DateTime($product->current_price->end_date))->format("d.m.Y")?>)
<?php endif; ?>
<br />
Derzeit regulärer Preis: <strong><?=$product->current_regular_price->price_setup?></strong><br />
Originalpreis: <?=$product->first_price->price_setup?>
</div>
<div class="form-group">
<button type="button" class="btn btn-outline-success" onclick='$("#pricehistory-<?=$netoperator->id?>-<?=$product->id?>").toggle()'><i class="fas fa-fw fa-list"></i> Preishistory anzeigen</button>
</div>
<div class="row hidden" id="pricehistory-<?=$netoperator->id?>-<?=$product->id?>">
<table class="table table-sm table-striped table-hover">
<tr>
<th>Preis</th>
<th>Gültig von</th>
<th>Gültig bis</th>
</tr>
<?php foreach(PreorderProductPrice::search(["netowner_id" => $netowner->id,"preorderproduct_id" => $product->id, "netoperator_id" => $netoperator->id]) as $line): ?>
<tr>
<td><?=$line->price_setup?></td>
<td><?=($line->start_date) ? (new DateTime($line->start_date))->format("d.m.Y") : "-"?></td>
<td><?=($line->end_date) ? (new DateTime($line->end_date))->format("d.m.Y") : "-"?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<h4>Neuer Preis</h4>
<div class="form-group">
<label>Bereitstellungsentgelt</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">€</span>
</div>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_setup]" value="" />
</div>
</div>
<div class="form-group">
<label>Neuer Preis Gültigkeit</label>
<div class="row">
<div class="col-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Preis gültig von</span>
</div>
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][start_date]" value="" />
</div>
</div>
<div class="col-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Preis gültig bis</span>
</div>
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][end_date]" value="" />
</div>
</div>
</div>
<small>
Ohne <strong>Gültig-Bis-Datum</strong> gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.<br />
Mit <strong>Gültig-Bis-Datum</strong> gilt der neue Preis bis einschließlich dem <strong>Gültig-Bis-Datum</strong>, danach gilt der vorige Preis wieder.
</small>
</div>
</div>
</div>

View File

@@ -1 +1,306 @@
<?php
/**
* @var Address $netowner
* @var Address $netoperator
* @var PreorderProduct $product
* @var Array $campaigns
* @var string $today_date
*/
?>
<div class="row">
<div class="col-6">
<form method="post" action="<?=self::getUrl("PreorderProduct", "save")?>">
<div class="form-group">
<button type="button" class="btn btn-outline-success" onclick='$("#pricehistory-<?=$netoperator->id?>-<?=$product->id?>").toggle()'><i class="fas fa-fw fa-list"></i> Preishistory anzeigen</button>
</div>
<div class="row hidden" id="pricehistory-<?=$netoperator->id?>-<?=$product->id?>">
<table class="table table-sm table-striped table-hover">
<tr>
<th>INET</th>
<th>INET+TV</th>
<th>CATV</th>
<th>Passive</th>
<th>Gültig von</th>
<th>Gültig bis</th>
<th>Kampagnen</th>
<th>Beschreibung</th>
<th>Erstellt von</th>
</tr>
<?php foreach(PreorderProductPrice::search(["netowner_id" => $netowner->id, "preorderproduct_id" => $product->id, "netoperator_id" => $netoperator->id]) as $line): ?>
<tr>
<td class="text-monospace">€ <?=number_format($line->price_inet, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($line->price_inet_tv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($line->price_catv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($line->price_passive, 2, ",", ".")?></td>
<td class="text-monospace"><?=($line->start_date) ? (new DateTime($line->start_date))->format("d.m.Y") : "-"?></td>
<td class="text-monospace"><?=($line->end_date) ? (new DateTime($line->end_date))->format("d.m.Y") : "-"?></td>
<td><?=(is_array($line->campaigns) && count($line->campaigns)) ? count($line->campaigns) : ""?></td>
<td><?=$line->description?></td>
<td><?=$line->creator->name?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div class="card">
<div class="card-header">
<h4 class="pointer text-info" data-toggle="collapse" data-target="#new-price-<?=$netoperator->id?>-<?=$product->id?>"
id="new-price-<?=$netoperator->id?>-<?=$product->id?>-collapse" data-collapse-indicator="fa-circle-chevron"
onclick="toggleCollapseIndicator(this)">
<i class="fas fa-fw fa-circle-chevron-right collapse-indicator"></i> Neuen Preis eingeben
</h4>
</div>
<div class="card-body collapse" id="new-price-<?=$netoperator->id?>-<?=$product->id?>">
<div class="row">
<div class="col">
<div class="form-group">
<label>Beschreibung</label>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][description]" value="" />
</div>
</div>
</div>
<div class="form-group">
<label>Preis Internet</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">€</span>
</div>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_inet]" value="" />
</div>
</div>
<div class="form-group">
<label>Preis Internet + TV</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">€</span>
</div>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_inet_tv]" value="" />
</div>
</div>
<div class="form-group">
<label>Preis Cable-TV</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">€</span>
</div>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_catv]" value="" />
</div>
</div>
<div class="form-group">
<label>Preis Passive Leitung</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">€</span>
</div>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_passive]" value="" />
</div>
</div>
<div class="form-group">
<label>Gültigkeit</label>
<div class="row">
<div class="col-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Preis gültig von</span>
</div>
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][start_date]" value="" />
</div>
</div>
<div class="col-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Preis gültig bis</span>
</div>
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][end_date]" value="" />
</div>
</div>
</div>
<small>
Ohne <strong>Gültig-Bis-Datum</strong> gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.<br />
Mit <strong>Gültig-Bis-Datum</strong> gilt der neue Preis bis einschließlich dem <strong>Gültig-Bis-Datum</strong>, danach gilt der vorige Preis wieder.
</small>
<div class="row mt-3">
<div class="col">
<div class="form-group">
<label>Nur gültig in folgenden Kampagnen</label>
<select class="select2-nc form-control select2-multiple" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][campaigns][]" multiple="multiple" data-placeholder="Kampagnen ...">
<?php foreach ($campaigns as $campaign): ?>
<option value="<?= $campaign->id ?>" <?= (is_array($product->campaigns) && array_key_exists($campaign->id, $product->campaigns)) ? "selected='selected'" : "" ?>><?= $campaign->name ?></option>
<?php endforeach; ?>
</select>
<small>
Wenn keine Kampagne ausgewählt wird, gilt der Preis für alle Kampagnen.
</small>
</div>
</div>
</div>
<h4>Netzdurchdringung</h4>
<div class="row">
<div class="col">
<p>Rabattierte Preise für das Erreichen on Netzdurchdringungszielen</p>
<p>0 - 15% ist der Standardpreis. Falls keine Netzdurchdringung </p>
<table class="table table-sm table-bordered table-striped table-hover">
<tr>
<th>Ziel</th>
<th>INET</th>
<th>INET+TV</th>
<th>CATV</th>
<th>Passive</th>
</tr><tr>
<th>0 - 15%</th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][inet]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][inet_tv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][catv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][passive]" /></th>
</tr><tr>
<th>15,01% - 20%</th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][inet]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][inet_tv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][catv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][passive]" /></th>
</tr><tr>
<th>20,01% - 25%</th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][inet]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][inet_tv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][catv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][passive]" /></th>
</tr><tr>
<th>25,01% - 30%</th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][inet]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][inet_tv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][catv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][passive]" /></th>
</tr><tr>
<th>30,01% - 35%</th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][inet]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][inet_tv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][catv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][passive]" /></th>
</tr><tr>
<th>35,01% - 40%</th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][inet]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][inet_tv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][catv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][passive]" /></th>
</tr><tr>
<th>40,01% - 45%</th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][inet]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][inet_tv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][catv]" /></th>
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][passive]" /></th>
</tr>
</table>
</div>
</div>
</div>
<input type="submit" class="btn btn-primary mt-2" value="Speichern" />
</div>
</div>
</form>
</div>
<?php
$current_price = $product->getCurrentPrice($today_date, true);
$current_regular_price = $product->getCurrentRegularPrice($today_date, true);
$first_price = $product->getFirstPrice($today_date);
?>
<div class="col-6">
<div class="row">
<div class="col">
<h4>Aktuelle Preise für <?=$product->getTodayDate()?></h4>
<table class="table">
<tr>
<th></th>
<th>INET</th>
<th>INET+TV</th>
<th>CATV</th>
<th>Passive</th>
<th></th>
</tr>
<tr>
<th>Heute gültiger Preis</th>
<td class="text-monospace">€ <?=number_format($current_price->price_inet, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($current_price->price_inet_tv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($current_price->price_catv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($current_price->price_passive, 2, ",", ".")?></td>
<td>
<?=$current_price->description?>
<?php if($current_price->end_date): ?>
bis <?=(new DateTime($current_price->end_date))->format("d.m.Y")?>
<?php endif; ?>
</td>
</tr><tr>
<th>Derzeit regulärer Preis</th>
<td class="text-monospace">€ <?=number_format($current_regular_price->price_inet, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($current_regular_price->price_inet_tv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($current_regular_price->price_catv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($current_regular_price->price_passive, 2, ",", ".")?></td>
<td><?=$current_regular_price->description?></td>
</tr><tr>
<td>Initialpreis</td>
<td class="text-monospace">€ <?=number_format($first_price->price_inet, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($first_price->price_inet_tv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($first_price->price_catv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($first_price->price_passive, 2, ",", ".")?></td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col">
<h4>Preis Pro Kampagne</h4>
<table class="table table-sm table-striped table-hover">
<tr>
<th>Kampagne</th>
<th>INET</th>
<th>INET+TV</th>
<th>CATV</th>
<th>Passive</th>
<th>Gültig von</th>
<th>Gültig bis</th>
<th>Beschreibung</th>
<th></th>
</tr>
<?php foreach($campaigns as $campaign): ?>
<?php $cprice = $product->getCampaignPrice($campaign->id, $today_date); ?>
<tr>
<td><?=$campaign->name?></td>
<td class="text-monospace">€ <?=number_format($cprice->price_inet, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($cprice->price_inet_tv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($cprice->price_catv, 2, ",", ".")?></td>
<td class="text-monospace">€ <?=number_format($cprice->price_passive, 2, ",", ".")?></td>
<td class="text-monospace"><?=($cprice->start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?></td>
<td class="text-monospace"><?=($cprice->end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?></td>
<td><?=$cprice->description?></td>
<td><?=$product->getTodayDate()?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,190 @@
<?php
/**
* @var Address $netowner
* @var Address $netoperator
* @var PreorderProduct $product
* @var Array $campaigns
* @var string $today_date
*/
?>
<div class="row">
<div class="col-6">
<form method="post" action="<?=self::getUrl("PreorderProduct", "save")?>">
<div class="form-group">
<button type="button" class="btn btn-outline-success" onclick='$("#pricehistory-<?=$netoperator->id?>-<?=$product->id?>").toggle()'><i class="fas fa-fw fa-list"></i> Preishistory anzeigen</button>
</div>
<div class="row hidden" id="pricehistory-<?=$netoperator->id?>-<?=$product->id?>">
<table class="table table-sm table-striped table-hover">
<tr>
<th>Preis</th>
<th>Gültig von</th>
<th>Gültig bis</th>
<th>Kampagnen</th>
<th>Beschreibung</th>
<th>Erstellt von</th>
</tr>
<?php foreach(PreorderProductPrice::search(["netowner_id" => $netowner->id, "preorderproduct_id" => $product->id, "netoperator_id" => $netoperator->id]) as $line): ?>
<tr>
<td class="text-monospace">€ <?=number_format($line->price_setup, 2, ",", ".")?></td>
<td class="text-monospace"><?=($line->start_date) ? (new DateTime($line->start_date))->format("d.m.Y") : "-"?></td>
<td class="text-monospace"><?=($line->end_date) ? (new DateTime($line->end_date))->format("d.m.Y") : "-"?></td>
<td><?=(is_array($line->campaigns) && count($line->campaigns)) ? count($line->campaigns) : ""?></td>
<td><?=$line->description?></td>
<td><?=$line->creator->name?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div class="card">
<div class="card-header">
<h4 class="pointer text-info" data-toggle="collapse" data-target="#new-price-<?=$netoperator->id?>-<?=$product->id?>"
id="new-price-<?=$netoperator->id?>-<?=$product->id?>-collapse" data-collapse-indicator="fa-circle-chevron"
onclick="toggleCollapseIndicator(this)">
<i class="fas fa-fw fa-circle-chevron-right collapse-indicator"></i> Neuen Preis eingeben
</h4>
</div>
<div class="card-body collapse" id="new-price-<?=$netoperator->id?>-<?=$product->id?>">
<div class="row">
<div class="col">
<div class="form-group">
<label>Beschreibung</label>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][description]" value="" />
</div>
</div>
</div>
<div class="form-group">
<label>Preis</label>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">€</span>
</div>
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_setup]" value="" />
</div>
</div>
<div class="form-group">
<label>Gültigkeit</label>
<div class="row">
<div class="col-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Preis gültig von</span>
</div>
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][start_date]" value="" />
</div>
</div>
<div class="col-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Preis gültig bis</span>
</div>
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][end_date]" value="" />
</div>
</div>
</div>
<small>
Ohne <strong>Gültig-Bis-Datum</strong> gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.<br />
Mit <strong>Gültig-Bis-Datum</strong> gilt der neue Preis bis einschließlich dem <strong>Gültig-Bis-Datum</strong>, danach gilt der vorige Preis wieder.
</small>
<div class="row mt-3">
<div class="col">
<div class="form-group">
<label>Nur gültig in folgenden Kampagnen</label>
<select class="select2-nc form-control select2-multiple" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][campaigns][]" multiple="multiple" data-placeholder="Kampagnen ...">
<?php foreach ($campaigns as $campaign): ?>
<option value="<?= $campaign->id ?>" <?= (is_array($product->campaigns) && array_key_exists($campaign->id, $product->campaigns)) ? "selected='selected'" : "" ?>><?= $campaign->name ?></option>
<?php endforeach; ?>
</select>
<small>
Wenn keine Kampagne ausgewählt wird, gilt der Preis für alle Kampagnen.
</small>
</div>
</div>
</div>
</div>
<input type="submit" class="btn btn-primary mt-2" value="Speichern" />
</div>
</div>
</form>
</div>
<?php
$current_price = $product->getCurrentPrice($today_date, true);
$current_regular_price = $product->getCurrentRegularPrice($today_date, true);
$first_price = $product->getFirstPrice($today_date);
?>
<div class="col-6">
<div class="row">
<div class="col">
<h4>Aktuelle Preise für <?=$product->getTodayDate()?></h4>
<table class="table">
<tr>
<th>Heute gültiger Preis</th>
<td class="text-monospace">€ <?=number_format($current_price->price_setup, 2, ",", ".")?></td>
<td>
<?=$current_price->description?>
<?php if($current_price->end_date): ?>
bis <?=(new DateTime($current_price->end_date))->format("d.m.Y")?>
<?php endif; ?>
</td>
</tr><tr>
<th>Derzeit regulärer Preis</th>
<td class="text-monospace">€ <?=number_format($current_regular_price->price_setup, 2, ",", ".")?></td>
<td><?=$current_regular_price->description?></td>
</tr><tr>
<td>Initialpreis <span class="text-monospace">€ <?=number_format($first_price->price_setup, 2, ",", ".")?></span></td>
<td></td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col">
<h4>Preis Pro Kampagne</h4>
<table class="table table-sm table-striped table-hover">
<tr>
<th>Kampagne</th>
<th>Preis</th>
<th>Gültig von</th>
<th>Gültig bis</th>
<th>Beschreibung</th>
<th></th>
</tr>
<?php foreach($campaigns as $campaign): ?>
<?php $cprice = $product->getCampaignPrice($campaign->id, $today_date); ?>
<tr>
<td><?=$campaign->name?></td>
<td class="text-monospace">€ <?=number_format($cprice->price_setup, 2, ",", ".")?></td>
<td class="text-monospace"><?=($cprice->start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?></td>
<td class="text-monospace"><?=($cprice->end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?></td>
<td><?=$cprice->description?></td>
<td><?=$product->getTodayDate()?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>