Contract WIP & Contractqueue WIP 2024-04-18
This commit is contained in:
@@ -156,10 +156,10 @@
|
||||
<td><?=($contract->product_external) ? "Ja" : "Nein"?></td>
|
||||
</tr><tr>
|
||||
<th>Setup Preis:</th>
|
||||
<td>€ <?=$contract->price_setup?></td>
|
||||
<td class="<?=($contract->price_setup < 0) ? "text-danger" : ""?>">€ <?=$contract->price_setup?></td>
|
||||
</tr><tr>
|
||||
<th>Preis Periodisch:</th>
|
||||
<td>€ <?=$contract->price?></td>
|
||||
<td class="<?=($contract->price < 0) ? "text-danger" : ""?>">€ <?=$contract->price?></td>
|
||||
</tr><tr>
|
||||
<th>Verrechnungsperiode:</th>
|
||||
<td>
|
||||
@@ -261,9 +261,15 @@
|
||||
<em>Vertrag manuell angelegt</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 endif; ?>
|
||||
</td>
|
||||
|
||||
<?php elseif($j->type == "credit_created"): ?>
|
||||
<td><i class="far fa-money-bill-simple-wave text-secondary pl-1"></i></td>
|
||||
<td style="width: 100%"><em>Gutschrift-Vertrag <a href="<?=self::getUrl("Contract", "View", ["contract_id" => $j->value])?>"><?=$j->value?></a> erstellt</em>
|
||||
|
||||
</td>
|
||||
<?php elseif($j->type == "link"): ?>
|
||||
<?php $link = new Contract($j->value); ?>
|
||||
<td><i class="fas fa-link text-secondary pl-1"></i></td>
|
||||
@@ -321,45 +327,56 @@
|
||||
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
|
||||
<table class="table table-striped table-sm table-bordered table-hover">
|
||||
<tr>
|
||||
<th>Typ</th>
|
||||
<th>Kunde</th>
|
||||
<th>Contract ID</th>
|
||||
<th>Typ</th>
|
||||
<th>Produkt</th>
|
||||
<th>Bestelldatum</th>
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
<?php
|
||||
|
||||
if($link->contract_id == $contract->id) {
|
||||
$direction = "von";
|
||||
$linkcontract = $link->origin;
|
||||
} else {
|
||||
$linkcontract = $link->contract;
|
||||
if($link->type == "upgrade" || $link->type == "downgrade") {
|
||||
$direction = "auf";
|
||||
}
|
||||
if($link->type == "relocation") {
|
||||
$direction = "nach";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=__($link->type, "contract")?> <?=($link->type != "link") ? $direction : ""?></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?> [<?=$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>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach([$contract->linkFrom, $contract->linkTo] as $links): ?>
|
||||
<?php foreach($links as $link): ?>
|
||||
<?php
|
||||
|
||||
if($link->contract_id == $contract->id) {
|
||||
$direction = "von";
|
||||
$linkcontract = $link->origin;
|
||||
if($link->type == "credit") {
|
||||
$direction = "";
|
||||
//continue;
|
||||
}
|
||||
} else {
|
||||
$linkcontract = $link->contract;
|
||||
if($link->type == "upgrade" || $link->type == "downgrade") {
|
||||
$direction = "auf";
|
||||
}
|
||||
if($link->type == "relocation") {
|
||||
$direction = "nach";
|
||||
}
|
||||
if($link->type == "credit") {
|
||||
$direction = "zu";
|
||||
//continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=__($link->type, "contract")?> <?=($link->type != "link") ? $direction : ""?></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
|
||||
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?> [<?=$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>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -78,360 +78,371 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
|
||||
<form method="post" action="<?=self::getUrl("Contractqueue", "commit")?>">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="float-left">
|
||||
<h4 class="header-title">Fertiggestellte Bestellungen</h4>
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-fw fa-check"></i> Markierte Elemente als Contract übernehmen</button>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Contractqueue", "importFinishedOrders")?>"><i class="fas fa-fw fa-file-import"></i> Fertiggestellte Bestellungen importieren</a>
|
||||
<a class="btn btn-outline-primary mb-2" href="<?=self::getUrl("Contractqueue", "importFinishedOrders")?>"><i class="fas fa-fw fa-file-import"></i> Fertiggestellte Bestellungen importieren</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<?php $i = 0; foreach($orders as $order_id => $contracts): ?>
|
||||
<?php $order = $contracts[0]->orderproduct->order; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card border-top-success">
|
||||
<div class="card-header">
|
||||
<span class="float-right order-date-pill active mr-2 mt-1">Fertigstellung: <span class="text-monospace font-weight-bold"><?=date("d.m.Y", $order->finish_date)?></span></span>
|
||||
<span class="float-right order-date-pill active mr-2 mt-1">Zuletzt bearbeitet: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->edit)?> (<?=$order->editor?>)</span></span>
|
||||
<span class="float-right order-date-pill active mr-2 mt-1">Erstellt: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->create)?> (<?=$order->creator?>)</span></span>
|
||||
|
||||
<h4><a href="<?=self::getUrl("Order", "", ["id" => $order_id])?>" target="_blank">Bestellung <?=$order_id?></a></h4>
|
||||
</div>
|
||||
<div class="card-body bg-light">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-6">
|
||||
<div class="card" id="owner-<?=$order_id?>">
|
||||
<div class="card-body">
|
||||
<div>
|
||||
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('owner', <?=$order_id?>, false)"></i></span>
|
||||
<h5 class="m-0">Inhaber</h5>
|
||||
</div>
|
||||
<hr class="mt-1" />
|
||||
<div class="text">
|
||||
<span class="text-monospace"><?=$order->owner->customer_number?></span><br />
|
||||
<strong><?=$order->owner->getCompanyOrName()?></strong><br />
|
||||
<?=$order->owner->street?><br />
|
||||
<?=$order->owner->zip?> <?=$order->owner->city?><br />
|
||||
|
||||
|
||||
<?php $i = 0; foreach($orders as $order_id => $contracts): ?>
|
||||
<?php $order = $contracts[0]->orderproduct->order; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card border-top-success">
|
||||
<div class="card-header">
|
||||
<span class="float-right order-date-pill active mr-2 mt-1">Fertigstellung: <span class="text-monospace font-weight-bold"><?=date("d.m.Y", $order->finish_date)?></span></span>
|
||||
<span class="float-right order-date-pill active mr-2 mt-1">Zuletzt bearbeitet: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->edit)?> (<?=$order->editor?>)</span></span>
|
||||
<span class="float-right order-date-pill active mr-2 mt-1">Erstellt: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->create)?> (<?=$order->creator?>)</span></span>
|
||||
|
||||
<h4><a href="<?=self::getUrl("Order", "", ["id" => $order_id])?>" target="_blank">Bestellung <?=$order_id?></a></h4>
|
||||
</div>
|
||||
<div class="card-body bg-light">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-6">
|
||||
<div class="card" id="owner-<?=$order_id?>">
|
||||
<div class="card-body">
|
||||
<div>
|
||||
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('owner', <?=$order_id?>, false)"></i></span>
|
||||
<h5 class="m-0">Inhaber</h5>
|
||||
</div>
|
||||
<hr class="mt-1" />
|
||||
<div class="text">
|
||||
<span class="text-monospace"><?=$order->owner->customer_number?></span><br />
|
||||
<strong><?=$order->owner->getCompanyOrName()?></strong><br />
|
||||
<?=$order->owner->street?><br />
|
||||
<?=$order->owner->zip?> <?=$order->owner->city?><br />
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select
|
||||
name="owner_id-<?=$order_id?>"
|
||||
class="form-control basicAutoComplete"
|
||||
autocomplete="off"
|
||||
id="owner_id-<?=$order_id?>"
|
||||
data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1"
|
||||
placeholder="Tippen zum Suchen... (Bestandskunden)"
|
||||
data-noresults-text="Keine Suchergebnisse"
|
||||
data-val="<?=$order->owner_id?>"
|
||||
data-ov="<?=$order->owner_id?>"
|
||||
>
|
||||
<option></option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-primary" onclick="saveAddress('owner', <?=$order_id?>)"><i class="fas fa-check"></i></button>
|
||||
<button type="button" class="btn btn-secondary" onclick="toggleEdit('owner', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select
|
||||
name="owner_id-<?=$order_id?>"
|
||||
</div>
|
||||
|
||||
<div class="card" id="billingaddress-<?=$order_id?>">
|
||||
<div class="card-body">
|
||||
<div>
|
||||
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"></i></span>
|
||||
<h5 class="m-0">Rechnungsempfänger</h5>
|
||||
</div>
|
||||
<hr class="mt-1" />
|
||||
<div class="text">
|
||||
<?php if($order->billingaddress_id): ?>
|
||||
<?=($order->billingaddress->customer_number) ? $order->billingaddress->customer_number."<br />" : ""?>
|
||||
<?=$order->billingaddress->getCompanyOrName()?><br />
|
||||
<?=$order->billingaddress->street?><br />
|
||||
<?=$order->billingaddress->zip?> <?=$order->billingaddress->city?><br />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select
|
||||
name="billingaddress_id-<?=$order_id?>"
|
||||
class="form-control basicAutoComplete"
|
||||
autocomplete="off"
|
||||
id="owner_id-<?=$order_id?>"
|
||||
id="billingaddress_id-<?=$order_id?>"
|
||||
data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1"
|
||||
placeholder="Tippen zum Suchen... (Bestandskunden)"
|
||||
data-noresults-text="Keine Suchergebnisse"
|
||||
data-val="<?=$order->owner_id?>"
|
||||
data-ov="<?=$order->owner_id?>"
|
||||
>
|
||||
<option></option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveAddress('owner', <?=$order_id?>)"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('owner', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
|
||||
data-val="<?=$order->billingaddress_id?>"
|
||||
data-ov="<?=$order->billingaddress_id?>"
|
||||
>
|
||||
<option></option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-primary" onclick="saveAddress('billingaddress', <?=$order_id?>)"><i class="fas fa-check"></i></button>
|
||||
<button type="button" class="btn btn-secondary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" id="billingaddress-<?=$order_id?>">
|
||||
<div class="card-body">
|
||||
<div>
|
||||
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"></i></span>
|
||||
<h5 class="m-0">Rechnungsempfänger</h5>
|
||||
</div>
|
||||
<hr class="mt-1" />
|
||||
<div class="text">
|
||||
<?php if($order->billingaddress_id): ?>
|
||||
<?=($order->billingaddress->customer_number) ? $order->billingaddress->customer_number."<br />" : ""?>
|
||||
<?=$order->billingaddress->getCompanyOrName()?><br />
|
||||
<?=$order->billingaddress->street?><br />
|
||||
<?=$order->billingaddress->zip?> <?=$order->billingaddress->city?><br />
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<div class="card mb-1">
|
||||
<div class="card-body">
|
||||
<h5 class="m-0">Bestelljournal</h5>
|
||||
|
||||
<table class="table table-sm table-striped mt-1 mb-0">
|
||||
<tr>
|
||||
<th>Erstellt</th>
|
||||
<th>Text</th>
|
||||
</tr>
|
||||
<?php foreach($order->journals as $journal): ?>
|
||||
<tr>
|
||||
<td class="text-monospace"><?=date("d.m.Y H:i", $journal->create)?> (<?=$journal->creator?>)</td>
|
||||
<td><?=nl2br($journal->text)?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select
|
||||
name="billingaddress_id-<?=$order_id?>"
|
||||
class="form-control basicAutoComplete"
|
||||
autocomplete="off"
|
||||
id="billingaddress_id-<?=$order_id?>"
|
||||
data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1"
|
||||
placeholder="Tippen zum Suchen... (Bestandskunden)"
|
||||
data-noresults-text="Keine Suchergebnisse"
|
||||
data-val="<?=$order->billingaddress_id?>"
|
||||
data-ov="<?=$order->billingaddress_id?>"
|
||||
>
|
||||
<option></option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveAddress('billingaddress', <?=$order_id?>)"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<?php if(trim($order->note)): ?>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="m-0">Interne Notiz</h5>
|
||||
<hr class="mt-1">
|
||||
<?=nl2br(htmlentities($order->note))?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<div class="card mb-1">
|
||||
<div class="card-body">
|
||||
<h5 class="m-0">Bestelljournal</h5>
|
||||
<?php endif; ?>
|
||||
<div class="row">
|
||||
|
||||
<table class="table table-sm table-striped mt-1 mb-0">
|
||||
<tr>
|
||||
<th>Erstellt</th>
|
||||
<th>Text</th>
|
||||
</tr>
|
||||
<?php foreach($order->journals as $journal): ?>
|
||||
<tr>
|
||||
<td class="text-monospace"><?=date("d.m.Y H:i", $journal->create)?> (<?=$journal->creator?>)</td>
|
||||
<td><?=nl2br($journal->text)?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<h5>Produkte</h5>
|
||||
<table class="table table-striped table-hover" id="order-products-<?=$order_id?>">
|
||||
<tr>
|
||||
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'order')" /></th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Preis</th>
|
||||
<th>Preis Setup</th>
|
||||
<th>Rechnungsperiode</th>
|
||||
<th>Verz. Verrechnungsstart</th>
|
||||
<th>Erstellt</th>
|
||||
<th>Zuletzt bearbeitet</th>
|
||||
</tr>
|
||||
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<tr id="contract-<?=$contract->id?>">
|
||||
<td><input type="checkbox" class="form-control pointer" value="<?=$contract->id?>" id="approve-order-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'order')" <?=($contract->approved) ? "checked='checked'" : ""?> /></td>
|
||||
<td class="text-wrap product">
|
||||
<div class="text">
|
||||
<!--i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"></i--> <span class="value"><?=$contract->product_name?></span>
|
||||
<?php if($contract->termination_id && $contract->termination): ?>
|
||||
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>"></select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="matchcode">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=htmlentities($contract->matchcode)?></span>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=htmlentities($contract->matchcode)?>" data-ov="<?=htmlentities($contract->matchcode)?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="price">
|
||||
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"></i> € <span class="value"><?=$contract->price?></span></div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->price?>" data-val="<?=$contract->price?>" data-ov="<?=$contract->price?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="price_setup">
|
||||
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"></i> € <span class="value"><?=$contract->price_setup?></span></div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->price_setup?>" data-val="<?=$contract->price_setup?>" data-ov="<?=$contract->price_setup?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="billing_period">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"></i>
|
||||
<span class="value">
|
||||
<?php if($contract->billing_period == 1): ?>
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 12): ?>
|
||||
Jährlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
2-jährlich
|
||||
<?php elseif($contract->billing_period == 36): ?>
|
||||
3-jährlich
|
||||
<?php else: ?>
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>">
|
||||
<option value="1" <?=($contract->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
|
||||
<option value="12" <?=($contract->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
|
||||
<option value="24" <?=($contract->billing_period == 24) ? "selected='selected'" : ""?>>2-Jährlich</option>
|
||||
<option value="36" <?=($contract->billing_period == 36) ? "selected='selected'" : ""?>>3-Jährlich</option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="billing_delay">
|
||||
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"></i> <span class="value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></span></div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->billing_delay?>" data-val="<?=$contract->billing_delay?>" data-ov="<?=$contract->billing_delay?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->create)?><br /><?=$contract->orderproduct->creator->name?></td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->edit)?><br /><?=$contract->orderproduct->editor->name?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<h5>Gutschriften / Provisionen</h5>
|
||||
<table class="table table-striped table-hover" id="credit-products-<?=$order_id?>">
|
||||
<tr>
|
||||
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'credit')" /></th>
|
||||
<th>Bezieher</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Provision</th>
|
||||
<th>Rechnungsperiode</th>
|
||||
<th>Verz. Verrechnungsstart</th>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<?php $credit = $contract->getCredit(); if(!$credit) continue; ?>
|
||||
<tr id="credit-<?=$contract->id?>">
|
||||
<td><input type="checkbox" class="form-control pointer" value="<?=$contract->id?>" id="approve-credit-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'credit')" <?=($contract->approved_credit) ? "checked='checked'" : ""?> /></td>
|
||||
<td class="crediting_partner_name text value"><?=($credit["partner"]) ? $credit["partner"]->getCompanyOrName() : ""?></td>
|
||||
<td class="text-wrap product text">
|
||||
<span class="value"><?=$contract->product_name?></span>
|
||||
<?php if($contract->termination_id && $contract->termination): ?>
|
||||
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="crediting_matchcode">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=$contract->crediting_matchcode?></span>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=$contract->crediting_matchcode?>" data-ov="<?=$contract->crediting_matchcode?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="crediting_partner_rate text value">
|
||||
<?=($credit["rate_source"] == "rate") ? "€ ".$credit["rate"] : "€ ".$contract->price_nne?> <?=($credit["rate_source"] == "rate") ? "(Prozentrate)" : "(NNE)"?>
|
||||
</td>
|
||||
<td class="billing_period text value">
|
||||
<?php if($contract->billing_period == 1): ?>
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
3-jährlich
|
||||
<?php elseif($contract->billing_period == 36): ?>
|
||||
3-jährlich
|
||||
<?php else: ?>
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="billing_delay text value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<?php if(trim($order->note)): ?>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="m-0">Interne Notiz</h5>
|
||||
<hr class="mt-1">
|
||||
<?=nl2br(htmlentities($order->note))?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<h5>Produkte</h5>
|
||||
<table class="table table-striped table-hover" id="order-products-<?=$order_id?>">
|
||||
<tr>
|
||||
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'order')" /></th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Preis</th>
|
||||
<th>Preis Setup</th>
|
||||
<th>Rechnungsperiode</th>
|
||||
<th>Verz. Verrechnungsstart</th>
|
||||
<th>Erstellt</th>
|
||||
<th>Zuletzt bearbeitet</th>
|
||||
</tr>
|
||||
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<tr id="contract-<?=$contract->id?>">
|
||||
<td><input type="checkbox" class="form-control pointer" id="approve-order-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'order')" <?=($contract->approved) ? "checked='checked'" : ""?> /></td>
|
||||
<td class="text-wrap product">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"></i> <span class="value"><?=$contract->product_name?></span>
|
||||
<?php if($contract->termination_id && $contract->termination): ?>
|
||||
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>"></select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="matchcode">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=htmlentities($contract->matchcode)?></span>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=htmlentities($contract->matchcode)?>" data-ov="<?=htmlentities($contract->matchcode)?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="price">
|
||||
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"></i> € <span class="value"><?=$contract->price?></span></div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->price?>" data-val="<?=$contract->price?>" data-ov="<?=$contract->price?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="price_setup">
|
||||
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"></i> € <span class="value"><?=$contract->price_setup?></span></div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->price_setup?>" data-val="<?=$contract->price_setup?>" data-ov="<?=$contract->price_setup?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="billing_period">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"></i>
|
||||
<span class="value">
|
||||
<?php if($contract->billing_period == 1): ?>
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 12): ?>
|
||||
Jährlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
2-jährlich
|
||||
<?php elseif($contract->billing_period == 36): ?>
|
||||
3-jährlich
|
||||
<?php else: ?>
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>">
|
||||
<option value="1" <?=($contract->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
|
||||
<option value="12" <?=($contract->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
|
||||
<option value="24" <?=($contract->billing_period == 24) ? "selected='selected'" : ""?>>2-Jährlich</option>
|
||||
<option value="36" <?=($contract->billing_period == 36) ? "selected='selected'" : ""?>>3-Jährlich</option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="billing_delay">
|
||||
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"></i> <span class="value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></span></div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->billing_delay?>" data-val="<?=$contract->billing_delay?>" data-ov="<?=$contract->billing_delay?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->create)?><br /><?=$contract->orderproduct->creator->name?></td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->edit)?><br /><?=$contract->orderproduct->editor->name?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
<h5>Gutschriften / Provisionen</h5>
|
||||
<table class="table table-striped table-hover" id="credit-products-<?=$order_id?>">
|
||||
<tr>
|
||||
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'credit')" /></th>
|
||||
<th>Bezieher</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Provision</th>
|
||||
<th>Rechnungsperiode</th>
|
||||
<th>Verz. Verrechnungsstart</th>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<?php $credit = $contract->getCredit(); if(!$credit) continue; ?>
|
||||
<tr id="credit-<?=$contract->id?>">
|
||||
<td><input type="checkbox" class="form-control pointer" id="approve-credit-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'credit')" <?=($contract->approved) ? "checked='checked'" : ""?> /></td>
|
||||
<td class="crediting_partner_name text value"><?=($credit["partner"]) ? $credit["partner"]->getCompanyOrName() : ""?></td>
|
||||
<td class="text-wrap product text">
|
||||
<span class="value"><?=$contract->product_name?></span>
|
||||
<?php if($contract->termination_id && $contract->termination): ?>
|
||||
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="crediting_matchcode">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=$contract->crediting_matchcode?></span>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=$contract->crediting_matchcode?>" data-ov="<?=$contract->crediting_matchcode?>" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
|
||||
<button class="btn btn-secondary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="crediting_partner_rate text value">
|
||||
<?=($credit["rate_source"] == "rate") ? "€ ".$credit["rate"] : "€ ".$contract->price_nne?> <?=($credit["rate_source"] == "rate") ? "(Prozentrate)" : "(NNE)"?>
|
||||
</td>
|
||||
<td class="billing_period text value">
|
||||
<?php if($contract->billing_period == 1): ?>
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
3-jährlich
|
||||
<?php elseif($contract->billing_period == 36): ?>
|
||||
3-jährlich
|
||||
<?php else: ?>
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="billing_delay text value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php $i++; endforeach; ?>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
|
||||
|
||||
<button type="submit" class="btn btn-primary"><i class="fas fa-fw fa-check"></i> Markierte Elemente als Contract übernehmen</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<?php
|
||||
@@ -444,6 +455,39 @@
|
||||
var products = <?=json_encode($prods)?>;
|
||||
|
||||
|
||||
$("input[id^='approve-order-'], input[id^='approve-credit-']").change(function() {
|
||||
var id = this.id;
|
||||
console.log(this);
|
||||
|
||||
var order_match = id.match(/approve-(order|credit)-(\d+)-contract-(\d+)/);
|
||||
var type = order_match[1];
|
||||
//var order_id = order_match[2];
|
||||
var cq_id = order_match[3];
|
||||
|
||||
var value = $(this).is(":checked") ? 1 : 0;
|
||||
|
||||
$.ajax({
|
||||
url: "<?=self::getUrl("Contractqueue", "api")?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
do: "setApproval",
|
||||
type: type,
|
||||
//order_id: order_id,
|
||||
cq_id: cq_id,
|
||||
value: value
|
||||
},
|
||||
dataType: "json",
|
||||
context: {
|
||||
element_id: this.id,
|
||||
checked: $(this).is(":checked")
|
||||
},
|
||||
success: function (success) {
|
||||
console.log(this.element_id);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function toggleOrderApproval(cbox, order_id, type) {
|
||||
if(!parseInt(order_id) || !order_id) return;
|
||||
@@ -455,6 +499,7 @@
|
||||
} else {
|
||||
$("#" + type + "-products-" + order_id + " input[id^='approve-" + type + "-" + order_id + "-contract-']").prop('checked', false);
|
||||
}
|
||||
$("input[id^='approve-" + type + "-" + order_id + "-contract-']").change();
|
||||
}
|
||||
|
||||
function toggleApproval(order_id, type) {
|
||||
@@ -473,6 +518,8 @@
|
||||
if(checked_count < box_count) {
|
||||
$("#" + type + "-products-" + order_id + " .checkbox-toggle").prop("checked", false);
|
||||
}
|
||||
$("input[id^='approve-" + type + "-" + order_id + "-contract-']").change();
|
||||
|
||||
}
|
||||
|
||||
function toggleEdit(type, id, control_name) {
|
||||
|
||||
@@ -50,6 +50,9 @@ class Contract extends mfBaseModel {
|
||||
case "link":
|
||||
$this->linkTo[] = $link;
|
||||
break;
|
||||
case "credit":
|
||||
$this->linkFrom[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeTo[] = $link;
|
||||
break;
|
||||
@@ -73,6 +76,9 @@ class Contract extends mfBaseModel {
|
||||
case "link":
|
||||
$this->linkFrom[] = $link;
|
||||
break;
|
||||
case "credit":
|
||||
$this->linkTo[] = $link;
|
||||
break;
|
||||
case "upgrade":
|
||||
$this->upgradeFrom[] = $link;
|
||||
break;
|
||||
@@ -126,7 +132,40 @@ class Contract extends mfBaseModel {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function addFilesFromOrder() {
|
||||
if(!$this->orderproduct_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$op = $this->getProperty("orderproduct");
|
||||
$order = $op->order;
|
||||
if(!$order || !$order->id) return true;
|
||||
|
||||
foreach($order->files as $file) {
|
||||
$cfile = ContractFileModel::create([
|
||||
"contract_id" => $this->id,
|
||||
"file_id" => $file->file_id,
|
||||
"name" => $file->name,
|
||||
"description" => $file->description,
|
||||
"create_by" => $file->create_by,
|
||||
"edit_by" => $file->edit_by
|
||||
]);
|
||||
$cfile->save();
|
||||
|
||||
$journal = ContractjournalModel::create([
|
||||
"contract_id" => $this->id,
|
||||
"type" => "file",
|
||||
"value" => $cfile->id,
|
||||
"text" => (array_key_exists($cfile->name, TT_ORDER_FILE_TYPES)) ? TT_ORDER_FILE_TYPES[$cfile->name] : $cfile->name
|
||||
]);
|
||||
$journal->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -227,7 +266,7 @@ class Contract extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "links") {
|
||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
|
||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => "link"]);
|
||||
//var_dump($this->links);exit;
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class ContractModel {
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function createFromOrderproduct($op) {
|
||||
public static function createFromOrderproduct(OrderProduct $op) {
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
if(!$op->id) {
|
||||
@@ -107,6 +107,82 @@ class ContractModel {
|
||||
|
||||
return $contract;
|
||||
}
|
||||
|
||||
public static function createFromContractQueue(Contractqueue $cq, $contracttype = "contract") {
|
||||
$log = mfLoghandler::singleton();
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
|
||||
if(!$cq->id) {
|
||||
$log->warning(__METHOD__."(): Invalid Contractqueue object");
|
||||
return false;
|
||||
}
|
||||
|
||||
$order_id = $cq->order_id;
|
||||
$product_id = $cq->product_id;
|
||||
|
||||
$order = new Order($order_id);
|
||||
$product = new Product($product_id);
|
||||
|
||||
if(!$order->id || !$product->id) {
|
||||
$log->warning(__METHOD__."(): Invalid Order or Product");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$order->finish_date || $order->finish_date > date("U")) {
|
||||
$log->warning(__METHOD__."(): Order not finished yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data["orderproduct_id"] = $cq->orderproduct_id;
|
||||
$data["matchcode"] = $cq->matchcode;
|
||||
$data["owner_id"] = $cq->owner_id;
|
||||
$data["billingaddress_id"] = ($cq->billingaddress_id) ? $cq->billingaddress_id : $cq->owner_id;
|
||||
$data["termination_id"] = ($cq->termination_id) ? $cq->termination_id : null;
|
||||
$data["product_id"] = $cq->product_id;
|
||||
$data["product_name"] = $cq->product_name;
|
||||
$data["product_info"] = $cq->product_info;
|
||||
$data["amount"] = $cq->amount;
|
||||
$data["sla_id"] = $cq->sla_id;
|
||||
$data["product_external"] = $cq->product_external;
|
||||
$data["product_external_id"] = $cq->product_external_id;
|
||||
$data["price"] = $cq->price;
|
||||
$data["price_setup"] = $cq->price_setup;
|
||||
$data["price_nne"] = $cq->price_nne;
|
||||
$data["price_nbe"] = $cq->price_nbe;
|
||||
$data["billing_delay"] = $cq->billing_delay;
|
||||
$data["billing_period"] = $cq->billing_period;
|
||||
$data["contract_term"] = $cq->contract_term;
|
||||
$data["order_date"] = $order->order_date;
|
||||
|
||||
|
||||
$data["finish_date"] = $order->finish_date;
|
||||
$data["finish_date_by"] = $me->id;
|
||||
$data["note"] = $order->note;
|
||||
|
||||
if($contracttype == "credit") {
|
||||
$crediting_price = $cq->price_nne;
|
||||
if($cq->crediting_partner_rate) {
|
||||
$crediting_price = round($cq->price / 100 * $cq->crediting_partner_rate, 4);
|
||||
}
|
||||
$crediting_price *= -1;
|
||||
|
||||
$data["matchcode"] = $cq->crediting_matchcode;
|
||||
$data["owner_id"] = $cq->crediting_partner_id;
|
||||
$data["billingaddress_id"] = $cq->crediting_partner_id;
|
||||
$data["termination_id"] = null;
|
||||
$data["price"] = $crediting_price;
|
||||
$data["price_setup"] = 0;
|
||||
$data["price_nne"] = 0;
|
||||
$data["price_nbe"] = 0;
|
||||
}
|
||||
|
||||
$contract = ContractModel::create($data);
|
||||
//var_dump($contract);exit;
|
||||
|
||||
return $contract;
|
||||
}
|
||||
|
||||
public function savePrecontract($contract) {
|
||||
|
||||
|
||||
@@ -167,6 +167,114 @@ class ContractqueueController extends mfBaseController {
|
||||
}
|
||||
$this->layout()->setFlash("Alle Bestellungen importiert", "success");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
protected function commitAction() {
|
||||
$r = $this->request;
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
$new_contracts = [];
|
||||
$c = 0;
|
||||
$o = 0;
|
||||
foreach(ContractqueueModel::search(["approved" => true, "contract_id" => null]) as $cq) {
|
||||
//var_dump($cq);exit;
|
||||
$contract = new Contract($cq->orderproduct_id);
|
||||
if($contract->id) continue; // contract should not yet exist
|
||||
|
||||
/*
|
||||
* Create Contract
|
||||
*/
|
||||
$contract = ContractModel::createFromContractqueue($cq);
|
||||
if(!$contract->save()) {
|
||||
$this->layout()->setFlash("Eine Position in Bestellung ".$cq->order_id." konnte nicht übernommen werden: Fehler beim Speichern");
|
||||
continue;
|
||||
}
|
||||
|
||||
$c++;
|
||||
|
||||
$cq->contract_id = $contract->id;
|
||||
$cq->save();
|
||||
|
||||
// create Contractjournal
|
||||
$journal = ContractjournalModel::create([
|
||||
'contract_id' => $contract->id,
|
||||
'type' => "created_from",
|
||||
'value' => "order"
|
||||
]);
|
||||
$journal->save();
|
||||
|
||||
$contract->addFilesFromOrder();
|
||||
|
||||
/*
|
||||
* Create Crediting Contract
|
||||
* if required
|
||||
*/
|
||||
|
||||
if($cq->approved_credit) {
|
||||
$credit = ContractModel::createFromContractQueue($cq, "credit");
|
||||
if(!$credit->save()) {
|
||||
$this->layout()->setFlash("Zu einer Position in Bestellung ".$cq->order_id." konnte keine Gutschrift erstellt werden: Fehler beim Speichern");
|
||||
continue;
|
||||
}
|
||||
$journal = ContractjournalModel::create([
|
||||
'contract_id' => $credit->id,
|
||||
'type' => "created_from",
|
||||
'value' => "order"
|
||||
]);
|
||||
$journal->save();
|
||||
$journal = ContractjournalModel::create([
|
||||
'contract_id' => $contract->id,
|
||||
'type' => "credit_created",
|
||||
'value' => $credit->id
|
||||
]);
|
||||
$journal->save();
|
||||
$link = ContractLinkModel::create([
|
||||
'contract_id' => $contract->id,
|
||||
'origin_contract_id' => $credit->id,
|
||||
'type' => 'credit'
|
||||
]);
|
||||
$link->save();
|
||||
// XXX: retour link erstellen?
|
||||
}
|
||||
|
||||
/*
|
||||
* Create ContractLinks
|
||||
*/
|
||||
foreach($new_contracts as $origin) {
|
||||
if(ContractLinkModel::getFirst(["contract_id" => $contract->id, "origin_contract_id" => $origin->id])) {
|
||||
continue;
|
||||
}
|
||||
$link = ContractLinkModel::create([
|
||||
'contract_id' => $contract->id,
|
||||
'origin_contract_id' => $origin->id,
|
||||
'type' => 'link'
|
||||
]);
|
||||
$link->save();
|
||||
if($link->id) {
|
||||
$journal = ContractjournalModel::create([
|
||||
'contract_id' => $contract->id,
|
||||
'type' => "link",
|
||||
'value' => $origin->id
|
||||
]);
|
||||
$journal->save();
|
||||
|
||||
$ojournal = ContractjournalModel::create([
|
||||
'contract_id' => $origin->id,
|
||||
'type' => "link",
|
||||
'value' => $contract->id
|
||||
]);
|
||||
$ojournal->save();
|
||||
}
|
||||
}
|
||||
|
||||
$new_contracts[] = $contract;
|
||||
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("$c Contracts erstellt", "success");
|
||||
$this->redirect("Contract");
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
@@ -180,6 +288,9 @@ class ContractqueueController extends mfBaseController {
|
||||
case "saveContract":
|
||||
$return = $this->saveContractApi();
|
||||
break;
|
||||
case "setApproval":
|
||||
$return = $this->setApprovalApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -304,4 +415,31 @@ class ContractqueueController extends mfBaseController {
|
||||
return ["contract" => $return, "credit" => $credit];
|
||||
|
||||
}
|
||||
|
||||
private function setApprovalApi() {
|
||||
$r = $this->request;
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
|
||||
$id = $r->cq_id;
|
||||
if(!is_numeric($id) || $id < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cq = new Contractqueue($id);
|
||||
if(!$cq->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($r->type == "order") {
|
||||
$cq->approved = $r->value;
|
||||
}
|
||||
if($r->type == "credit") {
|
||||
$cq->approved_credit = $r->value;
|
||||
}
|
||||
|
||||
$cq->save();
|
||||
|
||||
return ["message" => "contract saved"];
|
||||
}
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class ContractqueueModel {
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,16 @@ class ContractqueueModel {
|
||||
$where .= " AND Contractqueue.id like '%$id%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("approved", $filter)) {
|
||||
$approved = $filter['approved'];
|
||||
if($approved) {
|
||||
$where .= " AND Contractqueue.approved = 1";
|
||||
} else {
|
||||
$where .= " AND Contractqueue.approved = 0";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("contract_id", $filter)) {
|
||||
$contract_id = $filter['contract_id'];
|
||||
if(is_numeric($contract_id)) {
|
||||
|
||||
@@ -55,6 +55,7 @@ $l['contract.upgrade'] = "Upgrade";
|
||||
$l['contract.downgrade'] = "Downgrade";
|
||||
$l['contract.relocation'] = "Umzug";
|
||||
$l['contract.productchange'] = "Produktwechsel";
|
||||
$l['contract.credit'] = "Gutschrift";
|
||||
|
||||
|
||||
$l['cc.oesterreich'] = "AT";
|
||||
|
||||
@@ -212,6 +212,12 @@ class mfBaseModel {
|
||||
if($this->fieldprefix && !strstr($field,"_")) {
|
||||
$where=$this->fieldprefix."_id=$id";
|
||||
}
|
||||
if(method_exists($this, "beforeDelete")) {
|
||||
// delete can be canceled
|
||||
if(!$this->beforeDelete()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if($this->db->delete($this->table,$where)) {
|
||||
if(method_exists($this, "afterDelete")) {
|
||||
$this->afterDelete();
|
||||
|
||||
Reference in New Issue
Block a user