WIP Contract Form
This commit is contained in:
218
Layout/default/Contract/Form.php
Normal file
218
Layout/default/Contract/Form.php
Normal 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"); ?>
|
||||
@@ -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; ?>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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): ?>
|
||||
|
||||
@@ -121,6 +121,20 @@ class Address extends mfBaseModel {
|
||||
return $spin;
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
if(!$this->id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$a = [];
|
||||
$a['id'] = $this->id;
|
||||
foreach($this->data as $key => $value) {
|
||||
$a[$key] = $value;
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
@@ -241,6 +241,9 @@ class AddressController extends mfBaseController {
|
||||
$data = [];
|
||||
|
||||
switch($do) {
|
||||
case "getAddress":
|
||||
$return = $this->getAddressApi();
|
||||
break;
|
||||
case "findAddress":
|
||||
$return = $this->findAddressApi();
|
||||
break;
|
||||
@@ -257,6 +260,22 @@ class AddressController extends mfBaseController {
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function getAddressApi() {
|
||||
$id = trim($this->request->id);
|
||||
if(!is_numeric($id) || !$id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$address = new Address($id);
|
||||
if(!$address->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$a = $address->toArray();
|
||||
|
||||
return ['address' => $a];
|
||||
}
|
||||
|
||||
private function findAddressApi() {
|
||||
$search = trim($this->request->q);
|
||||
$autocomplete = $this->request->autocomplete;
|
||||
@@ -284,7 +303,7 @@ class AddressController extends mfBaseController {
|
||||
$addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "firstname" => $search]));
|
||||
$addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "lastname" => $search]));
|
||||
|
||||
if(!is_array($addresses) && !count($addresses)) {
|
||||
if(!is_array($addresses) || !count($addresses)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -302,7 +321,7 @@ class AddressController extends mfBaseController {
|
||||
if(!$autocomplete) {
|
||||
foreach($all_addresses as $id => $address) {
|
||||
$results[$id] = str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$address->getCompanyOrName()))." (".$address->zip." ".$address->city.", ".$address->street.")".(($address->customer_number) ? " [".$address->customer_number."]" : "");
|
||||
if(count($results) > 5) {
|
||||
if(count($results) > 15) {
|
||||
$results["more"] = "...";
|
||||
break;
|
||||
}
|
||||
@@ -315,7 +334,7 @@ class AddressController extends mfBaseController {
|
||||
foreach($all_addresses as $id => $address) {
|
||||
$result = ['value' => $id, 'text' => str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$address->getCompanyOrName()))." (".$address->zip." ".$address->city.", ".$address->street.")".(($address->customer_number) ? " [".$address->customer_number."]" : "")];
|
||||
$results[] = $result;
|
||||
if(count($results) > 5) {
|
||||
if(count($results) > 15) {
|
||||
$results[] = ['value' => 0, 'text' => " --> Mehr Suchergebnisse vorhanden. Bitte Suchbegriff genauer definieren <--"];
|
||||
break;
|
||||
}
|
||||
@@ -324,7 +343,5 @@ class AddressController extends mfBaseController {
|
||||
$this->returnJson($results);
|
||||
}
|
||||
|
||||
private function searchAddress() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ class Contract extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "orderproduct") {
|
||||
$this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id);
|
||||
$this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderproduct_id);
|
||||
if($this->orderproduct === null) {
|
||||
$this->orderproduct = new OrderProduct($this->orderorderproduct_id);
|
||||
$this->orderproduct = new OrderProduct($this->orderproduct_id);
|
||||
if($this->orderproduct->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id, $this->orderproduct);
|
||||
mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderproduct_id, $this->orderproduct);
|
||||
}
|
||||
}
|
||||
return $this->orderproduct;
|
||||
|
||||
@@ -55,4 +55,14 @@ class ContractController extends mfBaseController {
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
$this->layout()->setTemplate("Contract/Form");
|
||||
}
|
||||
|
||||
protected function editAction() {
|
||||
|
||||
|
||||
return $this->addAction();
|
||||
}
|
||||
}
|
||||
@@ -220,6 +220,8 @@ class ProductController extends mfBaseController {
|
||||
case "getProduct":
|
||||
$return = $this->getProductApi();
|
||||
break;
|
||||
case "findProduct":
|
||||
$return = $this->findProductApi();
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -259,4 +261,38 @@ class ProductController extends mfBaseController {
|
||||
|
||||
return ["product" => $product->data, "form_id" => $form_id];
|
||||
}
|
||||
|
||||
private function findProductApi() {
|
||||
$search = trim($this->request->q);
|
||||
$autocomplete = $this->request->autocomplete;
|
||||
|
||||
$products = [];
|
||||
|
||||
if(is_numeric($search)) {
|
||||
$pnumbers = ProductModel::search(["id" => $search]);
|
||||
if($pnumbers) {
|
||||
$products = array_merge($products, $pnumbers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$products = array_merge($products, ProductModel::search(["nameLike" => $search]));
|
||||
|
||||
if(!is_array($products) && !count($products)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$results = [];
|
||||
|
||||
// return bootstrap-autocomplete format
|
||||
foreach($products as $product) {
|
||||
$result = ['value' => $product->id, 'text' => str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$product->name))];
|
||||
$results[] = $result;
|
||||
if(count($results) > 15) {
|
||||
$results[] = ['value' => 0, 'text' => " --> Mehr Suchergebnisse vorhanden. Bitte Suchbegriff genauer definieren <--"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->returnJson($results);
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,13 @@ class ProductModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("id", $filter)) {
|
||||
$id = $db->escape($filter['id']);
|
||||
if($id) {
|
||||
$where .= " AND Product.`id` like '%$id%'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("productgroup_id", $filter)) {
|
||||
$productgroup_id = $filter['productgroup_id'];
|
||||
if(is_numeric($productgroup_id)) {
|
||||
@@ -138,14 +145,14 @@ class ProductModel {
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = $db->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND `name` like '$name'";
|
||||
$where .= " AND Product.`name` like '$name'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("nameLike", $filter)) {
|
||||
$name = $db->escape($filter['nameLike']);
|
||||
if($name) {
|
||||
$where .= " AND `name` like '%$name%'";
|
||||
$where .= " AND Product.`name` like '%$name%'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,8 +114,9 @@ class User extends mfBaseModel {
|
||||
}
|
||||
|
||||
foreach($what as $w) {
|
||||
if(is_object($this->permissions) && property_exists($this->permissions, "is$w")) {
|
||||
if($this->permissions->{"is$w"} === true) {
|
||||
$perm = ucfirst(strtolower($w));
|
||||
if(is_object($this->permissions) && property_exists($this->permissions, "is$perm")) {
|
||||
if($this->permissions->{"is$perm"} === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user