Files
thetool/Layout/default/Contract/LinkTable.php
2024-11-13 13:51:49 +00:00

78 lines
4.6 KiB
PHP

<?php
/**
* @var Contract $contract - asd
*/
?>
<h4>Verknüpfte Verträge <small>
<a href="<?= self::getUrl("Contract", "add", ["origin_contract_id" => $contract->id]) ?>">
<i class="fas fa-plus"></i>NeuenContract anlegen
</a>
</small>
</h4>
<?php if ((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
<table class="table table-striped table-sm table-bordered table-hover">
<tr>
<th>Typ</th>
<th>Kunde</th>
<th>Contract ID</th>
<th style="min-width: 300px">Produkt</th>
<th>Preis</th>
<th>Preis Setup</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th></th>
</tr>
<?php
$contract_link_data = [];
foreach ([$contract->linkFrom, $contract->linkTo] as $links):
foreach ($links as $link):
if ($link->contract_id == $contract->id) {
$direction = $link->type == "credit" ? "zu" : "von";
$linkcontract = $link->origin;
} else {
$linkcontract = $link->contract;
if ($link->type == "upgrade" || $link->type == "downgrade") {
$direction = "auf";
}
if ($link->type == "relocation") {
$direction = "nach";
}
if ($link->type == "credit") {
$direction = "";
}
}
?>
<tr>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?>"><?= __($link->type, "contract") ?> <?= ($link->type != "link") ? $direction : "" ?></td>
<td>
<a href="<?= self::getUrl("Address", "View", ["id" => $linkcontract->owner_id]) ?>"><?= $linkcontract->owner->getCompanyOrName() ?></a>
</td>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?> <?= (!$linkcontract->isFinished()) ? "not-finished" : "" ?>">
<a
href="<?= self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id]) ?>"><?= $linkcontract->id ?></a></td>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?> <?= (!$linkcontract->isFinished()) ? "not-finished" : "" ?>">
<a
href="<?= self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id]) ?>"><?= $linkcontract->product_name ?>
[<?= $linkcontract->matchcode ?>]</a></td>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?> <?= (!$linkcontract->isFinished()) ? "not-finished" : "" ?> <?= ($linkcontract->price < 0) ? "text-danger" : "" ?>">
€ <?= number_format($linkcontract->price, 4, ",", ".") ?></td>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?> <?= (!$linkcontract->isFinished()) ? "not-finished" : "" ?> <?= ($linkcontract->price_setup < 0) ? "text-danger" : "" ?>">
€ <?= number_format($linkcontract->price_setup, 4, ",", ".") ?></td>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?> <?= (!$linkcontract->isFinished()) ? "not-finished" : "" ?>"><?= ($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : "" ?></td>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?> <?= (!$linkcontract->isFinished()) ? "not-finished" : "" ?>"><?= ($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : "" ?></td>
<td class="contract <?= ($linkcontract->isCancelled()) ? "canceled" : "" ?> <?= (!$linkcontract->isFinished()) ? "not-finished" : "" ?> <?= ($linkcontract->cancel_date) ? "text-danger font-weight-bold" : "" ?>"><?= ($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : "" ?></td>
<td>
<a href="<?= self::getUrl("Contract", "deleteLink", ["link_id" => $link->id]) ?>"
onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i
class="fas fa-xmark-large"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
<?php endif; ?>