Added billing fields to address

This commit is contained in:
Frank Schubert
2022-01-20 22:59:33 +01:00
parent 18fba299a4
commit fec01ee1bc
4 changed files with 184 additions and 8 deletions

View File

@@ -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;