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,53 +280,108 @@ class AddressController extends mfBaseController { continue; } - // if supplier -> use it - if($address->fibu_supplier_number) { - $addresses[$address->fibu_supplier_number] = $address; - continue; - } - + + } + $country_code_errors = []; $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; + if(strlen($address->country) == 2) { + $a["countrycode"] = trim($address->country); + } else { + $a["countrycode"] = "AT"; + + if(trim($address->country)) { + $acountry = strtolower(trim($address->country)); + $cc = __($acountry, "cc"); + + $this->log->debug("is $cc == cc.$acountry"); + $this->log->debug("last translation failed: ".(__last_translation_failed() ? "true" : "false")); + + if(__last_translation_failed()) { + //if($cc == "cc.".$acountry) { + $a["countrycode"] = "AT"; + // email to buchhaltung + $country_code_errors[$fibu_num] = $address; + } else { + $a["countrycode"] = $cc; + } + } + } + $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; } + if(count($country_code_errors)) { + $msg = "Hallo,\r\n\r\ndas in thetool eingetragene Land von folgenden Kunden/Lieferanten konnte nicht in einen ISO-Code übersetzt werden:\r\n\r\n"; + foreach($country_code_errors as $fibu_num => $address) { + $msg .= "$fibu_num (".$address->getCompanyOrName()."): ".$address->country."\r\n"; + } + + $email = new Emailnotification(); + $email->setFrom(TT_OUTGOING_EMAIL, "thetool"); + $email->setTo(TT_FIBU_EMAIL_TO); + $email->setSubject("[BMD-Export] Fehlerhaftes Land"); + $email->setBody($msg); + $email->send(); + } @@ -325,13 +389,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 +456,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..9c5e67579 100644 --- a/lang/de.php +++ b/lang/de.php @@ -32,7 +32,7 @@ $l['connected-b'] = "Rohr im Haus"; $l['created-t'] = "Erstellt"; $l['planned-t'] = "Faserplan vorhanden"; $l['assigned-t'] = "Bauauftrag zugeteilt"; -$l['passed-t'] = "Fasern im Gebäude"; +$l['passed-t'] = "Fasern im Gebaeude"; $l['connected-t'] = "Passiv erschlossen"; $l['active-t'] = "Internetprodukt aktiv"; @@ -56,4 +56,87 @@ $l['contract.downgrade'] = "Downgrade"; $l['contract.relocation'] = "Umzug"; $l['contract.productchange'] = "Produktwechsel"; + +$l['cc.oesterreich'] = "AT"; +$l['cc.oestereich'] = "AT"; +$l['cc.osterreich'] = "AT"; +$l['cc.oesterreich'] = "AT"; +$l['cc.austria'] = "AT"; +$l['cc.at'] = "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.frankreich"] = "FR"; +$l["cc.france"] = "FR"; +$l["cc.francaise"] = "FR"; +$l["cc.République française"] = "FR"; +$l["cc.Republique francaise"] = "FR"; +$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 Koenigreich"] = "GB"; +$l["cc.Vereinigtes Koenigreich Großbritannien und Nordirland"] = "GB"; +$l["cc.Vereinigtes Koenigreich Grossbritannien 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.luxemburg"] = "LU"; +$l["cc.großherzogtum luxemburg"] = "LU"; +$l["cc.grossherzogtum luxemburg"] = "LU"; +$l["cc.luxembourg"] = "LU"; +$l["cc.grand duchy of luxembourg"] = "LU"; +$l["cc.groussherzogtum lëtzebuerg"] = "LU"; +$l["cc.groussherzogtum letzebuerg"] = "LU"; +$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.rumaenien"] = "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"; +$l["cc.Vereinigte Staaten"] = "US"; +$l["cc.Vereinigte Staaten von Amerika"] = "US"; +$l["cc.usa - vereinigte staaten"] = "US"; +$l["cc.Amerika"] = "US"; +$l["cc.US"] = "US"; +$l["cc.USA"] = "US"; +$l["cc.U.S.A."] = "US"; +$l["cc.America"] = "US"; +$l["cc.United States"] = "US"; +$l["cc.United States of America"] = "US"; +$l["cc.mm"] = "CW"; + $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..e854a12d4 100644 --- a/lib/mvcfronk/mfLayout/mfLayout.php +++ b/lib/mvcfronk/mfLayout/mfLayout.php @@ -261,7 +261,7 @@ function mfLayoutInclude($filename, $folder = "") { global $mfLayoutPackage; if($folder) { - $folder = $fodler."/"; + $folder = $folder."/"; } $inc_path = VIEWDIR . "/" . LAYOUT_DEFAULTPACKAGE . "/" . $folder . $filename; @@ -279,8 +279,15 @@ if(!isset($lang)) { $lang = []; } -function __($string, $prefix = null) { +$last_translation_failed = false; + +function __($_string, $prefix = null) { global $lang; + global $last_translation_failed; + $last_translation_failed = false; + + $string = str_replace(["Ä","Ö","Ü","ß","ä","ö","ü","ss"], ["ae","oe","ue"], strtolower($_string)); + if(!$lang) { //mfLoghandler::singleton()->debug("Loading language file for __() function"); @@ -294,6 +301,11 @@ function __($string, $prefix = null) { if (array_key_exists($string, $lang['de'])) { return $lang['de'][$string]; } + $last_translation_failed = true; return $string; } +function __last_translation_failed() { + global $last_translation_failed; + return $last_translation_failed; +} \ No newline at end of file