Merge branch 'fronkdev' into 'master'

Updated wohneinheit count script

See merge request fronk/thetool!495
This commit is contained in:
Frank Schubert
2024-07-17 15:39:50 +00:00
13 changed files with 1533 additions and 1264 deletions

View File

@@ -46,6 +46,11 @@
</tr><tr>
<th>Produkt Info:</th>
<td><?=$contract->product_info?></td>
</tr><tr>
<th>Verrechnungsperiode:</th>
<td>
<?=__($contract->billing_period, "billing_period")?>
</td>
</tr><tr>
<th>Fertigstellungsdatum:</th>
<td><?=date("d.m.Y",$contract->finish_date)?></td>
@@ -75,7 +80,7 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="cancel_date">Kündigungsdatum:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=($term_end_date) ? $term_end_date->format("d.m.Y") : ""?>">
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=($term_end_date) ? $term_end_date : ""?>">
</div>
</div>
@@ -84,8 +89,8 @@
<div class="col-lg-10">
<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>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?=($term_end_date) ? $term_end_date : ""?>')">Ende der Vertragslaufzeit</button>
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?=($period_end_date) ? $period_end_date : ""?>')">Ende der aktuellen Rechnungsperiode</button>
</div>
</div>
@@ -122,6 +127,7 @@
$linkcontract = $link->contract;
}
if($linkcontract->isCancelled()) continue;
if(!$linkcontract->billing_period) continue;
?>

View File

@@ -86,7 +86,7 @@
<div class="form-group row" id="termination_row">
<label class="col-lg-2 col-form-label" for="matchcode">Anschluss *</label>
<div class="col-lg-10">
<select name="products[<?=$i?>][termination_id]" id="termination_id-<?=$i?>" class="form-control select2">
<select name="termination_id" id="termination_id" class="form-control select2">
<option></option>
<?php foreach($terminations as $t): ?>
<option value="<?=$t->id?>" <?=($t->id == $contract->termination_id) ? "selected='selected'" : ""?>><?=$t->code?> - <?=$t->getAddress()?></option>

View File

