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

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');