diff --git a/Layout/default/ADBWohneinheit/Form.php b/Layout/default/ADBWohneinheit/Form.php index b3d9bbc7f..7773256c2 100644 --- a/Layout/default/ADBWohneinheit/Form.php +++ b/Layout/default/ADBWohneinheit/Form.php @@ -1 +1,178 @@ id && !array_key_exists($unit->hausnummer->netzgebiet_id, $my_adb_networks)) { + $this->setFlash("Keine Berechtigung", "error"); + mfBaseController::redirect("AddressDB"); + } + +?> + + +
+
+
+ +

Wohneinheit

+
+
+
+ + +
+
+ +
+
+

id) ? "Wohneinheit bearbeiten" : "Neue Adresse"?>

+ +
"> + +
+
+ +
+ +
+ hausnummer->rimo_id : ""?>" disabled="disabled" /> +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+
+ +
+
+ + +
+ +
+ +
+
+
+ + + rimo_workorder) && $unit->rimo_workorder->id) || (is_array($unit->ftu_data) && $unit->ftu_data->id)): ?> +
+
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +

FTU

FTU Name:ftu_data["name"]?> +
FTU External IDftu_data["id"]?> +

Workorder

Namerimo_workorder->rimo_name?>
External IDrimo_workorder->rimo_id?>
Statusrimo_workorder->rimo_status?>
Erstelltrimo_workorder)) ? date("d.m.Y H:i:s", $unit->rimo_workorder->create) : ""?>
+
+
+
+
+
+
+ + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/Layout/default/Address/Form.php b/Layout/default/Address/Form.php index 329805844..401696a18 100644 --- a/Layout/default/Address/Form.php +++ b/Layout/default/Address/Form.php @@ -1,4 +1,3 @@ -parent->types);exit;?> fibu_account_number?>" /> - + +
+
- +
- +
Standard: Tage
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ diff --git a/Layout/default/Address/Index.php b/Layout/default/Address/Index.php index 5fb7a9824..b5a06bb51 100644 --- a/Layout/default/Address/Index.php +++ b/Layout/default/Address/Index.php @@ -39,10 +39,11 @@
AR-Merge / Fibu Konten Import - " class="ml-2 btn btn-outline-primary" onclick="if(!confirm('Wirklich inkrementellen BMD-Export starten?')) return false;"> Inkrementellen BMD-Export starten + Inkrementellen BMD-Export starten Letzter Export: - "full"])?>" class="btn btn-outline-danger float-right" onclick="if(!confirm('Wirklich vollständigen BMD-Export starten?')) return false;"> Vollen BMD-Export starten + Vollen BMD-Export starten +
@@ -259,6 +260,30 @@ diff --git a/Layout/default/Address/View.php b/Layout/default/Address/View.php index f62321c14..9af125451 100644 --- a/Layout/default/Address/View.php +++ b/Layout/default/Address/View.php @@ -123,14 +123,23 @@ Ist primäres Verrechnungskonto fibu_primary_account) ? "" : ""?> - FIBU Verrechnungskonto + Verrechnungskonto fibu_account_number?> - FIBU Lieferanten Konto + Lieferantenkonto fibu_supplier_number?> - FIBU Lieferanten Zahlungsziel + Zahlungsziel Lieferant fibu_supplier_due?> + + Lieferant Skontotage + fibu_supplier_skonto?> + + Lieferant Skonto % + fibu_supplier_skonto_rate?> + + Lieferant Zahlsperre + fibu_supplier_paymentblock) ? " Automatische Zahlungen gesperrt" : "Nicht gesperrt"?>

Zusatzdaten

diff --git a/Layout/default/Address/bmd_export.csv.php b/Layout/default/Address/bmd_export.csv.php index 10b093993..49f51a8d6 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"])?>;;;;; +
+ +
+ + + + + +
+
+
diff --git a/Layout/default/AddressDB/Index.php b/Layout/default/AddressDB/Index.php index 04d6b936c..58c7f04a6 100644 --- a/Layout/default/AddressDB/Index.php +++ b/Layout/default/AddressDB/Index.php @@ -144,7 +144,7 @@
"> Neue Adresse anlegen - Bulk update +
diff --git a/Layout/default/AddressDB/View.php b/Layout/default/AddressDB/View.php index 3e147a561..7637bab06 100644 --- a/Layout/default/AddressDB/View.php +++ b/Layout/default/AddressDB/View.php @@ -31,7 +31,7 @@
-
+
@@ -47,6 +47,9 @@ Extref extref?> + + Rimo External ID + rimo_id?> Netzgebiet netzgebiet->name?> @@ -104,7 +107,7 @@
-
+
@@ -113,6 +116,7 @@ wohneinheiten) && count($address->wohneinheiten)): ?> + @@ -121,8 +125,17 @@ wohneinheiten as $unit): ?> + - + diff --git a/Layout/default/Dashboard/Dashboard.php b/Layout/default/Dashboard/Dashboard.php index b38155320..da882d900 100644 --- a/Layout/default/Dashboard/Dashboard.php +++ b/Layout/default/Dashboard/Dashboard.php @@ -66,28 +66,53 @@ $chartColors = [
-

Akquise Statistiken Momentan nur für Admins sichtbar

+

Akquise Statistiken

-
+
- - +
+
+ + is("Admin")): ?> +
Netzinhaber:
+ + + + + +
+
+
+
- +
Bestellungen

/

