Files
thetool/Layout/default/PreorderProduct/include/prices-setup.php
2025-02-25 20:33:47 +01:00

186 lines
9.6 KiB
PHP

<?php
/**
* @var Address $netowner
* @var Address $netoperator
* @var PreorderProduct $product
* @var Array $campaigns
* @var string $today_date
*/
?>
<div class="row" id="netop-<?=$netoperator->id?>-<?=$product->id?>">
<?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-7">
<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 class="col-5">
<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 title="Erstellt <?=date("d.m.Y H:i", $line->create)?>"><?=$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>
</div>