WIP Productchange 2024-07-16
This commit is contained in:
@@ -46,6 +46,11 @@
|
|||||||
</tr><tr>
|
</tr><tr>
|
||||||
<th>Produkt Info:</th>
|
<th>Produkt Info:</th>
|
||||||
<td><?=$contract->product_info?></td>
|
<td><?=$contract->product_info?></td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Verrechnungsperiode:</th>
|
||||||
|
<td>
|
||||||
|
<?=__($contract->billing_period, "billing_period")?>
|
||||||
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<th>Fertigstellungsdatum:</th>
|
<th>Fertigstellungsdatum:</th>
|
||||||
<td><?=date("d.m.Y",$contract->finish_date)?></td>
|
<td><?=date("d.m.Y",$contract->finish_date)?></td>
|
||||||
@@ -75,7 +80,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2 col-form-label" for="cancel_date">Kündigungsdatum:</label>
|
<label class="col-lg-2 col-form-label" for="cancel_date">Kündigungsdatum:</label>
|
||||||
<div class="col-lg-10">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -84,8 +89,8 @@
|
|||||||
<div class="col-lg-10">
|
<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('<?=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('<?=($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('<?=($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->format("d.m.Y") : ""?>')">Ende der aktuellen Rechnungsperiode</button>
|
<button type="button" class="btn btn-outline-primary" onclick="setCancelDate('<?=($period_end_date) ? $period_end_date : ""?>')">Ende der aktuellen Rechnungsperiode</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -122,6 +127,7 @@
|
|||||||
$linkcontract = $link->contract;
|
$linkcontract = $link->contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($linkcontract->isCancelled()) continue;
|
||||||
if(!$linkcontract->billing_period) continue;
|
if(!$linkcontract->billing_period) continue;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
<div class="form-group row" id="termination_row">
|
<div class="form-group row" id="termination_row">
|
||||||
<label class="col-lg-2 col-form-label" for="matchcode">Anschluss *</label>
|
<label class="col-lg-2 col-form-label" for="matchcode">Anschluss *</label>
|
||||||
<div class="col-lg-10">
|
<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>
|
<option></option>
|
||||||
<?php foreach($terminations as $t): ?>
|
<?php foreach($terminations as $t): ?>
|
||||||
<option value="<?=$t->id?>" <?=($t->id == $contract->termination_id) ? "selected='selected'" : ""?>><?=$t->code?> - <?=$t->getAddress()?></option>
|
<option value="<?=$t->id?>" <?=($t->id == $contract->termination_id) ? "selected='selected'" : ""?>><?=$t->code?> - <?=$t->getAddress()?></option>
|
||||||
|
|||||||
@@ -1,344 +1,447 @@
|
|||||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||||
|
|
||||||
<!-- start page title -->
|
<!-- start page title -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="page-title-box">
|
<div class="page-title-box">
|
||||||
<div class="page-title-right">
|
<div class="page-title-right">
|
||||||
<ol class="breadcrumb m-0">
|
<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("Dashboard")?>"><?=MFAPPNAME_SLUG?></a>
|
||||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
|
</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"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
|
||||||
<li class="breadcrumb-item active">Product-/Standortwechsel</li>
|
<li class="breadcrumb-item"><a
|
||||||
</ol>
|
href="<?=self::getUrl("Contract", "view", ['id' => $contract->id])?>"><?=$contract->product_name?>
|
||||||
</div>
|
[<?=$contract->matchcode?>]</a></li>
|
||||||
<h4 class="page-title">Aktives Produkt</h4>
|
<li class="breadcrumb-item active">Product-/Standortwechsel</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<h4 class="page-title">Aktives Produkt</h4>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- end page title -->
|
<!-- end page title -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<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="card">
|
||||||
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
|
<div class="card-body">
|
||||||
<h4>Verknüpfte Verträge</h4>
|
<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>
|
<tr>
|
||||||
<th title="Verlinkten Contract mit neuem Contract verknüpfen">Übernehmen</th>
|
<th style="max-width: 50vw;">Matchcode:</th>
|
||||||
<th title="Verlinkten Contract mit altem Contract zusammen kündigen">Kündigen</th>
|
<td style="width: 50vw;"><?=$contract->matchcode?></td>
|
||||||
<th>Kunde</th>
|
</tr><tr>
|
||||||
<th>Contract ID</th>
|
<th>Vertragsinhaber:</th>
|
||||||
<th>Produkt</th>
|
<td>
|
||||||
<th>Matchcode</th>
|
<a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->getCompanyOrName()?>
|
||||||
<th>Bestelldatum</th>
|
(<?=$contract->owner->customer_number?>)
|
||||||
<th>Fertigstellung</th>
|
</a>
|
||||||
<th>Kündigung</th>
|
</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>
|
</tr>
|
||||||
<?php foreach($contract->linksWithCredit as $link): ?>
|
</table>
|
||||||
<?php
|
|
||||||
|
|
||||||
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>
|
||||||
|
|
||||||
|
|
||||||
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
</div>
|
<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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<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>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(".select2").select2({
|
$(".select2").select2({
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
placeholder: ""
|
placeholder: ""
|
||||||
});
|
});
|
||||||
/*
|
$("#finish_date").datepicker({
|
||||||
* product autocomplete
|
language: 'de',
|
||||||
*/
|
format: "dd.mm.yyyy",
|
||||||
<?php if($contract->product_id && is_object(($contract->product))): ?>
|
showWeekDays: true,
|
||||||
$('#product_id').autoComplete('set', { value: <?=$contract->product_id?>, text: '<?=($contract->product_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->product->name))." [".$contract->product_id."]" : ""?>'});
|
todayBtn: 'linked',
|
||||||
<?php else: ?>
|
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();
|
$('#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) {
|
function linkActionChange(link_id) {
|
||||||
if(item && item.value === 0) {
|
//console.log($("#link-" + link_id + "-action-cancel").prop("checked"));
|
||||||
$('#product_id').autoComplete('set', null);
|
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>
|
</script>
|
||||||
|
|
||||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|
||||||
@@ -19,12 +19,11 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<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","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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@
|
|||||||
<th>Upgrade auf:</th>
|
<th>Upgrade auf:</th>
|
||||||
<td>
|
<td>
|
||||||
<?php foreach($contract->upgradeTo as $link): ?>
|
<?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; ?>
|
<?php endforeach; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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", "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>
|
<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: ?>
|
<?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; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -290,11 +289,13 @@
|
|||||||
<td><i class="fas fa-cogs text-secondary pl-1"></i></td>
|
<td><i class="fas fa-cogs text-secondary pl-1"></i></td>
|
||||||
<td style="width: 100%">
|
<td style="width: 100%">
|
||||||
<?php if($j->value == "manual"): ?>
|
<?php if($j->value == "manual"): ?>
|
||||||
<em>Vertrag manuell angelegt</em>
|
<em>Vertrag manuell erstellt</em>
|
||||||
<?php elseif($j->value == "import"): ?>
|
<?php elseif($j->value == "import"): ?>
|
||||||
<em>Vertrag importiert: <?=nl2br(htmlentities($j->text))?>
|
<em>Vertrag importiert: <?=nl2br(htmlentities($j->text))?>
|
||||||
<?php elseif($j->value == "order"): ?>
|
<?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 elseif($j->value == "productchange"): ?>
|
||||||
|
<em>Vertrag erstellt: <?=nl2br(htmlentities($j->text))?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
<?php elseif($j->type == "contract_finished"): ?>
|
<?php elseif($j->type == "contract_finished"): ?>
|
||||||
@@ -311,7 +312,9 @@
|
|||||||
<?php $link = new Contract($j->value); ?>
|
<?php $link = new Contract($j->value); ?>
|
||||||
<td><i class="fas fa-link text-secondary pl-1"></i></td>
|
<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>
|
<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; ?>
|
<?php endif; ?>
|
||||||
<td style="white-space: nowrap">
|
<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>
|
<a href="<?=self::getUrl("Contractjournal", "edit", ["journal_id" => $j->id])?>" title="Journaleintrag bearbeiten"><i class="fas fa-edit"></i></a>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -140,34 +140,13 @@ class ContractController extends mfBaseController
|
|||||||
$this->redirect("Contract", "view", ["contract_id" => $contract->id]);
|
$this->redirect("Contract", "view", ["contract_id" => $contract->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($contract->finish_date) {
|
$today = new DateTime();
|
||||||
$today = new DateTime();
|
$tomorrow = clone($today);
|
||||||
$tomorrow = clone($today);
|
$tomorrow->modify("+1 day");
|
||||||
$tomorrow->modify("+1 day");
|
|
||||||
|
|
||||||
$finish_date = new DateTime("@".$contract->finish_date);
|
$this->layout()->set("tomorrow", $tomorrow);
|
||||||
$finish_date->setTimezone(new DateTimeZone("Europe/Vienna"));
|
$this->layout()->set("term_end_date", $contract->getRegularCanceldate());
|
||||||
|
$this->layout()->set("period_end_date", $contract->getNextBillingPeriodEnd());
|
||||||
$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);
|
$this->layout()->set("contract", $contract);
|
||||||
@@ -191,7 +170,7 @@ class ContractController extends mfBaseController
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$cancel_date = DateTime::createFromFormat("d.m.Y", trim($r->cancel_date), new DateTimeZone("Europe/Vienna"));
|
$cancel_date = DateTime::createFromFormat("d.m.Y", trim($r->cancel_date), new DateTimeZone("Europe/Vienna"));
|
||||||
$cancel_date->setTime(2,0,0);
|
$cancel_date->setTime(23,59,59);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$this->layout()->setFlash("Ungültiges Datumsformat");
|
$this->layout()->setFlash("Ungültiges Datumsformat");
|
||||||
$this->redirect("Contract", "cancel", ["contract_id" => $contract->id]);
|
$this->redirect("Contract", "cancel", ["contract_id" => $contract->id]);
|
||||||
@@ -288,6 +267,7 @@ class ContractController extends mfBaseController
|
|||||||
protected function saveProductchangeAction()
|
protected function saveProductchangeAction()
|
||||||
{
|
{
|
||||||
$r = $this->request;
|
$r = $this->request;
|
||||||
|
//var_dump($r->links);exit;
|
||||||
|
|
||||||
$id = $r->contract_id;
|
$id = $r->contract_id;
|
||||||
if (!is_numeric($id) || !$id) {
|
if (!is_numeric($id) || !$id) {
|
||||||
@@ -330,6 +310,22 @@ class ContractController extends mfBaseController
|
|||||||
$contract_data['product_external_id'] = $product->external_id;
|
$contract_data['product_external_id'] = $product->external_id;
|
||||||
$contract_data['sla_id'] = $product->sla_id;
|
$contract_data['sla_id'] = $product->sla_id;
|
||||||
|
|
||||||
|
if($r->finish_date) {
|
||||||
|
try {
|
||||||
|
$finish_date = DateTime::createFromFormat("d.m.Y", $r->finish_date, new DateTimeZone("Europe/Vienna"));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->layout()->setFlash("Ungültiges Kündigungsdateum", "error");
|
||||||
|
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$finish_date->setTime(0,0,0);
|
||||||
|
$contract_data["finish_date"] = $finish_date->getTimestamp();
|
||||||
|
|
||||||
|
$contract_cancel_date = clone($finish_date);
|
||||||
|
$contract_cancel_date->modify("-1 day");
|
||||||
|
$contract_cancel_date->setTime(23,59,59);
|
||||||
|
}
|
||||||
|
|
||||||
$require_term = false;
|
$require_term = false;
|
||||||
if (array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $product->attributes) && $product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME]->value == 1) {
|
if (array_key_exists(TT_ATTRIB_TERMINATION_REQUIRED_NAME, $product->attributes) && $product->attributes[TT_ATTRIB_TERMINATION_REQUIRED_NAME]->value == 1) {
|
||||||
//var_dump($prod->attributes);
|
//var_dump($prod->attributes);
|
||||||
@@ -353,41 +349,124 @@ class ContractController extends mfBaseController
|
|||||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($contract_cancel_date) {
|
||||||
|
$contract->cancel_date = $contract_cancel_date->getTimestamp();
|
||||||
|
$contract->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$journal = ContractjournalModel::create([
|
||||||
|
'contract_id' => $new_contract->id,
|
||||||
|
'type' => "created_from",
|
||||||
|
'value' => "productchange",
|
||||||
|
'text' => "Produkt-/Standortwechsel von Contract ID ".$contract->id
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
|
||||||
if (is_array($r->links) && count($r->links)) {
|
if (is_array($r->links) && count($r->links)) {
|
||||||
foreach ($r->links as $link_id => $action) {
|
foreach ($r->links as $link_id => $link_data) {
|
||||||
|
$action = $link_data["action"];
|
||||||
|
$cancel_date = false;
|
||||||
|
if($link_data["cancel_date"]) {
|
||||||
|
try {
|
||||||
|
$cancel_date = DateTime::createFromFormat("d.m.Y", $link_data["cancel_date"], new DateTimeZone("Europe/Vienna"));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->layout()->setFlash("Ungültiges Kündigungsdateum", "error");
|
||||||
|
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$old_link = new ContractLink($link_id);
|
$old_link = new ContractLink($link_id);
|
||||||
if (!$old_link->id) continue;
|
if (!$old_link->id) continue;
|
||||||
|
|
||||||
// check if link contains this contract
|
// check if link contains this contract
|
||||||
if ($old_link->contract_id == $contract->id) {
|
if ($old_link->contract_id == $contract->id) {
|
||||||
|
$origin_id = $old_link->origin_contract_id;
|
||||||
|
$link_contract_id = $old_link->contract_id;
|
||||||
|
|
||||||
$new_link_contract_id = $new_contract->id;
|
$new_link_contract_id = $new_contract->id;
|
||||||
$new_link_origin_id = $old_link->origin_contract_id;
|
$new_link_origin_id = $old_link->origin_contract_id;
|
||||||
} elseif ($old_link->origin_contract_id == $contract->id) {
|
} elseif ($old_link->origin_contract_id == $contract->id) {
|
||||||
|
$origin_id = $old_link->contract_id;
|
||||||
|
$link_contract_id = $old_link->origin_contract_id;
|
||||||
|
|
||||||
$new_link_contract_id = $old_link->contract_id;
|
$new_link_contract_id = $old_link->contract_id;
|
||||||
$new_link_origin_id = $new_contract->id;
|
$new_link_origin_id = $new_contract->id;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$new_link = ContractLinkModel::create([
|
if($action != "cancel" && $old_link->type != "credit") {
|
||||||
'contract_id' => $new_link_contract_id,
|
$new_link = ContractLinkModel::create([
|
||||||
'origin_contract_id' => $new_link_origin_id,
|
'contract_id' => $new_link_contract_id,
|
||||||
'type' => $old_link->type,
|
'origin_contract_id' => $new_link_origin_id,
|
||||||
]);
|
'type' => $old_link->type,
|
||||||
if (!$new_link->save()) {
|
]);
|
||||||
$this->layout()->setFlash("Konnte neuen Link nicht speichern", "warn");
|
if (!$new_link->save()) {
|
||||||
}
|
$this->layout()->setFlash("Konnte neuen Link nicht speichern", "warn");
|
||||||
|
|
||||||
if ($action == "cancel") {
|
|
||||||
$old_link->change_action = "cancel";
|
|
||||||
if (!$old_link->save()) {
|
|
||||||
$this->layout()->setFlash("Konnte alten Link nicht speichern", "warn");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == "cancel") {
|
||||||
|
if($cancel_date) {
|
||||||
|
// insert cancel_date in old contract
|
||||||
|
$lc = new Contract($origin_id);
|
||||||
|
$lc->cancel_date = $cancel_date->getTimestamp();
|
||||||
|
$lc->save();
|
||||||
|
} else {
|
||||||
|
// leave cancellation for later (when finishing upgrade)
|
||||||
|
$old_link->change_action = "cancel";
|
||||||
|
if (!$old_link->save()) {
|
||||||
|
$this->layout()->setFlash("Konnte alten Link nicht speichern", "warn");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ($old_link->type == "credit" && $action == "keep") {
|
if ($old_link->type == "credit" && $action == "keep") {
|
||||||
$old_link->change_action = "recreate";
|
// XXX - if we have finish date then recreate credit contract right now
|
||||||
|
if($contract_cancel_date) {
|
||||||
|
$new_credit = ContractModel::createCreditForContract($new_contract);
|
||||||
|
$new_credit->save();
|
||||||
|
|
||||||
|
// create journal for credit
|
||||||
|
$journal = ContractjournalModel::create([
|
||||||
|
'contract_id' => $new_credit->id,
|
||||||
|
'type' => "created_from",
|
||||||
|
'value' => "productchange",
|
||||||
|
'text' => "Produkt-/Standortwechsel von Contract ID ".$new_link_origin_id
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
|
||||||
|
|
||||||
|
$this->log->debug(print_r($new_credit, true));
|
||||||
|
|
||||||
|
// set cancel date for old credit
|
||||||
|
$old_credit = new Contract($origin_id);
|
||||||
|
$old_credit->cancel_date = $contract_cancel_date->getTimestamp();
|
||||||
|
$old_credit->save();
|
||||||
|
|
||||||
|
// create link to new credit contract
|
||||||
|
$link = ContractLinkModel::create([
|
||||||
|
"contract_id" => $new_credit->id,
|
||||||
|
"origin_contract_id" => $new_contract->id,
|
||||||
|
"type" => "credit"
|
||||||
|
]);
|
||||||
|
$link->save();
|
||||||
|
|
||||||
|
// create upgrade link from old to new credit contract
|
||||||
|
$link = ContractLinkModel::create([
|
||||||
|
"contract_id" => $new_credit->id,
|
||||||
|
"origin_contract_id" => $origin_id,
|
||||||
|
"type" => "upgrade"
|
||||||
|
]);
|
||||||
|
$link->save();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$old_link->change_action = "recreate";
|
||||||
|
$old_link->save();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump($new_link);exit;
|
//var_dump($new_link);exit;
|
||||||
@@ -439,82 +518,23 @@ class ContractController extends mfBaseController
|
|||||||
$this->redirect("Contract");
|
$this->redirect("Contract");
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = date('U');
|
$now = new DateTime("now");
|
||||||
|
$now->setTime(0,0,0);
|
||||||
/*
|
|
||||||
* Vorgänger Contracts kündigen
|
|
||||||
*/
|
|
||||||
foreach (ContractLinkModel::search(['contract_id' => $id]) as $link) {
|
|
||||||
if (!in_array($link->type, ["upgrade", "downgrade", "relocation", "productchange"])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$origin = $link->origin;
|
|
||||||
$origin->cancel_date = $now;
|
|
||||||
$origin->cancel_date_by = $this->me->id;
|
|
||||||
$origin->edit_by = $this->me->id;
|
|
||||||
if (!$origin->save()) {
|
|
||||||
$this->layout()->setFlash("Achtung: Konnte nicht alle Vorgängercontracts kündigen!", "warn");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* alte Links übernehmen / kündigen
|
|
||||||
*/
|
|
||||||
foreach (ContractLinkModel::search(['type' => "link", 'contract_id' => $origin->id]) as $old_link) {
|
|
||||||
// verlinkten Contract kündigen (wenn nicht schon gekündigt)
|
|
||||||
if ($old_link->change_action == "cancel" && !$old_link->contract->cancel_date) {
|
|
||||||
$old_link->origin->update([
|
|
||||||
'cancel_date' => $now,
|
|
||||||
'cancel_date_by' => $this->me->id,
|
|
||||||
'edit_by' => $this->me->id
|
|
||||||
]);
|
|
||||||
$old_link->origin->save();
|
|
||||||
|
|
||||||
$old_link->change_action = null;
|
|
||||||
$old_link->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (ContractLinkModel::search(['type' => "link", 'origin_contract_id' => $origin->id]) as $old_link) {
|
|
||||||
// verlinkten Contract kündigen (wenn nicht schon gekündigt)
|
|
||||||
if ($old_link->change_action == "cancel" && !$old_link->contract->cancel_date) {
|
|
||||||
$old_link->contract->update([
|
|
||||||
'cancel_date' => $now,
|
|
||||||
'cancel_date_by' => $this->me->id,
|
|
||||||
'edit_by' => $this->me->id
|
|
||||||
]);
|
|
||||||
$old_link->contract->save();
|
|
||||||
|
|
||||||
$old_link->change_action = null;
|
|
||||||
$old_link->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (ContractLinkModel::search(['type' => "credit", 'contract_id' => $origin->id]) as $old_credit) {
|
|
||||||
// verlinkten Contract kündigen (wenn nicht schon gekündigt)
|
|
||||||
if ($old_credit->change_action == "recreate" && !$old_credit->contract->cancel_date) {
|
|
||||||
$old_credit->origin->update([
|
|
||||||
'cancel_date' => $now,
|
|
||||||
'cancel_date_by' => $this->me->id,
|
|
||||||
'edit_by' => $this->me->id
|
|
||||||
]);
|
|
||||||
$old_credit->origin->save();
|
|
||||||
|
|
||||||
$old_credit->change_action = null;
|
|
||||||
$old_credit->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$contract->finish_date = $now->getTimestamp();
|
||||||
|
$contract->finish_date_by = $this->me->id;
|
||||||
|
try {
|
||||||
|
$saved = $contract->save();
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$saved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$saved) {
|
||||||
$contract->finish_date = $now;
|
|
||||||
$contract->finish_date_by = $this->me->id;
|
|
||||||
if (!$contract->save()) {
|
|
||||||
$this->layout()->setFlash("Contract konnte nicht gespeichert werden", "error");
|
$this->layout()->setFlash("Contract konnte nicht gespeichert werden", "error");
|
||||||
$this->redirect("Contract", "view", ['contract_id' => $id]);
|
$this->redirect("Contract", "view", ['contract_id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// create Journal
|
// create Journal
|
||||||
$journal = ContractjournalModel::create([
|
$journal = ContractjournalModel::create([
|
||||||
'contract_id' => $contract->id,
|
'contract_id' => $contract->id,
|
||||||
@@ -620,6 +640,10 @@ class ContractController extends mfBaseController
|
|||||||
$contract_data['billing_delay'] = (int)$r->billing_delay;
|
$contract_data['billing_delay'] = (int)$r->billing_delay;
|
||||||
$contract_data['note'] = $r->note;
|
$contract_data['note'] = $r->note;
|
||||||
|
|
||||||
|
if($r->termination_id) {
|
||||||
|
$contract_data["termination_id"] = $r->termination_id;
|
||||||
|
}
|
||||||
|
|
||||||
if($r->order_date) {
|
if($r->order_date) {
|
||||||
$order_date = new DateTime("@" . $this->dateToTimestamp($r->order_date));
|
$order_date = new DateTime("@" . $this->dateToTimestamp($r->order_date));
|
||||||
$order_date->setTimezone(new DateTimeZone("Europe/Vienna"));
|
$order_date->setTimezone(new DateTimeZone("Europe/Vienna"));
|
||||||
|
|||||||
@@ -184,6 +184,108 @@ class ContractModel {
|
|||||||
|
|
||||||
return $contract;
|
return $contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function createCreditForContract($contract) {
|
||||||
|
$log = mfLoghandler::singleton();
|
||||||
|
$me = new User();
|
||||||
|
$me->loadMe();
|
||||||
|
|
||||||
|
if(!$contract->id) {
|
||||||
|
$log->warning(__METHOD__."(): Invalid Contractqueue object");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$product = $contract->product;
|
||||||
|
$owner = $contract->owner;
|
||||||
|
|
||||||
|
if(!$product->id) {
|
||||||
|
$log->warning(__METHOD__."(): Invalid Product");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get credit price from NNE or percentage of sales price
|
||||||
|
*/
|
||||||
|
$crediting_partner_id = false;
|
||||||
|
$crediting_partner_rate = false;
|
||||||
|
|
||||||
|
$product_attribs = $product->attributes;
|
||||||
|
if(is_array($product_attribs) && array_key_exists("crediting_partner", $product_attribs) && $product_attribs["crediting_partner"] && is_object($product_attribs["crediting_partner"])) {
|
||||||
|
if($product_attribs["crediting_partner"]->value) {
|
||||||
|
$crediting_partner_id = $product_attribs["crediting_partner"]->value;
|
||||||
|
}
|
||||||
|
if($product_attribs["crediting_rate"]->value) {
|
||||||
|
$crediting_partner_rate = str_replace(",", ".",$product_attribs["crediting_rate"]->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// or from netowner if anschluss product
|
||||||
|
if(!$crediting_partner_id && $contract->termination_id) {
|
||||||
|
$crediting_partner_id = $contract->termination->building->network->owner_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$crediting_partner = new Address($crediting_partner_id);
|
||||||
|
if(!$crediting_partner->id) {
|
||||||
|
$log->error(__METHOD__.": Kein Crediting Partner gefunden für Credit für Contract ID ".$contract->id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine price:
|
||||||
|
// either NNE or percentage based, depends on product
|
||||||
|
$crediting_price = $product->price_nne;
|
||||||
|
if($crediting_partner_rate) {
|
||||||
|
$crediting_price = round($contract->price / 100 * $crediting_partner_rate, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$crediting_price) return true;
|
||||||
|
$crediting_price *= -1;
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data["orderproduct_id"] = null;
|
||||||
|
$data["owner_id"] = $crediting_partner_id;
|
||||||
|
$data["billingaddress_id"] = null;
|
||||||
|
$data["termination_id"] = null;
|
||||||
|
$data["product_id"] = $contract->product_id;
|
||||||
|
$data["product_name"] = $contract->product_name;
|
||||||
|
$data["product_info"] = $contract->product_info;
|
||||||
|
$data["amount"] = $contract->amount;
|
||||||
|
$data["sla_id"] = $contract->sla_id;
|
||||||
|
$data["product_external"] = $contract->product_external;
|
||||||
|
$data["product_external_id"] = $contract->product_external_id;
|
||||||
|
$data["billing_delay"] = $contract->billing_delay;
|
||||||
|
$data["billing_period"] = $contract->billing_period;
|
||||||
|
$data["contract_term"] = $contract->contract_term;
|
||||||
|
$data["order_date"] = $contract->order_date;
|
||||||
|
|
||||||
|
$data["finish_date"] = $contract->finish_date;
|
||||||
|
$data["finish_date_by"] = $me->id;
|
||||||
|
$data["note"] = null;
|
||||||
|
|
||||||
|
|
||||||
|
// matchcode
|
||||||
|
$owner_address = $owner->street.", ".$owner->zip." ".$owner->city;
|
||||||
|
if($contract->termination_id) {
|
||||||
|
$termination = new Termination($contract->termination_id);
|
||||||
|
$termination_address = $termination->building->street.", ".$termination->building->zip." ".$termination->building->city;
|
||||||
|
$matchcode = $termination_address;
|
||||||
|
} else {
|
||||||
|
$matchcode = $owner_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
$matchcode = $contract->owner->getCompanyOrName()."; $matchcode";
|
||||||
|
|
||||||
|
$data["matchcode"] = $matchcode;
|
||||||
|
$data["price"] = $crediting_price;
|
||||||
|
$data["price_setup"] = 0;
|
||||||
|
$data["price_nne"] = 0;
|
||||||
|
$data["price_nbe"] = 0;
|
||||||
|
$data["vatgroup_id"] = $contract->vatgroup_id;
|
||||||
|
|
||||||
|
|
||||||
|
$credit = ContractModel::create($data);
|
||||||
|
|
||||||
|
return $credit;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getAll() {
|
public static function getAll() {
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|||||||
186
application/Contract/trigger/Finished.php
Normal file
186
application/Contract/trigger/Finished.php
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class ContractTrigger_Finished {
|
||||||
|
private $log;
|
||||||
|
private $db;
|
||||||
|
private $me;
|
||||||
|
private $contract;
|
||||||
|
public $errors;
|
||||||
|
|
||||||
|
public function __construct($injection = []) {
|
||||||
|
foreach($injection as $name => $value) {
|
||||||
|
if(in_array($name, ["log", "db", "contract", "me"])) {
|
||||||
|
$this->$name = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks Contract if can/must run
|
||||||
|
* return true if it wants to run
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function precheck() {
|
||||||
|
$contract = $this->contract;
|
||||||
|
if($contract->finish_date && !$contract->_old_data->finish_date) {
|
||||||
|
// contract was just finished, so we need to run
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run() {
|
||||||
|
$contract = $this->contract;
|
||||||
|
if($contract->_old_data->finish_date) {
|
||||||
|
var_dump($contract->finish_date, $contract->_old_data->finish_date);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// contract was just finished, so we need to run
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Vorgänger Contracts kündigen
|
||||||
|
*/
|
||||||
|
foreach (ContractLinkModel::search(['contract_id' => $contract->id]) as $link) {
|
||||||
|
if (!in_array($link->type, ["upgrade", "downgrade", "relocation", "productchange", "ownerchange"])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$now = new DateTime("now");
|
||||||
|
$now->setTime(2,0,0);
|
||||||
|
|
||||||
|
$cancel_date = clone($now);
|
||||||
|
$cancel_date->setTime(23,59,59);
|
||||||
|
|
||||||
|
$origin = $link->origin;
|
||||||
|
$origin->cancel_date = $cancel_date->getTimestamp();
|
||||||
|
$origin->cancel_date_by = $this->me->id;
|
||||||
|
$origin->edit_by = $this->me->id;
|
||||||
|
if (!$origin->save()) {
|
||||||
|
throw new Exception("Fehler beim Speichern der Kündigung des Vorgängercontracts!");
|
||||||
|
}
|
||||||
|
// cancel journal
|
||||||
|
$journal = ContractjournalModel::create([
|
||||||
|
'contract_id' => $origin->id,
|
||||||
|
'type' => "canceled",
|
||||||
|
'value' => "",
|
||||||
|
'text' => ""
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* alte Links übernehmen / kündigen
|
||||||
|
*/
|
||||||
|
foreach (ContractLinkModel::search(['type' => "link", 'contract_id' => $origin->id]) as $old_link) {
|
||||||
|
// verlinkten Contract kündigen (wenn nicht schon gekündigt)
|
||||||
|
if ($old_link->change_action == "cancel" && !$old_link->origin->cancel_date) {
|
||||||
|
$old_link->origin->update([
|
||||||
|
'cancel_date' => $now->getTimestamp(),
|
||||||
|
'cancel_date_by' => $this->me->id,
|
||||||
|
'edit_by' => $this->me->id
|
||||||
|
]);
|
||||||
|
if(!$old_link->origin->save()) {
|
||||||
|
throw new Exception("Fehler beim Speichern der Kündigung des Vorgängercontracts!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$old_link->change_action = null;
|
||||||
|
$old_link->save();
|
||||||
|
|
||||||
|
// cancel journal
|
||||||
|
$journal = ContractjournalModel::create([
|
||||||
|
'contract_id' => $old_link->origin->id,
|
||||||
|
'type' => "canceled",
|
||||||
|
'value' => "",
|
||||||
|
'text' => ""
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ContractLinkModel::search(['type' => "link", 'origin_contract_id' => $origin->id]) as $old_link) {
|
||||||
|
// verlinkten Contract kündigen (wenn nicht schon gekündigt)
|
||||||
|
if ($old_link->change_action == "cancel" && !$old_link->contract->cancel_date) {
|
||||||
|
$old_link->contract->update([
|
||||||
|
'cancel_date' => $now->getTimestamp(),
|
||||||
|
'cancel_date_by' => $this->me->id,
|
||||||
|
'edit_by' => $this->me->id
|
||||||
|
]);
|
||||||
|
//$this->log->debug(print_r($old_link->contract, true));
|
||||||
|
$old_link->contract->save();
|
||||||
|
|
||||||
|
$old_link->change_action = null;
|
||||||
|
$old_link->save();
|
||||||
|
|
||||||
|
// cancel journal
|
||||||
|
$journal = ContractjournalModel::create([
|
||||||
|
'contract_id' => $old_link->contract->id,
|
||||||
|
'type' => "canceled",
|
||||||
|
'value' => "",
|
||||||
|
'text' => ""
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (ContractLinkModel::search(['type' => "credit", 'origin_contract_id' => $origin->id]) as $old_credit) {
|
||||||
|
if ($old_credit->change_action == "recreate" && !$old_credit->contract->cancel_date) {
|
||||||
|
// Alte Gutschrift kündigen und neue anlegen
|
||||||
|
//var_dump($old_credit->contract);
|
||||||
|
$old_credit->contract->update([
|
||||||
|
'cancel_date' => $now->getTimestamp(),
|
||||||
|
'cancel_date_by' => $this->me->id,
|
||||||
|
'edit_by' => $this->me->id
|
||||||
|
]);
|
||||||
|
$old_credit->contract->save();
|
||||||
|
//var_dump($old_credit->contract);
|
||||||
|
//exit;
|
||||||
|
|
||||||
|
$old_credit->change_action = null;
|
||||||
|
$old_credit->save();
|
||||||
|
|
||||||
|
$new_credit = ContractModel::createCreditForContract($contract);
|
||||||
|
if(!$new_credit->save()) {
|
||||||
|
$this->log->debug(print_r($new_credit, true));
|
||||||
|
throw new Exception("Fehler beim Speichern des neuen Gutschrift Contracts");
|
||||||
|
}
|
||||||
|
|
||||||
|
// create journal for credit
|
||||||
|
$journal = ContractjournalModel::create([
|
||||||
|
'contract_id' => $new_credit->id,
|
||||||
|
'type' => "created_from",
|
||||||
|
'value' => "productchange",
|
||||||
|
'text' => "Produkt-/Standortwechsel von Contract ID ".$old_credit->contract_id
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
|
||||||
|
|
||||||
|
$this->log->debug(print_r($new_credit, true));
|
||||||
|
|
||||||
|
// create link to new credit contract
|
||||||
|
$link = ContractLinkModel::create([
|
||||||
|
"contract_id" => $new_credit->id,
|
||||||
|
"origin_contract_id" => $contract->id,
|
||||||
|
"type" => "credit"
|
||||||
|
]);
|
||||||
|
$link->save();
|
||||||
|
|
||||||
|
// create link from old to new credit contract
|
||||||
|
$link = ContractLinkModel::create([
|
||||||
|
"contract_id" => $new_credit->id,
|
||||||
|
"origin_contract_id" => $old_credit->contract_id,
|
||||||
|
"type" => "upgrade"
|
||||||
|
]);
|
||||||
|
$link->save();
|
||||||
|
|
||||||
|
$journal = ContractjournalModel::create([
|
||||||
|
'contract_id' => $old_credit->contract_id,
|
||||||
|
'type' => "canceled",
|
||||||
|
'value' => "",
|
||||||
|
'text' => ""
|
||||||
|
]);
|
||||||
|
$journal->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -103,7 +103,7 @@ class ContractqueueModel {
|
|||||||
$data["billing_delay"] = $op->billing_delay;
|
$data["billing_delay"] = $op->billing_delay;
|
||||||
$data["billing_period"] = $op->billing_period;
|
$data["billing_period"] = $op->billing_period;
|
||||||
$data["order_date"] = $order->order_date;
|
$data["order_date"] = $order->order_date;
|
||||||
|
|
||||||
$data["finish_date"] = $order->finish_date;
|
$data["finish_date"] = $order->finish_date;
|
||||||
$data["finish_date_by"] = 1;
|
$data["finish_date_by"] = 1;
|
||||||
$data["note"] = $order->note;
|
$data["note"] = $order->note;
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
final class ContractLinkChangeChangeactionToVarchar extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
$table = $this->table("ContractLink");
|
||||||
|
$table->changeColumn("change_action", "string", ["null" => true, "default" => null, "limit" => 64]);
|
||||||
|
$table->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
if($this->getEnvironment() == "thetool") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getEnvironment() == "addressdb") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user