@@ -97,13 +122,28 @@ $chartColors = [
- + +
+
+
+
+
+ +
+
Aktive Anschlüsse
+

/

+
+ +
+
+
+
- +
Status BEP Installed (244, SD)

/

@@ -118,7 +158,7 @@ $chartColors = [
- +
Status OTO Installed (245, MD)

/

@@ -128,20 +168,7 @@ $chartColors = [
-
-
-
-
-
- -
-
Aktive Anschlüsse
-

/

-
- -
-
-
+
@@ -159,22 +186,76 @@ $chartColors = [
ID OAID Status
$unit->id])?>"> id?>oaid?> + oaid): ?> + $unit->oaid])): ?> + ["oaid" => $unit->oaid]])?>" class="text-pink" target="_blank">oaid?> + + oaid?> + + + status->code?> - status->name?> ".(string)$unit."" : ""?> extref) ? "[".$unit->extref."]" : ""?>
- $count): ?> + $count): ?> - +
## % ()strtrim($provider,22)?>strtrim($partner,22)?>
- Keine Aktiven Anschlüsse + Keine Bestellungen
+ +
+
+
+

Bestellstatus je Partner

+
+
+ + $status): ?> +
+
+
+ strtrim($partner, 200)?> +
+
+
+
+ +
+
+ + $count): ?> + + + + + + + +
##% () - "> + +
+
+
+ +
+
+
+ +
+
+ + + +
+ + + Keine Bestellungen + + +
+
+
+
@@ -301,6 +382,56 @@ $chartColors = [ + var status = []; + + status[id?>] = {"code": "code?>", "name": "name?>"}; + + + + + var productCharts = []; + + $status): ?> + productCharts[] = new Chart(document.getElementById('partner-status-').getContext('2d'), { + type: 'doughnut', + data: { + labels: [ + $count): ?> + + " - (%)", + + + ], + datasets: [{ + data: [ + $count): ?> + + , + + ], + backgroundColor: [ + "" + ], + /*borderColor: [ + "#d54369", + "#4592e0" + ],*/ + borderWidth: 1 + + }] + }, + options: { + scales: { + y: { + beginAtZero: true + } + }, + legend: false + + } + }); + + }); diff --git a/Layout/default/OpenAccessId/ChangeUnit.php b/Layout/default/OpenAccessId/ChangeUnit.php new file mode 100644 index 000000000..e5ff8b8f5 --- /dev/null +++ b/Layout/default/OpenAccessId/ChangeUnit.php @@ -0,0 +1,101 @@ + + + +
+
+
+
+ +
+

Wohneinheit

+
+
+
+ + +
+
+ +
+
+

id) ? "Wohneinheit bearbeiten" : "Neue Adresse"?>

+ +
"> + +
+
+ +
+ +
+ +
+
+ +
+ +
+ adb_wohneinheit_id && is_object($oaid->adb_wohneinheit)): ?> + adb_wohneinheit : ""?>" + /> + +
+
+ +
+ +
+ + Wohneinheit ID +

+
+
+ + +
+
+ + +
+ +
+ +
+
+
+ +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/Layout/default/OpenAccessId/Index.php b/Layout/default/OpenAccessId/Index.php index 2e157176f..fd367b772 100644 --- a/Layout/default/OpenAccessId/Index.php +++ b/Layout/default/OpenAccessId/Index.php @@ -35,8 +35,8 @@ @@ -84,7 +84,7 @@
- ">Filter zurücksetzen + 1])?>">Filter zurücksetzen
[adb_wohneinheit->hausnummer->strasse->gemeinde->name?>] adb_wohneinheit->hausnummer->plz->plz?> adb_wohneinheit->hausnummer->ortschaft->name?>, diff --git a/Layout/default/Preorder/include/preorder-detail.php b/Layout/default/Preorder/include/preorder-detail.php index f0254f5a7..dfb5b3a66 100644 --- a/Layout/default/Preorder/include/preorder-detail.php +++ b/Layout/default/Preorder/include/preorder-detail.php @@ -312,6 +312,9 @@ Building Name: adb_hausnummer->extref?> + + Building External ID: + adb_hausnummer->rimo_id?> Home External ID: adb_wohneinheit->extref?> diff --git a/Layout/default/Productgroup/Form.php b/Layout/default/Productgroup/Form.php index c5b55d0d3..ad3830a8f 100644 --- a/Layout/default/Productgroup/Form.php +++ b/Layout/default/Productgroup/Form.php @@ -7,7 +7,7 @@
@@ -48,6 +48,20 @@
+
+ +
+ +
+
+ diff --git a/Layout/default/User/Form.php b/Layout/default/User/Form.php index 291b3e205..05877814e 100644 --- a/Layout/default/User/Form.php +++ b/Layout/default/User/Form.php @@ -50,7 +50,7 @@ @@ -219,6 +219,13 @@ + +
+
+ can("Statistics")) ? "checked='checked'" : ""?> /> + +
+

