212 lines
9.1 KiB
PHP
212 lines
9.1 KiB
PHP
<?php
|
|
$f = false;
|
|
$hide_credit = false;
|
|
?>
|
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
|
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a>
|
|
</li>
|
|
<li class="breadcrumb-item"><a href="<?=self::getUrl("Contract")?>">Aktive Produkte</a></li>
|
|
<li class="breadcrumb-item"><a
|
|
href="<?=self::getUrl("Contract", "view", ['id' => $contract->id])?>"><?=$contract->product_name?>
|
|
[<?=$contract->matchcode?>]</a></li>
|
|
<li class="breadcrumb-item active">Produkt-/Standortwechsel</li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Aktives Produkt</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<a href="<?=self::getUrl("Contract", "View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>"
|
|
class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card border-top-success">
|
|
<div class="card-body">
|
|
<h3 class="text-center mb-3"><?=$contract->product_name?> (<?=$contract->id?>)</h3>
|
|
|
|
<table class="table table-sm table-striped view-table">
|
|
<tr>
|
|
<th style="max-width: 50vw;">Matchcode:</th>
|
|
<td style="width: 50vw;"><?=$contract->matchcode?></td>
|
|
</tr><tr>
|
|
<th>Vertragsinhaber:</th>
|
|
<td>
|
|
<a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner->id])?>"><?=$contract->owner->getCompanyOrName()?>
|
|
(<?=$contract->owner->customer_number?>)
|
|
</a>
|
|
</td>
|
|
</tr><tr>
|
|
<th>Produkt:</th>
|
|
<td><?=$contract->product_name?> [<?=$contract->product_id?>
|
|
]<?=($contract->product_name != $contract->product->name) ? " <i>(" . $contract->product->name . ")</i>" : ""?></td>
|
|
</tr><tr>
|
|
<th>Produkt Info:</th>
|
|
<td><?=$contract->product_info?></td>
|
|
</tr><tr>
|
|
<th>Preis Netto:</th>
|
|
<td class="<?=($contract->price < 0) ? "text-danger" : ""?>">€ <?=number_format(($contract->amount != 1) ? $contract->price * $contract->amount : $contract->price, 4, ",", ".")?></td>
|
|
</tr><tr>
|
|
<th>Preis Brutto:</th>
|
|
<td class="<?=($contract->price < 0) ? "text-danger" : ""?>">€
|
|
<?php if($contract->price && $contract->vatrate): ?>
|
|
<?php if($contract->amount != 1): ?>
|
|
<?=number_format($contract->price + ($contract->price / 100) * $contract->vatrate, 4, ",", ".")?>
|
|
<?php else: ?>
|
|
<?=number_format(($contract->price + ($contract->price / 100) * $contract->vatrate) * $contract->amount, 4, ",", ".")?>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr><tr>
|
|
<th>Fertigstellungsdatum:</th>
|
|
<td><?=date("d.m.Y", $contract->finish_date)?></td>
|
|
</tr>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<?php include(realpath(dirname(__FILE__))."/include/productchange-action.php"); ?>
|
|
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<a href="<?=self::getUrl("Contract", "View", ['id' => $contract->id, 'filter' => $filter, 's' => $s])?>"
|
|
class="btn btn-sm btn-secondary mr-1"><i class="fas fa-list"></i> Zurück zur Vertragsansicht</a>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
$(".select2").select2({
|
|
allowClear: true,
|
|
placeholder: ""
|
|
});
|
|
$("#finish_date").datepicker({
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
/*
|
|
* product autocomplete
|
|
*/
|
|
<?php if($contract->product_id && is_object(($contract->product))): ?>
|
|
$('#product_id').autoComplete('set', {
|
|
value: <?=$contract->product_id?>,
|
|
text: '<?=($contract->product_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->product->name)) . " [" . $contract->product_id . "]" : ""?>'
|
|
});
|
|
<?php else: ?>
|
|
$('#product_id').autoComplete();
|
|
<?php endif; ?>
|
|
|
|
$('#product_id').keydown(function () {
|
|
if (event.keyCode == 13) {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('#product_id').on("autocomplete.select", function (evt, item) {
|
|
if (item && item.value === 0) {
|
|
$('#product_id').autoComplete('set', null);
|
|
}
|
|
if (item && item.value) {
|
|
updateProduct(item.value);
|
|
}
|
|
});
|
|
|
|
// product autocomplete
|
|
|
|
|
|
function updateProduct() {
|
|
var pid = $('input[name=product_id]').val();
|
|
|
|
$.get("<?=self::getUrl("Product", "Api")?>",
|
|
{
|
|
"do": "getProduct",
|
|
product_id: pid
|
|
},
|
|
function (success) {
|
|
//console.log(success);
|
|
p = success.result.product;
|
|
|
|
$('#product_name').val(p.name);
|
|
//$('#product_info').val(p.name);
|
|
$('#billing_delay').val(p.billing_delay);
|
|
$('#billing_period').val(p.billing_period);
|
|
$('#price').val(p.price);
|
|
$('#price_setup').val(p.price_setup);
|
|
$('#price_nne').val(p.price_nne);
|
|
$('#price_nbe').val(p.price_nbe);
|
|
|
|
if (typeof p.attributes === 'object' && "termination_required" in p.attributes && p.attributes.termination_required == 1) {
|
|
$('#termination_id-line').show();
|
|
$('#termination_id').select2({
|
|
allowClear: true,
|
|
placeholder: ""
|
|
});
|
|
} else {
|
|
$('#termination_id-line').hide();
|
|
//$('#termination_id-' + id + '-line').hide();
|
|
}
|
|
|
|
// set credit-link to cancel if new product does not need credit
|
|
const attrib = p.attributes;
|
|
|
|
let crediting_partner = false;
|
|
let crediting_rate = 0;
|
|
|
|
if (crediting_partner in p.attributes) {
|
|
crediting_partner = parseInt(p.attributes.crediting_partner);
|
|
}
|
|
if (crediting_rate in p.attributes) {
|
|
crediting_rate = parseFloat(p.attributes.crediting_rate);
|
|
}
|
|
|
|
let price_nne = parseFloat(p.price_nne);
|
|
//console.log(p.price_nne, crediting_partner, crediting_rate);
|
|
|
|
if (price_nne || (crediting_partner && crediting_rate)) {
|
|
$("#link-table tr[data-link-type='credit'] input.link-keep").prop("checked", "checked");
|
|
}
|
|
if (!price_nne && (!crediting_partner || !crediting_rate)) {
|
|
$("#link-table tr[data-link-type='credit'] input.link-cancel").prop("checked", "checked");
|
|
}
|
|
|
|
},
|
|
'json');
|
|
|
|
}
|
|
|
|
function linkActionChange(link_id) {
|
|
//console.log($("#link-" + link_id + "-action-cancel").prop("checked"));
|
|
if($("#link-" + link_id + "-action-cancel").prop("checked") && $("#finish_date").val()) {
|
|
$("#link-" + link_id + "-cancel_date").show();
|
|
} else {
|
|
$("#link-" + link_id + "-cancel_date").hide();
|
|
}
|
|
//link-<?=$link->id?>-action-cancel
|
|
}
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|