WIP Contract Form

This commit is contained in:
Frank Schubert
2022-06-09 17:05:34 +02:00
parent b2e72c35b0
commit 121312cdc3
11 changed files with 382 additions and 115 deletions

View File

@@ -0,0 +1,218 @@
<?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"); ?>

View File

@@ -24,6 +24,49 @@
<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("Building")?>">
<div class="row">
<div class="col-1">
<label class="form-label" for="filter_owner">Inhaber</label>
<input type="text" class="form-control" name="filter[owner]" id="filter_street" value="<?=$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="<?=$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="<?=$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="<?=$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("Building")?>">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="float-left">
@@ -38,21 +81,26 @@
<table class="table table-striped table-hover">
<tr>
<th>Contract ID</th>
<th>Inhaber</th>
<th>Produkt</th>
<th>Anschluss</th>
<th>Matchcode</th>
<th>Preis</th>
<th>Preis Setup</th>
<th>Rechnungsperiode</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th>Erstellt</th>
<th>Zuletzt bearbeitet</th>
<th></th>
</tr>
<?php foreach($contracts as $contract): ?>
<tr>
<td><a href="<?=self::getUrl("Address", "Edit", ["id" => $contract->owner_id])?>" target="_blank"><?=$contract->owner->getCompanyOrName()?></a></td>
<td><?=$contract->product->product->name?></td>
<td>
<td><?=$contract->id?></td>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><?=$contract->owner->getCompanyOrName()?></a></td>
<td><a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id])?>"><?=$contract->product->name?></a></td>
<td><a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
<!--<td>
<?php if($contract->termination_id): ?>
<?=$contract->termination->building->street?><br />
<?=$contract->termination->building->zip?> <?=$contract->termination->building->city?><br />
@@ -60,7 +108,7 @@
<span class="text-monospace text-pink"><?=$contract->termination->code?></span>
</a>
<?php endif; ?>
</td>
</td>-->
<td><?=$contract->price?></td>
<td><?=$contract->price_setup?></td>
<td>
@@ -74,12 +122,15 @@
<?=(12 / $contract->billing_period)?>x Jährlich
<?php endif; ?>
</td>
<td><?=date('d.m.Y H:i', $contract->create)?> (<?=$contract->creator->name?>)</td>
<td><?=date('d.m.Y H:i', $contract->edit)?> (<?=$contract->editor->name?>)</td>
<td class="text-monospace"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
<td class="text-monospace"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->create)?><br /><?=$contract->creator->name?></td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->edit)?><br /><?=$contract->editor->name?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("Contract", "view", ["id" => $contract->id])?>"><i class="far fa-eyes" title="Vertrag anzeigen"></i></a>
<a href="<?=self::getUrl("Contract", "edit", ["id" => $contract->id])?>"><i class="far fa-edit" title="Vertrag bearbeiten"></i></a>
<a href="<?=self::getUrl("Order", "edit", ["id" => $contract->product->order_id])?>"><i class="far fa-file-signature" title="Bestellung anzeigen"></i></a>
<a href="<?=self::getUrl("Contract", "cancel", ["id" => $contract->id])?>" class="text-danger" title="Vertrag kündigen"><i class="fas fa-trash"></i></a>
<a href="<?=self::getUrl("Contract", "cancel", ["id" => $contract->id])?>" class="text-danger" title="Vertrag kündigen"><i class="far fa-file-slash"></i></a>
<?php if($contract->orderproduct_id): ?><a href="<?=self::getUrl("Order", "edit", ["id" => $contract->orderproduct->order_id])?>"><i class="far fa-file-signature" title="Bestellung anzeigen"></i></a><?php endif; ?>
</td>
</tr>
<?php endforeach; ?>

View File

