Contract Cancelling done
This commit is contained in:
193
Layout/default/Contract/CancelForm.php
Normal file
193
Layout/default/Contract/CancelForm.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<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("Contract")?>">Aktive Produkte</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract", "view", ['id' => $contract->id])?>"><?=$contract->product_name?> [<?=$contract->matchcode?>]</a></li>
|
||||
<li class="breadcrumb-item active">Kündigung</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Aktives Produkt</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h3 class="text-center mb-3"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
|
||||
|
||||
<table class="table table-sm table-striped view-table">
|
||||
<tr>
|
||||
<th style="max-width: 50vw;">Matchcode:</th>
|
||||
<td style="width: 50vw;"><?=$contract->matchcode?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Vertragsinhaber:</th>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Produkt:</th>
|
||||
<td><?=$contract->product_name?> [<?=$contract->product_id?>]<?=($contract->product_name != $contract->product->name) ? " <i>(".$contract->product->name.")</i>" : ""?></td>
|
||||
</tr><tr>
|
||||
<th>Produkt Info:</th>
|
||||
<td><?=$contract->product_info?></td>
|
||||
</tr><tr>
|
||||
<th>Fertigstellungsdatum:</th>
|
||||
<td><?=date("d.m.Y",$contract->finish_date)?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="text-center mb-3">Kündigung</h4>
|
||||
|
||||
<form method="post" action="<?=self::getUrl("Contract", "saveCancel")?>">
|
||||
<input type="hidden" name="contract_id" value="<?=$contract->id?>" />
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-xl-8">
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<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">
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
|
||||
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
|
||||
<h4>Verknüpfte Verträge</h4>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered table-hover" id="link-table">
|
||||
<tr>
|
||||
<th title="Verlinkter Contract bleibt bestehen">nicht kündigen</th>
|
||||
<th title="Verlinkter Contract wird auch gekündigt">ebenfalls Kündigen</th>
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Preis Netto</th>
|
||||
<th>Bestelldatum</th>
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
<?php
|
||||
|
||||
if($link->contract_id == $contract->id) {
|
||||
$linkcontract = $link->origin;
|
||||
} else {
|
||||
$linkcontract = $link->contract;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<tr data-link-type="<?=$link->type?>">
|
||||
<td class="text-center">
|
||||
<input type="radio" class="form-check link-keep" id="link-<?=$linkcontract->id?>-action-keep" name="links[<?=$linkcontract->id?>]" value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?> />
|
||||
</td>
|
||||
<td><input type="radio" class="form-check link-cancel" id="link-<?=$linkcontract->id?>-action-cancel" name="links[<?=$linkcontract->id?>]" value="cancel" /></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>" target="_blank"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->id?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->product_name?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->matchcode?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?> <?=($linkcontract->price < 0) ? "text-danger" : ""?>">€ <?=number_format($linkcontract->price, 4, ",", ".")?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- TODO: Fileupload -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<input type="submit" class="btn btn-primary" value="Kündigung speichern" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<a href="<?=self::getUrl("Contract","View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
$('#cancel_date').datepicker({
|
||||
language: 'de',
|
||||
format: "dd.mm.yyyy",
|
||||
showWeekDays: true,
|
||||
todayBtn: 'linked',
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
function setCancelDate(date) {
|
||||
$("#cancel_date").val(date);
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -9,7 +9,7 @@
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract", "view", ['id' => $contract->id])?>"><?=$contract->product_name?> [<?=$contract->matchcode?>]</a></li>
|
||||
<li class="breadcrumb-item active">Konfiguration</li>
|
||||
<li class="breadcrumb-item active">Product-/Standortwechsel</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Aktives Produkt</h4>
|
||||
|
||||
@@ -411,7 +411,7 @@
|
||||
<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) ? date('d.m.Y', $linkcontract->cancel_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>
|
||||
|
||||
@@ -272,7 +272,7 @@ class Admin_IvtCreditImport {
|
||||
$link = ContractLinkModel::create([
|
||||
'contract_id' => $cred_contract->id,
|
||||
'origin_contract_id' => $contract->id,
|
||||
'type' => 'link'
|
||||
'type' => 'credit'
|
||||
]);
|
||||
$link->save();
|
||||
}
|
||||
|
||||
@@ -115,6 +115,82 @@ class ContractController extends mfBaseController
|
||||
|
||||
}
|
||||
|
||||
protected function cancelAction() {
|
||||
$this->layout()->setTemplate("Contract/CancelForm");
|
||||
|
||||
$id = $this->request->contract_id;
|
||||
if (!$id) $id = $this->request->id;
|
||||
|
||||
if(!$id) {
|
||||
$id = $this->request->id;
|
||||
}
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($id);
|
||||
if (!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$this->layout()->set("contract", $contract);
|
||||
|
||||
}
|
||||
|
||||
protected function saveCancel() {
|
||||
$r = $this->request;
|
||||
|
||||
$id = $r->contract_id;
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
$contract = new Contract($id);
|
||||
if (!$contract->id) {
|
||||
$this->layout()->setFlash("Vertrag nicht gefunden", "error");
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
|
||||
try {
|
||||
$cancel_date = DateTime::createFromFormat("d.m.Y", trim($r->cancel_date), new DateTimeZone("Europe/Vienna"));
|
||||
$cancel_date->setTime(2,0,0);
|
||||
} catch(Exception $e) {
|
||||
$this->layout()->setFlash("Ungültiges Datumsformat");
|
||||
$this->redirect("Contract", "cancel", ["contract_id" => $contract->id]);
|
||||
}
|
||||
|
||||
$contract->cancel_date = $cancel_date->getTimestamp();
|
||||
if(!$contract->save()) {
|
||||
$this->layout()->setFlash("Verlinkten Vertrag $link_id nicht gefunden", "error");
|
||||
$this->redirect("Contract", "cancel", ["contract_id" => $contract->id]);
|
||||
}
|
||||
|
||||
if(is_array($r->links)) {
|
||||
foreach($r->links as $link_id => $action) {
|
||||
if($action == "cancel") {
|
||||
$link_contract = new Contract($link_id);
|
||||
|
||||
if (!$link_contract->id) {
|
||||
$this->layout()->setFlash("Verlinkten Vertrag $link_id nicht gefunden", "warning");
|
||||
continue;
|
||||
}
|
||||
|
||||
$link_contract->cancel_date = $cancel_date->getTimestamp();
|
||||
if(!$link_contract->save()) {
|
||||
$this->layout()->setFlash("Fehler beim Speichern von verlinktem Vertrag", "warning");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Kündigung gespeichert", "success");
|
||||
$this->redirect("Contract", "view", ["contract_id" => $contract->id]);
|
||||
|
||||
}
|
||||
|
||||
protected function productchangeAction()
|
||||
{
|
||||
$this->layout()->setTemplate("Contract/ProductchangeForm");
|
||||
@@ -387,18 +463,6 @@ class ContractController extends mfBaseController
|
||||
|
||||
}
|
||||
|
||||
protected function cancelAction()
|
||||
{
|
||||
$id = $this->request->contract_id;
|
||||
if (!$id) $id = $this->request->id;
|
||||
|
||||
$this->layout()->setFlash("Not implemented", "error");
|
||||
if ($id) {
|
||||
$this->redirect("Contract", "view", ["id" => $id]);
|
||||
} else {
|
||||
$this->redirect("Contract");
|
||||
}
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
|
||||
@@ -93,6 +93,10 @@ h1, h2, h3, h4, h5, h6 {
|
||||
color: #323a36;
|
||||
}
|
||||
|
||||
.text-dark-red {
|
||||
color: #c1554c !important;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid #ced4da;
|
||||
/*box-shadow: 3px 3px 2px #a0a0a0;*/
|
||||
|
||||
Reference in New Issue
Block a user