From 724e2eccee39a477408e4752833479c1aeff5dfc Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Thu, 18 Jul 2024 15:05:24 +0200 Subject: [PATCH] Added birthday to Address --- Layout/default/Address/Form.php | 16 +++++++++- Layout/default/Address/View.php | 3 ++ application/Address/AddressController.php | 12 ++++++- application/Address/AddressModel.php | 1 + application/Preorder/Preorder.php | 2 -- .../20240718123809_address_add_birthdate.php | 31 +++++++++++++++++++ 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 db/migrations/20240718123809_address_add_birthdate.php diff --git a/Layout/default/Address/Form.php b/Layout/default/Address/Form.php index dca5d177d..3b53f3b26 100644 --- a/Layout/default/Address/Form.php +++ b/Layout/default/Address/Form.php @@ -120,7 +120,12 @@ - +
+ +
+ "> +
+
@@ -445,6 +450,15 @@ todayBtn: 'linked', autoclose: true }); + + $('#birthdate').datepicker({ + language: 'de', + format: "dd.mm.yyyy", + showWeekDays: true, + todayBtn: 'linked', + autoclose: true + }); + var bankdata_valid = false; diff --git a/Layout/default/Address/View.php b/Layout/default/Address/View.php index 199ca265c..29d1157a1 100644 --- a/Layout/default/Address/View.php +++ b/Layout/default/Address/View.php @@ -73,6 +73,9 @@ Email email?> + + Geburtsdatum + birthdate) ? (new DateTime($address->birthdate))->format("d.m.Y") : ""?> diff --git a/application/Address/AddressController.php b/application/Address/AddressController.php index 7a25bec41..4e0085f0d 100644 --- a/application/Address/AddressController.php +++ b/application/Address/AddressController.php @@ -266,7 +266,17 @@ class AddressController extends mfBaseController { $data['email'] = trim($r->email); $data['note'] = trim($r->note); $data['uid'] = trim($r->uid); - + + if(trim($r->birthdate)) { + try { + $data["birthdate"] = (DateTime::createFromFormat("d.m.Y", trim($r->birthdate)))->format("Y-m-d"); + } catch(Exception $e) { + $this->layout()->setFlash("Ungültiges Geburtsdaum", "warning"); + } + + } + + if($this->me->can("Fibu")) { $data["sepa_date"] = ($r->sepa_date) ? Layout::dateToInt($r->sepa_date) : null; diff --git a/application/Address/AddressModel.php b/application/Address/AddressModel.php index cd8b2053c..1c0f2841f 100644 --- a/application/Address/AddressModel.php +++ b/application/Address/AddressModel.php @@ -22,6 +22,7 @@ class AddressModel { public $fax; public $mobile; public $email; + public $birthday; public $uid; public $billing_type; public $billing_delivery; diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index cbb5e938a..2eadcf591 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -90,8 +90,6 @@ class Preorder extends mfBaseModel { ]); $history->save(); } - - } public function runStatusTrigger() { diff --git a/db/migrations/20240718123809_address_add_birthdate.php b/db/migrations/20240718123809_address_add_birthdate.php new file mode 100644 index 000000000..15240d16d --- /dev/null +++ b/db/migrations/20240718123809_address_add_birthdate.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $table = $this->table("Address"); + $table->addColumn("birthdate", "date", ["null" => true, "default" => null, "after" => "uid"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("Address")->removeColumn("birthdate")->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +}