Added billing fields to address
This commit is contained in:
@@ -22,9 +22,9 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title mb-2"><?=($address->id) ? "Person/Firma bearbeiten" : "Neue Person/Firma"?></h4>
|
||||
<h4><?=($address->id) ? "Person/Firma bearbeiten" : "Neue Person/Firma"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Address", "save")?>">
|
||||
<form class="form-horizontal" method="post" name="addressForm" id="addressForm" action="<?=self::getUrl("Address", "save")?>">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
@@ -131,6 +131,24 @@
|
||||
</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" <?=($address->allow_contact) ? "checked='checked'" : ""?> /> Informationen per Post/Email/Telefon</label>
|
||||
</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" <?=($address->allow_spin) ? "checked='checked'" : ""?> /> Auskunft mit Service PIN</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
@@ -158,7 +176,72 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4 class="header-title mb-2">Zusatzdaten</h4>
|
||||
|
||||
<h4>Verrechnungsdaten</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="uid">UID</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="uid" id="uid" value="<?=$address->uid?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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" <?=($address->billing_type == "invoice") ? "selected='selected'" : ""?>>Rechnung</option>
|
||||
<option value="sepa" <?=($address->billing_type == "sepa") ? "selected='selected'" : ""?>>SEPA Bankeinzug</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_delivery">Rechnungsversand</label>
|
||||
<div class="col-lg-10">
|
||||
<select class="form-control" name="billing_delivery" id="billing_delivery">
|
||||
<option value="email" <?=($address->billing_delivery == "email") ? "selected='selected'" : ""?>>Email</option>
|
||||
<option value="paper" <?=($address->billing_delivery == "paper") ? "selected='selected'" : ""?>>Post</option>
|
||||
</select>
|
||||
</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="<?=$address->bank_account_bank?>" />
|
||||
</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="<?=$address->bank_account_owner?>" />
|
||||
</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="<?=$address->bank_account_iban?>" />
|
||||
<small id="iban_error" class="hidden">IBAN ungültig!</small>
|
||||
</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="<?=$address->bank_account_bic?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h4>Zusatzdaten</h4>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
@@ -181,10 +264,12 @@
|
||||
</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>
|
||||
<button type="submit" class="btn btn-primary">Speichern</button> <span id="error" class="hidden ml-2 alert alert-danger text-danger">Fehler: Ungültige IBAN</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -204,6 +289,58 @@
|
||||
placeholder: ""
|
||||
});
|
||||
$("#addresstypes").select2();
|
||||
|
||||
|
||||
|
||||
|
||||
function validateIban(iban) {
|
||||
if(!iban) {
|
||||
return false;
|
||||
}
|
||||
iban = iban.toUpperCase().replace(/\s+/, '');
|
||||
//check format
|
||||
var m;
|
||||
|
||||
if(!iban.match(/^[A-Z]{2}[0-9]{2}[A-Z0-9]{1,30}$/)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var cc = iban.substr(0, 2);
|
||||
var check = parseInt(iban.substr(2, 2));
|
||||
var account = iban.substr(4);
|
||||
|
||||
var searchRange = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split('');
|
||||
//var replaceRange = [];
|
||||
var checkStr = account + cc + "00";
|
||||
for(var i = 0; i <= 25; i++) {
|
||||
checkStr = checkStr.replace(searchRange[i], i + 10);
|
||||
};
|
||||
// make checksum
|
||||
var checksum = parseInt(checkStr.substr(0,1));
|
||||
for(pos = 1; pos < checkStr.length; pos++) {
|
||||
checksum *= 10;
|
||||
checksum += parseInt(checkStr.substr(pos, 1));
|
||||
checksum %= 97;
|
||||
}
|
||||
|
||||
if(98 - checksum == check) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$('#addressForm').submit(function(e) {
|
||||
$("#error").hide();
|
||||
if($('#billing_type').val() == "sepa" && !validateIban($("#bank_account_iban").val())) {
|
||||
$("#error").show();
|
||||
console.log("nope");
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/footer.php"); ?>
|
||||
@@ -104,7 +104,7 @@ class AddressController extends mfBaseController {
|
||||
protected function saveAction() {
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r);
|
||||
//var_dump($r);exit;
|
||||
if(is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$address = new Address($id);
|
||||
@@ -132,6 +132,47 @@ class AddressController extends mfBaseController {
|
||||
$data['mobile'] = $r->mobile;
|
||||
$data['email'] = $r->email;
|
||||
$data['note'] = $r->note;
|
||||
$data['uid'] = $r->uid;
|
||||
|
||||
|
||||
// billing data
|
||||
// validate sepa
|
||||
if(!$r->billing_type) {
|
||||
$this->layout()->setFlash("Ungültige Verrechnungsart.");
|
||||
$this->layout()->set("order", $r);
|
||||
return $this->add();
|
||||
}
|
||||
|
||||
if($r->billing_type == "sepa") {
|
||||
foreach(['bank', 'owner', 'iban', 'bic'] as $required) {
|
||||
if(!$r->{"bank_account_$required"}) {
|
||||
$this->layout()->setFlash("Bitte Bankdaten für SEPA ausfüllen.");
|
||||
$this->layout()->set("address", $r);
|
||||
return $this->add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($r->billing_type == "sepa") {
|
||||
$data['billing_type'] = "sepa";
|
||||
} else {
|
||||
$data['billing_type'] = "invoice";
|
||||
}
|
||||
|
||||
if($r->billing_delivery == "paper") {
|
||||
$data['billing_delivery'] = "paper";
|
||||
} else {
|
||||
$data['billing_delivery'] = "email";
|
||||
}
|
||||
|
||||
|
||||
$data['bank_account_bank'] = $r->bank_account_bank;
|
||||
$data['bank_account_owner'] = $r->bank_account_owner;
|
||||
$data['bank_account_iban'] = $r->bank_account_iban;
|
||||
$data['bank_account_bic'] = $r->bank_account_bic;
|
||||
$data['allow_contact'] = ($r->allow_contact) ? 1 : 0;
|
||||
$data['allow_spin'] = ($r->allow_spin) ? 1 : 0;
|
||||
|
||||
|
||||
$data['edit_by'] = 1;
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ class AddressModel {
|
||||
public $allow_contact;
|
||||
public $allow_spin;
|
||||
|
||||
|
||||
|
||||
public $note = null;
|
||||
|
||||
public $create_by = null;
|
||||
|
||||
@@ -24,7 +24,7 @@ foreach(IvtCustomerModel::getAll() as $cust) {
|
||||
if(!$cust->id) {
|
||||
continue;
|
||||
}
|
||||
foreach(['deleted', 'deletet', 'deleded', 'delete'] as $word) {
|
||||
foreach(['deleted', 'deletet', 'deleded', 'delete', 'deledet'] as $word) {
|
||||
if(strtolower(trim($cust->company)) == $word || strtolower(trim($cust->surname)) == $word || strtolower(trim($cust->firstname)) == $word) {
|
||||
continue 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user