@@ -541,6 +541,7 @@
<?php endif; ?>
<?php if(!$order->finish_date || (!is_array($order->contracts) || !count($order->contracts))): ?>
<!-- New position -->
<div class="row product-container" id="position-<?=$i?>">
<div class="col-md-1 product-<?=$i?>">
@@ -638,99 +639,9 @@
</div>
</div>
</div>
<?php endif; ?>
<!--<div class="row product-container" id="position-<?=$i?>">
<div class="col-md-1 product-new">
<div class="form-group">
<label class="form-label" for="pos-new" >Position</label>
<input type="number" class="form-control" name="products[new][pos]" id="pos-new" value="<?=$order->products['new']['pos']?>" placeholder="Position" />
</div>
</div>
<div class="col-md-11">
<div class="row">
<div class="col-4">
<label class="form-label" for="product_id-new">Produkt</label>
<select name="products[new][product_id]" id="product_id-new" class="form-control" onchange="updateProduct('new')">
<option></option>
<?php foreach($products as $p): ?>
<option value="<?=$p->id?>" <?=($p->id == $order->products['new']['product_id']) ? "selected='selected'" : ""?>><?=$p->name?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-2">
<label class="form-label" for="amount-new">Anzahl/Menge</label>
<input type="number" class="form-control" name="products[new][amount]" id="amount-new" value="<?=$order->products['new']['amount']?>" placeholder="Anzahl/Menge (Standard: 1)" />
</div>
<div class="col-2">
<label class="form-label" for="billing_period-new" >Verrechungsperiode</label>
<select class="form-control" name="products[new][billing_period]" id="billing_period-new" value="<?=$order->products['new']['billing_period']?>" placeholder="Verrechnungsperiode">
<option value="1">Monatlich</option>
<option value="12">Jährlich</option>
</select>
</div>
<div class="col-2">
<label class="form-label" for="price-new" >Preis p. Periode</label>
<input type="text" class="form-control" name="products[new][price]" id="price-new" value="<?=$order->products['new']['price']?>" placeholder="Preis p. Periode" />
</div>
<div class="col-2">
<label class="form-label" for="price_setup-new" >Preis Setup</label>
<input type="text" class="form-control" name="products[new][price_setup]" id="price_setup-new" value="<?=$order->products['new']['price_setup']?>" placeholder="Preis Setup" />
</div>
</div>
<div class="row mt-1 mb-2 <?=($order->action != "Save") ? "hidden" : ""?>" id="termination_id-new-line">
<div class="col-12">
<label class="form-label" for="termination_id-new">Anschluss</label>
<select name="products[new][termination_id]" id="termination_id-new" class="form-control">
<option></option>
<?php foreach($terminations as $t): ?>
<option value="<?=$t->id?>" <?=($t->id == $order->products['new']['termination_id']) ? "selected='selected'" : ""?> ><?=$t->code?> - <?=$t->getAddress()?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="row mt-1 mb-2">
<div class="col-8">
<label class="form-label" for="description-new" >Zusatztext</label>
<textarea class="form-control" name="products[new][description]" id="description-new" placeholder="Zusatztext"><?=$order->products['new']['description']?></textarea>
</div>
<div class="col-2">
<label class="form-label" for="billing_delay-new" >Verzögerter Verrechnungsstart</label>
<input type="number" class="form-control" name="products[new][billing_delay]" id="billing_delay-new" value="<?=$order->products['new']['billing_delay']?>" placeholder="Freimonate" />
<small>Max. 6 Monate</small>
</div>
<?php if($me->is("Admin")): ?>
<div class="col-1">
<label class="form-label" for="price_nne-new">Preis NNE</label>
<input type="text" class="form-control" name="products[new][price_nne]" id="price_nne-new" value="<?=$order->products['new']['price_nne']?>" placeholder="NNE" />
</div>
<div class="col-1">
<label class="form-label" for="price_nbe-new">Preis NBE</label>
<input type="text" class="form-control" name="products[new][price_nbe]" id="price_nbe-new" value="<?=$order->products['new']['price_nbe']?>" placeholder="NBE" />
</div>
<?php endif; ?>
</div>
</div>
</div>-->
</div>
</div>
@@ -886,7 +797,7 @@
<?php endif; ?>
$('#owner_id').keydown(function() {
if(event.keyCode == 9 || event.keyCode == 13) {
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
@@ -916,7 +827,7 @@
<?php endif; ?>
$('#billingaddress_id').keydown(function() {
if(event.keyCode == 9 || event.keyCode == 13) {
if(event.keyCode == 13) {
event.preventDefault();
return false;
}

View File

@@ -59,6 +59,7 @@
<th>Firma / Person</th>
<th>Email</th>
<th>Admin</th>
<th>Techniker</th>
<th></th>
</tr>
<?php foreach($users as $user): ?>
@@ -68,6 +69,7 @@
<td><?=($user->address->company) ? $user->address->company : $user->address->getFullName()?></td>
<td><?=$user->email?></td>
<td><?=($user->isAdmin()) ? "Ja" : "Nein"?></td>
<td><?=($user->is("Technician")) ? "Ja" : "Nein"?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?=self::getUrl("User","edit", ['id' => $user->id])?>" title="User bearbeiten"><i class="far fa-edit"></i></a>
<?php if($user->id > 1): ?>