Finished Contract Cancel

This commit is contained in:
Frank Schubert
2024-07-11 14:07:29 +02:00
parent 87f3708fe8
commit 3b35bd561e
3 changed files with 33 additions and 5 deletions

View File

@@ -290,7 +290,7 @@
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?> <?=($contract->price_setup < 0) ? "text-danger" : ""?>">€ <?=number_format($contract->price_setup,4,",",".")?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->order_date) ? date('d.m.Y', $contract->order_date) : ""?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
<td class="contract <?=($contract->isCancelled()) ? "canceled" : ""?> <?=($contract->cancel_date) ? "font-weight-bold text-danger" : ""?>"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
</tr>
<?php endforeach; ?>

View File

@@ -75,16 +75,17 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="cancel_date">Kyndigungsdatum:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="30.06.2025">
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=($term_end_date) ? $term_end_date->format("d.m.Y") : ""?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for=""></label>
<div class="col-lg-10">
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?="10.06.2024"?>')">Heute</button>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?="30.06.2025"?>')">Ende der Laufzeit</button>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?="31.07.2024"?>')">Ende der aktuellen Rechnungsperiode</button>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?=date("d.m.Y")?>')">Heute</button>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?=($tomorrow) ? $tomorrow->format("d.m.Y") : ""?>')">Morgen</button>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?=($term_end_date) ? $term_end_date->format("d.m.Y") : ""?>')">Ende der Vertragslaufzeit</button>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?=($period_end_date) ? $period_end_date->format("d.m.Y") : ""?>')">Ende der aktuellen Rechnungsperiode</button>
</div>
</div>

View File

@@ -135,6 +135,33 @@ class ContractController extends mfBaseController
$this->redirect("Contract");
}
if($contract->finish_date) {
$today = new DateTime();
$tomorrow = clone($today);
$tomorrow->modify("+1 day");
$finish_date = new DateTime("@".$contract->finish_date);
$finish_date->setTimezone(new DateTimeZone("Europe/Vienna"));
$period_end_date = clone($finish_date);
$period_end_date->modify("+".$contract->contract_term." months");
while($period_end_date->format("Y-m-d") <= $today->format("Y-m-d")) {
$period_end_date = $finish_date->modify("+".$contract->billing_period." months");
}
$period_end_date->modify("-1 day");
$next_billing_period = clone($finish_date);
$next_billing_period->modify("+".$contract->billing_period." months");
while($next_billing_period->format("Y-m-d") <= $today->format("Y-m-d")) {
$next_billing_period->modify("+".$contract->billing_period." months");
}
$next_billing_period->modify("-1 day");
$this->layout()->set("tomorrow", $tomorrow);
$this->layout()->set("term_end_date", $period_end_date);
$this->layout()->set("period_end_date", $next_billing_period);
}
$this->layout()->set("contract", $contract);
}