218 lines
8.3 KiB
PHP
218 lines
8.3 KiB
PHP
<?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="<?=self::getUrl("Contract", "save")?>">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<input type="hidden" name="id" value="<?=$contact->id?>" />
|
|
<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="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?>">
|
|
</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?>">
|
|
</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">
|
|
$(".select2").select2({
|
|
allowClear: true,
|
|
placeholder: ""
|
|
});
|
|
|
|
// 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"
|
|
);
|
|
|
|
});
|
|
|
|
// rechnungsadresse
|
|
<?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);
|
|
}
|
|
});
|
|
|
|
|
|
// Produkt
|
|
|
|
// kunde
|
|
<?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);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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"); ?>
|