Contractqueue: commit to Contract finished

This commit is contained in:
Frank Schubert
2024-04-18 22:58:37 +02:00
parent b9f270fb10
commit e388c6e066
12 changed files with 932 additions and 721 deletions
+1 -1
View File
@@ -377,7 +377,7 @@
*/
<?php if($contract->product_id && is_object(($contract->product))): ?>
$('#product_id').autoComplete('set', { value: <?=$contract->product_id?>, text: '<?=($contract->product_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->product->name))." [".$contract->product_id."]" : ""?>'});
<?php if(array_key_exists("termination_required", $contract->product) && $contract->product->attributes["termination_required"] != 1): ?>
<?php if(array_key_exists("termination_required", $contract->product->attributes) && $contract->product->attributes["termination_required"] != 1): ?>
$("#termination_row").hide();
<?php endif; ?>
<?php else: ?>
+14 -7
View File
@@ -63,7 +63,14 @@
<option value="1" <?=($filter['show_canceled'] == 1 ) ? "selected='selected'" : ""?>>Anzeigen</option>
</select>
</div>
<div class="col-2">
<label class="form-label" for="filter_show_credit">Gutschriften</label>
<select class="form-control" name="filter[show_credit]" id="filter_show_credit">
<option value="0" <?=($filter['show_credit'] == 0) ? "selected='selected'" : ""?>>Ausblenden</option>
<option value="1" <?=($filter['show_credit'] == 1 ) ? "selected='selected'" : ""?>>Anzeigen</option>
</select>
</div>
</div>
<div class="row mt-2">
<div class="col">
@@ -110,8 +117,8 @@
<tr>
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->id?></a></td>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</td>
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->product_name?></a></td>
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?>"><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->product_name?></a></td>
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?>"><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
<!--<td>
<?php if($contract->termination_id): ?>
<?=$contract->termination->building->street?><br />
@@ -121,9 +128,9 @@
</a>
<?php endif; ?>
</td>-->
<td><?=$contract->price?></td>
<td><?=$contract->price_setup?></td>
<td>
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?> <?=($contract->price < 0) ? "text-danger" : ""?>"><?=$contract->price?></td>
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?> <?=($contract->price_setup < 0) ? "text-danger" : ""?>"><?=$contract->price_setup?></td>
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?>">
<?php if($contract->billing_period == 1): ?>
monatlich
<?php elseif($contract->billing_period == 24): ?>
@@ -134,7 +141,7 @@
<?=(12 / $contract->billing_period)?>x Jährlich
<?php endif; ?>
</td>
<td class="text-monospace"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
<td class="text-monospace <?=(!$contract->isFinished()) ? "not-finished" : "" ?>"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
<td class="text-monospace"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->create)?><br /><?=$contract->creator->name?></td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->edit)?><br /><?=$contract->editor->name?></td>
+33 -5
View File
@@ -165,7 +165,7 @@
<?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">
<table class="table table-striped table-sm table-bordered table-hover" id="link-table">
<tr>
<th title="Verlinkten Contract mit neuem Contract verknüpfen">Übernehmen</th>
<th title="Verlinkten Contract mit altem Contract zusammen kündigen">Kündigen</th>
@@ -177,7 +177,7 @@
<th>Fertigstellung</th>
<th>Kündigung</th>
</tr>
<?php foreach($contract->links as $link): ?>
<?php foreach($contract->linksWithCredit as $link): ?>
<?php
if($link->contract_id == $contract->id) {
@@ -188,9 +188,14 @@
}
?>
<tr>
<td><input type="radio" class="form-check" id="link-<?=$link->id?>-action-keep" name="links[<?=$link->id?>]" value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?> /></td>
<td><input type="radio" class="form-check" id="link-<?=$link->id?>-action-cancel" name="links[<?=$link->id?>]" value="cancel" /></td>
<tr data-link-type="<?=$link->type?>">
<td>
<input type="radio" class="form-check link-keep" id="link-<?=$link->id?>-action-keep" name="links[<?=$link->id?>]" value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?> />
<?php if($link->type == "credit"): ?>
(Gutschrift wird neu erstellt)
<?php endif; ?>
</td>
<td><input type="radio" class="form-check link-cancel" id="link-<?=$link->id?>-action-cancel" name="links[<?=$link->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>
@@ -307,6 +312,29 @@
//$('#termination_id-' + id + '-line').hide();
}
// set credit-link to cancel if new product does not need credit
const attrib = p.attributes;
let crediting_partner = false;
let crediting_rate = 0;
if(crediting_partner in p.attributes) {
crediting_partner = parseInt(p.attributes.crediting_partner);
}
if(crediting_rate in p.attributes) {
crediting_rate = parseFloat(p.attributes.crediting_rate);
}
let price_nne = parseFloat(p.price_nne);
//console.log(p.price_nne, crediting_partner, crediting_rate);
if(price_nne || (crediting_partner && crediting_rate)) {
$("#link-table tr[data-link-type='credit'] input.link-keep").prop("checked", "checked");
}
if(!price_nne && (!crediting_partner || !crediting_rate)) {
$("#link-table tr[data-link-type='credit'] input.link-cancel").prop("checked", "checked");
}
},
'json');
+17 -6
View File
@@ -29,12 +29,17 @@
<div class="card border-top-success">
<div class="card-body">
<?php if(!$contract->finish_date || $contract->finish_date > date('U')): ?>
<?php if(!$contract->isFinished()): ?>
<h2 class="text-center mb-3 text-secondary">In Herstellung</h2>
<?php endif; ?>
<?php if($contract->isCancelled()): ?>
<h2 class="text-center mb-3 text-danger">GEKÜNDIGT</h2>
<?php endif; ?>
<?php if(str_contains(strtolower($contract->sla->name), "residential")): ?>
<h2 class="text-center mb-3 text-danger">Privatprodukt</h2>
<?php else: ?>
<h2 class="text-center mb-3 text-primary">Businessprodukt</h2>
<?php endif; ?>
<h3 class="text-center mb-3 <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=$contract->product_name?> [<?=$contract->id?>]</h3>
<table class="table table-sm table-striped view-table">
@@ -232,7 +237,13 @@
<td style="white-space: nowrap" class="text-monospace"><?=date("d.m.Y H:i", $j->create)?> (<?=$j->creator?>)</td>
<?php if($j->type == "text" || $j->type == "phone"):?>
<td><i class="fas <?=($j->type == "text") ? "fa-align-left bg-success" : "fa-phone bg-success"?> text-white p-1"></i></td>
<td>
<?php if($j->type == "text"): ?>
<i class="fas fa-align-left bg-warning text-white p-1" title="Kommentar"></i>
<?php else: ?>
<i class="fas fa-phone bg-warning text-white p-1" title="Anruf"></i>
<?php endif; ?>
</td>
<?php if(strlen($j->text) > 120): ?>
<td style="width: 100%" class="pointer" onclick="toggleTruncatedJournalText(<?=$j->id?>)">
<span id="truncated-<?=$j->id?>"><i class="fas fa-caret-right"></i> <?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 120)?></span>
@@ -246,7 +257,7 @@
</td>
<?php elseif($j->type == "file"): ?>
<td><i class="fas fa-download bg-primary text-white p-1"></i></td>
<td><i class="fas fa-download bg-primary text-white p-1" title="Dateiupload"></i></td>
<td style="width: 100%">
<?php if($j->text): ?>
<?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 128)?><br />
@@ -262,7 +273,7 @@
<?php elseif($j->value == "import"): ?>
<em>Vertrag importiert: <?=nl2br(htmlentities($j->text))?>
<?php elseif($j->value == "order"): ?>
<em>Vertrag aus Bestellung #<a href="<?=self::getUrl("Order", "edit", ["id" => $contract->orderproduct->order_id])?>"><?=$contract->orderproduct->order_id?></a> erstellt
<em>Vertrag aus Bestellung <a href="<?=self::getUrl("Order", "edit", ["id" => $contract->orderproduct->order_id])?>">#<?=$contract->orderproduct->order_id?></a> erstellt
<?php endif; ?>
</td>
<?php elseif($j->type == "credit_created"): ?>
@@ -344,7 +355,7 @@
$direction = "von";
$linkcontract = $link->origin;
if($link->type == "credit") {
$direction = "";
$direction = "zu";
//continue;
}
} else {
@@ -356,7 +367,7 @@
$direction = "nach";
}
if($link->type == "credit") {
$direction = "zu";
$direction = "";
//continue;
}