749 lines
44 KiB
PHP
749 lines
44 KiB
PHP
<?php
|
|
$pagination_baseurl = $this->getUrl($Mod,"Index");
|
|
$pagination_baseurl_params = ["filter" => $filter];
|
|
$pagination_entity_name = "Produkte";
|
|
?>
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
|
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
|
<li class="breadcrumb-item active">Fertiggestellte Bestellungen</li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Contractfreigabe</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
<h4 class="header-title mb-3">Filter</h4>
|
|
|
|
<form method="get" action="<?=self::getUrl("Contractqueue")?>">
|
|
<div class="row">
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_owner">Kundennummer</label>
|
|
<input type="text" class="form-control" name="filter[customer_number]" id="filter_street" value="<?=(array_key_exists("customer_number", $filter)) ? $filter['customer_number'] : ""?>" />
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_owner">Order ID</label>
|
|
<input type="text" class="form-control" name="filter[order_id]" id="filter_order_id" value="<?=(array_key_exists("order_id", $filter)) ? $filter['order_id'] : ""?>" />
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_owner">Inhaber Name</label>
|
|
<input type="text" class="form-control" name="filter[owner]" id="filter_street" value="<?=(array_key_exists("owner", $filter)) ? $filter['owner'] : ""?>" />
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_billingaddress">Rech.Empfänger</label>
|
|
<input type="text" class="form-control" name="filter[billingaddress]" id="filter_billingaddress" value="<?=(array_key_exists("billing_address", $filter)) ? $filter['billingaddress'] : ""?>" />
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_product_group">Produktgruppe</label>
|
|
<input type="text" class="form-control" name="filter[product_group]" id="filter_product_group" value="<?=(array_key_exists("product_group", $filter)) ? $filter['product_group'] : ""?>" />
|
|
</div>
|
|
|
|
<div class="col-1">
|
|
<label class="form-label" for="filter_product_name">Produkt</label>
|
|
<input type="text" class="form-control" name="filter[product_name]" id="filter_product_name" value="<?=(array_key_exists("product_name", $filter)) ? $filter['product_name'] : ""?>" />
|
|
</div>
|
|
|
|
</div>
|
|
<div class="row mt-2">
|
|
<div class="col">
|
|
<button type="submit" class="btn btn-primary">Filter anwenden</button>
|
|
<a class="btn btn-secondary" href="<?=self::getUrl("Contractqueue")?>?resetFilter=1">Filter zurücksetzen</a>
|
|
</div>
|
|
<!--<div class="col">
|
|
<button class="btn btn-info" type="button" onclick="refreshMap()"><i class="far fa-map"></i> Auf Karte anzeigen</button>
|
|
</div>-->
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="float-left">
|
|
<h4 class="header-title">Fertiggestellte Bestellungen</h4>
|
|
</div>
|
|
<div class="float-right">
|
|
<a class="btn btn-outline-danger mb-2" href="<?=self::getUrl("Contractqueue", "deleteOpenOrders")?>"><i class="fas fa-fw fa-file-import"></i> Offene löschen und neu 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 />
|
|
</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>
|
|
|
|
<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="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 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="col-6">
|
|
<div class="card mb-1" id="orderjournal-<?=$order->id?>" style="max-height: 280px; overflow: hidden; ">
|
|
<div onclick="toggleJournal(<?=$order->id?>)" class="opener text-center align-bottom pointer" style="position: absolute ; bottom: 0; height: 60px; width: 100%; background: linear-gradient(0deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);">
|
|
<i class="fas fa-chevron-down text-secondary" style="font-size: 18px; position:absolute; bottom:8px;"></i>
|
|
</div>
|
|
<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>
|
|
</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>Anzahl</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>
|
|
<th></th>
|
|
</tr>
|
|
|
|
<?php foreach($contracts as $contract): ?>
|
|
<tr id="contract-<?=$contract->id?>">
|
|
<td><?=(float)number_format($contract->amount, 4, ".", ",")?></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; ?>
|
|
|
|
<?php $voicenumbers = []; ?>
|
|
<?php foreach($contract->voicenumbers as $voicenumber): ?>
|
|
<?php $voicenumbers[] = $voicenumber->number; ?>
|
|
<?php endforeach; ?>
|
|
<?php if(count($voicenumbers)): ?>
|
|
<br />Sprachtarif: <?=$contract->voiceplan->name?>
|
|
<br /><strong><?=implode(", ", $voicenumbers);?></strong>
|
|
<?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 type="button" class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-check"></i></button>
|
|
<button type="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 type="button" class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
|
|
<button type="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 type="button" class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-check"></i></button>
|
|
<button type="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 type="button" class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-check"></i></button>
|
|
<button type="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 elseif($contract->billing_period > 0): ?>
|
|
<?=(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 type="button" class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-check"></i></button>
|
|
<button type="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 type="button" class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-check"></i></button>
|
|
<button type="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>
|
|
<td>
|
|
<a href="<?=self::getUrl("Contractqueue", "deletePosition", ["op_id" => $contract->orderproduct_id])?>" onclick="if(!confirm('Löscht die Position in Bestellung und Contractqueue. Wirklich löschen?')) return false;">
|
|
<i class="far fa-xmark text-danger" title="Position in Bestellung und Contractqueue löschen"></i>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
|
|
<h5>Gutschriften / Provisionen</h5>
|
|
<table class="table table-striped table-hover" id="credit-products-<?=$order_id?>">
|
|
<tr>
|
|
<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 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 type="button" class="btn btn-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
|
|
<button type="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>
|
|
|
|
<form method="post" action="<?=self::getUrl("Contractqueue", "commitOrder")?>">
|
|
<input type="hidden" name="order_id" value="<?=$contract->order_id?>" />
|
|
<button type="submit" class="btn btn-primary"><i class="fas fa-fw fa-check"></i> Produkte dieser Bestellung als Contract übernehmen</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php $i++; endforeach; ?>
|
|
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
|
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
<?php
|
|
$prods = [];
|
|
foreach(ProductModel::getActive() as $product):
|
|
$prods[] = ["id" => $product->id, "name" => $product->name];
|
|
endforeach;
|
|
?>
|
|
|
|
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;
|
|
|
|
//var checked_count = $("#order-products-" + order_id + " input[id^='approve-contract-']:checked").length;
|
|
|
|
if($(cbox).is(":checked")) {
|
|
$("#" + type + "-products-" + order_id + " input[id^='approve-" + type + "-" + order_id + "-contract-']").prop('checked', true);
|
|
} 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) {
|
|
if(!parseInt(order_id) || !order_id) return;
|
|
|
|
console.log("#" + type + "-products-" + order_id + " input[id^='approve-" + order_id + "-contract-']");
|
|
|
|
var box_count = $("#" + type + "-products-" + order_id + " input[id^='approve-" + type + "-" + order_id + "-contract-']").length;
|
|
var checked_count = $("#" + type + "-products-" + order_id + " input[id^='approve-" + type + "-" + order_id + "-contract-']:checked").length;
|
|
|
|
console.log("box_count: " + box_count + " checked_count: " + checked_count);
|
|
|
|
if(checked_count == box_count) {
|
|
$("#" + type + "-products-" + order_id + " .checkbox-toggle").prop("checked", true);
|
|
}
|
|
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) {
|
|
if(type === "owner" || type === "billingaddress") {
|
|
$("#" + type + "-" + id + " .text").toggle();
|
|
$("#" + type + "-" + id + " .edit").toggle();
|
|
|
|
if($("#" + type + "-" + id + " .edit").is(":visible")) {
|
|
console.log("visible");
|
|
$("#" + type + "-" + id + " .edit select").autoComplete();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
var textBlock = $("#" + type + "-" + id + " ." + control_name + " .text");
|
|
var editBlock = $("#" + type + "-" + id + " ." + control_name + " .edit");
|
|
|
|
var control = $("#" + type + "-" + id + " ." + control_name + " .edit .edit-control");
|
|
|
|
var current_val = control.data("val");
|
|
var original_val = control.data("ov");
|
|
|
|
textBlock.toggle();
|
|
editBlock.toggle();
|
|
|
|
|
|
if(control_name == "product") {
|
|
if(!control.children().length) {
|
|
products.forEach((product) => {
|
|
var opt = document.createElement("option");
|
|
opt.text = product.name;
|
|
opt.value = product.id;
|
|
control.append(opt);
|
|
});
|
|
console.log(current_val);
|
|
control.val(current_val);
|
|
}
|
|
}
|
|
}
|
|
|
|
function saveEdit(type, id, control_name) {
|
|
var textBlock = $("#" + type + "-" + id + " ." + control_name + " .text");
|
|
var editBlock = $("#" + type + "-" + id + " ." + control_name + " .edit");
|
|
|
|
var control = $("#" + type + "-" + id + " ." + control_name + " .edit .edit-control");
|
|
control.removeClass("invalid");
|
|
|
|
var current_val = control.data("val");
|
|
var original_val = control.data("ov");
|
|
|
|
var new_value = control.val();
|
|
|
|
console.log(new_value);
|
|
|
|
if(!new_value.length && control_name !== "billing_delay") {
|
|
control.addClass("invalid");
|
|
return;
|
|
}
|
|
|
|
var action = "saveContract";
|
|
if(type === "credit") {
|
|
var action = "saveCredit";
|
|
}
|
|
|
|
var data = {};
|
|
data["do"] = action;
|
|
data["id"] = id;
|
|
data[control_name] = new_value;
|
|
|
|
console.log(data);
|
|
|
|
var ctx = {id: id, control_name: control_name};
|
|
// save
|
|
$.ajax({
|
|
url: "<?=self::getUrl("Contractqueue", "api")?>",
|
|
type: "POST",
|
|
data: data,
|
|
context: ctx,
|
|
success: function (success) {
|
|
console.log(ctx);
|
|
const id = ctx.id;
|
|
const control_name = ctx.control_name;
|
|
|
|
var textBlock = $("#" + type + "-" + id + " ." + control_name + " .text");
|
|
var editBlock = $("#" + type + "-" + id + " ." + control_name + " .edit");
|
|
|
|
//console.log(success);
|
|
if(success.status != "OK") {
|
|
$("#" + type + "-" + id + " ." + control_name + " .edit .edit-control").addClass("invalid");
|
|
return;
|
|
}
|
|
|
|
Object.entries(success.result.contract).forEach(item => {
|
|
const [key, value] = item;
|
|
console.log(key + ": " + value);
|
|
var text = $("#contract-" + id + " ." + key + " .text .value");
|
|
var control = $("#contract-" + id + " ." + key + " .edit .edit-control");
|
|
|
|
if (text.length && control.length) {
|
|
if(key === "billing_period") {
|
|
switch (parseInt(value)) {
|
|
case 1:
|
|
text.text("Monatlich");
|
|
$("#credit-" + id + " .billing_period.text.value").text("Monatlich");
|
|
break;
|
|
case 12:
|
|
text.text("Jährlich");
|
|
$("#credit-" + id + " .billing_period.text.value").text("Jährlich");
|
|
break;
|
|
case 24:
|
|
text.text("2-Jährlich");
|
|
$("#credit-" + id + " .billing_period.text.value").text("2-Jährlich");
|
|
break;
|
|
case 36:
|
|
text.text("3-Jährlich");
|
|
$("#credit-" + id + " .billing_period.text.value").text("3-Jährlich");
|
|
break;
|
|
}
|
|
} else if(key === "billing_delay") {
|
|
if (value > 0) {
|
|
text.text(value + " Monate");
|
|
$("#credit-" + id + " .billing_delay.text.value").text(value + " Monate");
|
|
} else {
|
|
text.text("");
|
|
$("#credit-" + id + " .billing_delay.text.value").text("");
|
|
}
|
|
} else if(key === "product") {
|
|
var product_name = success.result.contract.product_name;
|
|
text.text(product_name);
|
|
$("#credit-" + id + " .product.text .value").text(product_name);
|
|
} else {
|
|
text.text(value);
|
|
}
|
|
|
|
control.data("val", value);
|
|
control.data("ov", value);
|
|
}
|
|
});
|
|
|
|
|
|
Object.entries(success.result.credit).forEach(item => {
|
|
const [key, value] = item;
|
|
console.log(key + ": " + value);
|
|
|
|
var text = $("#credit-" + id + " ." + key + " .text .value");
|
|
//var control = $("#credit-" + id + " ." + key + " .edit .edit-control");
|
|
|
|
if(key === "crediting_rate") {
|
|
console.log(success.result.credit.crediting_partner_text);
|
|
$("#credit-" + id + " .crediting_partner_rate.text.value").text(success.result.credit.crediting_partner_text);
|
|
} /*else if(key === "crediting_partner_id") {
|
|
if(!value) {
|
|
$("#credit-" + id + " .crediting_partner_text.text.value").text("");
|
|
}
|
|
$("#credit-" + id + " .crediting_partner_text.text.value").text(value);
|
|
}*/ else {
|
|
text.text(value);
|
|
}
|
|
|
|
});
|
|
|
|
editBlock.hide();
|
|
textBlock.show();
|
|
},
|
|
dataType: "json"
|
|
});
|
|
}
|
|
|
|
function saveAddress(type, id) {
|
|
var new_value = $("input[name='" + type + "_id-" + id + "'").val();
|
|
|
|
$.ajax({
|
|
url: "<?=self::getUrl("Address", "api")?>",
|
|
type: "GET",
|
|
context: id,
|
|
data: {
|
|
do: "getAddress",
|
|
id: new_value
|
|
},
|
|
success: function(success) {
|
|
if(success.status !== "OK") {
|
|
return;
|
|
}
|
|
address = success.result.address;
|
|
|
|
|
|
|
|
$("#" + type + "-" + id + " .text").html(
|
|
`<span class="text-monospace">${address.customer_number}</span><br />
|
|
<strong>${address.name}</strong><br />
|
|
${address.street}<br />
|
|
${address.zip} ${address.city}<br />`
|
|
);
|
|
$("#" + type + "-" + id + " .text").toggle();
|
|
$("#" + type + "-" + id + " .edit").toggle();
|
|
},
|
|
dataType: "json"
|
|
});
|
|
}
|
|
|
|
function toggleJournal(order_id) {
|
|
$("#orderjournal-" + order_id).find("div.opener").remove();
|
|
$("#orderjournal-" + order_id).css("max-height", "550px").css("overflow", "auto");
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|