WIP Contractqueue & snopp api
This commit is contained in:
@@ -35,7 +35,12 @@
|
||||
<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'] : ""?>" />
|
||||
@@ -105,34 +110,79 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-6">
|
||||
<div class="card">
|
||||
<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" />
|
||||
<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 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 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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<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>
|
||||
<hr class="mt-1" />
|
||||
</div>
|
||||
<?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; ?>
|
||||
<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 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>
|
||||
</div>
|
||||
@@ -199,7 +249,7 @@
|
||||
<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> <?=$contract->product_name?>
|
||||
<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 ?>
|
||||
@@ -208,7 +258,7 @@
|
||||
<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"><i class="fas fa-check"></i></button>
|
||||
<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>
|
||||
@@ -216,37 +266,37 @@
|
||||
</td>
|
||||
<td class="matchcode">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"></i> <?= htmlentities($contract->matchcode)?>
|
||||
<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"><i class="fas fa-check"></i></button>
|
||||
<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> € <?=$contract->price?></div>
|
||||
<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"><i class="fas fa-check"></i></button>
|
||||
<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> € <?=$contract->price_setup?></div>
|
||||
<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"><i class="fas fa-check"></i></button>
|
||||
<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>
|
||||
@@ -255,15 +305,19 @@
|
||||
<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>
|
||||
<?php if($contract->billing_period == 1): ?>
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
biennal
|
||||
<?php elseif($contract->billing_period == 36): ?>
|
||||
triennal
|
||||
<?php else: ?>
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
<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">
|
||||
@@ -274,19 +328,19 @@
|
||||
<option value="36" <?=($contract->billing_period == 36) ? "selected='selected'" : ""?>>3-Jährlich</option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary"><i class="fas fa-check"></i></button>
|
||||
<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> <?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></div>
|
||||
<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"><i class="fas fa-check"></i></button>
|
||||
<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>
|
||||
@@ -309,45 +363,50 @@
|
||||
<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><?=($credit["partner"]) ? $credit["partner"]->getCompanyOrName() : ""?></td>
|
||||
<td class="text-wrap">
|
||||
<?=$contract->product_name?>
|
||||
<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 ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="matchcode">
|
||||
<td class="crediting_matchcode">
|
||||
<div class="text">
|
||||
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"></i> <?=$contract->matchcode?>
|
||||
<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->matchcode?>" data-ov="<?=$contract->matchcode?>" />
|
||||
<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"><i class="fas fa-check"></i></button>
|
||||
<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><?=($credit["rate_source"] == "rate") ? "€ ".$credit["rate"] : "€ ".$contract->price_nne?> <?=($credit["rate_source"] == "rate") ? "(Prozentrate)" : "(NNE)"?></td>
|
||||
<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
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
biennal
|
||||
3-jährlich
|
||||
<?php elseif($contract->billing_period == 36): ?>
|
||||
triennal
|
||||
3-jährlich
|
||||
<?php else: ?>
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class=""><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></td>
|
||||
<td class="billing_delay text value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -383,7 +442,9 @@
|
||||
?>
|
||||
|
||||
var products = <?=json_encode($prods)?>;
|
||||
|
||||
|
||||
|
||||
|
||||
function toggleOrderApproval(cbox, order_id, type) {
|
||||
if(!parseInt(order_id) || !order_id) return;
|
||||
|
||||
@@ -413,39 +474,207 @@
|
||||
$("#" + type + "-products-" + order_id + " .checkbox-toggle").prop("checked", false);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleEdit(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");
|
||||
|
||||
var current_val = control.data("val");
|
||||
var original_val = control.data("ov");
|
||||
|
||||
textBlock.toggle();
|
||||
editBlock.toggle();
|
||||
|
||||
if(type == "owner" || type == "billingaddress") {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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"
|
||||
});
|
||||
console.log(current_val);
|
||||
control.val(current_val);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
Reference in New Issue
Block a user