@@ -248,9 +255,9 @@
"> apikey): ?> - + - +
diff --git a/Layout/default/header.php b/Layout/default/header.php index 8c5371192..69f06c620 100644 --- a/Layout/default/header.php +++ b/Layout/default/header.php @@ -9,17 +9,17 @@ - - + + - + - + - + @@ -38,7 +38,7 @@ - + diff --git a/application/ADBWohneinheit/ADBWohneinheitController.php b/application/ADBWohneinheit/ADBWohneinheitController.php index 6836891c8..7906de192 100644 --- a/application/ADBWohneinheit/ADBWohneinheitController.php +++ b/application/ADBWohneinheit/ADBWohneinheitController.php @@ -2,4 +2,104 @@ class ADBWohneinheitController extends mfBaseController { + protected function init() { + $this->needlogin=true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me",$me); + + if(!$me->is(["Admin", "netowner"]) && !$me->can("Preorder")) { + $this->redirect("Dashboard"); + } + } + + protected function addAction() { + $this->layout()->setTemplate("ADBWohneinheit/Form"); + + if($this->me->is("Admin")) { + $my_networks = NetworkModel::getAll(); + } else { + $my_networks = $this->me->myNetworks(["netowner", "salespartner"]); + } + + $netzgebiet_ids = []; + $my_adb_networks = []; + foreach($my_networks as $network) { + if($network->adb_netzgebiet_id && !in_array($network->adb_netzgebiet_id, $netzgebiet_ids)) { + $netzgebiet_ids[] = $network->adb_netzgebiet_id; + $my_adb_networks[$network->adb_netzgebiet_id] = new ADBNetzgebiet($network->adb_netzgebiet_id); + } + } + $this->layout()->set("my_adb_networks", $my_adb_networks); + + } + + protected function editAction() { + $id = $this->request->id; + if(!is_numeric($id) || $id < 1) { + $this->layout()->setFlash("Adresse nicht gefunden", "error"); + $this->redirect("AddressDB"); + } + + $unit = new ADBWohneinheit($id); + if(!$unit->id) { + $this->layout()->setFlash("Wohneinheit nicht gefunden", "error"); + $this->redirect("AddressDB"); + } + + /*if(!in_array($hausnummer->netzgebiet_id, $my_adb_networks)) { + $this->layout()->setFlash("Adresse nicht gefunden", "error"); + $this->redirect("AddressDB"); + }*/ + + $this->layout()->set("unit", $unit); + + return $this->addAction(); + } + + protected function saveAction() { + $r = $this->request; + $id = $r->id; + //var_dump($r->get());exit; + + $unit_data = []; + + if(is_numeric($id) && $id > 0) { + $mode = "edit"; + $unit = new ADBWohneinheit($id); + if(!$unit->id) { + $this->layout()->setFlash("Wohneinheit nicht gefunden", "error"); + $this->redirect("AddressDB"); + } + } else { + $mode = "add"; + } + + + //$unit_data["oaid"] = ($r->oaid) ? trim($r->oaid) : null; + $unit_data["extref"] = ($r->extref) ? trim($r->extref) : null; + $unit_data["block"] = ($r->block) ? trim($r->block) : null; + $unit_data["stiege"] = ($r->stiege) ? trim($r->stiege) : null; + $unit_data["stock"] = ($r->stock) ? trim($r->stock) : null; + $unit_data["tuer"] = ($r->tuer) ? trim($r->tuer) : null; + $unit_data["zusatz"] = ($r->zusatz) ? trim($r->zusatz) : null; + $unit_data["bezeichner"] = ($r->bezeichner) ? trim($r->bezeichner) : null; + + if($mode == "add") { + $unit = ADBWohneinheitModel::create($unit_data); + } else { + $unit->update($unit_data); + } + + if(!$unit->save()) { + $this->layout()->setFlash("Beim Speichern der Wohneinheit ist ein Fehler aufgetreten.", "error"); + $this->layout()->set("unit", $unit); + return $this->addAction(); + } + + $this->layout()->setFlash("Wohneinheit erfolgreich gespeichert.", "success"); + $this->redirect("AddressDB", "view", ["id" => $unit->hausnummer_id]); + } + } \ No newline at end of file diff --git a/application/ADBWohneinheit/ADBWohneinheitModel.php b/application/ADBWohneinheit/ADBWohneinheitModel.php index 17243b32c..aa3f0dfe0 100644 --- a/application/ADBWohneinheit/ADBWohneinheitModel.php +++ b/application/ADBWohneinheit/ADBWohneinheitModel.php @@ -1,6 +1,8 @@ loadMe(); if($this->fibu_account_number) { - $fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $this->customer_number]); + $old_custnum = $this->customer_number; + if($old_custnum > 900000) { + $old_custnum -= 900000; + } + + $name_search = []; + if($this->company) $name_search[] = $this->company; + if($this->lastname) $name_search[] = $this->lastname; + + $fibumerge = XinonFibuMergeModel::getFirst(["old_custnum" => $old_custnum, "name" => $name_search]); if(!$fibumerge) { // create fibu merge $fibumerge = XinonFibuMergeModel::create([ - "old_custnum" => $this->customer_number, + "source" => "t", + "old_custnum" => $old_custnum, "new_custnum" => $this->fibu_account_number, "name" => ($this->company) ? $this->company : $this->lastname, "vorname" => ($this->company) ? "" : $this->firstname, @@ -86,7 +96,7 @@ class Address extends mfBaseModel { $fibumerge->save(); return true; } - + if($fibumerge->new_custnum != $this->fibu_account_number) { $fibumerge->new_custnum = $this->fibu_account_number; $fibumerge->save(); diff --git a/application/Address/AddressController.php b/application/Address/AddressController.php index 0be42eee9..d8d1e9c7a 100644 --- a/application/Address/AddressController.php +++ b/application/Address/AddressController.php @@ -192,17 +192,22 @@ class AddressController extends mfBaseController { $last_export = $export_ts->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,116 @@ 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["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["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; + if($fibu_num >= 300000 && $fibu_num < 400000) { + $a["fibu_supplier_due"] = (is_numeric($address->fibu_supplier_due)) ? $address->fibu_supplier_due : TT_ADDRESS_DEFAULT_SUPPLIER_DUE; + $a["fibu_supplier_skonto"] = $address->fibu_supplier_skonto; + $a["fibu_supplier_skonto_rate"] = $address->fibu_supplier_skonto_rate; + $a["fibu_supplier_paymentblock"] = $address->fibu_supplier_paymentblock; + } else { + $a["fibu_supplier_due"] = ""; + $a["fibu_supplier_skonto"] = ""; + $a["fibu_supplier_skonto_rate"] = ""; + $a["fibu_supplier_paymentblock"] = ""; + } $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 +397,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(); @@ -362,29 +441,38 @@ class AddressController extends mfBaseController { $data = []; $data['parent_id'] = (!$r->parent_id) ? null : $r->parent_id; - $data['company'] = $r->company; - $data['firstname'] = $r->firstname; - $data['lastname'] = $r->lastname; - $data['street'] = $r->street; - $data['zip'] = $r->zip; - $data['city'] = $r->city; - $data['country'] = $r->country; - $data['phone'] = $r->phone; - $data['fax'] = $r->fax; - $data['mobile'] = $r->mobile; - $data['email'] = $r->email; - $data['note'] = $r->note; - $data['uid'] = $r->uid; + $data['company'] = trim($r->company); + $data['firstname'] = trim($r->firstname); + $data['lastname'] = trim($r->lastname); + $data['street'] = trim($r->street); + $data['zip'] = trim($r->zip); + $data['city'] = trim($r->city); + $data['country'] = trim($r->country); + $data['phone'] = trim($r->phone); + $data['fax'] = trim($r->fax); + $data['mobile'] = trim($r->mobile); + $data['email'] = trim($r->email); + $data['note'] = trim($r->note); + $data['uid'] = trim($r->uid); if($this->me->can("Fibu")) { - $data['fibu_account_number'] = ($r->fibu_account_number) ? $r->fibu_account_number : null; - $data['fibu_supplier_number'] = ($r->fibu_supplier_number) ? $r->fibu_supplier_number : null; + $data['fibu_account_number'] = ($r->fibu_account_number) ? trim($r->fibu_account_number) : null; + $data['fibu_supplier_number'] = ($r->fibu_supplier_number) ? trim($r->fibu_supplier_number) : null; if($r->fibu_primary_account) { $data['fibu_primary_account'] = 1; } else { $data['fibu_primary_account'] = 0; } - $data['fibu_supplier_due'] = ($r->fibu_supplier_due) ? $r->fibu_supplier_due : null; + + if($r->fibu_supplier_paymentblock) { + $data['fibu_supplier_paymentblock'] = 1; + } else { + $data['fibu_supplier_paymentblock'] = 0; + } + + $data['fibu_supplier_due'] = ($r->fibu_supplier_due) ? trim($r->fibu_supplier_due) : null; + $data['fibu_supplier_skonto'] = ($r->fibu_supplier_skonto) ? trim($r->fibu_supplier_skonto) : null; + $data['fibu_supplier_skonto_rate'] = ($r->fibu_supplier_skonto_rate) ? trim($r->fibu_supplier_skonto_rate) : null; } @@ -419,10 +507,10 @@ class AddressController extends mfBaseController { } - $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['bank_account_bank'] = trim($r->bank_account_bank); + $data['bank_account_owner'] = trim($r->bank_account_owner); + $data['bank_account_iban'] = trim($r->bank_account_iban); + $data['bank_account_bic'] = trim($r->bank_account_bic); $data['allow_contact'] = ($r->allow_contact) ? 1 : 0; $data['allow_spin'] = ($r->allow_spin) ? 1 : 0; 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/application/AddressDB/AddressDB.php b/application/AddressDB/AddressDB.php index 4b1985c4e..c955246e9 100644 --- a/application/AddressDB/AddressDB.php +++ b/application/AddressDB/AddressDB.php @@ -234,6 +234,7 @@ class AddressDB { //$hausnummer_data['oaid'] = (array_key_exists("oaid", $data) && $data['oaid']) ? $data['oaid'] : null; $hausnummer_data['adrcd'] = ($data['adrcd']) ? $data['adrcd'] : null; $hausnummer_data['extref'] = ($data['extref']) ? $data['extref'] : null; + $hausnummer_data['rimo_id'] = ($data['rimo_id']) ? $data['rimo_id'] : null; $hausnummer_data['netzgebiet_id'] = $netzgebiet_id; $hausnummer_data['ortschaft_id'] = $ortschaft->id; $hausnummer_data['plz_id'] = $plz->id; diff --git a/application/AddressDB/AddressDBController.php b/application/AddressDB/AddressDBController.php index 850728fff..3670858c0 100644 --- a/application/AddressDB/AddressDBController.php +++ b/application/AddressDB/AddressDBController.php @@ -270,7 +270,7 @@ class AddressDBController extends mfBaseController { if(!$this->me->is("Admin")) { $required[] = "netzgebiet_id"; } - foreach(['adrcd','extref','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count'] as $field) { + foreach(['adrcd','extref','rimo_id','netzgebiet_id','strasse','hausnummer','plz','ortschaft','gemeinde','grund_nr','gdaeigenschaft','meridian','rw','hw','gps_lat','gps_long','unit_count'] as $field) { if(in_array($field, $required)) { if(!trim($r->$field)) { $this->layout()->setFlash("'".ucfirst($field)."' darf nicht leer sein!", "error"); @@ -370,7 +370,9 @@ class AddressDBController extends mfBaseController { $this->layout()->setFlash("Fehler beim Erstellen einer Wohneinheit!", "warning"); return $this->addAction(); } - $wohneinheit->oaid = $wohneinheit->getNewOAID(); + if($hausnummer->netzgebiet->unit_create_oaid) { + $wohneinheit->oaid = $wohneinheit->getNewOAID(); + } $wohneinheit->save(); $w++; } @@ -472,6 +474,9 @@ class AddressDBController extends mfBaseController { case 'findBuildings': $return = $this->findBuildingsApi(); break; + case 'getUnit': + $return = $this->getUnitApi(); + break; case "findUnit": break; default: @@ -487,6 +492,18 @@ class AddressDBController extends mfBaseController { $this->returnJson($data); } + private function getUnitApi() { + $id = $this->request->id; + if(!$id) return false; + + $unit = new ADBWohneinheit($id); + if(!$unit->id) return false; + + $return = $unit->hausnummer->getAddress(); + if((string)$unit) $return .= " ".(string)$unit; + return["string" => $return]; + } + private function findAddressApi() { $addresses = []; $search = trim($this->request->q); diff --git a/application/Dashboard/DashboardController.php b/application/Dashboard/DashboardController.php index 5adff48a1..00e5dc4d8 100644 --- a/application/Dashboard/DashboardController.php +++ b/application/Dashboard/DashboardController.php @@ -23,8 +23,7 @@ class DashboardController extends mfBaseController { $newss = NewsModel::getAll(); $this->layout()->set("newss", $newss); - //if($this->me->is(["Admin", "netowner", "salespartner"]) || $this->me->can("Preorder")) { - if($this->me->is("Admin")) { + if($this->me->can("Statistics") && $this->me->is(["Admin", "netowner", "salespartner"])) { return $this->dashboardAction(); } @@ -40,52 +39,63 @@ class DashboardController extends mfBaseController { $campaign_ids = [$campaign_ids]; } - + $netowner_id = intval($r->netowner_id); + $this->layout()->set("netowner_id", $netowner_id); if($this->me->is("Admin")) { - $campaigns = PreordercampaignModel::getAll(); + if($netowner_id) { + $campaigns = PreordercampaignModel::search(["owner_id" => $netowner_id]); + } else { + $campaigns = PreordercampaignModel::getAll(); + } if(!$campaign_ids) { - foreach(PreordercampaignModel::getAll() as $campaign) { + $campaign_filter = []; + if($netowner_id) { + $campaign_filter['owner_id'] = $netowner_id; + } + foreach(PreordercampaignModel::search($campaign_filter) as $campaign) { $campaign_ids[] = $campaign->id; } } - - $max_connections = $this->getTotalHomes($campaign_ids); - $count_orders = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0]); - $weekly_orders = $this->getWeeklyOrders($campaign_ids); - - $status_connected_single = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 244]); - $status_connected_multi = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 245]); - - $status_connected = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 500]); - - $partner_orders = $this->getPartnerOrderCount($campaign_ids); } else { $campaigns = PreordercampaignModel::search(["owner_id" => $this->me->address_id]); - + $campaign_filter = ["preordercampaign_id" => $campaign_ids]; if(!$campaign_ids) { foreach(PreordercampaignModel::search(["owner_id" => $this->me->address_id]) as $campaign) { $campaign_ids[] = $campaign->id; } } - - $max_connections = $this->getTotalHomes($campaign_ids); - $count_orders = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0]); - $weekly_orders = $this->getWeeklyOrders($campaign_ids); - - $status_connected_single = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 244]); - $status_connected_multi = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 245]); - - $status_connected = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 500]); - $partner_orders = $this->getPartnerOrderCount($campaign_ids); } + if(!$campaign_ids) { + $campaign_ids = [0]; + } + + $max_connections = $this->getTotalHomes($campaign_ids); + $count_orders = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0]); + $weekly_orders = $this->getWeeklyOrders($campaign_ids); + + $status_connected_single = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 244]); + $status_connected_multi = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 245]); + + $status_connected = PreorderModel::count(["preordercampaign_id" => $campaign_ids, "deleted" => 0, "status_code" => 500]); + + $partner_orders = $this->getPartnerOrderCount($campaign_ids); + $partner_orders_by_status = $this->getPartnerOrdersByStatus($campaign_ids); + $total_orders = $partner_orders["total"]; unset($partner_orders["total"]); //var_dump($partner_orders);exit; + $stati = []; + foreach(PreorderstatusModel::getAll() as $status) { + $stati[$status->id] = ["code" => $status->code, "name" => $status->name]; + } + + $this->layout()->set("stati", $stati); + $this->layout()->set("max_connections", $max_connections); $this->layout()->set("count_orders", $count_orders); $this->layout()->set("weekly_orders", $weekly_orders); @@ -95,6 +105,7 @@ class DashboardController extends mfBaseController { $this->layout()->set("status_connected", $status_connected); $this->layout()->set("partner_orders", $partner_orders); $this->layout()->set("total_orders", $total_orders); + $this->layout()->set("partner_orders_by_status", $partner_orders_by_status); $this->layout()->set("campaigns", $campaigns); $this->layout()->set("campaign_id", $r->campaign_id); @@ -107,7 +118,7 @@ class DashboardController extends mfBaseController { foreach($preordercampaign_id as $campaign_id) { $campaign = new Preordercampaign($campaign_id); if($campaign->id) { - $total_homes += $campaign->total_homes; + $total_homes += ($campaign->homes_total) ? $campaign->homes_total : $campaign->total_homes; } } @@ -118,19 +129,24 @@ class DashboardController extends mfBaseController { $orders = []; $totals = 0; - - foreach(AddressModel::search(["addresstype" => ["salespartner"]]) as $partner) { - $count = PreorderModel::count(["partner_id" => $partner->id, "preordercampaign_id" => $preordercampaign_id, "deleted" => 0]); - if($count) { - if(!array_key_exists($partner->getCompanyOrName(), $orders)) { - $orders[$partner->getCompanyOrName()] = $count; + $sql = "SELECT COUNT(Preorder.id) as cnt, IF(Address.company IS NOT NULL AND Address.company <> '', Address.company, CONCAT(Address.firstname, ' ', Address.lastname)) as partner FROM Preorder + LEFT JOIN Address ON (Preorder.partner_id = Address.id) + LEFT JOIN Addresstype ON (Addresstype.address_id = Address.id AND Addresstype.type='salespartner') + WHERE Preorder.deleted = 0 AND Preorder.preordercampaign_id IN (".implode(",", $preordercampaign_id).") + GROUP BY Address.id + "; + $this->log->debug($sql); + $res = $this->db()->query($sql); + if($this->db()->num_rows($res)) { + while($data = $this->db()->fetch_object($res)) { + if($data->partner) { + $orders[$data->partner] = $data->cnt; } else { - $orders[$partner->getCompanyOrName()] += $count; + $orders["Kein Partner"] = $data->cnt; } - $totals += $count; + $totals += $data->cnt; } } - arsort($orders); $orders["total"] = $totals; return $orders; @@ -161,6 +177,26 @@ class DashboardController extends mfBaseController { //var_dump($orders);exit; } + private function getPartnerOrdersByStatus($preordercampaign_id = []) { + $orders = []; + + foreach(PreorderModel::search(["preordercampaign_id" => $preordercampaign_id, "deleted" => 0]) as $preorder) { + $name = $preorder->partner->getCompanyOrName(); + if(!$name) $name = "Kein Partner"; + if(!array_key_exists($name, $orders)) { + $orders[$name] = []; + $orders[$name]["total"] = 0; + } + if(!array_key_exists($preorder->status->id, $orders[$name])) { + $orders[$name][$preorder->status->id] = 0; + } + $orders[$name][$preorder->status->id]++; + $orders[$name]["total"]++; + } + //var_dump($orders);exit; + return $orders; + } + protected function pdfAction() { $order = new Order(7); $owner = new Address(1); diff --git a/application/Init/Init.php b/application/Init/Init.php index a4abe2daf..fe782d108 100644 --- a/application/Init/Init.php +++ b/application/Init/Init.php @@ -1,2 +1,10 @@ layout()->set("git_merge_ts", $last_merge_ts->value()); diff --git a/application/OpenAccessId/OpenAccessId.php b/application/OpenAccessId/OpenAccessId.php index 6f9b6dc80..17e191361 100644 --- a/application/OpenAccessId/OpenAccessId.php +++ b/application/OpenAccessId/OpenAccessId.php @@ -3,6 +3,7 @@ class OpenAccessId extends mfBaseModel { private $owner; private $adb_wohneinheit; + private $adb_wohneinheit_count; private $termination; public function loadRandomUnassigned($attributes = []) { @@ -94,8 +95,8 @@ class OpenAccessId extends mfBaseModel { $qs = http_build_query($params); //echo $qs."\n"; - $createOrderEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_QUERY_HOME; - $get_url = $createOrderEp."?".$qs; + $queryHomeEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_QUERY_HOME; + $get_url = $queryHomeEp."?".$qs; $ctx = stream_context_create($ctx_opts); $this->log->debug(__METHOD__.": Getting Home to fetch FTU: $get_url"); //exit; @@ -189,8 +190,84 @@ class OpenAccessId extends mfBaseModel { $this->save(); } else { $this->log->debug(__METHOD__.": OAID ".$this->oaid.": Already created in RIMO"); + + /************************************************************************* + * get OAID from rimo and check if it's the same FTU as our Wohneinheit + */ + + $ftu_data = $wohneinheit->ftu_data; + if($ftu_data['id'] && $ftu_data['name']) { + + $params = []; + $params['apiKey'] = RIMO_API_JSON_APIKEY; + + $ctx_opts = [ + 'http' => [ + 'method' => 'GET', + 'header' => 'accept: application/json' + ] + ]; + + $qs = http_build_query($params); + //echo $qs."\n"; + + $getOaidEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_GET_OAID; + $getOaidEp .= "/".$this->oaid; + $get_url = $getOaidEp."?".$qs; + $ctx = stream_context_create($ctx_opts); + $this->log->debug(__METHOD__.": Getting OAID from Rimo: $get_url"); + $response = file_get_contents($get_url, false, $ctx); + //var_dump($response);exit; + if($response === false) { + $this->log->error("Fehler beim abfragen der OAID in RIMO ".$this->oaid."\n"); + return false; + } + + $resp_data = json_decode($response); + if($resp_data->terminiationUnit && $resp_data->terminiationUnit->id) { + if($ftu_data['id'] != $resp_data->terminiationUnit->id) { + $old_ftu_id = $resp_data->terminiationUnit->id; + + + // unassign oaid from FTU + $ctx_opts["http"]["method"] = "DELETE"; + $unassignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_UNASSIGN_OAID_TO_FTU; + $unassignEp = str_replace("{oaidName}", $this->oaid, $unassignEp); + $unassignEp = str_replace("{ftuExternalId}", $old_ftu_id, $unassignEp); + + $delete_url = $unassignEp."?".$qs; + $ctx = stream_context_create($ctx_opts); + $this->log->debug(__METHOD__.": Unassigning OAID from FTU $old_ftu_id: $delete_url"); + $response = file_get_contents($delete_url, false, $ctx); + + + // assign oaid to Wohneinheit FTU + $ctx_opts["http"]["method"] = "POST"; + $assignEp = RIMO_API_JSON_URL.RIMO_API_JSON_EP_ASSIGN_OAID_TO_FTU; + $assignEp = str_replace("{oaidName}", $this->oaid, $assignEp); + $assignEp = str_replace("{ftuExternalId}", $ftu_data['id'], $assignEp); + + $post_url = $assignEp."?".$qs; + $ctx = stream_context_create($ctx_opts); + $this->log->debug(__METHOD__.": Assigning OAID to current FTU ".$ftu_data['id'].": $post_url"); + $response = file_get_contents($post_url, false, $ctx); + + // update OAID export data + $exp_data_update = json_decode($this->export_data); + $exp_data_update->rimo->ftu_id = $ftu_data['id']; + $exp_data_update->rimo->ftu_name = $ftu_data['name']; + $exp_data_update->rimo->ftu_assigned_date = date("U"); + $this->export_data = json_encode($ext_data_update); + $this->save(); + } + } + } } + + + + /************************************************************************* * assign OAID to FTU - POST /v1/oaid-management/oaids/{oaidName}/ftu/{ftuExternalId} */ @@ -332,6 +409,11 @@ class OpenAccessId extends mfBaseModel { return $this->adb_wohneinheit; } + if($name == "adb_wohneinheit_count") { + $this->adb_wohneinheit_count = ADBWohneinheitModel::count(["oaid" => $this->oaid]); + return $this->adb_wohneinheit_count; + } + $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); diff --git a/application/OpenAccessId/OpenAccessIdController.php b/application/OpenAccessId/OpenAccessIdController.php index a0caab2d5..a5cf3e77c 100644 --- a/application/OpenAccessId/OpenAccessIdController.php +++ b/application/OpenAccessId/OpenAccessIdController.php @@ -17,11 +17,23 @@ class OpenAccessIdController extends mfBaseController { protected function indexAction() { $this->layout()->setTemplate("OpenAccessId/Index"); - $this->layout->set("filter", $this->request->filter); - if($this->request->filter) { - $filter = $this->getPreparedFilter($this->request->filter); + if($this->request->resetFilter) { + unset($_SESSION[MFAPPNAME.'-OpenAccessId-filter']); } + $filter = []; + if(is_array($this->request->filter)) { + $filter = $this->request->filter; + $_SESSION[MFAPPNAME.'-OpenAccessId-filter'] = $filter; + } else { + if(array_key_exists(MFAPPNAME.'-OpenAccessId-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-OpenAccessId-filter'])) { + $filter = $_SESSION[MFAPPNAME.'-OpenAccessId-filter']; + } + } + + $this->layout->set("filter", $filter); + $filter = $this->getPreparedFilter($filter); + // pagination defaults $pagination = []; $pagination['start'] = 0; @@ -73,6 +85,79 @@ class OpenAccessIdController extends mfBaseController { return $new_filter; } + protected function changeADBWohneinheitAction() { + $this->layout()->setTemplate("OpenAccessId/ChangeUnit"); + $id = $this->request->id; + if(!$id || $id <1) { + $this->layout()->setFlash("Ungültige OAID", "error"); + $this->redirect("OpenAccessId"); + } + + $oaid = new OpenAccessId($id); + if(!$oaid->id) { + $this->layout()->setFlash("Ungültige OAID", "error"); + $this->redirect("OpenAccessId"); + } + + $this->layout()->set("oaid", $oaid); + + if(!$this->request->new_unit_id) { + return true; + } + + // get old and new unit_id + $old_unit = ADBWohneinheitModel::getFirst(["oaid" => $oaid->oaid]); + $new_unit = new ADBWohneinheit($this->request->new_unit_id); + + + + + + + if($old_unit) { + $old_preorder = PreorderModel::getFirst(["adb_wohneinheit_id" => $old_unit->id]); + if($old_preorder) { + // remove oaid from preorder + $old_preorder->oaid = null; + $old_preorder->save(); + } + // unassign oaid from rimo ftu + // get oaid from rimo + // unassign ftu from aoid + // remove oaid from old unit + + // remove meta data from oaid + $oaid->assigned = 0; + $oaid->adb_wohneinheit_id = null; + $oaid->termination_id = null; + $oaid->exported = 0; + $oaid->exported_to = null; + $oaid->exported_data = null; + $oaid->address = null; + $oaid->unit_string = null; + $oaid->save(); + } + + if($new_unit) { + $new_preorder = PreorderModel::getFirst(["adb_wohneinheit_id" => $new_unit->id]); + // add oaid to new unit + // assign oaid to new ftu in rimo + if($new_preorder) { + // add oaid to preorder + $new_preorder->oaid = $oaid->oaid; + } + // save metadata to oaid + $oaid->assigned = date("U"); + $oaid->adb_wohneinheit_id = $new_unit->id; + $oaid->termination_id = null; + $oaid->exported = date("U"); + + } + + + + } + protected function importerAction() { $this->layout()->setTemplate("OpenAccessId/Importer"); diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 8b654ad38..86afc24b3 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -2,7 +2,7 @@ class Preorder extends mfBaseModel { protected $forcestr = ['street','company','zip','phone','email','note']; - private $in_after_save = false; + private $in_after_save = 0; private $status; private $campaign; @@ -38,7 +38,7 @@ class Preorder extends mfBaseModel { // prevent potential infinite loop if($this->in_after_save) return true; - $this->in_after_save = true; + $this->in_after_save++; // update preorder OAID if it's different from the unit OAID // but only if the unit OAID is of the same origin as the campaign $old_oaid = $this->oaid; @@ -52,6 +52,8 @@ class Preorder extends mfBaseModel { $this->cascadeStatus(); // Cascade status changes down all active preorders with the same hausnummer $this->cascadeStatusToPreorders(); + + $this->in_after_save--; } /* diff --git a/application/Productgroup/ProductgroupController.php b/application/Productgroup/ProductgroupController.php index 38a5cc812..c89e3dd18 100644 --- a/application/Productgroup/ProductgroupController.php +++ b/application/Productgroup/ProductgroupController.php @@ -87,6 +87,24 @@ class ProductgroupController extends mfBaseController { $group_data = []; $group_data['name'] = $name; + $group_data["matchcodeorigin"] = null; + + if($r->matchcodeorigin) { + switch($r->matchcodeorigin) { + case "address": + $group_data["matchcodeorigin"] = "address"; + break; + case "domain": + $group_data["matchcodeorigin"] = "domain"; + break; + case "terminationaddress": + $group_data["matchcodeorigin"] = "terminationaddress"; + break; + case "voicenumber": + $group_data["matchcodeorigin"] = "voicenumber"; + break; + } + } if($mode == "edit") { $group->update($group_data); diff --git a/application/Productgroup/ProductgroupModel.php b/application/Productgroup/ProductgroupModel.php index e418345d6..3bd4112e1 100644 --- a/application/Productgroup/ProductgroupModel.php +++ b/application/Productgroup/ProductgroupModel.php @@ -1,8 +1,9 @@ layout()->setTemplate('User/Form'); - $addresses = AddressModel::getAll(); + $roles = TT_NETWORK_ROLES_WITH_OWNER; + $roles[] = "systemowner"; + $addresses = AddressModel::search(["addresstype" => $roles]); $this->layout()->set("addresses", $addresses); if ($this->request->address_id) { @@ -225,6 +227,7 @@ class UserController extends mfBaseController $user->permissions->canPreorder = "false"; $user->permissions->canOrder = "false"; $user->permissions->canFibu = "false"; + $user->permissions->canStatistics = "false"; if($r->get("can") && is_array($r->can)) { foreach($r->can as $key => $can) { diff --git a/application/XinonFibuMerge/XinonFibuMergeModel.php b/application/XinonFibuMerge/XinonFibuMergeModel.php index 2e46a3983..6a3c66934 100644 --- a/application/XinonFibuMerge/XinonFibuMergeModel.php +++ b/application/XinonFibuMerge/XinonFibuMergeModel.php @@ -1,7 +1,7 @@ escape($filter['name']); + $where .= " AND XinonFibuMerge.name='$name'"; + } + } //var_dump($filter, $where);exit; return $where; diff --git a/bin/post_merge_hook.php b/bin/post_merge_hook.php new file mode 100755 index 000000000..9a214dceb --- /dev/null +++ b/bin/post_merge_hook.php @@ -0,0 +1,41 @@ +#!/usr/bin/php +id); +define("INTERNAL_USER_USERNAME", $me->username); + +$now = date("U"); + +// update last merge timestamp +$merge_ts = new mfConfig("git.merge.ts"); +$merge_ts->type("int"); +$merge_ts->value($now); +$merge_ts->save(); + + +// update git commit ref +$git_ref = new mfConfig("git.lastref"); + +$sc = new SystemController(); +$commitid = $sc->getLastCommit(); + +if($commitid) { + $git_ref->value($commitid); + $git_ref->save(); +} 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/db/migrations/20240118193741_productgroup_add_matchcodeorigin.php b/db/migrations/20240118193741_productgroup_add_matchcodeorigin.php new file mode 100644 index 000000000..df899e32e --- /dev/null +++ b/db/migrations/20240118193741_productgroup_add_matchcodeorigin.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $table = $this->table("Productgroup"); + $table->addColumn("matchcodeorigin", "string", ["null" => true, "default" => null, "limit" => 64, "after" => "name"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("Productgroup")->removeColumn("matchcodeorigin")->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/db/migrations/20240119124212_add_can_statistics_permission.php b/db/migrations/20240119124212_add_can_statistics_permission.php new file mode 100644 index 000000000..fe7593c84 --- /dev/null +++ b/db/migrations/20240119124212_add_can_statistics_permission.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $table = $this->table("WorkerPermission"); + $table->addColumn("canStatistics", "enum", ["values" => 'false,true', "default" => "false", "after" => "canOrder"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("WorkerPermission")->removeColumn("canStatistics")->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/db/migrations/20240122150833_netzgebiet_add_unit_create_oaid.php b/db/migrations/20240122150833_netzgebiet_add_unit_create_oaid.php new file mode 100644 index 000000000..7c322799b --- /dev/null +++ b/db/migrations/20240122150833_netzgebiet_add_unit_create_oaid.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + + } + + if($this->getEnvironment() == "addressdb") { + $table = $this->table("Netzgebiet"); + $table->addColumn("unit_create_oaid", "integer", ["null" => false, "default" => 0, "after" => "unit_count"]); + $table->update(); + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + + } + + if($this->getEnvironment() == "addressdb") { + $this->table("Netzgebiet")->removeColumn("unit_create_oaid")->save(); + } + } +} diff --git a/db/migrations/20240123132303_address_add_fibu_supplier_paymentblock.php b/db/migrations/20240123132303_address_add_fibu_supplier_paymentblock.php new file mode 100644 index 000000000..412b71a0b --- /dev/null +++ b/db/migrations/20240123132303_address_add_fibu_supplier_paymentblock.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $table = $this->table("Address"); + $table->addColumn("fibu_supplier_paymentblock", "integer", ["null" => false, "default" => 0, "limit" => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, "after" => "fibu_supplier_skonto_rate"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("Address")->removeColumn("fibu_supplier_paymentblock")->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/lang/de.php b/lang/de.php index 6e2612066..e734966c6 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,84 @@ $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.Ceska 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.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 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.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..f4564eb7f 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,14 @@ 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(["Ä","Ö","Ü","ß","ä","ö","ü","ß"], ["ae","oe","ue","ss","ae","oe","ue", "ss"], strtolower($_string)); if(!$lang) { //mfLoghandler::singleton()->debug("Loading language file for __() function"); @@ -294,6 +300,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 diff --git a/lib/mvcfronk/mfRequest/mfRequest.php b/lib/mvcfronk/mfRequest/mfRequest.php index faef3c2ae..1619b5283 100644 --- a/lib/mvcfronk/mfRequest/mfRequest.php +++ b/lib/mvcfronk/mfRequest/mfRequest.php @@ -2,6 +2,7 @@ class mfRequest { protected static $instance; + protected $original_request = []; protected $request = []; public function __construct(Array $request = []) { @@ -9,8 +10,19 @@ class mfRequest { $this->request = $request; } else { // get request from POST/GET - if(isset($_POST) && isset($_GET)) { - $this->request = array_merge($_GET, $_POST); + $_request = []; + if(isset($_GET)) { + $_request = array_merge($_request, $_GET); + } + if(isset($_POST)) { + $_request = array_merge($_request, $_POST); + } + if(!count($_request)) { + return true; + } + foreach($_request as $key => $name) { + $this->original_request[$key] = $name; + $this->request[$key] = trim($name); } } } @@ -41,6 +53,18 @@ class mfRequest { return $this->request; } + public function getUnmodified($name = null) { + if($name) { + if(array_key_exists($name, $this->original_request)) { + //var_dump($this->request);exit; + return $this->original_request[$name]; + } else { + return null; + } + } + return $this->request; + } + public function __get($name) { return $this->get($name); }