Order/Form: Changed owner and billingaddress to autocomplete instead of
select
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
$includes_external_product = false;
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/header.php"); ?>
|
||||
@@ -41,17 +42,17 @@
|
||||
|
||||
<div class="form-group row">
|
||||
|
||||
|
||||
|
||||
<div class="col-lg-12 mb-2">
|
||||
<h4>Vertragsinhaber</h4>
|
||||
<select class="form-control select2" name="owner_id" id="owner_id">
|
||||
|
||||
<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..." data-noresults-text="Keine Suchergebnisse">
|
||||
<option></option>
|
||||
<option value="new" <?=($order->owner_id == "new") ? "selected='selected'" : ""?>>Neu...</option>
|
||||
<?php foreach($addresses as $address): ?>
|
||||
<option value="<?=$address->id?>" <?=($address->id == $order->owner_id) ? "selected='selected'" : ""?>><?=$address->getCompanyOrName()?> (<?=$address->zip?> <?=$address->city?>, <?=$address->street?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 mb-2">
|
||||
<div class="mt-2"><label><input type="checkbox" id="owner_new" /> Neukunde anlegen</label></div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 hidden" id="owner-form">
|
||||
@@ -152,13 +153,15 @@
|
||||
|
||||
<div class="col-lg-12 mb-2">
|
||||
<h4>Rechungsadresse</h4>
|
||||
<select class="form-control select2" name="billingaddress_id" id="billingaddress_id">
|
||||
|
||||
<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..." data-noresults-text="Keine Suchergebnisse">
|
||||
<option></option>
|
||||
<option value="new" <?=($order->billingaddress_id == "new") ? "selected='selected'" : ""?>>Neu...</option>
|
||||
<?php foreach($addresses as $address): ?>
|
||||
<option value="<?=$address->id?>" <?=($address->id == $order->billingaddress_id) ? "selected='selected'" : ""?>><?=$address->getCompanyOrName()?> (<?=$address->zip?> <?=$address->city?>, <?=$address->street?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 mb-2">
|
||||
<div class="mt-2"><label><input type="checkbox" id="billingaddress_new" /> Neue Rechnungsadresse anlegen</label></div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 hidden" id="billingaddress-form">
|
||||
@@ -269,21 +272,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-3">Verzögerte Herstellung:</h5>
|
||||
<h4 class="mt-3">Verzögerte Herstellung:</h4>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_after">Herstellbar ab</label>
|
||||
<div class="col-lg-4">
|
||||
<input type="text" class="form-control" name="finish_after" id="finish_after" value="<?=($order->finish_after) ? date("d.m.Y", $order->finish_after) : ""?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_after_comment">Verzögerungsgrund</label>
|
||||
<div class="col-lg-4">
|
||||
<textarea class="form-control" name="finish_after_comment" id="finish_after_comment" placeholder="Verzögerungsgrund"><?=$order->finish_after_comment?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_after">Herstellbar ab</label>
|
||||
<div class="col-lg-4">
|
||||
<input type="text" class="form-control" name="finish_after" id="finish_after" value="<?=($order->finish_after) ? date("d.m.Y", $order->finish_after) : ""?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="finish_after_comment">Verzögerungsgrund</label>
|
||||
<div class="col-lg-4">
|
||||
<textarea class="form-control" name="finish_after_comment" id="finish_after_comment" placeholder="Verzögerungsgrund"><?=$order->finish_after_comment?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -291,64 +294,68 @@
|
||||
</div>
|
||||
|
||||
|
||||
<h4>Verrechnung</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_type">Verrechnungsart</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="billing_type" id="billing_type">
|
||||
<option value="invoice" <?=($order->billing_type == "invoice") ? "selected='selected'" : ""?>>Rechnung</option>
|
||||
<option value="sepa" <?=($order->billing_type == "sepa") ? "selected='selected'" : ""?>>SEPA Bankeinzug</option>
|
||||
</select>
|
||||
<div id="billing_block" class="hidden">
|
||||
<h4>Verrechnung</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_type">Verrechnungsart</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="billing_type" id="billing_type">
|
||||
<option value="invoice" <?=($order->billing_type == "invoice") ? "selected='selected'" : ""?>>Rechnung</option>
|
||||
<option value="sepa" <?=($order->billing_type == "sepa") ? "selected='selected'" : ""?>>SEPA Bankeinzug</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_bank">Kreditinstitut</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_bank" id="bank_account_bank" value="<?=$order->bank_account_bank?>" />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_bank">Kreditinstitut</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_bank" id="bank_account_bank" value="<?=$order->bank_account_bank?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_owner">Kontoinhaber</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_owner" id="bank_account_owner" value="<?=$order->bank_account_owner?>" />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_owner">Kontoinhaber</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_owner" id="bank_account_owner" value="<?=$order->bank_account_owner?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_iban">IBAN</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_iban" id="bank_account_iban" value="<?=$order->bank_account_iban?>" />
|
||||
<small id="iban_error" class="hidden">IBAN ungültig!</small>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_iban">IBAN</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_iban" id="bank_account_iban" value="<?=$order->bank_account_iban?>" />
|
||||
<small id="iban_error" class="hidden">IBAN ungültig!</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_bic">BIC</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_bic" id="bank_account_bic" value="<?=$order->bank_account_bic?>" />
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="bank_account_bic">BIC</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="bank_account_bic" id="bank_account_bic" value="<?=$order->bank_account_bic?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4>Einwilligungen</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-10">
|
||||
<label class="form-check-label"><input type="checkbox" class="form-check-input" name="allow_contact" id="allow_contact" <?=($order->allow_contact) ? "checked='checked'" : ""?> /> Informationen per Post/Email/Telefon</label>
|
||||
<div id="accept_block" class="hidden">
|
||||
<h4>Einwilligungen</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-10">
|
||||
<label class="form-check-label"><input type="checkbox" class="form-check-input" name="allow_contact" id="allow_contact" <?=($order->allow_contact) ? "checked='checked'" : ""?> /> Informationen per Post/Email/Telefon</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-10">
|
||||
<label class="form-check-label"><input type="checkbox" class="form-check-input" name="allow_spin" id="allow_spin" <?=($order->allow_spin) ? "checked='checked'" : ""?> /> Auskunft mit Service PIN</label>
|
||||
<div class="form-group row">
|
||||
<div class="col-lg-2"></div>
|
||||
<div class="col-lg-10">
|
||||
<label class="form-check-label"><input type="checkbox" class="form-check-input" name="allow_spin" id="allow_spin" <?=($order->allow_spin) ? "checked='checked'" : ""?> /> Auskunft mit Service PIN</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -362,6 +369,8 @@
|
||||
<?php if(is_array($order->products) && count($order->products)): ?>
|
||||
<?php foreach($order->products as $product): ?>
|
||||
<?php
|
||||
if(!is_object($product)) continue;
|
||||
|
||||
if($product->product->external == 1) {
|
||||
$includes_external_product = true;
|
||||
}
|
||||
@@ -391,7 +400,7 @@
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="amount-<?=$product->id?>">Anzahl/Menge</label>
|
||||
<input type="number" class="form-control" name="products[<?=$product->id?>][amount]" id="amount-<?=$product->id?>" value="<?=$product->formatAmount()?>" placeholder="Anzahl/Menge" />
|
||||
<input type="number" class="form-control" name="products[<?=$product->id?>][amount]" id="amount-<?=$product->id?>" value="<?=($product) ? $product->formatAmount() : ""?>" placeholder="Anzahl/Menge" />
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="billing_period-<?=$product->id?>">Verrechungsperiode</label>
|
||||
@@ -705,6 +714,74 @@
|
||||
placeholder: ""
|
||||
});*/
|
||||
|
||||
/************************
|
||||
* autocomplete
|
||||
*/
|
||||
|
||||
// kunde
|
||||
<?php if($order->owner_id && is_object(($order->owner))): ?>
|
||||
$('#owner_id').autoComplete('set', { value: <?=$order->owner_id?>, text: '<?=($order->owner_id) ? $order->owner->getCompanyOrName()." (".$order->owner->zip." ".$order->owner->city.", ".$order->owner->street.")".(($order->owner->customer_number) ? " [".$order->owner->customer_number."]" : "") : ""?>'});
|
||||
<?php else: ?>
|
||||
$('#owner_id').autoComplete();
|
||||
<?php endif; ?>
|
||||
|
||||
$('#owner_id').keydown(function() {
|
||||
if(event.keyCode == 9 || event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#owner_new').change(function() {
|
||||
if($('#owner_new').is(":checked")) {
|
||||
console.log("is new");
|
||||
$('#owner_id').autoComplete('set', null);
|
||||
$('#owner_id').prop('disabled', true);
|
||||
} else {
|
||||
$('#owner_id').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#owner_id').on("autocomplete.select", function(evt, item) {
|
||||
if(item && item.value === 0) {
|
||||
$('#owner_id').autoComplete('set', null);
|
||||
}
|
||||
});
|
||||
|
||||
// rechnungsadresse
|
||||
<?php if($order->billingaddress_id && is_object($order->billingaddress)): ?>
|
||||
$('#billingaddress_id').autoComplete('set', { value: <?=$order->billingaddress_id?>, text: '<?=($order->billingaddress_id) ? $order->billingaddress->getCompanyOrName()." (".$order->billingaddress->zip." ".$order->billingaddress->city.", ".$order->billingaddress->street.")" : ""?>'});
|
||||
<?php else: ?>
|
||||
$('#billingaddress_id').autoComplete();
|
||||
<?php endif; ?>
|
||||
|
||||
$('#billingaddress_id').keydown(function() {
|
||||
if(event.keyCode == 9 || event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('#billingaddress_new').change(function() {
|
||||
if($('#billingaddress_new').is(":checked")) {
|
||||
console.log("billing is new");
|
||||
$('#billingaddress_id').autoComplete('set', null);
|
||||
$('#billingaddress_id').prop('disabled', true);
|
||||
} else {
|
||||
$('#billingaddress_id').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#billingaddress_id').on("autocomplete.select", function(evt, item) {
|
||||
if(item && item.value === 0) {
|
||||
$('#billingaddress_id').autoComplete('set', null);
|
||||
}
|
||||
});
|
||||
/*
|
||||
* autocomplete
|
||||
*******************************/
|
||||
|
||||
|
||||
$('.select2').each(function(){
|
||||
$(this).select2({
|
||||
allowClear: true,
|
||||
@@ -747,7 +824,27 @@
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
$('#owner_id').change(function() {
|
||||
$('#owner_new').change(function() {
|
||||
if($('#owner_new').prop('checked')) {
|
||||
$('#owner-form').show();
|
||||
$('#billing_block').show();
|
||||
$('#accept_block').show();
|
||||
} else {
|
||||
$('#owner-form').hide();
|
||||
$('#billing_block').hide();
|
||||
$('#accept_block').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#billingaddress_new').change(function() {
|
||||
if($('#billingaddress_new').prop('checked')) {
|
||||
$('#billingaddress-form').show();
|
||||
} else {
|
||||
$('#billingaddress-form').hide();
|
||||
}
|
||||
});
|
||||
|
||||
/*$('#owner_id').change(function() {
|
||||
var val = $('#owner_id').val();
|
||||
|
||||
if(val == "new") {
|
||||
@@ -755,7 +852,7 @@
|
||||
} else {
|
||||
$('#owner-form').hide();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
$('#billingaddress_id').change(function() {
|
||||
var val = $('#billingaddress_id').val();
|
||||
@@ -896,8 +993,8 @@
|
||||
|
||||
function validateOrderForm() {
|
||||
var allFields = [
|
||||
"owner_id", "owner_company", "owner_firstname", "owner_lastname", "owner_street", "owner_zip", "owner_city", "owner_country", "owner_phone", "owner_email",
|
||||
"billingaddress_id", "billing_company", "billing_firstname", "billing_lastname", "billing_street", "billing_zip", "billing_city", "billing_country", "billing_phone", "billing_email",
|
||||
"owner_company", "owner_firstname", "owner_lastname", "owner_street", "owner_zip", "owner_city", "owner_country", "owner_phone", "owner_email",
|
||||
"billing_company", "billing_firstname", "billing_lastname", "billing_street", "billing_zip", "billing_city", "billing_country", "billing_phone", "billing_email",
|
||||
"order_date", "finish_after", "finish_after_comment", "billing_type", "bank_account_bank", "bank_account_owner", "bank_account_iban", "bank_account_bic"
|
||||
];
|
||||
var checkEmpty = [];
|
||||
@@ -918,7 +1015,7 @@
|
||||
checkEmpty.push("finish_after_comment");
|
||||
}
|
||||
|
||||
if($('#owner_id').val() == "new") {
|
||||
if(!$('#owner_id').length) {
|
||||
if(!$('#owner_company').val()) {
|
||||
//console.log("no owner_company");
|
||||
if(!$('#owner_firstname').val() || !$('#owner_lastname').val()) {
|
||||
@@ -935,14 +1032,14 @@
|
||||
checkEmpty.push("owner_phone");
|
||||
checkEmpty.push("owner_email");
|
||||
}
|
||||
|
||||
/*
|
||||
if(!$('#owner_id :selected').val()) {
|
||||
$('#owner_id').addClass("invalid");
|
||||
$('#owner_id').next().find('.select2-selection').addClass('invalid');
|
||||
error = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
if($('#billingaddress_id').val() == "new") {
|
||||
if(!$('#billingaddress_id').length) {
|
||||
if(!$('#billing_company').val()) {
|
||||
//console.log("no billing_company");
|
||||
if(!$('#billing_firstname').val() || !$('#billing_lastname').val()) {
|
||||
@@ -961,14 +1058,14 @@
|
||||
}
|
||||
|
||||
//alert("error: " + error);
|
||||
|
||||
/*
|
||||
if(!$('#billingaddress_id :selected').val()) {
|
||||
if(!$('#owner_id :selected').val()) {
|
||||
$('#billingaddress_id').addClass("invalid");
|
||||
$('#billingaddress_id').next().find('.select2-selection').addClass('invalid');
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// check bankdaten
|
||||
if($('#billing_type').val() == "sepa") {
|
||||
@@ -983,6 +1080,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
// owner_id & billingaddress_id
|
||||
if(!$('input[name=owner_id').length) {
|
||||
error = true;
|
||||
console.log("owner_id empty");
|
||||
$('input[name=owner_id').addClass("invalid");
|
||||
}
|
||||
if(!$('input[name=billingaddress_id').length) {
|
||||
error = true;
|
||||
console.log("billingaddress_id empty");
|
||||
$('input[name=billingaddress_id').addClass("invalid");
|
||||
}
|
||||
|
||||
if(checkEmpty.length) {
|
||||
checkEmpty.forEach(function(field) {
|
||||
if(!$("#" + field).val().length) {
|
||||
|
||||
Reference in New Issue
Block a user