462 lines
20 KiB
PHP
462 lines
20 KiB
PHP
<?php
|
|
$urlfilter = [];
|
|
if($s) {
|
|
$urlfilter['s'] = $s;
|
|
}
|
|
if(is_array($filter) && count($filter)) {
|
|
$urlfilter["filter"] = $filter;
|
|
}
|
|
$posturl = self::getUrl("Contract", "save", $urlfilter);
|
|
?>
|
|
<?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")?>">Verträge</a></li>
|
|
<li class="breadcrumb-item active"><?=($contract->id) ? "bearbeiten" : "Neu" ?></li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Verträge</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4 class="header-title mb-2"><?=($contract->id) ? "Vertrag bearbeiten" : "Neuer Vertrag"?></h4>
|
|
|
|
<form class="form-horizontal" method="post" action="<?=$posturl?>">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<input type="hidden" name="id" value="<?=$contract->id?>" />
|
|
<input type="hidden" name="f" value="<?=$f?>" />
|
|
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="owner_id">Vertragsinhaber *</label>
|
|
<div class="col-lg-10">
|
|
<select class="form-control basicAutoComplete" autocomplete="off" name="owner_id" id="owner_id" data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1" placeholder="Tippen zum Suchen... (Bestandskunden)" data-noresults-text="Keine Suchergebnisse">
|
|
<option></option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="billingaddress_id">Rechnungsempfänger</label>
|
|
<div class="col-lg-10">
|
|
<select class="form-control basicAutoComplete" autocomplete="off" name="billingaddress_id" id="billingaddress_id" data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1" placeholder="Tippen zum suchen... (Bestandskunden)" data-noresults-text="Keine Suchergebnisse">
|
|
<option></option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="product_id">Produkt *</label>
|
|
<div class="col-lg-10">
|
|
<select class="form-control basicAutoComplete" autocomplete="off" name="product_id" id="product_id" data-url="<?=self::getUrl('Product','api')?>?do=findProduct&autocomplete=1" placeholder="Tippen zum suchen..." data-noresults-text="Keine Suchergebnisse">
|
|
<option></option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="matchcode">Matchcode</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="matchcode" id="matchcode" value="<?=$contract->matchcode?>">
|
|
<small class="font-italic">Eindeutige Identifizierung das Produkts. Z.B. Anschlussadresse, Domainname usw.</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="product_name">Individueller Produktname</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="product_name" id="product_name" value="<?=$contract->product_name?>">
|
|
<small class="font-italic">Scheint statt dem echten Produktnamen auf der Rechnung auf</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="product_info">Produkt Zusatztext</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="product_info" id="product_info" value="<?=$contract->product_info?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="amount">Anzahl</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="amount" id="product_info" placeholder="1" value="<?=$contract->amount?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="price">Preis</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="price" id="price" value="<?=$contract->price?>">
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="price_setup">Preis Setup</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="price_setup" id="price_setup" value="<?=$contract->price_setup?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="price_nne">Preis NNE</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="price_nne" id="price_nne" value="<?=$contract->price_nne?>">
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="price_nbe">Preis NBE</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="price_nbe" id="price_nbe" value="<?=$contract->price_nbe?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="billing_period">Verrechnungsperiode</label>
|
|
<div class="col-lg-10">
|
|
<select class="form-control" name="billing_period" id="billing_period" placeholder="Verrechnungsperiode">
|
|
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
|
|
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="billing_delay">Verzögerter Verrechnungsstart</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="billing_delay" id="billing_delay" placeholder="Freimonate" value="<?=$contract->billing_delay?>">
|
|
</div>
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="finish_date">Fertigstellungsdatum</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="finish_date" id="finish_date" value="<?=($contract->finish_date) ? date("d.m.Y",$contract->finish_date) : ""?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="cancel_date">Kündigungsdatum</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="cancel_date" id="cancel_date" value="<?=($contract->cancel_date) ? date("d.m.Y", $contract->cancel_date) : ""?>">
|
|
</div>
|
|
</div>
|
|
|
|
<!--
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="price_reason">Rabatt</label>
|
|
<div class="col-lg-10">
|
|
<input type="text" class="form-control" name="price" id="price" value="<?=$contract->price?>">
|
|
</div>
|
|
</div>
|
|
-->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body" id="link-container">
|
|
<h4>Verknüpfungen</h4>
|
|
<?php $linknum = 1337; ?>
|
|
<div class="form-group row" id="link-<?=$linknum?>">
|
|
<label class="col-lg-2 col-form-label" for="links_<?=$linknum?>_contract_id"></label>
|
|
<div class="col-lg-6">
|
|
<div class="input-group mb-3">
|
|
<div class="input-group-prepend">
|
|
<select class="form-control" name="links[<?=$linknum?>][type]">
|
|
<option value="link">Verknüpfung mit</option>
|
|
<option value="upgrade">Upgrade von</option>
|
|
<option value="downgrade">Downgrade von</option>
|
|
<option value="relocation">Umzug von</option>
|
|
<option value="productchange">Produktwechsel von</option>
|
|
</select>
|
|
</div>
|
|
<!--input type="text" class="form-control" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" value="<?=$contract->cancel_date?>"-->
|
|
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[<?=$linknum?>][contract_id]" id="links_<?=$linknum?>_contract_id" data-linknum="<?=$linknum?>" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse">
|
|
<option></option>
|
|
</select>
|
|
<div class="input-group-append">
|
|
<button type="button" class="btn btn-danger" onclick="clearNewLink(<?=$linknum?>)"><i class="fas fa-xmark-large mr-1"></i> Entfernen</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
|
|
<div class="col-lg-10">
|
|
<textarea id="note" class="form-control" name="note" rows="5"><?=$building->note?></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2"></label>
|
|
<div class="col-lg-10">
|
|
<button type="submit" class="btn btn-primary">Speichern</button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
$('#finish_date').datepicker({
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
|
|
$('#cancel_date').datepicker({
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
|
|
$(".select2").select2({
|
|
allowClear: true,
|
|
placeholder: ""
|
|
});
|
|
|
|
|
|
/*
|
|
* customer autocomplete
|
|
*/
|
|
// kunde
|
|
<?php if($contract->owner_id && is_object(($contract->owner))): ?>
|
|
$('#owner_id').autoComplete('set', { value: <?=$contract->owner_id?>, text: '<?=($contract->owner_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->owner->getCompanyOrName()))." (".$contract->owner->zip." ".$contract->owner->city.", ".$contract->owner->street.")".(($contract->owner->customer_number) ? " [".$contract->owner->customer_number."]" : "") : ""?>'});
|
|
<?php else: ?>
|
|
$('#owner_id').autoComplete();
|
|
<?php endif; ?>
|
|
|
|
$('#owner_id').keydown(function() {
|
|
if(event.keyCode == 13) {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('#owner_id').on("autocomplete.select", function(evt, item) {
|
|
if(item && item.value === 0) {
|
|
$('#owner_id').autoComplete('set', null);
|
|
return;
|
|
}
|
|
|
|
console.log($('input[name=owner_id]').val());
|
|
var id = $('input[name=owner_id]').val();
|
|
|
|
if($('#matchcode').val()) {
|
|
return;
|
|
}
|
|
|
|
$.get("<?=self::getUrl('Address', 'Api')?>",
|
|
{
|
|
"do": "getAddress",
|
|
"id": id
|
|
},
|
|
function (success) {
|
|
if(success.status == "OK") {
|
|
var address = success.result.address;
|
|
console.log(address);
|
|
var string = address.street + ", " + address.zip + " " + address.city;
|
|
$('#matchcode').val(string);
|
|
}
|
|
},
|
|
"json"
|
|
);
|
|
|
|
});
|
|
// customer autocomplete
|
|
|
|
|
|
/*
|
|
* billingaddress autocomplete
|
|
*/
|
|
<?php if($contract->billingaddress_id && is_object($contract->billingaddress)): ?>
|
|
$('#billingaddress_id').autoComplete('set', { value: <?=$contract->billingaddress_id?>, text: '<?=($contract->billingaddress_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->billingaddress->getCompanyOrName()))." (".$contract->billingaddress->zip." ".$contract->billingaddress->city.", ".$contract->billingaddress->street.")" : ""?>'});
|
|
<?php else: ?>
|
|
$('#billingaddress_id').autoComplete();
|
|
<?php endif; ?>
|
|
|
|
$('#billingaddress_id').keydown(function() {
|
|
if(event.keyCode == 13) {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('#billingaddress_id').on("autocomplete.select", function(evt, item) {
|
|
if(item && item.value === 0) {
|
|
$('#billingaddress_id').autoComplete('set', null);
|
|
}
|
|
});
|
|
// billingaddress autocomplete
|
|
|
|
/*
|
|
* 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);
|
|
}
|
|
});
|
|
// product autocomplete
|
|
|
|
|
|
<?php if($contract->owner_id && is_object(($contract->owner))): ?>
|
|
//$('.link-autocomplete').autoComplete('set', { value: <?=$contract->owner_id?>, text: '<?=($contract->owner_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->owner->getCompanyOrName()))." (".$contract->owner->zip." ".$contract->owner->city.", ".$contract->owner->street.")".(($contract->owner->customer_number) ? " [".$contract->owner->customer_number."]" : "") : ""?>'});
|
|
<?php else: ?>
|
|
//$('.link-autocomplete').autoComplete();
|
|
<?php endif; ?>
|
|
$('.link-autocomplete').autoComplete();
|
|
$('.link-autocomplete').keydown(function() {
|
|
if(event.keyCode == 13) {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
/*
|
|
* Links autocomplete
|
|
*/
|
|
$('.link-autocomplete').on("autocomplete.select", function(evt, item) {
|
|
autocompleteSelect(evt,item);
|
|
});
|
|
|
|
function autocompleteSelect(evt, item) {
|
|
if(item && item.value === 0) {
|
|
$('.link-autocomplete').autoComplete('set', null);
|
|
return;
|
|
}
|
|
|
|
var match = evt.currentTarget.id.match(/links_(\d+)_contract_id/);
|
|
var link_num = match[1];
|
|
if(!link_num) {
|
|
console.log("Couldn't find selected Link");
|
|
}
|
|
addLink(Number(link_num) + 1);
|
|
}
|
|
|
|
|
|
function deleteLink(linknum) {
|
|
|
|
}
|
|
|
|
function addLink(linknum) {
|
|
if(!linknum) {
|
|
console.log("no linknum");
|
|
return false;
|
|
}
|
|
|
|
if($("#links_" + linknum + "_contract_id").length) {
|
|
console.log("gibs scho");
|
|
return false;
|
|
}
|
|
|
|
var new_link = '<div class="form-group row" id="link-' + linknum + '"> \
|
|
<label class="col-lg-2 col-form-label" for="links_' + linknum + '_contract_id"></label> \
|
|
<div class="col-lg-6"> \
|
|
<div class="input-group mb-3"> \
|
|
<div class="input-group-prepend"> \
|
|
<select class="form-control" name="links[' + linknum + '][type]"> \
|
|
<option value="link">Verknüpfung mit</option> \
|
|
<option value="upgrade">Upgrade von</option> \
|
|
<option value="downgrade">Downgrade von</option> \
|
|
<option value="relocation">Umzug von</option> \
|
|
<option value="productchange">Produktwechsel von</option> \
|
|
</select> \
|
|
</div> \
|
|
<select class="form-control basicAutoComplete link-autocomplete" autocomplete="off" name="links[' + linknum + '][contract_id]" id="links_' + linknum + '_contract_id" data-linknum="' + linknum + '" data-url="<?=self::getUrl('Contract','api')?>?do=findContract&autocomplete=1" placeholder="Contract ID oder Suche nach Produkt, Matchcode, Kunde" data-noresults-text="Keine Suchergebnisse"> \
|
|
<option></option> \
|
|
</select> \
|
|
<div class="input-group-append"> \
|
|
<button type="button" class="btn btn-danger" onclick="clearNewLink(' + linknum + ')"><i class="fas fa-xmark-large mr-1"></i> Entfernen</button> \
|
|
</div> \
|
|
</div> \
|
|
</div> \
|
|
</div>';
|
|
|
|
$('#link-container').append(new_link);
|
|
//$('#links_' + linknum + '_contract_id').autocomplete();
|
|
$('#links_' + linknum + '_contract_id').autoComplete();
|
|
$('#links_' + linknum + '_contract_id').keydown(function() {
|
|
if(event.keyCode == 13) {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('#links_' + linknum + '_contract_id').on("autocomplete.select", function(evt, item) {
|
|
autocompleteSelect(evt,item);
|
|
});
|
|
}
|
|
|
|
function clearNewLink(linknum) {
|
|
if(!$("#link-" + linknum).length) {
|
|
return;
|
|
|
|
}
|
|
|
|
// only remove is not the only one
|
|
if($('#link-container').find('div.row').length > 1) {
|
|
$("#link-" + linknum).remove();
|
|
}
|
|
|
|
}
|
|
|
|
// disable mousewheel on input number field when in focus
|
|
$('form').on('focus', 'input[type=number]', function (e) {
|
|
$(this).on('wheel.disableScroll', function (e) {
|
|
e.preventDefault()
|
|
})
|
|
});
|
|
$('form').on('blur', 'input[type=number]', function (e) {
|
|
$(this).off('wheel.disableScroll')
|
|
});
|
|
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|