@@ -1,344 +1,447 @@
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<?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">Product-/Standortwechsel</li>
</ol>
</div>
<h4 class="page-title">Aktives Produkt</h4>
<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">Product-/Standortwechsel</li>
</ol>
</div>
<h4 class="page-title">Aktives Produkt</h4>
</div>
</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>
</table>
</div>
</div>
<div class="card">
<div class="card-body">
<h4 class="text-center mb-3">Neuer Contract</h4>
<form method="post" action="<?=self::getUrl("Contract", "saveProductchange")?>">
<input type="hidden" name="contract_id" value="<?=$contract->id?>" />
<div class="row justify-content-center">
<div class="col-xl-6">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_id">Produkt</label>
<div class="col-lg-10">
<select class="form-control basicAutoComplete" autocomplete="off" name="product_id" id="product_id" data-url="<?=self::getUrl('Product','api')?>?do=findProduct&autocomplete=1" placeholder="Tippen zum suchen..." data-noresults-text="Keine Suchergebnisse">
<option></option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="matchcode">Matchcode:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="matchcode" id="matchcode" value="<?=$contract->matchcode?>">
<small class="font-italic">Eindeutige Identifizierung das Produkts. Z.B. Anschlussadresse, Domainname usw.</small>
</div>
</div>
<?php if(
(is_array($contract->product->attributes) && count($contract->product->attributes))
&& (array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $contract->product->attributes)
&& $contract->product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME]->value == 1)
|| $contract->termination_id
): ?>
<div class="form-group row" id="termination_id-line">
<?php else: ?>
<div class="form-group row hidden" id="termination_id-line">
<?php endif; ?>
<label class="col-lg-2 col-form-label" for="matchcode">Anschluss</label>
<div class="col-lg-10">
<select name="termination_id" id="termination_id" class="form-control select2">
<option></option>
<?php foreach($terminations as $t): ?>
<option value="<?=$t->id?>" <?=($t->id == $contract->termination_id) ? "selected='selected'" : ""?>><?=$t->code?> - <?=$t->getAddress(true)?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_name">Individueller Produktname:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="product_name" id="product_name" value="<?=$contract->product_name?>">
<small class="font-italic">Scheint statt dem echten Produktnamen auf der Rechnung auf</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_info">Produkt Zusatztext:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="product_info" id="product_info" value="<?=$contract->product_info?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price_setup">Preis Setup:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_setup" id="price_setup" value="<?=$contract->price_setup?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price">Preis Periodisch:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price" id="price" value="<?=$contract->price?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price_nne">Preis NNE</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_nne" id="price_nne" value="<?=$contract->price_nne?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price_nbe">Preis NBE</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_nbe" id="price_nbe" value="<?=$contract->price_nbe?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="billing_period">Verrechnungsperiode</label>
<div class="col-lg-10">
<select class="form-control" name="billing_period" id="billing_period" placeholder="Verrechnungsperiode">
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="billing_delay">Verzögerter Verrechnungsstart</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="billing_delay" id="billing_delay" placeholder="Freimonate" value="<?=$contract->billing_delay?>">
</div>
</div>
<div class="col-lg-12">
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
<h4>Verknüpfte Verträge</h4>
<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>
<table class="table table-striped table-sm table-bordered table-hover" id="link-table">
<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 title="Verlinkten Contract mit neuem Contract verknüpfen">Übernehmen</th>
<th title="Verlinkten Contract mit altem Contract zusammen kündigen">Kündigen</th>
<th>Kunde</th>
<th>Contract ID</th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<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>Preis Netto:</th>
<td class="<?=($contract->price < 0) ? "text-danger" : ""?>">€ <?=number_format(($contract->amount != 1) ? $contract->price * $contract->amount : $contract->price, 4, ",", ".")?></td>
</tr><tr>
<th>Preis Brutto:</th>
<td class="<?=($contract->price < 0) ? "text-danger" : ""?>">€
<?php if($contract->price && $contract->vatrate): ?>
<?php if($contract->amount != 1): ?>
<?=number_format($contract->price + ($contract->price / 100) * $contract->vatrate, 4, ",", ".")?>
<?php else: ?>
<?=number_format(($contract->price + ($contract->price / 100) * $contract->vatrate) * $contract->amount, 4, ",", ".")?>
<?php endif; ?>
<?php endif; ?>
</td>
</tr><tr>
<th>Fertigstellungsdatum:</th>
<td><?=date("d.m.Y", $contract->finish_date)?></td>
</tr>
<?php foreach($contract->linksWithCredit as $link): ?>
<?php
</table>
if($link->contract_id == $contract->id) {
$linkcontract = $link->origin;
} else {
$linkcontract = $link->contract;
}
?>
<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>
<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->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; ?>
<!-- TODO: Fileupload -->
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="note" rows="5"><?=$contract->note?></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<h4 class="text-center mb-3">Neuer Contract</h4>
<form method="post" action="<?=self::getUrl("Contract", "saveProductchange")?>">
<input type="hidden" name="contract_id" value="<?=$contract->id?>"/>
<div class="row justify-content-center">
<div class="col-xl-10">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_id">Produkt</label>
<div class="col-lg-10">
<select class="form-control basicAutoComplete" autocomplete="off"
name="product_id" id="product_id"
data-url="<?=self::getUrl('Product', 'api')?>?do=findProduct&autocomplete=1"
placeholder="Tippen zum suchen..."
data-noresults-text="Keine Suchergebnisse">
<option></option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="matchcode">Matchcode:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="matchcode" id="matchcode"
value="<?=$contract->matchcode?>">
<small class="font-italic">Eindeutige Identifizierung das Produkts. Z.B.
Anschlussadresse, Domainname usw.</small>
</div>
</div>
<?php if(
(is_array($contract->product->attributes) && count($contract->product->attributes))
&& (array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $contract->product->attributes)
&& $contract->product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME]->value == 1)
|| $contract->termination_id
): ?>
<div class="form-group row" id="termination_id-line">
<?php else: ?>
<div class="form-group row hidden" id="termination_id-line">
<?php endif; ?>
<label class="col-lg-2 col-form-label" for="matchcode">Anschluss</label>
<div class="col-lg-10">
<select name="termination_id" id="termination_id"
class="form-control select2">
<option></option>
<?php foreach($terminations as $t): ?>
<option value="<?=$t->id?>" <?=($t->id == $contract->termination_id) ? "selected='selected'" : ""?>><?=$t->code?>
- <?=$t->getAddress(true)?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_name">Individueller
Produktname:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="product_name"
id="product_name" value="<?=$contract->product_name?>">
<small class="font-italic">Scheint statt dem echten Produktnamen auf der
Rechnung auf</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_info">Produkt
Zusatztext:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="product_info"
id="product_info" value="<?=$contract->product_info?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price_setup">Preis Setup:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_setup" id="price_setup"
value="<?=$contract->price_setup?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price">Preis Periodisch:</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price" id="price"
value="<?=$contract->price?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price_nne">Preis NNE</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_nne" id="price_nne"
value="<?=$contract->price_nne?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price_nbe">Preis NBE</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="price_nbe" id="price_nbe"
value="<?=$contract->price_nbe?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="billing_period">Verrechnungsperiode</label>
<div class="col-lg-10">
<select class="form-control" name="billing_period" id="billing_period"
placeholder="Verrechnungsperiode">
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>
Monatlich
</option>
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>
Jährlich
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="billing_delay">Verzögerter
Verrechnungsstart</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="billing_delay"
id="billing_delay" placeholder="Freimonate"
value="<?=$contract->billing_delay?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="billing_delay">Fertigstellungsdatum</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="finish_date" id="finish_date" value="">
</div>
</div>
<?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="Verlinkten Contract mit neuem Contract verknüpfen">
Übernehmen
</th>
<th title="Verlinkten Contract mit altem Contract zusammen kündigen">
Kündigen
</th>
<th>Kü.Datum</th>
<th>Kunde</th>
<th>Contract ID</th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
</tr>
<?php foreach($contract->linksWithCredit as $link): ?>
<?php
if($link->contract_id == $contract->id) {
$linkcontract = $link->origin;
} else {
$linkcontract = $link->contract;
}
if($linkcontract->isCancelled()) continue;
?>
<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?>][action]"
value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?>
onchange="linkActionChange(<?=$link->id?>)" />
<?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?>][action]" value="cancel"
onchange="linkActionChange(<?=$link->id?>)" />
</td>
<td>
<input type="text" class="form-control hidden" id="link-<?=$link->id?>-cancel_date" name="links[<?=$link->id?>][cancel_date]" value="<?=$linkcontract->getRegularCanceldate()?>" />
</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->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; ?>
<!-- TODO: Fileupload -->
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea id="note" class="form-control" name="note"
rows="5"><?=$contract->note?></textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col text-center">
<input type="submit" class="btn btn-primary" value="Produktwechsel speichern"/>
</div>
</div>
</form>
<div class="row">
<div class="col text-center">
<input type="submit" class="btn btn-primary" value="Produktwechsel 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 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>
$(".select2").select2({
allowClear: true,
placeholder: ""
});
/*
* product autocomplete
*/
<?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 else: ?>
$(".select2").select2({
allowClear: true,
placeholder: ""
});
$("#finish_date").datepicker({
language: 'de',
format: "dd.mm.yyyy",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
/*
* product autocomplete
*/
<?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 else: ?>
$('#product_id').autoComplete();
<?php endif; ?>
<?php endif; ?>
$('#product_id').keydown(function () {
if (event.keyCode == 13) {
event.preventDefault();
return false;
}
});
$('#product_id').on("autocomplete.select", function (evt, item) {
if (item && item.value === 0) {
$('#product_id').autoComplete('set', null);
}
if (item && item.value) {
updateProduct(item.value);
}
});
// product autocomplete
function updateProduct() {
var pid = $('input[name=product_id]').val();
$.get("<?=self::getUrl("Product", "Api")?>",
{
"do": "getProduct",
product_id: pid
},
function (success) {
//console.log(success);
p = success.result.product;
$('#product_name').val(p.name);
//$('#product_info').val(p.name);
$('#billing_delay').val(p.billing_delay);
$('#billing_period').val(p.billing_period);
$('#price').val(p.price);
$('#price_setup').val(p.price_setup);
$('#price_nne').val(p.price_nne);
$('#price_nbe').val(p.price_nbe);
if (typeof p.attributes === 'object' && "termination_required" in p.attributes && p.attributes.termination_required == 1) {
$('#termination_id-line').show();
$('#termination_id').select2({
allowClear: true,
placeholder: ""
});
} else {
$('#termination_id-line').hide();
//$('#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');
$('#product_id').keydown(function() {
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
$('#product_id').on("autocomplete.select", function(evt, item) {
if(item && item.value === 0) {
$('#product_id').autoComplete('set', null);
function linkActionChange(link_id) {
//console.log($("#link-" + link_id + "-action-cancel").prop("checked"));
if($("#link-" + link_id + "-action-cancel").prop("checked")) {
$("#link-" + link_id + "-cancel_date").show();
} else {
$("#link-" + link_id + "-cancel_date").hide();
}
//link-<?=$link->id?>-action-cancel
}
if(item && item.value) {
updateProduct(item.value);
}
});
// product autocomplete
function updateProduct() {
var pid = $('input[name=product_id]').val();
$.get("<?=self::getUrl("Product", "Api")?>",
{
"do": "getProduct",
product_id: pid
},
function (success) {
//console.log(success);
p = success.result.product;
$('#product_name').val(p.name);
//$('#product_info').val(p.name);
$('#billing_delay').val(p.billing_delay);
$('#billing_period').val(p.billing_period);
$('#price').val(p.price);
$('#price_setup').val(p.price_setup);
$('#price_nne').val(p.price_nne);
$('#price_nbe').val(p.price_nbe);
if(typeof p.attributes === 'object' && "termination_required" in p.attributes && p.attributes.termination_required == 1) {
$('#termination_id-line').show();
$('#termination_id').select2({
allowClear: true,
placeholder: ""
});
} else {
$('#termination_id-line').hide();
//$('#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');
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -19,12 +19,11 @@
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<a href="<?=self::getUrl("Contract","Index")?>" class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsübersicht</a>
<a href="<?=self::getUrl("Contract","edit", ['contract_id' => $contract->id, 'f' => "view"])?>" class="btn btn-sm btn-outline-success"><i class="fas fa-edit"></i> Vertrag bearbeiten</a>
<?php if($me->username == "fronk"): ?><a href="<?=self::getUrl("Contract","sendCancelNotification", ['contract_id' => $contract->id])?>" class="btn btn-sm btn-purple"><i class="fas fa-edit"></i> Temp button</a><?php endif; ?>
</div>
</div>
@@ -64,7 +63,7 @@
<th>Upgrade auf:</th>
<td>
<?php foreach($contract->upgradeTo as $link): ?>
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->contract_id])?>" class="contract-link <?=($link->contract->cancel_date && $link->contract->cancel_date <= date('U')) ? "canceled" : ""?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
<a href="<?=self::getUrl("Contract", "View", ["contract_id" => $link->contract_id])?>" class="contract-link <?=($link->contract->cancel_date && $link->contract->cancel_date <= date('U')) ? "canceled" : ""?> <?=(!$link->contract->isFinished()) ? "not-finished" : "" ?>"><?=$link->contract->product_name?> [<?=$link->contract->matchcode?>] (<?=$link->contract_id?>)</a><br />
<?php endforeach; ?>
</td>
</tr>
@@ -233,7 +232,7 @@
<a href="<?=self::getUrl("Contract", "productchange", ["contract_id" => $contract->id])?>"><button type="button" class="btn btn-sm btn-outline-purple"><i class="far fa-truck-container fa-fw"></i> Produkt-/Standortwechsel</button></a>
<a href="<?=self::getUrl("Contract", "cancel", ["contract_id" => $contract->id])?>"><button type="button" class="btn btn-sm btn-outline-danger"><i class="far fa-axe fa-fw"></i> Kündigen</button></a>
<?php else: ?>
<a href="<?=self::getUrl("Contract", "finishContract", ['contract_id' => $contract->id])?>" onclick="if(!confirm('Jetzt fertigstellen und in Verrechnung geben?')) return false"><button type="button" class="btn btn-sm btn-success"><i class="far fa-face-confused fa-fw"></i> Fertigstellen</button></a>
<a href="<?=self::getUrl("Contract", "finishContract", ['contract_id' => $contract->id])?>" onclick="if(!confirm('Jetzt fertigstellen und in Verrechnung geben?')) return false"><button type="button" class="btn btn-sm btn-success"><i class="far fa-face-confused fa-fw"></i> Jetzt fertigstellen</button></a>
<?php endif; ?>
</td>
</tr>
@@ -290,11 +289,13 @@
<td><i class="fas fa-cogs text-secondary pl-1"></i></td>
<td style="width: 100%">
<?php if($j->value == "manual"): ?>
<em>Vertrag manuell angelegt</em>
<em>Vertrag manuell erstellt</em>
<?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
<?php elseif($j->value == "productchange"): ?>
<em>Vertrag erstellt: <?=nl2br(htmlentities($j->text))?>
<?php endif; ?>
</td>
<?php elseif($j->type == "contract_finished"): ?>
@@ -311,7 +312,9 @@
<?php $link = new Contract($j->value); ?>
<td><i class="fas fa-link text-secondary pl-1"></i></td>
<td style="width: 100%"><em>Verknüpfung mit <a href="<?=self::getUrl("Contract", "view", ['contract_id' => $link->id])?>"><?=$link->id?> - <?=$link->product_name?> [<?=$link->matchcode?>]</a> erstellt</em></td>
<?php elseif($j->type == "canceled"): ?>
<td><i class="fas fa-skull-crossbones bg-danger text-white p-1"></i></td>
<td style="width: 100%"><em>Vertag gekündigt</em></td>
<?php endif; ?>
<td style="white-space: nowrap">
<a href="<?=self::getUrl("Contractjournal", "edit", ["journal_id" => $j->id])?>" title="Journaleintrag bearbeiten"><i class="fas fa-edit"></i></a>