diff --git a/Layout/default/Address/Form.php b/Layout/default/Address/Form.php index 329805844..4512bf3bb 100644 --- a/Layout/default/Address/Form.php +++ b/Layout/default/Address/Form.php @@ -1,4 +1,3 @@ -parent->types);exit;?>
- +
- +
Standard: Tage
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ diff --git a/Layout/default/Address/bmd_export.csv.php b/Layout/default/Address/bmd_export.csv.php index 10b093993..1ca733dfc 100644 --- a/Layout/default/Address/bmd_export.csv.php +++ b/Layout/default/Address/bmd_export.csv.php @@ -1,9 +1,10 @@ -Lieferant;Kunde;address_id;FIBU-Verrechnungsnummer;FIBU Lieferantennummer;Zahlungsziel Lieferant;Firma;Vorname;Nachname;Straße Hausnummer;PLZ;Ort;Land;Telefon;Mobil;Mail;UID;Verrechnungsart;Rechnungsversand;Kreditinstitut;Kontoinhaber;IBAN;BIC setReturnValue(["header" => $header]); foreach($addresses as $a): ?> -;;;;;;nl2ws($a["company"])?>;nl2ws($a["firstname"])?>;nl2ws($a["lastname"])?>;nl2ws($a["street"])?>;nl2ws($a["$address->zip"])?>;nl2ws($a["city"])?>;nl2ws($a["country"])?>;nl2ws($a["phone"])?>;nl2ws($a["mobile"])?>;nl2ws($a["email"])?>;nl2ws($a["uid"])?>;;;;;; +;;;;nl2ws($a["firstname"])?>;nl2ws($a["lastname"])?>;nl2ws($a["street"])?>;nl2ws($a["zip"])?>;nl2ws($a["city"])?>;nl2ws($a["countrycode"])?>;nl2ws($a["phone"])?>;nl2ws($a["email"])?>;nl2ws($a["uid"])?>;;;;; value(); } - $type = "inc"; + if(!file_exists(TT_ADDRESS_BMD_EXPORT_PATH)) { + $this->layout()->setFlash("Export Pfad (".TT_ADDRESS_BMD_EXPORT_PATH.") nicht gefunden!", "error"); + } + $filepath = TT_ADDRESS_BMD_EXPORT_PATH."/".TT_ADDRESS_BMD_EXPORT_FILENAME; + $type = "inc"; if($this->request->type == "full") { $last_export = 0; $type = "full"; } - if(!file_exists(TT_ADDRESS_BMD_EXPORT_PATH)) { - $this->layout()->setFlash("Export Pfad (".TT_ADDRESS_BMD_EXPORT_PATH.") nicht gefunden!", "error"); + // delete export file if export if full + if($last_export == 0 && file_exists($filepath)) { + unlink($filepath); } - + $export_ts->value(date('U')); $search = ["edit>" => $last_export, "customer_or_fibu_numbers" => true]; @@ -215,7 +220,11 @@ class AddressController extends mfBaseController { $addresses = []; foreach(AddressModel::search($search) as $address) { - + // if supplier -> add it as extra line + if($address->fibu_supplier_number) { + $addresses[$address->fibu_supplier_number] = $address; + if(!$address->fibu_account_number) continue; + } // if is primary -> use it if($address->fibu_account_number && $address->fibu_primary_account) { @@ -271,48 +280,68 @@ class AddressController extends mfBaseController { continue; } - // if supplier -> use it - if($address->fibu_supplier_number) { - $addresses[$address->fibu_supplier_number] = $address; - continue; - } - + + } $export_addresses = []; - foreach($addresses as $address) { + foreach($addresses as $fibu_num => $address) { $a = []; $a["id"] = $address->id; - $a["is_supplier"] = (array_key_exists("supplier", $address->types) && $address->types['supplier']) ? "1" : "0"; - $a["is_customer"] = "1"; - $a["customer_number"] = $address->customer_number; - $a["fibu_account_number"] = $address->fibu_account_number; - $a["fibu_supplier_number"] = $address->fibu_supplier_number; + //$a["is_supplier"] = (array_key_exists("supplier", $address->types) && $address->types['supplier']) ? "1" : "0"; + //$a["is_customer"] = "1"; + //$a["customer_number"] = $address->customer_number; + $a["fibu_account_number"] = $fibu_num; + //$a["fibu_supplier_number"] = $address->fibu_supplier_number; $a["fibu_supplier_due"] = (is_numeric($address->fibu_supplier_due)) ? $address->fibu_supplier_due : TT_ADDRESS_DEFAULT_SUPPLIER_DUE; - $a["company"] = $address->company; - $a["firstname"] = $address->firstname; - $a["lastname"] = $address->lastname; + $a["fibu_supplier_skonto"] = $address->fibu_supplier_skonto; + $a["fibu_supplier_skonto_rate"] = $address->fibu_supplier_skonto_rate; $a["street"] = $address->street; $a["zip"] = $address->zip; $a["city"] = $address->city; - $a["country"] = $address->country; - $a["phone"] = $address->phone; - $a["mobile"] = $address->mobile; - $a["email"] = $address->email; + $a["countrycode"] = ($address->country) ? __($address->country, "cc") : "AT"; + $a["phone"] = ""; + if($address->mobile) $a["phone"] = $address->mobile; + if($address->phone) $a["phone"] = $address->phone; $a["uid"] = $address->uid; - $a["billing_type"] = $address->billing_type; - $a["billing_delivery"] = $address->billing_delivery; - if(array_key_exists("billing", $address->links) && $address->links["billing"]) { - $a["bank"] = $address->links["billing"]->bank_account_bank; - $a["bank_owner"] = $address->links["billing"]->bank_account_owner; - $a["iban"] = $address->links["billing"]->bank_account_iban; - $a["bic"] = $address->links["billing"]->bank_account_bic; + $a["billing_type"] = ($address->billing_type == "sepa") ? "1" : "0"; + //$a["billing_delivery"] = $address->billing_delivery; + + if($address->company) { + $a["firstname"] = ""; + $a["lastname"] = $address->company; + } else { + $a["firstname"] = $address->firstname; + $a["lastname"] = $address->lastname; + } + + if(array_key_exists("billing", $address->links) && $address->links["billing"][0] && $address->links["billing"][0]->address_id) { + //var_dump($address->links);exit; + $bill = $address->links["billing"][0]->address; + $a["bank"] = $bill->bank_account_bank; + $a["bank_owner"] = $bill->bank_account_owner; + $a["iban"] = $bill->bank_account_iban; + $a["bic"] = $bill->bank_account_bic; + $a["email"] = $bill->email; } else { $a["bank"] = $address->bank_account_bank; $a["bank_owner"] = $address->bank_account_owner; $a["iban"] = $address->bank_account_iban; $a["bic"] = $address->bank_account_bic; + $a["email"] = $address->email; + } + + $a["customer_numbers"] = []; + $a["customer_numbers"][] = $address->customer_number; + + // add all customer numbers to customer_numbers + if($address->fibu_account_number) { + foreach(AddressModel::search(["fibu_account_number" => $address->fibu_account_number]) as $secondary) { + if($secondary->customer_number && !in_array($secondary->customer_number, $a["customer_numbers"])) { + $a["customer_numbers"][] = $secondary->customer_number; + } + } } $export_addresses[] = $a; @@ -325,13 +354,20 @@ class AddressController extends mfBaseController { $tpl->setTemplate("Address/bmd_export.csv"); $tpl->set("addresses", $export_addresses); $csv_content = $tpl->render(); + $return_values = $tpl->getReturnedValue(); + $csv_header = $return_values['header']; - $filename = "thetool_address_export_".$type."_".date("Y-m-d-H-i-s").".csv"; - // save to TT_ADDRESS_BMD_EXPORT_PATH - $filepath = TT_ADDRESS_BMD_EXPORT_PATH."/".$filename; - if(!file_put_contents($filepath, $csv_content)) { + if(file_exists($filepath)) { + // if file exists, append new content + $result = file_put_contents($filepath, $csv_content, FILE_APPEND); + } else { + // else, add content with csv header + $result = file_put_contents($filepath, $csv_header.$csv_content); + } + + if($result === false) { $this->layout()->setFlash("Datei $filepath konnte nicht gespeichert werden!", "error"); } else { $export_ts->save(); @@ -385,6 +421,8 @@ class AddressController extends mfBaseController { $data['fibu_primary_account'] = 0; } $data['fibu_supplier_due'] = ($r->fibu_supplier_due) ? $r->fibu_supplier_due : null; + $data['fibu_supplier_skonto'] = ($r->fibu_supplier_skonto) ? $r->fibu_supplier_skonto : null; + $data['fibu_supplier_skonto_rate'] = ($r->fibu_supplier_skonto_rate) ? $r->fibu_supplier_skonto_rate : null; } diff --git a/application/Address/AddressModel.php b/application/Address/AddressModel.php index 62f80f9c0..76ab3dee8 100644 --- a/application/Address/AddressModel.php +++ b/application/Address/AddressModel.php @@ -5,6 +5,9 @@ class AddressModel { public $customer_number; public $fibu_account_number; public $fibu_supplier_number; + public $fibu_supplier_due; + public $fibu_supplier_skonto; + public $fibu_supplier_skonto_rate; public $fibu_primary_account; public $spin; public $company; diff --git a/db/migrations/20240116132506_address_add_skonto.php b/db/migrations/20240116132506_address_add_skonto.php new file mode 100644 index 000000000..86cfca51f --- /dev/null +++ b/db/migrations/20240116132506_address_add_skonto.php @@ -0,0 +1,35 @@ +getEnvironment() == "thetool") { + $table = $this->table("Address"); + $table->addColumn("fibu_supplier_skonto", "integer", ["null" => true, "default" => null, "after" => "fibu_supplier_due"]); + $table->addColumn("fibu_supplier_skonto_rate", "integer", ["null" => true, "default" => null, "after" => "fibu_supplier_skonto"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $table = $this->table("Address"); + $table->removeColumn("fibu_supplier_skonto_rate"); + $table->removeColumn("fibu_supplier_skonto"); + $table->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/lang/de.php b/lang/de.php index 6e2612066..feef57f38 100644 --- a/lang/de.php +++ b/lang/de.php @@ -56,4 +56,62 @@ $l['contract.downgrade'] = "Downgrade"; $l['contract.relocation'] = "Umzug"; $l['contract.productchange'] = "Produktwechsel"; + +$l['cc.österreich'] = "AT"; +$l['cc.osterreich'] = "AT"; +$l['cc.oesterreich'] = "AT"; +$l['cc.austria'] = "AT"; +$l["cc.bulgarien"] = "BG"; +$l["cc.bulgaria"] = "BG"; +$l["cc.schweiz"] = "CH"; +$l["cc.switzerland"] = "CH"; +$l["cc.zypern"] = "CY"; +$l["cc.cyprus"] = "CY"; +$l["cc.tschechien"] = "CZ"; +$l["cc.czechia"] = "CZ"; +$l["cc.tschechische republik"] = "CZ"; +$l["cc.czech republic"] = "CZ"; +$l["cc.Česká republika"] = "CZ"; +$l["cc.deutschland"] = "DE"; +$l["cc.germany"] = "DE"; +$l["cc.großbritannien"] = "GB"; +$l["cc.grossbritannien"] = "GB"; +$l["cc.britain"] = "GB"; +$l["cc.great britain"] = "GB"; +$l["cc.uk"] = "GB"; +$l["cc.united kingdom"] = "GB"; +$l["cc.United Kingdom of Great Britain and Northern Ireland"] = "GB"; +$l["cc.Vereinigtes Königreich"] = "GB"; +$l["cc.Vereinigtes Königreich Großbritannien und Nordirland"] = "GB"; +$l["cc.ungarn"] = "HU"; +$l["cc.hungary"] = "HU"; +$l["cc.irland"] = "IE"; +$l["cc.ireland"] = "IE"; +$l["cc.republic of ireland"] = "IE"; +$l["cc.italien"] = "IT"; +$l["cc.italia"] = "IT"; +$l["cc.japan"] = "JP"; +$l["cc.jpn"] = "JP"; +$l["cc.nippon"] = "JP"; +$l["cc.nihon"] = "JP"; +$l["cc.日本"] = "JP"; +$l["cc.日本国"] = "JP"; +$l["cc.niederlande"] = "NL"; +$l["cc.netherlands"] = "NL"; +$l["cc.nederland"] = "NL"; +$l["cc.holland"] = "NL"; +$l["cc.polen"] = "PL"; +$l["cc.poland"] = "PL"; +$l["cc.polska"] = "PL"; +$l["cc.rumänien"] = "RO"; +$l["cc.rumaenien"] = "RO"; +$l["cc.romania"] = "RO"; +$l["cc.slowenien"] = "SL"; +$l["cc.slovenia"] = "SL"; +$l["cc.slowakei"] = "SK"; +$l["cc.slovakia"] = "SK"; +$l["cc.slowakische republik"] = "SK"; +$l["cc.Slovak Republic"] = "SK"; + + $lang['de'] = $l; \ No newline at end of file diff --git a/lib/mvcfronk/mfLayout/mfLayout.php b/lib/mvcfronk/mfLayout/mfLayout.php index eeb3ceec5..31416a252 100644 --- a/lib/mvcfronk/mfLayout/mfLayout.php +++ b/lib/mvcfronk/mfLayout/mfLayout.php @@ -279,9 +279,12 @@ if(!isset($lang)) { $lang = []; } -function __($string, $prefix = null) { +function __($_string, $prefix = null) { global $lang; + $string = str_replace(["Ä","Ö","Ü"],["ä","ö","ü"] , strtolower($_string)); + + if(!$lang) { //mfLoghandler::singleton()->debug("Loading language file for __() function"); include(BASEDIR . "/lang/de.php");