@@ -566,30 +577,32 @@
background: "bg-danger"
});
- function sendTestStatusEmail(status_code) {
- if(!status_code) return;
+
+ function sendTestStatusEmail(status_code) {
+ if(!status_code) return;
- var template_id = $("#mailtemplate-" + status_code).val();
- var email_to = $("#test-to-" + status_code).val();
+ var template_id = $("#mailtemplate-" + status_code).val();
+ var email_to = $("#test-to-" + status_code).val();
- $.post("=self::getUrl("Preordercampaign", "Api")?>",
- {
- do: "sendStatusEmail",
- campaign_id: =$campaign->id?>,
- template_id: template_id,
- to_email: email_to
- },
- (success) => {
- if(success.status == "OK") {
- window.notify("success", "Testmail wurde versendet");
- } else {
- window.notify("error", "Beim versenden ist ein Fehler aufgetragen.");
- }
+ $.post("=self::getUrl("Preordercampaign", "Api")?>",
+ {
+ do: "sendStatusEmail",
+ campaign_id: =$campaign->id?>,
+ template_id: template_id,
+ to_email: email_to
+ },
+ (success) => {
+ if(success.status == "OK") {
+ window.notify("success", "Testmail wurde versendet");
+ } else {
+ window.notify("error", "Beim versenden ist ein Fehler aufgetragen.");
+ }
- console.log(success);
- },
- "json"
- );
- }
+ console.log(success);
+ },
+ "json"
+ );
+ }
+
\ No newline at end of file
diff --git a/Layout/default/WarehouseOrder/PDF_FOOTER.html b/Layout/default/WarehouseOrder/PDF_FOOTER.html
new file mode 100644
index 000000000..0a984b7d6
--- /dev/null
+++ b/Layout/default/WarehouseOrder/PDF_FOOTER.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
diff --git a/Layout/default/WarehouseOrder/PDF_HEADER.html b/Layout/default/WarehouseOrder/PDF_HEADER.html
new file mode 100644
index 000000000..21802f9d5
--- /dev/null
+++ b/Layout/default/WarehouseOrder/PDF_HEADER.html
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
diff --git a/Layout/default/WarehouseOrder/PDF_MAIN.php b/Layout/default/WarehouseOrder/PDF_MAIN.php
new file mode 100644
index 000000000..144555322
--- /dev/null
+++ b/Layout/default/WarehouseOrder/PDF_MAIN.php
@@ -0,0 +1,133 @@
+setReturnValue(['filename' => $order["id"] . ".pdf"]);
+?>
+
+
+
+
+
+
+
XINON Lieferantenbestellung vom =date("d.m.Y", $order["create"])?>
+
+
+
+ | Position |
+ Artikel |
+ Art.-Nr. Lieferant |
+ Menge |
+ Einzelpreis |
+ Gesamtpreis |
+
+
+
+ ">
+ | = $i + 1 ?> |
+ =$p["articleName"]?> |
+ =$p["distributorArticleNumber"]?> |
+ =$p["amount"]?> |
+ =number_format($p["buyPrice"], 2, ",", ".")?> € |
+ =number_format($p["amount"] * $p["buyPrice"], 2, ",", ".")?> € |
+
+
+
+
+
+
+ | Summe |
+ =number_format($sum, 2, ",", ".")?> € |
+
+
+
+
+
+
+
Anmerkungen
+
+ =$order["note"]?>
+
+
+
+
\ No newline at end of file
diff --git a/Layout/default/menu.php b/Layout/default/menu.php
index 75cc6e347..0acf0392f 100644
--- a/Layout/default/menu.php
+++ b/Layout/default/menu.php
@@ -198,7 +198,7 @@
is(["Admin","salespartner"]) && $me->can("Order")): ?>
"> Bestellungen
- is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209])): ?>
+ is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908])): ?>
"> Zustimmungserklärungen
diff --git a/application/ADBWohneinheit/ADBWohneinheit.php b/application/ADBWohneinheit/ADBWohneinheit.php
index 363449209..552ef9c6b 100644
--- a/application/ADBWohneinheit/ADBWohneinheit.php
+++ b/application/ADBWohneinheit/ADBWohneinheit.php
@@ -8,6 +8,7 @@ class ADBWohneinheit extends mfBaseModel {
private $status;
private $statusflags; // TODO
private $preorders;
+ private $active_preorders;
protected function init() {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
@@ -65,6 +66,8 @@ class ADBWohneinheit extends mfBaseModel {
$gda_egenschaft = strtolower($hausnummer->rimo_type);
}
+ if(strtolower($gda_egenschaft) == "greenfield") continue;
+
if(!$gda_egenschaft) {
$unit_count_gda["sd"] += $hausnummer->unit_count;
continue;
@@ -107,11 +110,13 @@ class ADBWohneinheit extends mfBaseModel {
$old_status = new ADBStatus($this->_old_data->status_id);
$new_status = new ADBStatus($this->data->status_id);
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."' [".$old_status->code." => ".$new_status->code."]";
- } elseif($key = "external_data" && $this->_old_data->external_data && $this->external_data) {
+ } elseif($key == "external_data" && $this->_old_data->external_data && $this->external_data) {
$old_data = json_decode($this->_old_data->external_data);
$new_data = json_decode($this->external_data);
if(json_encode($old_data) !== json_encode($new_data)) {
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."'";
+ } else {
+ continue;
}
} else {
$logstr .= "| '$key' => FROM '".$this->_old_data->$key."' TO '".$this->data->$key."'";
@@ -312,6 +317,15 @@ class ADBWohneinheit extends mfBaseModel {
return $this->preorders;
}
+ if($name == "active_preorders") {
+ $preorders = PreorderModel::searchActive(["adb_wohneinheit_id" => $this->id]);
+ if(!count($preorders)) {
+ return [];
+ }
+ $this->preorders = $preorders;
+ return $this->preorders;
+ }
+
if($name == "ftu_data") {
$rimo_data = $this->getExternalRimoData();
diff --git a/application/Address/AddressController.php b/application/Address/AddressController.php
index 26c0fed77..cdb9f1543 100644
--- a/application/Address/AddressController.php
+++ b/application/Address/AddressController.php
@@ -1,659 +1,678 @@
needlogin=true;
- $me = new User();
- $me->loadMe();
- $this->me = $me;
- $this->layout()->set("me",$me);
-
- if(!$me->is(["Admin", "salespartner"])) {
- $this->redirect("Dashboard");
- }
- }
-
- protected function indexAction() {
- $rfilter = $this->request->filter;
- iF(!is_array($rfilter)) {
- $rfilter = [];
- }
- if(!array_key_exists("addresstype", $rfilter)) {
- $rfilter["addresstype"] = [];
- }
-
- if($this->request->resetFilter) {
- unset($_SESSION[MFAPPNAME.'-Address-filter']);
- }
-
- $filter = [];
- if(is_array($this->request->filter)) {
- $filter = $this->request->filter;
- $_SESSION[MFAPPNAME.'-Address-filter'] = $filter;
- } else {
- if(array_key_exists(MFAPPNAME.'-Address-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-Address-filter'])) {
- $filter = $_SESSION[MFAPPNAME.'-Address-filter'];
- }
- }
-
- $this->layout->set("filter", $filter);
- $filter = $this->getPreparedFilter($filter);
-
- // pagination defaults
- $pagination = [];
- $pagination['start'] = 0;
- $pagination['count'] = 25;
- $pagination['maxItems'] = 0;
-
- if(is_numeric($this->request->s)) {
- $pagination['start'] = intval($this->request->s);
- }
- //var_dump($filter);exit;
- $pagination['maxItems'] = AddressModel::count($filter);
- $addresses = AddressModel::search($filter, $pagination);
-
- $this->layout()->set("addresses", $addresses);
- $this->layout()->set("request", $this->request);
- $this->layout()->set("pagination", $pagination);
-
-
- $last_export = false;
- $bmd_export_ts = new mfConfig("bmd.export.ts");
- if($bmd_export_ts->value()) {
- $last_export = $bmd_export_ts->value();
- }
- $this->layout()->set("last_bmd_export", $last_export);
-
- return true;
- }
-
-
- private function getPreparedFilter($filter) {
- $new_filter = [];
-
- if(is_array($filter) && count($filter)) {
-
- $new_filter['add-where'] = "";
-
- if(array_key_exists("kunde", $filter) && $filter["kunde"]) {
- $kunde = $this->db()->escape($filter['kunde']);
- // if kunde contains ß or ss we want to search both cases but not with % because it can lead to wrong results
- if (strpos($kunde, "ß") !== false || strpos($kunde, "ss") !== false) {
- $kundeWithSS = str_replace("ß", "ss", $kunde);
- $kundeWithoutSS = str_replace("ss", "ß", $kunde);
- $new_filter['add-where'] .= " AND (company like '%$kundeWithoutSS%' OR firstname like '%$kundeWithoutSS%' OR lastname like '%$kundeWithoutSS%' OR concat(firstname, ' ', lastname) like '%$kundeWithoutSS%' OR concat(lastname, ' ', firstname) like '%$kundeWithoutSS%')";
- $new_filter['add-where'] .= " OR (company like '%$kundeWithSS%' OR firstname like '%$kundeWithSS%' OR lastname like '%$kundeWithSS%' OR concat(firstname, ' ', lastname) like '%$kundeWithSS%' OR concat(lastname, ' ', firstname) like '%$kundeWithSS%')";
- } else {
- $new_filter['add-where'] .= " AND (company like '%$kunde%' OR firstname like '%$kunde%' OR lastname like '%$kunde%' OR concat(firstname, ' ', lastname) like '%$kunde%' OR concat(lastname, ' ', firstname) like '%$kunde%')";
+ private $filter;
+
+ protected function init() {
+ $this->needlogin = true;
+ $me = new User();
+ $me->loadMe();
+ $this->me = $me;
+ $this->layout()->set("me", $me);
+
+ if (!$me->is(["Admin", "salespartner"])) {
+ $this->redirect("Dashboard");
}
- }
-
- if(!array_key_exists("parents_only", $filter)) {
- $new_filter["parents_only"] = 1;
- }
-
- if(array_key_exists("fibu_account_number", $filter) && $filter['fibu_account_number']) {
- $new_filter['fibu_or_supplier_account_number'] = $filter['fibu_account_number']."%";
- unset($filter['fibu_account_number']);
- }
-
-
- if(!array_key_exists("customer_number", $filter) || !$filter["customer_number"]) {
- if(array_key_exists("type", $filter)) {
- if($filter["type"] == "systemowner") {
- $new_filter["customer_or_fibu_numbers"] = true;
- } elseif($filter["type"] == "others") {
- $new_filter["customer_or_fibu_numbers"] = false;
- }
+ }
+
+ protected function indexAction() {
+ $rfilter = $this->request->filter;
+ iF(!is_array($rfilter)) {
+ $rfilter = [];
+ }
+ if (!array_key_exists("addresstype", $rfilter)) {
+ $rfilter["addresstype"] = [];
+ }
+
+ if ($this->request->resetFilter) {
+ unset($_SESSION[MFAPPNAME . '-Address-filter']);
+ }
+
+ $filter = [];
+ if (is_array($this->request->filter)) {
+ $filter = $this->request->filter;
+ $_SESSION[MFAPPNAME . '-Address-filter'] = $filter;
} else {
- if(defined("TT_ADDRESS_FILTER_DEFAULT_SYSOWNER") && TT_ADDRESS_FILTER_DEFAULT_SYSOWNER) {
- $new_filter["customer_or_fibu_numbers"] = true; // default
+ if (array_key_exists(MFAPPNAME . '-Address-filter', $_SESSION) && count($_SESSION[MFAPPNAME . '-Address-filter'])) {
+ $filter = $_SESSION[MFAPPNAME . '-Address-filter'];
}
}
- unset($filter["type"]);
- unset($filter["customer_number"]);
- }
-
- foreach($filter as $name => $value) {
- $new_filter[$name] = $value;
- }
- }
- return $new_filter;
- }
-
- protected function addAction() {
- $this->layout()->setTemplate("Address/Form");
+ $this->layout->set("filter", $filter);
+ $filter = $this->getPreparedFilter($filter);
- $this->layout->set("filter", $this->request->filter);
-
- //$parents = AddressModel::search(['parent_id' => null]);
- //$this->layout()->set("parents", $parents);
- }
-
- protected function viewAction() {
- $this->layout()->setTemplate("Address/View");
-
- $this->layout->set("filter", $this->request->filter);
- $this->layout->set("f", $this->request->f);
- $this->layout->set("s", $this->request->s);
-
- $address = new Address($this->request->id);
- $this->layout()->set("address", $address);
+ // pagination defaults
+ $pagination = [];
+ $pagination['start'] = 0;
+ $pagination['count'] = 25;
+ $pagination['maxItems'] = 0;
- //var_dump($address->links_to);exit;
-
- if(!$address->id) {
- $this->layout()->setFlash("Addresse nicht gefunden", "error");
- $this->redirect("Address");
- }
-
- }
+ if (is_numeric($this->request->s)) {
+ $pagination['start'] = intval($this->request->s);
+ }
+ //var_dump($filter);exit;
+ $pagination['maxItems'] = AddressModel::count($filter);
+ $addresses = AddressModel::search($filter, $pagination);
- protected function invoiceAction() {
- $this->layout()->setTemplate("Address/invoice");
-
- $address_id = $this->request->address_id;
- if(!is_numeric($address_id) || $address_id < 1) {
- $this->layout()->setFlash("Addresse nicht gefunden", "error");
- $this->redirect("Address");
- }
-
- $address = new Address($address_id);
- if(!$address->id) {
- $this->layout()->setFlash("Addresse nicht gefunden", "error");
- $this->redirect("Address");
- }
-
- $invoices = InvoiceModel::search(["owner_or_billingaddress_id" => $address->id], false, "invoice_date DESC");
- $this->layout()->set("invoices", $invoices);
- $this->layout()->set("address", $address);
+ $this->layout()->set("addresses", $addresses);
+ $this->layout()->set("request", $this->request);
+ $this->layout()->set("pagination", $pagination);
+ $last_export = false;
+ $bmd_export_ts = new mfConfig("bmd.export.ts");
+ if ($bmd_export_ts->value()) {
+ $last_export = $bmd_export_ts->value();
+ }
+ $this->layout()->set("last_bmd_export", $last_export);
- }
-
- protected function editAction() {
- $address = new Address($this->request->id);
-
- $this->layout->set("filter", $this->request->filter);
- $this->layout->set("f", $this->request->f);
- $this->layout->set("s", $this->request->s);
-
- $this->layout()->set("address", $address);
-
- if(!$address->id) {
- $this->layout()->setFlash("Addresse nicht gefunden", "error");
- return $this->addAction();
+ return true;
}
-
- return $this->addAction();
- }
-
- protected function deleteLink() {
- $id = $this->request->id;
-
- if(!is_numeric($id) || !$id) {
- $this->layout()->setFlash("Addresse nicht gefunden", "error");
- $this->redirect("Address");
- }
-
- $link = new AddressLink($id);
- if(!$link->id) {
- $this->layout()->setFlash("Addresse nicht gefunden", "error");
- $this->redirect("Address");
- }
-
- $address_id = $link->origin_address_id;
- $link->delete();
- $this->layout()->setFlash("Verknüpfung erfolgreich entfernt", "success");
- $this->redirect("Address", "edit", ['id' => $address_id]);
-
- }
-
- protected function exportBmdAction() {
- if(!$this->me->can("Fibu")) {
- $this->layout()->setFlash("Sicha ned!", "error");
- $this->redirect("Address");
- }
-
- $return = Address::runBmdExport($this->request->type);
-
- if($return === 10) {
- $this->layout()->setFlash("Export Pfad (".TT_ADDRESS_BMD_EXPORT_PATH.") nicht gefunden!", "error");
- $this->redirect("Address");
- }
-
- if($return === 11) {
- $this->layout()->setFlash("Keine geänderten Adressdatensätze gefunden. Export abgebrochen.", "warn");
- $this->redirect("Address");
- }
-
- if($return === 19) {
- $this->layout()->setFlash("Datei ".TT_ADDRESS_BMD_EXPORT_PATH."/".TT_ADDRESS_BMD_EXPORT_FILENAME." konnte nicht gespeichert werden!", "error");
- $this->redirect("Address");
- }
-
- if($return === true) {
- $this->layout()->setFlash("Adressen erfolgreich exportiert", "success");
- $this->redirect("Address");
- }
-
-
- }
-
- protected function saveAction() {
- $r = $this->request;
- $id = $r->id;
- //var_dump($r->get());exit;
- if(is_numeric($id) && $id > 0) {
- $mode = "edit";
- $address = new Address($id);
- if(!$address->id) {
- $this->layout()->setFlash("Addresse nicht gefunden", "error");
- $this->redirect("Address");
- }
- } else {
- $mode = "add";
- }
-
- //var_dump($r->addresstypes);exit;
-
- $data = [];
- $data['parent_id'] = (!$r->parent_id) ? null : $r->parent_id;
- $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_id'] = $r->country_id;
- $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(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");
+
+ private function getPreparedFilter($filter) {
+ $new_filter = [];
+
+ if (is_array($filter) && count($filter)) {
+
+ $new_filter['add-where'] = "";
+
+ if (array_key_exists("kunde", $filter) && $filter["kunde"]) {
+ $kunde = $this->db()->escape($filter['kunde']);
+ // if kunde contains ß or ss we want to search both cases but not with % because it can lead to wrong results
+ if (strpos($kunde, "ß") !== false || strpos($kunde, "ss") !== false) {
+ $kundeWithSS = str_replace("ß", "ss", $kunde);
+ $kundeWithoutSS = str_replace("ss", "ß", $kunde);
+ $new_filter['add-where'] .= " AND (company like '%$kundeWithoutSS%' OR firstname like '%$kundeWithoutSS%' OR lastname like '%$kundeWithoutSS%' OR concat(firstname, ' ', lastname) like '%$kundeWithoutSS%' OR concat(lastname, ' ', firstname) like '%$kundeWithoutSS%')";
+ $new_filter['add-where'] .= " OR (company like '%$kundeWithSS%' OR firstname like '%$kundeWithSS%' OR lastname like '%$kundeWithSS%' OR concat(firstname, ' ', lastname) like '%$kundeWithSS%' OR concat(lastname, ' ', firstname) like '%$kundeWithSS%')";
+ } else {
+ $new_filter['add-where'] .= " AND (company like '%$kunde%' OR firstname like '%$kunde%' OR lastname like '%$kunde%' OR concat(firstname, ' ', lastname) like '%$kunde%' OR concat(lastname, ' ', firstname) like '%$kunde%')";
+ }
+ }
+
+ if (!array_key_exists("parents_only", $filter)) {
+ $new_filter["parents_only"] = 1;
+ }
+
+ if (array_key_exists("fibu_account_number", $filter) && $filter['fibu_account_number']) {
+ $new_filter['fibu_or_supplier_account_number'] = $filter['fibu_account_number'] . "%";
+ unset($filter['fibu_account_number']);
+ }
+
+
+ if (!array_key_exists("customer_number", $filter) || !$filter["customer_number"]) {
+ if (array_key_exists("type", $filter)) {
+ if ($filter["type"] == "systemowner") {
+ $new_filter["customer_or_fibu_numbers"] = true;
+ } elseif ($filter["type"] == "others") {
+ $new_filter["customer_or_fibu_numbers"] = false;
+ }
+ } else {
+ if (defined("TT_ADDRESS_FILTER_DEFAULT_SYSOWNER") && TT_ADDRESS_FILTER_DEFAULT_SYSOWNER) {
+ $new_filter["customer_or_fibu_numbers"] = true; // default
+ }
+ }
+ unset($filter["type"]);
+ unset($filter["customer_number"]);
+ }
+
+ foreach ($filter as $name => $value) {
+ $new_filter[$name] = $value;
+ }
+ }
+
+ return $new_filter;
+ }
+
+ protected function addAction() {
+ $this->layout()->setTemplate("Address/Form");
+
+ $this->layout->set("filter", $this->request->filter);
+
+ //$parents = AddressModel::search(['parent_id' => null]);
+ //$this->layout()->set("parents", $parents);
+ }
+
+ protected function viewAction() {
+ $this->layout()->setTemplate("Address/View");
+
+ $this->layout->set("filter", $this->request->filter);
+ $this->layout->set("f", $this->request->f);
+ $this->layout->set("s", $this->request->s);
+
+ $address = new Address($this->request->id);
+ $this->layout()->set("address", $address);
+
+ //var_dump($address->links_to);exit;
+
+ if (!$address->id) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ $this->redirect("Address");
}
}
+ protected function invoiceAction() {
+ $this->layout()->setTemplate("Address/invoice");
- if($this->me->can("Fibu")) {
- $data["sepa_date"] = ($r->sepa_date) ? Layout::dateToInt($r->sepa_date) : 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;
- }
-
- 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;
- }
-
-
- // 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(['owner', 'iban', 'bic'] as $required) {
- if(!$r->{"bank_account_$required"}) {
- $this->layout()->setFlash("Bitte Bankdaten für SEPA ausfüllen.", "warn");
- $this->layout()->set("address", $r);
- return $this->add();
+ $address_id = $this->request->address_id;
+ if (!is_numeric($address_id) || $address_id < 1) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ $this->redirect("Address");
}
- }
- }
-
- if($r->billing_type == "sepa") {
- $data['billing_type'] = "sepa";
- if(!$r->sepa_date) {
- if($mode == "add" || ($mode == "edit" && !$address->sepa_date)) {
- $data['sepa_date'] = date('U');
+
+ $address = new Address($address_id);
+ if (!$address->id) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ $this->redirect("Address");
}
- } else {
- $data['sepa_date'] = Layout::dateToInt($r->sepa_date);
- }
- } else {
- $data['billing_type'] = "invoice";
+
+ $invoices = InvoiceModel::search(["owner_or_billingaddress_id" => $address->id], false, "invoice_date DESC");
+ $this->layout()->set("invoices", $invoices);
+ $this->layout()->set("address", $address);
+
+
}
-
- if($r->billing_delivery == "paper") {
- $data['billing_delivery'] = "paper";
- } else {
- $data['billing_delivery'] = "email";
+
+ protected function editAction() {
+ $address = new Address($this->request->id);
+
+ $this->layout->set("filter", $this->request->filter);
+ $this->layout->set("f", $this->request->f);
+ $this->layout->set("s", $this->request->s);
+
+ $this->layout()->set("address", $address);
+
+ if (!$address->id) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ return $this->addAction();
+ }
+
+ return $this->addAction();
}
-
-
- $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;
-
- if($mode == "add") {
- $address = AddressModel::create($data);
- } else {
- $address->update($data);
+
+ protected function deleteLink() {
+ $id = $this->request->id;
+
+ if (!is_numeric($id) || !$id) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ $this->redirect("Address");
+ }
+
+ $link = new AddressLink($id);
+ if (!$link->id) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ $this->redirect("Address");
+ }
+
+ $address_id = $link->origin_address_id;
+ $link->delete();
+ $this->layout()->setFlash("Verknüpfung erfolgreich entfernt", "success");
+ $this->redirect("Address", "edit", ['id' => $address_id]);
+
}
-
- //var_dump($address);exit;
-
- $new_id = $address->save();
- if(!$new_id) {
- $this->layout()->setFlash("Fehler beim Speichern", "error");
- $this->layout()->set("address", $address);
- return $this->add();
+
+ protected function exportBmdAction() {
+ if (!$this->me->can("Fibu")) {
+ $this->layout()->setFlash("Sicha ned!", "error");
+ $this->redirect("Address");
+ }
+
+ $return = Address::runBmdExport($this->request->type);
+
+ if ($return === 10) {
+ $this->layout()->setFlash("Export Pfad (" . TT_ADDRESS_BMD_EXPORT_PATH . ") nicht gefunden!", "error");
+ $this->redirect("Address");
+ }
+
+ if ($return === 11) {
+ $this->layout()->setFlash("Keine geänderten Adressdatensätze gefunden. Export abgebrochen.", "warn");
+ $this->redirect("Address");
+ }
+
+ if ($return === 19) {
+ $this->layout()->setFlash("Datei " . TT_ADDRESS_BMD_EXPORT_PATH . "/" . TT_ADDRESS_BMD_EXPORT_FILENAME . " konnte nicht gespeichert werden!", "error");
+ $this->redirect("Address");
+ }
+
+ if ($return === true) {
+ $this->layout()->setFlash("Adressen erfolgreich exportiert", "success");
+ $this->redirect("Address");
+ }
+
+
}
-
- // check for multiple primary fibu accounts, and remove from any other than this one
- if($address->fibu_primary_account && $address->fibu_account_number) {
- foreach(AddressModel::search(["fibu_primary_account" => true, "fibu_account_number" => $address->fibu_account_number]) as $fibu_primary) {
- if($fibu_primary->id == $address->id) continue;
- $fibu_primary->fibu_primary_account = 0;
- $fibu_primary->save();
- }
- }
-
-
- // save address types
- $new_types = $r->addresstypes;
- if(is_array($new_types)) {
- foreach($address->types as $existing_type) {
- //var_dump($existing_type);
- //var_dump($new_types);
- //echo $existing_type->type;
- if(!in_array($existing_type->type, $new_types)) {
- $existing_type->delete();
+
+ protected function saveAction() {
+ $r = $this->request;
+ $id = $r->id;
+ //var_dump($r->get());exit;
+ if (is_numeric($id) && $id > 0) {
+ $mode = "edit";
+ $address = new Address($id);
+ if (!$address->id) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ $this->redirect("Address");
+ }
} else {
- // remove existing type from new_types array (dont need to create again)
- $new_types = array_diff($new_types, [$existing_type->type]);
- //unset($new_types[$existing_type]);
+ $mode = "add";
}
- }
- //exit;
- foreach($new_types as $type) {
- $type_object = AddresstypeModel::create(['address_id' => $address->id, 'type' => $type]);
- $type_object->save();
- $address->types[$type] = $type_object;
- }
- }
-
- // generate new supplier account number if is supplier and supplier num empty
- //var_dump($mode, $address->fibu_supplier_number, $address->types);exit;
- if(!$address->fibu_supplier_number && array_key_exists("supplier", $address->types)) {
- $supplier_num = Address::getNextSupplierNumber();
- if(!$supplier_num) {
- $this->layout()->setFlash("Lieferantennummer konnte nicht generiert werden.");
- } else {
- $this->log->debug("new supplier number: ". $supplier_num);
- $address->fibu_supplier_number = $supplier_num;
- $address->save();
- }
- }
-
- $attribs = $r->attributes;
- //var_dump($attribs);exit;
- if(is_array($attribs) && count($attribs)) {
- foreach($attribs as $attrib => $value) {
- $aa = AddressattributeModel::getFirst(["address_id" => $new_id, "name" => $attrib]);
-
- if(!$aa) {
- $aa = AddressattributeModel::create(["address_id" => $new_id, "name" => $attrib]);
+
+ //var_dump($r->addresstypes);exit;
+
+ $data = [];
+ $data['parent_id'] = (!$r->parent_id) ? null : $r->parent_id;
+ $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_id'] = $r->country_id;
+ $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 (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");
+ }
+
}
- $aa->value = $value;
- $aa->save();
- }
- }
-
-
- //$address->deleteLinks();
-
- $existing_links = [];
- foreach(AddressLinkModel::search(['origin_address_id', $new_id]) as $elink) {
- $existing_links[$elink->address_id] = $elink;
- }
-
- //var_dump($r->links);exit;
- if(is_array($r->links) && count($r->links)) {
- //var_dump($r->links);exit;
- foreach($r->links as $linknum => $link) {
- if(!$link['type'] || !$link['address_id']) {
- continue;
+
+
+ if ($this->me->can("Fibu")) {
+ $data["sepa_date"] = ($r->sepa_date) ? Layout::dateToInt($r->sepa_date) : 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;
+ }
+
+ 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;
}
- if(array_key_exists($link['address_id'], $existing_links)) {
- continue;
+
+
+ // billing data
+ // validate sepa
+ if (!$r->billing_type) {
+ $this->layout()->setFlash("Ungültige Verrechnungsart.");
+ $this->layout()->set("order", $r);
+ return $this->add();
}
- $l = AddressLinkModel::create([
- 'origin_address_id' => $new_id,
- 'type' => $link['type'],
- 'address_id' => $link['address_id']
- ]);
- $l->save();
-
- }
+
+ if ($r->billing_type == "sepa") {
+ foreach (['owner', 'iban', 'bic'] as $required) {
+ if (!$r->{"bank_account_$required"}) {
+ $this->layout()->setFlash("Bitte Bankdaten für SEPA ausfüllen.", "warn");
+ $this->layout()->set("address", $r);
+ return $this->add();
+ }
+ }
+ }
+
+ if ($r->billing_type == "sepa") {
+ $data['billing_type'] = "sepa";
+ if (!$r->sepa_date) {
+ if ($mode == "add" || ($mode == "edit" && !$address->sepa_date)) {
+ $data['sepa_date'] = date('U');
+ }
+ } else {
+ $data['sepa_date'] = Layout::dateToInt($r->sepa_date);
+ }
+ } else {
+ $data['billing_type'] = "invoice";
+ }
+
+ if ($r->billing_delivery == "paper") {
+ $data['billing_delivery'] = "paper";
+ } else {
+ $data['billing_delivery'] = "email";
+ }
+
+
+ $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;
+
+ if ($mode == "add") {
+ $address = AddressModel::create($data);
+ } else {
+ $address->update($data);
+ }
+
+ //var_dump($address);exit;
+
+ $new_id = $address->save();
+ if (!$new_id) {
+ $this->layout()->setFlash("Fehler beim Speichern", "error");
+ $this->layout()->set("address", $address);
+ return $this->add();
+ }
+
+ // check for multiple primary fibu accounts, and remove from any other than this one
+ if ($address->fibu_primary_account && $address->fibu_account_number) {
+ foreach (AddressModel::search(["fibu_primary_account" => true, "fibu_account_number" => $address->fibu_account_number]) as $fibu_primary) {
+ if ($fibu_primary->id == $address->id) continue;
+ $fibu_primary->fibu_primary_account = 0;
+ $fibu_primary->save();
+ }
+ }
+
+
+ // save address types
+ $new_types = $r->addresstypes;
+ if (is_array($new_types)) {
+ foreach ($address->types as $existing_type) {
+ //var_dump($existing_type);
+ //var_dump($new_types);
+ //echo $existing_type->type;
+ if (!in_array($existing_type->type, $new_types)) {
+ $existing_type->delete();
+ } else {
+ // remove existing type from new_types array (dont need to create again)
+ $new_types = array_diff($new_types, [$existing_type->type]);
+ //unset($new_types[$existing_type]);
+ }
+ }
+ //exit;
+ foreach ($new_types as $type) {
+ $type_object = AddresstypeModel::create(['address_id' => $address->id, 'type' => $type]);
+ $type_object->save();
+ $address->types[$type] = $type_object;
+ }
+ }
+
+ // generate new supplier account number if is supplier and supplier num empty
+ //var_dump($mode, $address->fibu_supplier_number, $address->types);exit;
+ if (!$address->fibu_supplier_number && array_key_exists("supplier", $address->types)) {
+ $supplier_num = Address::getNextSupplierNumber();
+ if (!$supplier_num) {
+ $this->layout()->setFlash("Lieferantennummer konnte nicht generiert werden.");
+ } else {
+ $this->log->debug("new supplier number: " . $supplier_num);
+ $address->fibu_supplier_number = $supplier_num;
+ $address->save();
+ }
+ }
+
+ $attribs = $r->attributes;
+ //var_dump($attribs);exit;
+ if (is_array($attribs) && count($attribs)) {
+ foreach ($attribs as $attrib => $value) {
+ $aa = AddressattributeModel::getFirst(["address_id" => $new_id, "name" => $attrib]);
+
+ if (!$aa) {
+ $aa = AddressattributeModel::create(["address_id" => $new_id, "name" => $attrib]);
+ }
+ $aa->value = $value;
+ $aa->save();
+ }
+ }
+
+
+ //$address->deleteLinks();
+
+ $existing_links = [];
+ foreach (AddressLinkModel::search(['origin_address_id', $new_id]) as $elink) {
+ $existing_links[$elink->address_id] = $elink;
+ }
+
+ //var_dump($r->links);exit;
+ if (is_array($r->links) && count($r->links)) {
+ //var_dump($r->links);exit;
+ foreach ($r->links as $linknum => $link) {
+ if (!$link['type'] || !$link['address_id']) {
+ continue;
+ }
+ if (array_key_exists($link['address_id'], $existing_links)) {
+ continue;
+ }
+ $l = AddressLinkModel::create([
+ 'origin_address_id' => $new_id,
+ 'type' => $link['type'],
+ 'address_id' => $link['address_id']
+ ]);
+ $l->save();
+
+ }
+ }
+
+ // run afterSave() again in case anything importand has changed
+ $address->afterSave();
+
+ $sq = "";
+ $query = [];
+ if ($r->s) {
+ $query['s'] = $r->s;
+ }
+ if ($r->return != "index") {
+ $query['id'] = $new_id;
+ }
+
+ $qs = http_build_query($query);
+
+ $this->layout()->setFlash("Adresse erfolgreich gespeichert.", "success");
+ if ($r->return == "index") {
+ $this->redirect("Address", "Index", $qs);
+ }
+ if ($r->f == "view") {
+ $this->redirect("Address", "View", $qs);
+ }
+ $this->redirect("Address", "Edit", $qs);
}
- // run afterSave() again in case anything importand has changed
- $address->afterSave();
-
- $sq = "";
- $query = [];
- if($r->s) {
- $query['s'] = $r->s;
- }
- if($r->return != "index") {
- $query['id'] = $new_id;
- }
-
- $qs = http_build_query($query);
-
- $this->layout()->setFlash("Adresse erfolgreich gespeichert.", "success");
- if($r->return == "index") {
- $this->redirect("Address", "Index", $qs);
- }
- if($r->f == "view") {
- $this->redirect("Address", "View", $qs);
- }
- $this->redirect("Address", "Edit", $qs);
- }
-
-
- protected function apiAction() {
- if(!$this->me->is(["Admin","salespartner"])) {
- $this->redirect("Dashboard");
- }
- $do = $this->request->do;
- $data = [];
-
- switch($do) {
- case "getAddress":
- $return = $this->getAddressApi();
- break;
- case "findAddress":
- $return = $this->findAddressApi();
- break;
- case "validateIbanBic":
- $return = $this->validateIbanBicApi();
- break;
- default:
- $return = false;
- }
-
- if(!is_array($return) || !count($return)) {
- $data = ["status" => "error"];
- $this->returnJson($data);
- }
- $data['status'] = "OK";
- $data['result'] = $return;
- $this->returnJson($data);
- }
-
- private function getAddressApi() {
- $id = trim($this->request->id);
- if(!is_numeric($id) || !$id) {
- return false;
- }
-
- $address = new Address($id);
- if(!$address->id) {
- return false;
- }
-
- $a = $address->toArray();
- $a['name'] = $address->getCompanyOrName();
-
- return ['address' => $a];
- }
-
- private function findAddressApi() {
- $search = trim($this->request->q);
- $autocomplete = $this->request->autocomplete;
- if($autocomplete && $this->request->searchedID) {
- $address = new Address($this->request->searchedID);
- if($address->id) {
- $result = [
- 'value' => $address->id,
- 'text' => str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$address->getCompanyOrName()))." (".$address->zip." ".$address->city.", ".$address->street.")".(($address->customer_number) ? " [".$address->customer_number."]" : "")
- ];
+ protected function apiAction() {
+ if (!$this->me->is(["Admin", "salespartner"])) {
+ $this->redirect("Dashboard");
+ }
+ $do = $this->request->do;
+ $data = [];
+
+ switch ($do) {
+ case "getAddress":
+ $return = $this->getAddressApi();
+ break;
+ case "findAddress":
+ $return = $this->findAddressApi();
+ break;
+ case "validateIbanBic":
+ $return = $this->validateIbanBicApi();
+ break;
+ default:
+ $return = false;
+ }
+
+ if (!is_array($return) || !count($return)) {
+ $data = ["status" => "error"];
+ $this->returnJson($data);
+ }
+ $data['status'] = "OK";
+ $data['result'] = $return;
+ $this->returnJson($data);
+ }
+
+ private function getAddressApi() {
+ $id = trim($this->request->id);
+ if (!is_numeric($id) || !$id) {
+ return false;
+ }
+
+ $address = new Address($id);
+ if (!$address->id) {
+ return false;
+ }
+
+ $a = $address->toArray();
+ $a['name'] = $address->getCompanyOrName();
+
+ return ['address' => $a];
+ }
+
+ private function findAddressApi() {
+ $search = trim($this->request->q);
+ $autocomplete = $this->request->autocomplete;
+
+ if ($autocomplete && $this->request->searchedID) {
+ $address = new Address($this->request->searchedID);
+ if ($address->id) {
+ $result = [
+ 'value' => $address->id,
+ 'text' => str_replace("'", "\\'", str_replace(["\n",
+ "\r"], " ", $address->getCompanyOrName())) . " (" . $address->zip . " " . $address->city . ", " . $address->street . ")" . (($address->customer_number) ? " [" . $address->customer_number . "]" : "")
+ ];
+ $results[] = $result;
+ $this->returnJson($results);
+ die();
+ }
+ }
+
+ $po = 1;
+ $role = false;
+ // if searching for billingaddress, set role and parents_only to 0
+ if ($this->request->role == "billingaddress") {
+ $role = "billing";
+ $po = 0;
+ }
+ if ($this->request->role == "techcontact") {
+ $role = "techcontact";
+ $po = 0;
+ }
+
+ $this->log->debug(print_r($this->request->get(), true));
+
+ $addresses = [];
+
+ if (is_numeric($search)) {
+ $cnumbers = AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "customer_number" => $search]);
+ if ($cnumbers) {
+ $addresses = array_merge($addresses, $cnumbers);
+ }
+ }
+
+
+ if (isset($_GET['fibu_primary_account'])) {
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po,
+ "addresstype" => [$role],
+ "mergedName" => $search,
+ "fibu_primary_account" => true]));
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po,
+ "addresstype" => [$role],
+ "company" => $search,
+ "fibu_primary_account" => true]));
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po,
+ "addresstype" => [$role],
+ "firstname" => $search,
+ "fibu_primary_account" => true]));
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po,
+ "addresstype" => [$role],
+ "lastname" => $search,
+ "fibu_primary_account" => true]));
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po,
+ "addresstype" => [$role],
+ "street" => $search,
+ "fibu_primary_account" => true]));
+
+ } else {
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "mergedName" => $search]));
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "company" => $search]));
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "firstname" => $search]));
+ $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "lastname" => $search]));
+ }
+
+ if (!is_array($addresses) || !count($addresses)) {
+ return false;
+ }
+
+ $all_addresses = [];
+
+ // remove duplicates
+ foreach ($addresses as $address) {
+ if (!array_key_exists($address->id, $all_addresses)) {
+ $all_addresses[$address->id] = $address;
+ }
+ }
+
+ $results = [];
+
+ if (!$autocomplete) {
+ foreach ($all_addresses as $id => $address) {
+ $results[$id] = str_replace("'", "\\'", str_replace(["\n",
+ "\r"], " ", $address->getCompanyOrName())) . " (" . $address->zip . " " . $address->city . ", " . $address->street . ")" . (($address->customer_number) ? " [" . $address->customer_number . "]" : "");
+ if (count($results) > 15) {
+ $results["more"] = "...";
+ break;
+ }
+ }
+
+ return ["addresses" => $results];
+ }
+
+ // return bootstrap-autocomplete format
+ foreach ($all_addresses as $id => $address) {
+ $result = ['value' => $id,
+ 'text' => str_replace("'", "\\'", str_replace(["\n",
+ "\r"], " ", $address->getCompanyOrName())) . " (" . $address->zip . " " . $address->city . ", " . $address->street . ")" . (($address->customer_number) ? " [" . $address->customer_number . "]" : "")];
$results[] = $result;
- $this->returnJson($results);
- die();
+ if (count($results) > 15) {
+ $results[] = ['value' => 0,
+ 'text' => " --> Mehr Suchergebnisse vorhanden. Bitte Suchbegriff genauer definieren <--"];
+ break;
+ }
}
+
+ $this->returnJson($results);
}
- $po = 1;
- $role = false;
- // if searching for billingaddress, set role and parents_only to 0
- if($this->request->role == "billingaddress") {
- $role = "billing";
- $po = 0;
- }
- if($this->request->role == "techcontact") {
- $role = "techcontact";
- $po = 0;
- }
-
- $this->log->debug(print_r($this->request->get(),true));
-
- $addresses = [];
-
- if(is_numeric($search)) {
- $cnumbers = AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "customer_number" => $search]);
- if($cnumbers) {
- $addresses = array_merge($addresses, $cnumbers);
- }
- }
-
+ private function validateIbanBicApi() {
+ $iban = trim($this->request->iban);
+ $bic = trim($this->request->bic);
- if (isset($_GET['fibu_primary_account'])) {
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "mergedName" => $search, "fibu_primary_account" => true]));
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "company" => $search, "fibu_primary_account" => true]));
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "firstname" => $search, "fibu_primary_account" => true]));
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "lastname" => $search, "fibu_primary_account" => true]));
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "street" => $search, "fibu_primary_account" => true]));
-
- } else {
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "mergedName" => $search]));
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "company" => $search]));
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "firstname" => $search]));
- $addresses = array_merge($addresses, AddressModel::search(["parents_only" => $po, "addresstype" => [$role], "lastname" => $search]));
- }
-
- if(!is_array($addresses) || !count($addresses)) {
- return false;
- }
-
- $all_addresses = [];
-
- // remove duplicates
- foreach($addresses as $address) {
- if(!array_key_exists($address->id, $all_addresses)) {
- $all_addresses[$address->id] = $address;
- }
- }
-
- $results = [];
-
- if(!$autocomplete) {
- foreach($all_addresses as $id => $address) {
- $results[$id] = str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$address->getCompanyOrName()))." (".$address->zip." ".$address->city.", ".$address->street.")".(($address->customer_number) ? " [".$address->customer_number."]" : "");
- if(count($results) > 15) {
- $results["more"] = "...";
- break;
+ if (!$iban) {
+ return false;
}
- }
- return ["addresses" => $results];
- }
-
- // return bootstrap-autocomplete format
- foreach($all_addresses as $id => $address) {
- $result = ['value' => $id, 'text' => str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$address->getCompanyOrName()))." (".$address->zip." ".$address->city.", ".$address->street.")".(($address->customer_number) ? " [".$address->customer_number."]" : "")];
- $results[] = $result;
- if(count($results) > 15) {
- $results[] = ['value' => 0, 'text' => " --> Mehr Suchergebnisse vorhanden. Bitte Suchbegriff genauer definieren <--"];
- break;
- }
+ $result = IbanValidator::validate($iban, $bic);
+ if (is_array($result) && $result) {
+ return $result;
+ }
+
+ return false;
+
}
- $this->returnJson($results);
- }
-
- private function validateIbanBicApi() {
- $iban = trim($this->request->iban);
- $bic = trim($this->request->bic);
-
- if(!$iban) {
- return false;
- }
-
- $result = IbanValidator::validate($iban, $bic);
- if(is_array($result) && $result) {
- return $result;
- }
-
- return false;
-
- }
-
- public function createTicketAction() {
+ public function createTicketAction() {
// die('{"derivedStartDate":null,"derivedDueDate":null,"spentTime":"PT0S","laborCosts":"0,00 EUR","materialCosts":"0,00 EUR","overallCosts":"0,00 EUR","_embedded":{"attachments":{"_type":"Collection","total":0,"count":0,"_embedded":{"elements":[]},"_links":{"self":{"href":"/api/v3/work_packages/6664/attachments"}}},"relations":{"_type":"Collection","total":0,"count":0,"_embedded":{"elements":[]},"_links":{"self":{"href":"/api/v3/work_packages/6664/relations"}}},"type":{"_type":"Type","id":12,"name":"Störung","color":"#FF3300","position":4,"isDefault":true,"isMilestone":false,"createdAt":"2023-02-22T20:19:25Z","updatedAt":"2023-02-23T11:59:16Z","_links":{"self":{"href":"/api/v3/types/12","title":"Störung"}}},"priority":{"_type":"Priority","id":8,"name":"Residential","position":2,"color":"#74C0FC","isDefault":true,"isActive":true,"_links":{"self":{"href":"/api/v3/priorities/8","title":"Residential"}}},"project":{"_type":"Project","id":10,"identifier":"storungen-and-support","name":"Störungen & Support","active":true,"public":false,"description":{"format":"markdown","raw":"","html":""},"createdAt":"2023-02-22T19:45:24Z","updatedAt":"2024-01-19T19:56:27Z","statusExplanation":{"format":"markdown","raw":"","html":""},"_links":{"self":{"href":"/api/v3/projects/10","title":"Störungen & Support"},"createWorkPackage":{"href":"/api/v3/projects/10/work_packages/form","method":"post"},"createWorkPackageImmediately":{"href":"/api/v3/projects/10/work_packages","method":"post"},"workPackages":{"href":"/api/v3/projects/10/work_packages"},"categories":{"href":"/api/v3/projects/10/categories"},"versions":{"href":"/api/v3/projects/10/versions"},"memberships":{"href":"/api/v3/memberships?filters=%5B%7B%22project%22%3A%7B%22operator%22%3A%22%3D%22%2C%22values%22%3A%5B%2210%22%5D%7D%7D%5D"},"types":{"href":"/api/v3/projects/10/types"},"schema":{"href":"/api/v3/projects/schema"},"status":{"href":null},"ancestors":[{"href":"/api/v3/projects/5","title":"XINON"}],"parent":{"href":"/api/v3/projects/5","title":"XINON"}}},"status":{"_type":"Status","id":1,"name":"Neu","isClosed":false,"color":"#1098AD","isDefault":true,"isReadonly":false,"defaultDoneRatio":null,"position":1,"_links":{"self":{"href":"/api/v3/statuses/1","title":"Neu"}}},"author":{"_type":"User","id":30,"name":"Luca Haid","createdAt":"2024-02-05T11:35:52Z","updatedAt":"2024-10-21T06:32:44Z","login":"luca.haid@xinon.eu","firstName":"Luca","lastName":"Haid","email":"luca.haid@xinon.eu","avatar":"https://secure.gravatar.com/avatar/37a35a87af3c506c1ce722826834ce38?default=404&secure=true","status":"active","identityUrl":null,"language":"de","_links":{"self":{"href":"/api/v3/users/30","title":"Luca Haid"},"memberships":{"href":"/api/v3/memberships?filters=%5B%7B%22principal%22%3A%7B%22operator%22%3A%22%3D%22%2C%22values%22%3A%5B%2230%22%5D%7D%7D%5D","title":"Mitglieder"},"showUser":{"href":"/users/30","type":"text/html"}}},"customActions":[],"costsByType":{"_type":"Collection","total":0,"count":0,"_embedded":{"elements":[]},"_links":{"self":{"href":"/api/v3/work_packages/6664/summarized_costs_by_type"}}}},"_type":"WorkPackage","id":6664,"lockVersion":1,"subject":"tes","description":{"format":"markdown","raw":"ttest","html":"
ttest
"},"scheduleManually":false,"startDate":null,"dueDate":null,"estimatedTime":null,"derivedEstimatedTime":null,"duration":null,"ignoreNonWorkingDays":false,"percentageDone":0,"createdAt":"2024-10-31T12:48:27Z","updatedAt":"2024-10-31T12:48:27Z","readonly":false,"remainingTime":null,"customField1":null,"customField2":"4 Quality GmbH & Co KG","customField3":"Grazerstraße 87, 8111 Judendorf-Straßengel","customField4":"test","customField5":"office@4quality.at","customField6":"2215","customField7":"ZE4889","_links":{"attachments":{"href":"/api/v3/work_packages/6664/attachments"},"addAttachment":{"href":"/api/v3/work_packages/6664/attachments","method":"post"},"self":{"href":"/api/v3/work_packages/6664","title":"tes"},"update":{"href":"/api/v3/work_packages/6664/form","method":"post"},"schema":{"href":"/api/v3/work_packages/schemas/10-12"},"updateImmediately":{"href":"/api/v3/work_packages/6664","method":"patch"},"logTime":{"href":"/api/v3/time_entries","title":"Log time on tes"},"move":{"href":"/work_packages/6664/move/new","type":"text/html","title":"Move tes"},"copy":{"href":"/work_packages/6664/copy","title":"Copy tes"},"pdf":{"href":"/work_packages/6664.pdf","type":"application/pdf","title":"Export as PDF"},"atom":{"href":"/work_packages/6664.atom","type":"application/rss+xml","title":"Atom feed"},"availableRelationCandidates":{"href":"/api/v3/work_packages/6664/available_relation_candidates","title":"Potential work packages to relate to"},"activities":{"href":"/api/v3/work_packages/6664/activities"},"availableWatchers":{"href":"/api/v3/work_packages/6664/available_watchers"},"relations":{"href":"/api/v3/work_packages/6664/relations"},"revisions":{"href":"/api/v3/work_packages/6664/revisions"},"watchers":{"href":"/api/v3/work_packages/6664/watchers"},"addWatcher":{"href":"/api/v3/work_packages/6664/watchers","method":"post","payload":{"user":{"href":"/api/v3/users/{user_id}"}},"templated":true},"removeWatcher":{"href":"/api/v3/work_packages/6664/watchers/{user_id}","method":"delete","templated":true},"addRelation":{"href":"/api/v3/work_packages/6664/relations","method":"post","title":"Add relation"},"addChild":{"href":"/api/v3/projects/storungen-and-support/work_packages","method":"post","title":"Add child of tes"},"changeParent":{"href":"/api/v3/work_packages/6664","method":"patch","title":"Change parent of tes"},"addComment":{"href":"/api/v3/work_packages/6664/activities","method":"post","title":"Add comment"},"previewMarkup":{"href":"/api/v3/render/markdown?context=/api/v3/work_packages/6664","method":"post"},"timeEntries":{"href":"/api/v3/time_entries?filters=%5B%7B%22work_package_id%22%3A%7B%22operator%22%3A%22%3D%22%2C%22values%22%3A%5B%226664%22%5D%7D%7D%5D","title":"Time entries"},"category":{"href":null},"type":{"href":"/api/v3/types/12","title":"Störung"},"priority":{"href":"/api/v3/priorities/8","title":"Residential"},"project":{"href":"/api/v3/projects/10","title":"Störungen & Support"},"status":{"href":"/api/v3/statuses/1","title":"Neu"},"author":{"href":"/api/v3/users/30","title":"Luca Haid"},"responsible":{"href":null},"assignee":{"href":null},"version":{"href":null},"logCosts":{"href":"/work_packages/6664/cost_entries/new","type":"text/html","title":"Log costs on tes"},"showCosts":{"href":"/projects/10/cost_reports?fields%5B%5D=WorkPackageId&operators%5BWorkPackageId%5D=%3D&set_filter=1&values%5BWorkPackageId%5D=6664","type":"text/html","title":"Show cost entries"},"costsByType":{"href":"/api/v3/work_packages/6664/summarized_costs_by_type"},"github_pull_requests":{"href":"/api/v3/work_packages/6664/github_pull_requests","title":"GitHub pull requests"},"unwatch":{"href":"/api/v3/work_packages/6664/watchers/30","method":"delete"},"ancestors":[],"parent":{"href":null,"title":null},"customActions":[]}}');
- // subject: test
- //description: test
- //customer_name: 4 Quality GmbH & Co KG
- //customer_number: 2215
- //customer_address: Grazerstraße 87, 8111 Judendorf-Straßengel
- //customer_phone_number: 0664
- //customer_email: office@4quality.at
- //customer_service_pin: ZE4889
+ // subject: test
+ //description: test
+ //customer_name: 4 Quality GmbH & Co KG
+ //customer_number: 2215
+ //customer_address: Grazerstraße 87, 8111 Judendorf-Straßengel
+ //customer_phone_number: 0664
+ //customer_email: office@4quality.at
+ //customer_service_pin: ZE4889
- $subject = $this->request->subject;
+ $subject = $this->request->subject;
$description = $this->request->description;
$customer_name = $this->request->customer_name;
$customer_number = $this->request->customer_number;
@@ -661,12 +680,29 @@ class AddressController extends mfBaseController {
$customer_phone_number = $this->request->customer_phone_number;
$customer_email = $this->request->customer_email;
$customer_service_pin = $this->request->customer_service_pin;
- $user_api_key = (string)$this->me->getFlag('project_api_key');
+ $user_api_key = (string) $this->me->getFlag('project_api_key');
$xinon_project = new XinonProject();
$response = $xinon_project->createNewFaultTicket($subject, $description, $customer_name, $customer_number, $customer_address, $customer_phone_number, $customer_email, $customer_service_pin, $user_api_key);
die($response);
- }
+ }
+
+ protected function ticketsAction() {
+ $address_id = $this->request->address_id;
+
+ $address = new Address($address_id);
+ if (!$address->id) {
+ $this->layout()->setFlash("Addresse nicht gefunden", "error");
+ $this->redirect("Address");
+ }
+
+ $xinon_project = new XinonProject();
+ $tickets = $xinon_project->searchSupportTickets('', 0, ['pageSize' => 100,
+ 'filters' => json_encode([['customField6' => ['operator' => '=', 'values' => [$address->customer_number]]]])]);
+
+ Helper::renderVue($this,"AddressTickets",
+ "Tickets von Kunden: " . $address->getCompanyOrName() . '(' . $address->customer_number . ')', ["TICKETS" => $tickets]);
+ }
}
diff --git a/application/AddressDB/AddressDBController.php b/application/AddressDB/AddressDBController.php
index abb0e9048..409dccfcf 100644
--- a/application/AddressDB/AddressDBController.php
+++ b/application/AddressDB/AddressDBController.php
@@ -1066,7 +1066,7 @@ class AddressDBController extends mfBaseController {
$u['zusatz'] = $unit->zusatz;
$u['usage'] = $unit->nutzung;
$u['oaid'] = $unit->oaid;
- $u['preorder_count'] = count($unit->preorders);
+ $u['preorder_count'] = count($unit->active_preorders);
$results[] = $u;
}
diff --git a/application/Api/v1/AddressdbApicontroller.php b/application/Api/v1/AddressdbApicontroller.php
index 41bfb98e8..dbdfccecc 100644
--- a/application/Api/v1/AddressdbApicontroller.php
+++ b/application/Api/v1/AddressdbApicontroller.php
@@ -447,6 +447,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
'sort_key' => $sort_key,
'oaid' => $data->hausnummer_oaid,
'cluster_id' => $data->netzgebiet_extref,
+ 'rimo_external_id' => null,
+ 'visibility' => null,
+ 'adrcd' => null,
+ 'subcd' => null,
'zip' => $data->plz,
'city' => $data->gemeinde,
"municipality" => "",
@@ -472,6 +476,17 @@ class AddressdbApicontroller extends mfBaseApicontroller {
} else {
unset($tmp_addresses[$address_key]['municipality']);
}
+ if($this->me->is("preorderaddressreporting")) {
+ $tmp_addresses[$address_key]['rimo_external_id'] = $data->hausnummer_rimo_id;
+ $tmp_addresses[$address_key]['visibility'] = $data->visibility;
+ $tmp_addresses[$address_key]['adrcd'] = $data->adrcd;
+ $tmp_addresses[$address_key]['subcd'] = $data->subcd;
+ } else {
+ unset($tmp_addresses[$address_key]['rimo_external_id']);
+ unset($tmp_addresses[$address_key]["visibility"]);
+ unset($tmp_addresses[$address_key]["adrcd"]);
+ unset($tmp_addresses[$address_key]["subcd"]);
+ }
}
$unit_data = [
@@ -589,6 +604,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
$new_address['ordered'] = $u['ordered'];
$new_address['orderType'] = $u['orderType'];
$new_address['ispName'] = $u['ispName'];
+ $new_address['rimo_external_id'] = $ta['rimo_external_id'];
+ $new_address['visibility'] = $ta['visibility'];
+ $new_address['adrcd'] = $ta['adrcd'];
+ $new_address['subcd'] = $ta['subcd'];
}
$new_address['oaid'] = $u['oaid'];
$new_address['building_oaid'] = $ta['oaid'];
@@ -743,6 +762,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
$tmp_addresses[$address_key] = [
'oaid' => $data->hausnummer_oaid,
'cluster_id' => $data->netzgebiet_extref,
+ 'rimo_external_id' => null,
+ 'visibility' => null,
+ 'adrcd' => null,
+ 'subcd' => null,
'zip' => $data->plz,
'city' => $data->gemeinde,
"municipality" => "",
@@ -768,7 +791,17 @@ class AddressdbApicontroller extends mfBaseApicontroller {
} else {
unset($tmp_addresses[$address_key]['municipality']);
}
-
+ if($this->me->is("preorderaddressreporting")) {
+ $tmp_addresses[$address_key]['rimo_external_id'] = $data->hausnummer_rimo_id;
+ $tmp_addresses[$address_key]['visibility'] = $data->visibility;
+ $tmp_addresses[$address_key]['adrcd'] = $data->adrcd;
+ $tmp_addresses[$address_key]['subcd'] = $data->subcd;
+ } else {
+ unset($tmp_addresses[$address_key]['rimo_external_id']);
+ unset($tmp_addresses[$address_key]["visibility"]);
+ unset($tmp_addresses[$address_key]["adrcd"]);
+ unset($tmp_addresses[$address_key]["subcd"]);
+ }
}
$unit_data = [
@@ -808,6 +841,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
$new_address['ordered'] = $u['ordered'];
$new_address['orderType'] = $u['orderType'];
$new_address['ispName'] = $u['ispName'];
+ $new_address['rimo_external_id'] = $ta['rimo_external_id'];
+ $new_address['visibility'] = $ta['visibility'];
+ $new_address['adrcd'] = $ta['adrcd'];
+ $new_address['subcd'] = $ta['subcd'];
}
$new_address['oaid'] = $u['oaid'];
$new_address['building_oaid'] = $ta['oaid'];
diff --git a/application/Building/Building.php b/application/Building/Building.php
index ea0e41dd3..abf734f3a 100644
--- a/application/Building/Building.php
+++ b/application/Building/Building.php
@@ -15,7 +15,9 @@ class Building extends mfBaseModel {
private $workflowitems;
private $files;
private $pipework_enabler;
-
+ private $creator;
+ private $editor;
+
public function getAddress($singelLine = false) {
if(!$this->id) {
return false;
@@ -327,6 +329,28 @@ class Building extends mfBaseModel {
return $this->pipework_enabler;
}
+ if($name == "creator") {
+ $this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
+ if($this->creator === null) {
+ $this->creator = new User($this->create_by);
+ if($this->creator->id) {
+ mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
+ }
+ }
+ return $this->creator;
+ }
+
+ if($name == "editor") {
+ $this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
+ if($this->editor === null) {
+ $this->editor = new User($this->edit_by);
+ if($this->editor->id) {
+ mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
+ }
+ }
+ return $this->editor;
+ }
+
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield);
diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php
index fd39c11e7..7ed55d299 100644
--- a/application/ConstructionConsent/ConstructionConsentController.php
+++ b/application/ConstructionConsent/ConstructionConsentController.php
@@ -10,9 +10,7 @@ class ConstructionConsentController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me", $me);
- if (!$me->is(["Admin"])) {
- $this->redirect("Dashboard");
- }
+ if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
}
protected function indexAction() : void {
diff --git a/application/ConstructionConsentContact/ConstructionConsentContactController.php b/application/ConstructionConsentContact/ConstructionConsentContactController.php
index 84d215b9d..afaf61e7d 100644
--- a/application/ConstructionConsentContact/ConstructionConsentContactController.php
+++ b/application/ConstructionConsentContact/ConstructionConsentContactController.php
@@ -11,9 +11,7 @@ class ConstructionConsentContactController extends mfBaseController
$this->me = $me;
$this->layout()->set("me", $me);
- if (!$me->is(["Admin"])) {
- $this->redirect("Dashboard");
- }
+ if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
}
protected function saveAction()
diff --git a/application/ConstructionConsentJournal/ConstructionConsentJournalController.php b/application/ConstructionConsentJournal/ConstructionConsentJournalController.php
index f7203f25f..98cab83af 100644
--- a/application/ConstructionConsentJournal/ConstructionConsentJournalController.php
+++ b/application/ConstructionConsentJournal/ConstructionConsentJournalController.php
@@ -9,9 +9,7 @@ class ConstructionConsentJournalController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me",$me);
- if(!$me->is(["Admin"])) {
- $this->redirect("Dashboard");
- }
+ if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
}
protected function saveAction() {
diff --git a/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php b/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php
index 08c08f7fb..c9c1eb425 100644
--- a/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php
+++ b/application/ConstructionConsentOwner/ConstructionConsentOwnerController.php
@@ -11,9 +11,7 @@ class ConstructionConsentOwnerController extends mfBaseController
$this->me = $me;
$this->layout()->set("me", $me);
- if (!$me->is(["Admin"])) {
- $this->redirect("Dashboard");
- }
+ if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
}
protected function uploadDocumentAction() {
diff --git a/application/ConstructionConsentProject/ConstructionConsentProject.php b/application/ConstructionConsentProject/ConstructionConsentProject.php
index d80a96606..00d4ac2ed 100644
--- a/application/ConstructionConsentProject/ConstructionConsentProject.php
+++ b/application/ConstructionConsentProject/ConstructionConsentProject.php
@@ -4,6 +4,7 @@ class ConstructionConsentProject extends mfBaseModel {
private $consents;
private $networks;
private $adb_networks;
+ private $addresses;
protected function beforeUpdate($data) {
if(!array_key_exists("edit_by", $data)) {
@@ -18,11 +19,21 @@ class ConstructionConsentProject extends mfBaseModel {
public function getProperty($name) {
if($this->$name == null) {
+ if($name == "addresses") {
+ $addresses = ConstructionConsentProjectAddress::search(["constructionconsentproject_id" => $this->id]);
+ if(!count($addresses)) {
+ return [];
+ }
+ foreach($addresses as $address) {
+ $this->addresses[$address->address->id] = $address;
+ }
+ return $this->addresses;
+ }
+
if($name == "consents") {
$consents = ConstructionConsent::search(["constructionconsentproject_id" => $this->id]);
if(!$consents) {
return [];
-
}
$this->consents = $consents;
return $this->consents;
diff --git a/application/ConstructionConsentProject/ConstructionConsentProjectController.php b/application/ConstructionConsentProject/ConstructionConsentProjectController.php
index 47bdd40a2..fa6b13769 100644
--- a/application/ConstructionConsentProject/ConstructionConsentProjectController.php
+++ b/application/ConstructionConsentProject/ConstructionConsentProjectController.php
@@ -10,9 +10,7 @@ class ConstructionConsentProjectController extends mfBaseController {
$this->me = $me;
$this->layout()->set("me", $me);
- if (!$me->is(["Admin"])) {
- $this->redirect("Dashboard");
- }
+ if (!($me->is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908]))) $this->redirect("Dashboard");
}
protected function indexAction() : void {
@@ -135,30 +133,21 @@ class ConstructionConsentProjectController extends mfBaseController {
return $this->addAction();
}
- $netzgebiete = [];
if(!$project->save()) {
$this->layout()->setFlash("Fehler beim Speichern", "error");
return $this->addAction();
}
+
+ // save networks
+ $netzgebiete = [];
foreach($r->adb_netzgebiet_id as $netzgebiet_id) {
$netzgebiet = new ADBNetzgebiet($netzgebiet_id);
if(!$netzgebiet->id) continue;
$netzgebiete[] = $netzgebiet_id;
}
-
- /*
- if($mode == "add") {
- $project = ConstructionConsentProject::create($data);
- } else {
- $project->update($data);
- }*/
-
-
-
- //save networks
foreach($netzgebiete as $netzgebiet_id) {
$ccn = ConstructionConsentNetwork::getFirst(["constructionconsentproject_id" => $project->id, "adb_netzgebiet_id" => $netzgebiet_id]);
if(!$ccn) {
@@ -169,17 +158,40 @@ class ConstructionConsentProjectController extends mfBaseController {
$ccn->save();
}
}
-
foreach(ConstructionConsentNetwork::search(["constructionconsentproject_id" => $project->id]) as $ccn) {
if(!in_array($ccn->adb_netzgebiet_id, $netzgebiete)) {
$ccn->delete();
}
}
+ //var_dump($r->get());exit;
+ // save addresses
+ $addresses = [];
+ foreach($r->address_id as $address_id) {
+ $address = new Address($address_id);
+ if(!$address->id) continue;
+
+ $addresses[] = $address_id;
+ }
+ foreach($addresses as $address_id) {
+ $cca = ConstructionConsentProjectAddress::getFirst(["constructionconsentproject_id" => $project->id, "address_id" => $address_id]);
+ if(!$cca) {
+ $cca = ConstructionConsentProjectAddress::create([
+ "constructionconsentproject_id" => $project->id,
+ "address_id" => $address_id
+ ]);
+ $cca->save();
+ }
+ }
+ foreach(ConstructionConsentProjectAddress::search(["constructionconsentproject_id" => $project->id]) as $cca) {
+ if(!in_array($cca->address_id, $addresses)) {
+ $cca->delete();
+ }
+ }
+
+
$this->layout()->setFlash("Zustimmungserklärungsprojekt erfolgreich gespeichert", "success");
$this->redirect("ConstructionConsentProject");
-
-
}
diff --git a/application/Device/DeviceController.php b/application/Device/DeviceController.php
index b55d259a0..ac050b9b0 100644
--- a/application/Device/DeviceController.php
+++ b/application/Device/DeviceController.php
@@ -417,9 +417,9 @@ class DeviceController extends mfBaseController
private function getDevices()
{
- if (!$this->me->is(["Admin"])) {
- if ($this->allowedPops === null) return [];
- }
+
+ if ($this->allowedPops === null) return [];
+
$devices = DeviceModel::search(['popIds' => $this->allowedPops]);
foreach ($devices as $device) {
diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php
index 2454c2426..ff7480d07 100644
--- a/application/Preorder/Preorder.php
+++ b/application/Preorder/Preorder.php
@@ -37,6 +37,12 @@ class Preorder extends mfBaseModel {
}
}
+ public function beforeSave() {
+ if(!isset($this->data->status_id)) {
+ $this->data->status_id = 1;
+ }
+ }
+
public function afterSave() {
// reset auto magic properties
$this->status = null;
@@ -111,6 +117,9 @@ class Preorder extends mfBaseModel {
}
}
+ $campaign = $this->getProperty("campaign");
+ if($campaign->oaid_origin == "other") return true;
+
if($this->adb_wohneinheit_id && is_array($this->getProperty("adb_wohneinheit")->rimo_workorders)) {
foreach($this->getProperty("adb_wohneinheit")->rimo_workorders as $workorder) {
Rimoapi::updateWorkorder($workorder->rimo_id, $update);
@@ -425,7 +434,7 @@ class Preorder extends mfBaseModel {
$new_status = new Preorderstatus($this->status_id);
if(!$new_status->id) {
- $this->log->warning(__METHOD__ . ": Preorder has invalid status!");
+ $this->log->warning(__METHOD__ . ": Preorder has invalid status! ".print_r($this, true));
return true;
}
@@ -583,6 +592,23 @@ class Preorder extends mfBaseModel {
return true;
}
+ /*if($campaign->oaid_origin == "other") {
+ // oaid in wohneinheit übernehmen, falls in Preorder schon vorhanden
+ if($this->oaid)
+ // oaid aus wohneinheit übernehmen, falls vorhanden
+
+
+ $this->log->debug(__METHOD__.": Kampagne unterstützt keine OAIDs");
+ return true;
+ }*/
+
+ if($campaign->oaid_origin == "other") {
+ if($wohneinheit->oaid != $this->oaid) {
+ $this->oaid = $wohneinheit->oaid;
+ }
+ return true;
+ }
+
if($this->oaid) {
// If current OAID is from correct Origin then do nothing
if($campaign->oaid_origin == "thetool") {
@@ -755,6 +781,13 @@ class Preorder extends mfBaseModel {
return false;
}
+ $campaign = new Preordercampaign($this->preordercampaign_id);
+
+ if($campaign->oaid_origin == "other") {
+ $this->log->debug(__METHOD__.": Kampagne unterstützt keine OAIDs");
+ return false;
+ }
+
if(!$this->oaid) {
$this->setOrCreateOaid();
if(!$this->oaid) {
diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php
index f354215ec..e2588193e 100644
--- a/application/Preorder/PreorderController.php
+++ b/application/Preorder/PreorderController.php
@@ -399,6 +399,28 @@ class PreorderController extends mfBaseController {
$this->redirect("Preordercampaign");
}
+ $new_status = false;
+ if($data['adb_wohneinheit_id']) {
+ $unit = new ADBWohneinheit($data['adb_wohneinheit_id']);
+ if ($unit->id) {
+ $new_status = PreorderstatusModel::getFirst(["code" => $unit->status->code]);
+ if ($unit->hausnummer->status->code > $unit->status->code) {
+ $new_status = PreorderstatusModel::getFirst(["code" => $unit->hausnummer->status->code]);
+ }
+ }
+ } elseif($data['adb_hausnummer_id']) {
+ $h = new ADBHausnummer($data['adb_hausnummer_id']);
+ if($h->id) {
+ $new_status = PreorderstatusModel::getFirst(["code" => $h->status->code]);
+ }
+ }
+ if($new_status) {
+ $data["status_id"] = $new_status->id;
+ } else {
+ $data["status_id"] = 1;
+ }
+
+
if($campaign->product_type != "setup_only") {
$data['product_id'] = $r->product_id;
@@ -1345,12 +1367,14 @@ class PreorderController extends mfBaseController {
/*if($preorder->type != "legacytransfer") {
return false;
}*/
- if(!$this->me->is("Admin")) {
+ if(!$this->me->is("Admin") && !$this->me->can("preorder")) {
+ $this->log->debug(__METHOD__.": no permission");
return false;
}
$workorder = $preorder->createRimoWorkorder();
if(!$workorder) {
+ $this->log->debug(__METHOD__.": error creating workorder");
return false;
}
@@ -1369,7 +1393,8 @@ class PreorderController extends mfBaseController {
}
private function deleteWorkorderApi() {
- if(!$this->me->is("Admin")) {
+ if(!$this->me->is("Admin") && !$this->me->can("preorder")) {
+ $this->log->debug(__METHOD__.": no permission");
return false;
}
diff --git a/application/Preordercampaign/PreordercampaignController.php b/application/Preordercampaign/PreordercampaignController.php
index 4c606bbcd..fbc8494f0 100644
--- a/application/Preordercampaign/PreordercampaignController.php
+++ b/application/Preordercampaign/PreordercampaignController.php
@@ -257,8 +257,10 @@ class PreordercampaignController extends mfBaseController {
if($r->oaid_origin == "ofaa") {
$data['oaid_origin'] = "ofaa";
- } else {
+ } elseif($r->oaid_origin == "thetool") {
$data['oaid_origin'] = "thetool";
+ } else {
+ $data['oaid_origin'] = "other";
}
if($r->product_type == "setup_only") {
@@ -776,7 +778,7 @@ class PreordercampaignController extends mfBaseController {
protected function assignOpenAccessIdsToPreordersAction() {
$this->layout()->setTemplate("Preordercampaign/Admin");
-
+
$id = $this->request->id;
if(!is_numeric($id) || !$id) {
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
@@ -788,6 +790,11 @@ class PreordercampaignController extends mfBaseController {
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
$this->redirect("Preordercampaign");
}
+
+ if($campaign->oaid_origin == "other") {
+ $this->layout()->setFlash("Kampagne unterstützt keine OAIDs", "warning");
+ $this->redirect("Preordercampaign", "Admin", ["id" => $id]);
+ }
$assigned_oaids = 0;
$multiple_unit = 0;
@@ -865,6 +872,11 @@ class PreordercampaignController extends mfBaseController {
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
$this->redirect("Preordercampaign");
}
+
+ if($campaign->oaid_origin == "other") {
+ $this->layout()->setFlash("Kampagne unterstützt keine OAIDs, somit können keine Workorders erstellt werden", "warning");
+ $this->redirect("Preordercampaign", "Admin", ["id" => $id]);
+ }
$missing_units = [];
$missing_extrefs = [];
@@ -992,6 +1004,11 @@ class PreordercampaignController extends mfBaseController {
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
$this->redirect("Preordercampaign");
}
+
+ if($campaign->oaid_origin == "other") {
+ $this->layout()->setFlash("Kampagne unterstützt keine OAIDs", "warning");
+ $this->redirect("Preordercampaign", "Admin", ["id" => $id]);
+ }
$oaid_assigned = 0;
$missing_units = 0;
@@ -1058,6 +1075,11 @@ class PreordercampaignController extends mfBaseController {
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
$this->redirect("Preordercampaign");
}
+
+ if($campaign->oaid_origin == "other") {
+ $this->layout()->setFlash("Kampagne unterstützt keine OAIDs", "warning");
+ $this->redirect("Preordercampaign", "Admin", ["id" => $id]);
+ }
$oaid_updated = 0;
diff --git a/application/Termination/Termination.php b/application/Termination/Termination.php
index 8f19c38e6..112a0b3df 100644
--- a/application/Termination/Termination.php
+++ b/application/Termination/Termination.php
@@ -183,7 +183,6 @@ class Termination extends mfBaseModel {
}
$bcode = $this->getProperty("building")->code;
- var_dump($bcode);
if(!$bcode) {
return false;
}
diff --git a/application/WarehouseArticle/WarehouseArticleController.php b/application/WarehouseArticle/WarehouseArticleController.php
index 77c80a59e..93eae95cc 100644
--- a/application/WarehouseArticle/WarehouseArticleController.php
+++ b/application/WarehouseArticle/WarehouseArticleController.php
@@ -24,6 +24,8 @@ class WarehouseArticleController extends TTCrud {
['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center', 'priority' => 8]]
];
+ protected array $autocompleteColumns = ['articleNumber', 'title', 'description', 'category'];
+
protected array $additionalActions = [
['key' => 'openHistory','title' => 'Historie','class' => 'fas fa-history text-secondary'],
['key' => 'editDistributorEntries','title' => 'Lieferanten','class' => 'fas fa-truck text-cyan'],
diff --git a/application/WarehouseEShopOrder/WarehouseEShopOrderController.php b/application/WarehouseEShopOrder/WarehouseEShopOrderController.php
index 18d5bf81c..85af3dd82 100644
--- a/application/WarehouseEShopOrder/WarehouseEShopOrderController.php
+++ b/application/WarehouseEShopOrder/WarehouseEShopOrderController.php
@@ -336,6 +336,7 @@ class WarehouseEShopOrderController extends TTCrud {
$id = WarehouseEShopOrderModel::create(['status' => 'new',
'extRef' => $json['extRef'],
'deliveryMode' => $json['deliveryMode'],
+ 'deliveryAddressAdditional' => $json['deliveryAddressAdditional'],
'deliveryAddressName' => $json['deliveryAddressName'],
'deliveryAddressLine' => $json['deliveryAddressLine'],
'deliveryAddressPLZ' => $json['deliveryAddressPLZ'],
diff --git a/application/WarehouseOffer/WarehouseOffer.php b/application/WarehouseOffer/WarehouseOffer.php
new file mode 100644
index 000000000..7aff40082
--- /dev/null
+++ b/application/WarehouseOffer/WarehouseOffer.php
@@ -0,0 +1,9 @@
+ 'id', 'text' => 'ID', 'modal' => false],
+ ['key' => 'offerNumber', 'text' => 'Angebotsnummer', 'required' => true, 'modal' => false],
+ ['key' => 'customerNumber', 'text' => 'Kundennummer', 'required' => true, 'modal' => false],
+ ['key' => 'customerName', 'text' => 'Kundenname', 'required' => true, 'modal' => false],
+ ['key' => 'customerCity', 'text' => 'Stadt', 'required' => true, 'modal' => false],
+ ['key' => 'customerVAT', 'text' => 'UID', 'required' => true, 'modal' => false],
+ ['key' => 'editor', 'text' => 'Sachbearbeiter', 'required' => true, 'modal' => false],
+ ['key' => 'totalAmount', 'text' => 'Gesamtbetrag', 'required' => true, 'modal' => false],
+ ['key' => 'status', 'text' => 'Status', 'required' => true, 'modal' => ['type' => 'select']],
+ ['key' => 'create', 'text' => 'Erstellt', 'required' => true, 'modal' => false],
+ ['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'modal' => ['type' => 'select']],
+ ['key' => 'actions',
+ 'text' => 'Aktionen',
+ 'required' => false,
+ 'modal' => false,
+ 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
+ ];
+
+ protected array $permissionCheck = ['WarehouseAdmin'];
+
+ protected array $additionalActions = [
+ ['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary'],
+ ['key' => 'sendOffer', 'title' => 'Angebot senden', 'class' => 'fas fa-paper-plane text-success']
+ ];
+
+ protected array $infoMessages = [
+ 'create' => 'Angebot wurde erfolgreich erstellt.',
+ 'update' => 'Angebot wurde aktualisiert.',
+ 'delete' => 'Angebot wurde gelöscht',
+ 'noChanges' => 'Keine Änderungen',
+ 'sent' => 'Angebot wurde erfolgreich gesendet',
+ ];
+
+ protected function beforeCreate(): bool {
+ $currentCount = WarehouseOfferModel::count(['create' => ['from' => strtotime(date('Y-01-01'))]]);
+ $this->postData['offerNumber'] = 'AN' . date('Y') . '-' . str_pad($currentCount + 1, 4, '0', STR_PAD_LEFT);
+
+ return true;
+ }
+
+ protected function beforeUpdate($postData): bool {
+ (new WarehouseHistoryController)->create($postData, $this->mod);
+ return true;
+ }
+
+ protected function getHistoryAction() {
+ self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
+ }
+}
diff --git a/application/WarehouseOffer/WarehouseOfferModel.php b/application/WarehouseOffer/WarehouseOfferModel.php
new file mode 100644
index 000000000..c49405483
--- /dev/null
+++ b/application/WarehouseOffer/WarehouseOfferModel.php
@@ -0,0 +1,52 @@
+ 'id', 'text' => 'ID', 'modal' => false],
- ['key' => 'orderNumber', 'text' => 'Bestellnummer', 'required' => true, 'modal' => false],
- ['key' => 'delAddrCity', 'text' => 'Stadt', 'required' => true, 'modal' => false],
- ['key' => 'delAddrEMail', 'text' => 'E-Mail', 'required' => true, 'modal' => false],
- ['key' => 'delAddrLine', 'text' => 'Adresse', 'required' => true, 'modal' => false],
- ['key' => 'delAddrName', 'text' => 'Name', 'required' => true, 'modal' => false],
- ['key' => 'delAddrPLZ', 'text' => 'PLZ', 'required' => true, 'modal' => false],
- ['key' => 'editor', 'text' => 'Bearbeiter', 'required' => true, 'modal' => false],
- ['key' => 'note', 'text' => 'Notiz', 'required' => true, 'modal' => false],
- ['key' => 'positions', 'text' => 'Positionen', 'required' => true, 'modal' => false],
- ['key' => 'create', 'text' => 'Erstellt', 'required' => true, 'modal' => false],
- ['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'modal' => ['type' => 'select']],
- ['key' => 'actions',
- 'text' => 'Aktionen',
- 'required' => false,
- 'modal' => false,
- 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
- ];
-
protected array $permissionCheck = ['WarehouseAdmin'];
- protected array $additionalActions = [['key' => 'openHistory', 'title' => 'Historie', 'class' => 'fas fa-history text-primary']];
+ //@formatter:off
+ protected array $columns = [
+ ['key' => 'id', 'text' => 'ID', 'modal' => false, 'table' => false],
+ ['key' => 'orderNumber', 'text' => 'Bestellnummer', 'required' => true, 'modal' => false],
+ ['key' => 'distributor', 'text' => 'Lieferant', 'required' => false, 'modal' => false, 'table' => ['filter' => false]],
+ ['key' => 'delAddrCity', 'text' => 'Stadt', 'required' => true, 'modal' => false, 'table' => false],
+ ['key' => 'delAddrEMail', 'text' => 'E-Mail', 'required' => true, 'modal' => false, 'table' => false],
+ ['key' => 'delAddrLine', 'text' => 'Adresse', 'required' => true, 'modal' => false, 'table' => false],
+ ['key' => 'delAddrName', 'text' => 'Name', 'required' => true, 'modal' => false, 'table' => false],
+ ['key' => 'delAddrPLZ', 'text' => 'PLZ', 'required' => true, 'modal' => false, 'table' => false],
+ ['key' => 'editor', 'text' => 'Bearbeiter', 'required' => true, 'modal' => ['type' => 'select'], 'table' => ['filter' => 'select']],
+ ['key' => 'note', 'text' => 'Notiz', 'required' => true, 'modal' => false, 'table' => false],
+ ['key' => 'sum', 'text' => 'Summe', 'required' => false, 'modal' => false, 'table' => ['class' => 'text-right']],
+ ['key' => 'status', 'text' => 'Status', 'required' => false, 'modal' => ['type' => 'select', 'items' => []], 'table' => ['filter' => 'select']],
+ ['key' => 'positions', 'text' => 'Positionen', 'required' => true, 'modal' => false, 'table' => false],
+ ['key' => 'extReference', 'text' => 'Externe Referenz', 'required' => true, 'modal' => false],
+ ['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'modal' => ['type' => 'select'], 'table' => ['filter' => 'select']],
+ ['key' => 'create', 'text' => 'Erstellt', 'required' => true, 'modal' => false],
+ ['key' => 'actions', 'text' => 'Aktionen', 'required' => false, 'modal' => false, 'table' => ['filter' => false, 'sortable' => false, 'class' => 'text-center']],
+ ];
+ //@formatter:on
protected array $infoMessages = ['create' => 'Bestellung wurde erfolgreich erstellt.',
'update' => 'Bestellung wurde aktualisiert.',
'delete' => 'Bestellung wurde gelöscht',
'noChanges' => 'Keine Änderungen',];
+ protected function prepareCrudConfig(): void {
+ $editorColumnIndex = array_search('editor', array_column($this->columns, 'key'));
+ $this->columns[$editorColumnIndex]['modal']['items'] = array_map(function ($user) {
+ return ['value' => intval($user->id), 'text' => $user->name];
+ }, UserModel::search(['employee' => true]));
+
+ $statusIndex = array_search('status', array_column($this->columns, 'key'));
+ $this->columns[$statusIndex]['modal']['items'] = [
+ ['value' => 'new', 'text' => 'Neu'],
+ ['value' => 'accepted', 'text' => 'Akzeptiert'],
+ ['value' => 'ordered', 'text' => 'Bestellt'],
+ ['value' => 'sent', 'text' => 'Versendet'],
+ ['value' => 'partiallyDelivered', 'text' => 'Teilweise geliefert'],
+ ['value' => 'fullyDelivered', 'text' => 'Geliefert'],
+ ['value' => 'cancelled', 'text' => 'Storniert'],
+ ];
+ }
+
protected function beforeCreate(): bool {
- $currentCount = WarehouseOrderModel::count(['create' => ['from' => strtotime(date('Y-01-01'))]]);
- $this->postData['orderNumber'] = 'PO' . date('Y') . '-' . str_pad($currentCount + 1, 4, '0', STR_PAD_LEFT);
+ $this->postData['orderNumber'] = 'PO' . date('Y') . '-' . str_pad(WarehouseOrderModel::count(['create' => ['from' => strtotime(date('Y-01-01'))]]) + 1, 4, '0', STR_PAD_LEFT);
return true;
}
protected function getArticleDistributorDataAction() {
- $data = [];
- $article = $this->request->articleId;
+ $articleId = $this->request->articleId;
+ if ($this->request->allDistributor === 'true') self::returnJson(array_map(fn($d) => ['id' => $d->id,
+ 'name' => $d->name], WarehouseDistributorModel::getAll()));
+ else if (!empty($articleId)) self::returnJson(array_map(fn($d) => ['id' => $d->distributorId,
+ 'name' => WarehouseDistributorModel::get($d->distributorId)->name,
+ 'purchasePrice' => $d->purchasePrice,
+ 'externalArticleNumber' => $d->externalArticleNumber], WarehouseArticleDistributorModel::getAll(['articleId' => $articleId])));
+ else self::returnJson([]);
+ }
- if ($this->request->allDistributor === 'true') {
- foreach (WarehouseDistributorModel::getAll() as $distributor) {
- $data[] = [
- 'id' => $distributor->id,
- 'name' => $distributor->name,
- ];
- }
- } elseif (!empty($article)) {
- foreach (WarehouseArticleDistributorModel::getAll(['articleId' => $this->request->articleId]) as $distributor) {
- $data[] = [
- 'id' => $distributor->distributorId,
- 'name' => WarehouseDistributorModel::get($distributor->distributorId)->name,
- 'purchasePrice' => $distributor->purchasePrice,
- 'externalArticleNumber' => $distributor->externalArticleNumber,
- ];
- }
+ protected function getByIdParse(array $order): array {
+ $order['positions'] = json_decode($order['positions'], true);
+
+ foreach ($order['positions'] as &$position) {
+ $position['distributorName'] = WarehouseDistributorModel::get($position['distributorId'])->name;
+ $position['articleName'] = WarehouseArticleModel::get($position['article'])->title;
}
- self::returnJson($data);
+ return $order;
}
- protected function beforeUpdate($postData): bool {
- (new WarehouseHistoryController)->create($postData, $this->mod);
- return true;
+ protected function createPDFAction() {
+ $order = (array) WarehouseOrderModel::get($this->request->id);
+ $order['positions'] = json_decode($order['positions'], true);
+ // check if all positions have the same distributor
+ $distributorId = $order['positions'][0]['distributorId'];
+ foreach ($order['positions'] as $key => $position) {
+ if ($position['distributorId'] !== $distributorId) {
+ self::returnJson(['error' => 'Die Bestellung enthält Positionen von verschiedenen Lieferanten.']);
+ }
+
+ // we need to get the article name and distributor name for the pdf
+ $position['distributorName'] = WarehouseDistributorModel::get($position['distributorId'])->name;
+ $position['articleName'] = WarehouseArticleModel::get($position['article'])->title;
+
+ $order['positions'][$key] = $position;
+ }
+
+ $pdf_vars = ['order' => $order,
+ 'distributor' => WarehouseDistributorModel::get($distributorId),
+ "bank_iban" => TT_INVOICE_BANK_IBAN,
+ "bank_bic" => TT_INVOICE_BANK_BIC,
+ "bank_bank" => TT_INVOICE_BANK_BANK,
+ "bank_owner" => TT_INVOICE_BANK_OWNER];
+
+
+ $countryText = CountryModel::search(['id' => WarehouseDistributorModel::get($distributorId)->countryId])[0]->name;
+
+ $headerHtml = file_get_contents(BASEDIR . "/Layout/default/WarehouseOrder/PDF_HEADER.html");
+ $headerHtml = str_replace("{{ basedir }}", BASEDIR, $headerHtml);
+ $headerHtml = str_replace("{{ externalReference }}","
Ihre Referenz: ". $order['extReference'], $headerHtml);
+
+ $headerHtml = str_replace("{{ addressLine_1 }}", WarehouseDistributorModel::get($distributorId)->name, $headerHtml);
+ $headerHtml = str_replace("{{ addressLine_2 }}", WarehouseDistributorModel::get($distributorId)->address, $headerHtml);
+ $headerHtml = str_replace("{{ addressLine_3 }}", WarehouseDistributorModel::get($distributorId)->plz . " " . WarehouseDistributorModel::get($distributorId)->city, $headerHtml);
+ $headerHtml = str_replace("{{ addressLine_4 }}", $countryText, $headerHtml);
+
+ $headerHtml = str_replace("{{ billingAddressLine_1 }}", "Xinon GmbH", $headerHtml);
+ $headerHtml = str_replace("{{ billingAddressLine_2 }}", "Fladnitz im Raabtal 150", $headerHtml);
+ $headerHtml = str_replace("{{ billingAddressLine_3 }}", "8322 Studenzen", $headerHtml);
+ $headerHtml = str_replace("{{ billingAddressLine_4 }}", "Österreich", $headerHtml);
+ $headerHtml = str_replace("{{ billingAddressLine_5 }}", "einkauf@xinon.at", $headerHtml);
+ $headerHtml = str_replace("{{ billingAddressLine_6 }}", "
Referenz: ". $order["orderNumber"] . "", $headerHtml);
+
+ // if order dellAddrLine is Fladnitz im Raabtal 150 we need to set all template strings to empty
+
+ $chk = $order['delAddrLine'] == "Fladnitz im Raabtal 150";
+
+ $headerHtml = str_replace("{{ shippingAddressLine_1 }}", $chk ? "" : $order['delAddrName'], $headerHtml);
+ $headerHtml = str_replace("{{ shippingAddressLine_2 }}", $chk ? "" : $order['delAddrLine'], $headerHtml);
+ $headerHtml = str_replace("{{ shippingAddressLine_3 }}", $chk ? "" : $order['delAddrPLZ'] . " " . $order['delAddrCity'], $headerHtml);
+ $headerHtml = str_replace("{{ shippingAddressLine_4 }}", $chk ? "" : $order['delAddrEMail'], $headerHtml);
+
+
+ $headerFile = BASEDIR . "/var/temp/order_header-" . date("U") . "-" . rand(1000, 9999) . ".html";
+ file_put_contents($headerFile, $headerHtml);
+
+ $footerHtml = file_get_contents(BASEDIR . "/Layout/default/WarehouseOrder/PDF_FOOTER.html");
+ $footerHtml = str_replace("{{ bank_iban }}", TT_INVOICE_BANK_IBAN_FORMATTED, $footerHtml);
+ $footerHtml = str_replace("{{ bank_bic }}", TT_INVOICE_BANK_BIC, $footerHtml);
+ $footerHtml = str_replace("{{ bank_bank }}", TT_INVOICE_BANK_BANK, $footerHtml);
+ $footerHtml = str_replace("{{ bank_owner }}", TT_INVOICE_BANK_OWNER, $footerHtml);
+
+ $footerFile = BASEDIR . "/var/temp/order_footer-" . date("U") . "-" . rand(1000, 9999) . ".html";
+ file_put_contents($footerFile, $footerHtml);
+
+
+ $pdf = new PdfForm("WarehouseOrder/PDF_MAIN", $pdf_vars);
+ $wkhtmltopdfArgs = "--header-html $headerFile --footer-html $footerFile";
+ $filename = $pdf->render($wkhtmltopdfArgs);
+
+ // return the pdf and die so the client sees the pdf not the filename
+ header('Content-Type: application/pdf');
+ header('Content-Disposition: inline; filename="' . $filename . '"');
+ readfile($filename);
+
}
- protected function getHistoryAction() {
- self::returnJson((new WarehouseHistoryController)->getHistory($this->request->id, $this->mod, $this->columns));
- }
+
}
\ No newline at end of file
diff --git a/application/WarehouseOrder/WarehouseOrderModel.php b/application/WarehouseOrder/WarehouseOrderModel.php
index 84070625f..ac4677800 100644
--- a/application/WarehouseOrder/WarehouseOrderModel.php
+++ b/application/WarehouseOrder/WarehouseOrderModel.php
@@ -1,5 +1,5 @@
'title', 'text' => 'Titel', 'required' => true, 'table' => ['class' => 'text-nowrap', 'priority' => 9]],
+ ['key' => 'description', 'text' => 'Beschreibung', 'required' => true, 'table' => ['class' => 'text-nowrap']],
+ ['key' => 'createBy', 'text' => 'Erstellt von', 'required' => true, 'type' => 'select', 'table' => ['class' => 'text-nowrap', 'filter' => 'select'], 'modal' => ['items' => [], 'type' => 'select']],
+ ['key' => 'create', 'text' => 'Erstellt am', 'required' => true, 'table' => ['filter' => 'date', 'class' => 'text-center']],
+ ['key' => 'address', 'text' => 'Adresse', 'required' => true, 'type' => 'autocomplete', 'table' => ['class' => 'text-nowrap', 'filter' => false], 'modal' => ['apiUrl' => '/Address/api?do=findAddress', 'items' => '/Address/api?do=findAddress', 'type' => 'autocomplete']],
+ ['key' => 'status', 'text' => 'Status', 'required' => true, 'table' => ['filter' => 'select'], 'modal' => [ 'type' => 'select', 'items' => [ ['value' => 'erstellt', 'text' => 'Erstellt'], ['value' => 'in_bearbeitung', 'text' => 'In Bearbeitung'], ['value' => 'erledigt', 'text' => 'Erledigt'], ['value' => 'verrechnet', 'text' => 'Verrechnet']]]]
+ ];
+
+
+ protected array $additionalActions = [
+ ];
+
+ protected array $infoMessages = [
+ 'create' => 'Projekt wurde erstellt',
+ 'update' => 'Projekt wurde aktualisiert',
+ 'delete' => 'Projekt wurde gelöscht',
+ 'noChanges' => 'Keine Änderungen',
+ ];
+ //@formatter:on
+
+ public function prepareCrudConfig() {
+ $users = array_map(function($user) {
+ return ['value' => $user->id, 'text' => $user->name];
+ }, UserModel::search(['employee' => true]));
+
+ $this->columns[1]['modal']['items'] = $users;
+ }
+}
\ No newline at end of file
diff --git a/application/WarehouseProject/WarehouseProjectModel.php b/application/WarehouseProject/WarehouseProjectModel.php
new file mode 100644
index 000000000..a1aa8f680
--- /dev/null
+++ b/application/WarehouseProject/WarehouseProjectModel.php
@@ -0,0 +1,15 @@
+$name == null) {
-
+
if($name == "value") {
if(!$this->object_id) {
- $this->log->warn(__CLASS__."::getProperty('value'): Object ID not set");
- $this->log->debug("[Backtrace] ================");
- $this->log->debug("[Backtrace] START Backtrace");
- $bt = debug_backtrace();
- foreach($bt as $n => $b) {
- $this->log->debug($n.") ".$b["file"]."(".$b['line']."): ".$b['class']."->".$b['function']."()" );
- }
- $this->log->debug("[Backtrace] $sql");
- $this->log->debug("[Backtrace] END Backtrace");
return null;
}
$value = mfValuecache::singleton()->get("wfItemvalue-item-".$this->id."-object-".$this->object_id);
- if($this->id == 55 && $this->object_id == 509) {
- var_dump($value);exit;
- }
if($value) {
$this->value = $value;
return $value;
diff --git a/db/migrations/20250204190000_warehouse_modify_12.php b/db/migrations/20250204190000_warehouse_modify_12.php
new file mode 100644
index 000000000..028289ce1
--- /dev/null
+++ b/db/migrations/20250204190000_warehouse_modify_12.php
@@ -0,0 +1,21 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("WarehouseOrder");
+ $table->addColumn("extReference", "string", ["length" => 255, "null" => true]);
+ $table->save();;
+ }
+ }
+
+ public function down(): void {
+ if ($this->getEnvironment() == "thetool") {
+ $table = $this->table("WarehouseOrder");
+ $table->removeColumn("extReference");
+ $table->save();;
+ }
+ }
+}
diff --git a/db/migrations/20250205150003_create_construction_consent_project_address.php b/db/migrations/20250205150003_create_construction_consent_project_address.php
new file mode 100644
index 000000000..836f5361f
--- /dev/null
+++ b/db/migrations/20250205150003_create_construction_consent_project_address.php
@@ -0,0 +1,36 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("ConstructionConsentProjectAddress");
+ $table->addColumn("constructionconsentproject_id", "integer", ["null" => false]);
+ $table->addColumn("address_id", "integer", ["null" => false]);
+ $table->addColumn("create_by", "integer", ["null" => false]);
+ $table->addColumn("edit_by", "integer", ["null" => false]);
+ $table->addColumn("create", "integer", ["null" => false]);
+ $table->addColumn("edit", "integer", ["null" => false]);
+ $table->create();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $this->table("ConstructionConsentProjectAddress")->drop()->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/lib/Helper/Helper.php b/lib/Helper/Helper.php
index 3668e1b8d..aa31b8c6e 100644
--- a/lib/Helper/Helper.php
+++ b/lib/Helper/Helper.php
@@ -8,7 +8,7 @@ class Helper {
* @param string $columnName The name of the column in the database table.
* @return string The SQL condition generated based on the filter value and column name.
*/
- public static function generateFilterCondition($filterValue, string $columnName, bool $exactMatch = false): string {
+ public static function generateFilterCondition($filterValue, $columnName, bool $exactMatch = false): string {
$sql = "";
if (is_array($filterValue)) {
@@ -30,6 +30,9 @@ class Helper {
} else if (!empty($filterValue)) {
if ($exactMatch) {
$sql .= " AND `$columnName` = '" . $filterValue . "'";
+ } else if (strpos($columnName, "|") !== false) {
+ foreach (explode(" ", $filterValue) as $item)
+ $sql .= " AND CONCAT(" . join(",", explode("|", $columnName)) . ") LIKE '%" . str_replace("%", "", $item) . "%'";
} else if ($filterValue[0] === "%") {
$sql .= " AND `$columnName` LIKE '" . $filterValue . "'";
} else if ($filterValue[strlen($filterValue) - 1] === "%") {
diff --git a/lib/SNOPP/SNOPP.php b/lib/SNOPP/SNOPP.php
new file mode 100644
index 000000000..d995ea3e5
--- /dev/null
+++ b/lib/SNOPP/SNOPP.php
@@ -0,0 +1,36 @@
+ [
+ 'method' => 'GET',
+ 'header' => "X-Api-Key: $SNOPP_API_KEY\r\n",
+ ]
+ ];
+
+ $snopp_output = file_get_contents("$SNOPP_API_URL/ticket/find?provider_id=all&status=open", false, stream_context_create($ctx_opts));
+ $ticket_obj = json_decode($snopp_output);
+ $tickets = $ticket_obj->result->tickets;
+
+ return $tickets;
+ }
+
+}
+?>
diff --git a/lib/TTCrud/TTCrud.php b/lib/TTCrud/TTCrud.php
index 8288b6123..daca7bbcc 100644
--- a/lib/TTCrud/TTCrud.php
+++ b/lib/TTCrud/TTCrud.php
@@ -10,6 +10,8 @@
* @property array $additionalJSVariables
* @property array $infoMessages
* @property bool $onlyView
+ * @property array $defaultOrder
+ * @property array $autocompleteColumns
*/
class TTCrud extends mfBaseController {
public User $user;
@@ -82,9 +84,7 @@ class TTCrud extends mfBaseController {
* @return array
*/
protected function getCrudConfig(): array {
- if (method_exists($this, 'prepareCrudConfig')) {
- $this->prepareCrudConfig();
- }
+
$column = array_search('createBy', array_column($this->columns, 'key'));
if ($column !== false) {
@@ -93,6 +93,10 @@ class TTCrud extends mfBaseController {
}, UserModel::search(['employee' => true]));
}
+ if (method_exists($this, 'prepareCrudConfig')) {
+ $this->prepareCrudConfig();
+ }
+
$columns = array_map(function ($column) {
if (isset($column['type']) && (!isset($column['modal']) || !isset($column['modal']['type']))) {
@@ -251,18 +255,20 @@ class TTCrud extends mfBaseController {
}
protected function autocompleteAction() {
- $searchedID = $this->request->searchedID;
-
$textKey = property_exists($this->model, 'name') ? 'name' : 'title';
-
- if (strlen($searchedID) > 0) {
- $filter = ['id' => $searchedID];
+ if (strlen($this->request->searchedID) > 0) {
+ $filter = ['id' => $this->request->searchedID];
$data = $this->model::getAll($filter, 10);
} else {
- $filter = [$textKey => $this->request->q . '%'];
- $data = $this->model::getAll($filter, 10);
+ if (isset($this->autocompleteColumns) && is_array($this->autocompleteColumns)) {
+ $filterKey = join('|', $this->autocompleteColumns);
+ } else {
+ $filterKey = $textKey;
+ }
+
+ $data = [];
if (count($data) < 11) {
- $filter = [$textKey => $this->request->q];
+ $filter = [$filterKey => '%' . $this->request->q . '%'];
$lazyData = $this->model::getAll($filter, 10);
$data = array_merge($data, $lazyData);
$data = array_unique($data, SORT_REGULAR);
@@ -270,7 +276,6 @@ class TTCrud extends mfBaseController {
}
}
-
self::returnJson(array_map(function ($item) use ($textKey) {
return ['value' => $item->id, 'text' => $item->$textKey];
}, $data));
@@ -285,6 +290,7 @@ class TTCrud extends mfBaseController {
}
$data = (array) $this->model::get($id);
+ if (method_exists($this, 'getByIdParse') && !isset($_GET['disableParse'])) $data = $this->getByIdParse($data);
self::returnJson($data);
}
}
diff --git a/lib/TTCrudBaseModel/TTCrudBaseModel.php b/lib/TTCrudBaseModel/TTCrudBaseModel.php
index 3184ffa10..4815dde9f 100644
--- a/lib/TTCrudBaseModel/TTCrudBaseModel.php
+++ b/lib/TTCrudBaseModel/TTCrudBaseModel.php
@@ -81,17 +81,13 @@ class TTCrudBaseModel {
}
- public static function get($id, $die= false): TTCrudBaseModel {
+ public static function get($id): TTCrudBaseModel {
$FronkDB = FronkDB::singleton();
$db = $FronkDB->link;
$id = $db->real_escape_string($id);
$table = self::getTable();
$sql = "SELECT * FROM `$table` WHERE `id` = $id";
- if($die) {
- die($sql);
- }
-
$result = $db->query($sql);
// as TTCRudBaseModel is abstract, we need to get the class name of the child class
$class = get_called_class();
@@ -109,16 +105,16 @@ class TTCrudBaseModel {
return $result->fetch_assoc()['count'];
}
- public static function getSQLFilter($filter): string {
- if (empty($filter)) {
- return "";
- }
+ public static function getSQLFilter(array $filter): string {
+ if (empty($filter)) return '';
+ $sql = 'WHERE 1=1';
+ $calledClass = get_called_class();
- $sql = "WHERE 1=1";
foreach ($filter as $key => $value) {
- if (!property_exists(get_called_class(), $key)) {
- http_response_code(500);
- throw new Exception("Field $key does not exist in " . get_called_class());
+ foreach (explode('|', $key) as $column) {
+ if (!property_exists($calledClass, $column)) {
+ throw new InvalidArgumentException("Field $column does not exist in $calledClass");
+ }
}
$sql .= Helper::generateFilterCondition($value, $key, gettype($value) === "integer");
}
diff --git a/lib/XinonProject/XinonProject.php b/lib/XinonProject/XinonProject.php
index 9fdd63394..f32895350 100644
--- a/lib/XinonProject/XinonProject.php
+++ b/lib/XinonProject/XinonProject.php
@@ -58,14 +58,13 @@ class XinonProject {
* @param int $pageSize - The number of results to return.
* @return array - The search results.
*/
- public function searchSupportTickets(string $search, int $pageSize = 25): array {
+ public function searchSupportTickets(string $search, int $pageSize = 25, $overrideQueryParams = null): array {
$curl = curl_init();
$baseUrl = 'https://project.xinon.at/api/v3/projects/10/work_packages';
- $queryParams = [
- 'pageSize' => 25,
- 'filters' => json_encode([['search' => ['operator' => '**', 'values' => [$search]]]])
- ];
+ $queryParams = ['pageSize' => $pageSize, 'filters' => json_encode([['search' => ['operator' => '**', 'values' => [$search]]]])];
+
+ if (!is_null($overrideQueryParams)) $queryParams = $overrideQueryParams;
curl_setopt_array($curl, array(
CURLOPT_URL => $baseUrl . '?' . http_build_query($queryParams),
diff --git a/public/js/pages/AddressTickets/AddressTickets.js b/public/js/pages/AddressTickets/AddressTickets.js
new file mode 100644
index 000000000..8103c0a9d
--- /dev/null
+++ b/public/js/pages/AddressTickets/AddressTickets.js
@@ -0,0 +1,55 @@
+Vue.component('AddressTickets', {
+ template: `
+
+
+
+
+
+ | Kundennummer |
+ Erstellt am |
+ Betreff |
+ Letztes Update |
+ Aktion |
+
+
+
+
+ | {{ ticket.customField7 }} |
+ {{ formatDate(ticket.createdAt) }} |
+ {{ ticket.subject }} |
+ {{ formatDate(ticket.updatedAt) }} |
+
+
+
+ Ticket anzeigen
+
+ |
+
+
+
+
+
+ `,
+ data() {
+ return {
+ window: window,
+ }
+ },
+ computed: {
+ parsedTickets() {
+ return this.window.TT_CONFIG.TICKETS.map(ticket => ({
+ id: ticket.id,
+ customField7: ticket.customField7,
+ createdAt: ticket.createdAt,
+ subject: ticket.subject,
+ updatedAt: ticket.updatedAt,
+ activitiesHref: ticket._links.activities.href
+ }));
+ }
+ },
+ methods: {
+ formatDate(dateString) {
+ return this.window.moment(dateString).format('DD.MM.YYYY HH:mm');
+ }
+ }
+});
diff --git a/public/js/pages/Radius/Radius.css b/public/js/pages/Radius/Radius.css
index 66f1a5ee1..ac8f00c41 100644
--- a/public/js/pages/Radius/Radius.css
+++ b/public/js/pages/Radius/Radius.css
@@ -19,7 +19,7 @@
.filters {
display: grid;
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
+ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
grid-gap: 15px;
margin-bottom: 20px;
justify-content: center;
diff --git a/public/js/pages/Radius/Radius.js b/public/js/pages/Radius/Radius.js
index 182f7a37b..bb57045ca 100644
--- a/public/js/pages/Radius/Radius.js
+++ b/public/js/pages/Radius/Radius.js
@@ -273,6 +273,45 @@ Vue.component('radius-ont-parser', {
}
});
+Vue.component('radius-online-state', {
+ props: ['username'],
+ template: `
+
+
+
+
+
+
+ {{ data.ip }}
+
+
+
+ {{ data.ip }}
+
+
+
+ `,
+ data() {
+ return {
+ data: null,
+ };
+ },
+ async created() {
+ await this.fetchOnlineState();
+ },
+ methods: {
+ async fetchOnlineState() {
+ const response = await fetch(window.TT_CONFIG['BASE_PATH'] + '/Radius/proxyUnsecureHTTPRequestToRadius?action2=fetchRadacct&username=' + this.username);
+ if (response.ok) this.data = await response.json();
+ }
+ }
+})
Vue.component('radius', {
template: `
@@ -292,6 +331,7 @@ Vue.component('radius', {
+
@@ -317,6 +358,11 @@ Vue.component('radius', {
@@ -419,10 +465,12 @@ Vue.component('radius', {
custnum: '',
window: window,
showRadacctModal: false,
+ checkOnlineState: 0,
radacctData: null,
}
},
async mounted() {
+ console.log("hallo");
await this.loadFreeUsers();
},
methods: {
@@ -442,7 +490,11 @@ Vue.component('radius', {
});
const response = await fetch(`${window.TT_CONFIG['BASE_PATH']}/Radius/proxyUnsecureHTTPRequestToRadius?${params.toString()}`);
if (response.ok) {
- this.radiusUsers = await response.json();
+ const users = await response.json()
+ if (users.length < 6) {
+ this.checkOnlineState = 1;
+ }
+ this.radiusUsers = users;
} else {
console.error('Failed to load radius users');
}
diff --git a/public/js/pages/WarehouseOffer/WarehouseOffer.css b/public/js/pages/WarehouseOffer/WarehouseOffer.css
new file mode 100644
index 000000000..7951745f0
--- /dev/null
+++ b/public/js/pages/WarehouseOffer/WarehouseOffer.css
@@ -0,0 +1,14 @@
+@media (min-width: 992px) {
+ .modal-lg, .modal-xl {
+ /*max width either 90% or 1120px*/
+ max-width: min(90vw, 1120px) !important;
+ }
+}
+
+@media (max-width: 992px) {
+ .warehouse-order-modal-positions-entry-container {
+ display: grid;
+ grid-template-columns: 1fr 1fr !important;
+ grid-gap: 10px;
+ }
+}
\ No newline at end of file
diff --git a/public/js/pages/WarehouseOffer/WarehouseOffer.js b/public/js/pages/WarehouseOffer/WarehouseOffer.js
new file mode 100644
index 000000000..fe1365051
--- /dev/null
+++ b/public/js/pages/WarehouseOffer/WarehouseOffer.js
@@ -0,0 +1,178 @@
+Vue.component('warehouse-offer-modal', {
+ props: {
+ id: {type: [String, Number], required: true},
+ mode: {type: String, default: 'edit'}
+ },
+ template: `
+
+ `,
+ data() {
+ return {
+ window: window,
+ positionsConfig: {
+ fields: {
+ article: {
+ type: 'autocomplete',
+ label: 'Artikel',
+ apiUrl: '/WarehouseArticle/autoComplete',
+ customFieldReference: 'WarehouseArticle',
+ },
+ amount: {type: 'input', label: 'Menge', inputType: 'number'},
+ unit: {type: 'input', label: 'Einheit'},
+ articleNumber: {type: 'input', label: 'Artikelnummer'},
+ unitPrice: {type: 'input', label: 'Einzelpreis', inputType: 'number'},
+ discount: {type: 'input', label: 'Rabatt (%)', inputType: 'number'},
+ },
+ validateForm: (formData) => {
+ const requiredFields = ['article', 'amount', 'unitPrice'];
+ for (const field of requiredFields) {
+ if (!formData[field]) {
+ window.notify('error', `Bitte füllen Sie ${this.positionsConfig.fields[field].label} aus`);
+ return false;
+ }
+ }
+ return true;
+ },
+ },
+ alternativePositionsConfig: {
+ fields: {
+ article: {type: 'input', label: 'Artikel'},
+ description: {type: 'textarea', label: 'Beschreibung'},
+ },
+ },
+ paymentTerms: [
+ {value: 'net30', text: '30 Tage netto'},
+ {value: 'net60', text: '60 Tage netto'},
+ {value: 'immediate', text: 'Sofort fällig'},
+ ],
+ deliveryTerms: [
+ {value: 'ex_works', text: 'Ab Werk'},
+ {value: 'free_delivery', text: 'Frei Haus'},
+ {value: 'fob', text: 'FOB'},
+ ],
+ closingTexts: [
+ {value: 'standard', text: 'Standardtext'},
+ {value: 'custom1', text: 'Angepasster Text 1'},
+ {value: 'custom2', text: 'Angepasster Text 2'},
+ ],
+ offer: {
+ editor: window.TT_CONFIG['USER_ID'],
+ customerNumber: '',
+ reference: '',
+ purpose: '',
+ customerName: '',
+ customerStreet: '',
+ customerZip: '',
+ customerCity: '',
+ customerVAT: '',
+ positions: [],
+ alternativePositions: [],
+ totalDiscount: 0,
+ paymentTerms: 'net30',
+ deliveryTerms: 'ex_works',
+ closingText: 'standard',
+ notes: '',
+ }
+ }
+ },
+ async mounted() {
+ if (this.id !== 'create') {
+ const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOffer/getById`, {params: {id: this.id}});
+ this.offer = response.data;
+ this.offer.positions = JSON.parse(this.offer.positions);
+ this.offer.alternativePositions = JSON.parse(this.offer.alternativePositions);
+ }
+ },
+ methods: {
+ async submit() {
+ if (this.offer.positions.length === 0) return window.notify('error', 'Bitte fügen Sie mindestens eine Position hinzu.');
+
+ const url = this.id === 'create'
+ ? `${window.TT_CONFIG["BASE_PATH"]}/WarehouseOffer/create`
+ : `${window.TT_CONFIG["BASE_PATH"]}/WarehouseOffer/update`;
+
+ const response = await axios.post(url, this.offer);
+
+ if (response.data.success) {
+ window.notify('success', response.data.message ?? 'Angebot erfolgreich gespeichert');
+ this.$emit('close');
+ } else {
+ window.notify('error',
+ response.data.errors ? Object.values(response.data.errors).join('
') : response.data.message || 'Ein Fehler ist aufgetreten');
+ }
+ },
+ async fetchArticleData(article) {
+ if (typeof article === 'number') {
+ const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseArticle/getById`, {params: {id: article}});
+ this.$refs.positionsManager.updateField('articleNumber', response.data.articleNumber);
+ this.$refs.positionsManager.updateField('unitPrice',
+ Object.values(JSON.parse(response.data.cheapestSellPrice)).find(price => price.title === 'Verkauf').price);
+ this.$refs.positionsManager.updateField('unit', response.data.unit);
+ }
+ },
+ },
+});
+
+Vue.component('warehouse-offer', {
+ template: `
+
+ `,
+ data() {
+ return {
+ window: window,
+ offerModalId: null,
+ }
+ },
+});
diff --git a/public/js/pages/WarehouseOrder/WarehouseOrder.css b/public/js/pages/WarehouseOrder/WarehouseOrder.css
index 878a34a77..9b3746d82 100644
--- a/public/js/pages/WarehouseOrder/WarehouseOrder.css
+++ b/public/js/pages/WarehouseOrder/WarehouseOrder.css
@@ -24,4 +24,29 @@
grid-template-columns: 1fr 1fr !important;
grid-gap: 10px;
}
-}
\ No newline at end of file
+}
+
+
+/* Expanded Row Styling */
+.order-summary {
+ padding: 1rem;
+}
+.position-item {
+ margin-bottom: 1rem;
+ border: 1px solid #ddd;
+ border-radius: 4px;
+}
+.position-header {
+ background-color: #f0f0f0;
+ padding: 0.5rem;
+ font-weight: bold;
+}
+.position-details {
+ display: grid;
+ grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
+ padding: 0.5rem;
+}
+.field-item {
+ margin-bottom: 0.5rem;
+}
+
diff --git a/public/js/pages/WarehouseOrder/WarehouseOrder.js b/public/js/pages/WarehouseOrder/WarehouseOrder.js
index fcd97373a..c9b937d86 100644
--- a/public/js/pages/WarehouseOrder/WarehouseOrder.js
+++ b/public/js/pages/WarehouseOrder/WarehouseOrder.js
@@ -16,6 +16,7 @@ Vue.component('warehouse-order-modal', {
sm
row
v-model="order.editor"/>
+
@@ -80,6 +81,7 @@ Vue.component('warehouse-order-modal', {
},
},
order: {
+ extReference: '',
delAddrName: 'XINON GmbH',
delAddrLine: 'Fladnitz im Raabtal 150',
delAddrPLZ: '8322',
@@ -92,11 +94,13 @@ Vue.component('warehouse-order-modal', {
}
},
async mounted() {
- if (this.id !== 'create') {
- const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getById`, {params: {id: this.id}});
- response.data.positions = JSON.parse(response.data.positions);
- this.order = response.data;
- }
+ if (this.id === 'create') return;
+
+ console.log(this.id);
+
+ const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getById?disableParse`, {params: {id: this.id}});
+ response.data.positions = JSON.parse(response.data.positions);
+ this.order = response.data;
},
methods: {
async submit() {
@@ -112,18 +116,20 @@ Vue.component('warehouse-order-modal', {
positions: this.order.positions.filter(position => position.distributorId === distributorId)
}
);
- if (response.data.success) window.notify('success', response.data.message ?? 'Bestellung erfolgreich erstellt');
- else window.notify('error',
+ if (response.data.success) {
+ this.$emit('close');
+ window.notify('success', response.data.message ?? 'Bestellung erfolgreich erstellt');
+ } else window.notify('error',
response.data.errors ? Object.values(response.data.errors).join('
') : response.data.message || 'Ein Fehler ist aufgetreten');
}
} else {
const response = await axios.post(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/update`, this.order);
- if (response.data.success) window.notify('success', response.data.message ?? 'Bestellung erfolgreich aktualisiert');
- else window.notify('error',
+ if (response.data.success) {
+ this.$emit('close');
+ window.notify('success', response.data.message ?? 'Bestellung erfolgreich aktualisiert');
+ } else window.notify('error',
response.data.errors ? Object.values(response.data.errors).join('
') : response.data.message || 'Ein Fehler ist aufgetreten');
}
- this.$emit('close');
-
},
async fetchDistributors(article) {
const url = `${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getArticleDistributorData`;
@@ -148,22 +154,93 @@ Vue.component('warehouse-order-modal', {
},
});
-
-Vue.component('warehouse-order', {
+Vue.component('warehouse-order-detail', {
//language=Vue
template: `
- `, data() {
- return {
- window: window,
- orderModalId: null,
+
+
+
+ `,
+ props: {
+ id: {type: [String, Number], required: true}
+ },
+ data() {
+ return {
+ window: window,
+ order: {},
+ loading: true
}
},
-})
\ No newline at end of file
+ async mounted() {
+ const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseOrder/getById`, {params: {id: this.id}});
+ this.order = response.data;
+ this.loading = false;
+ },
+});
+
+Vue.component('warehouse-order', {
+ template: `
+
+ `,
+ data() {
+ return {
+ orderModalId: null,
+ }
+ },
+ methods: {
+ closeOrderModal() {
+ this.orderModalId = null;
+ this.$refs.table.$refs.table.refreshTable();
+ },
+ calculateSum(positions) {
+ return positions.reduce((sum, position) => sum + position.amount * position.buyPrice, 0);
+ }
+ }
+});
diff --git a/public/js/pages/WarehouseProject/WarehouseProject.css b/public/js/pages/WarehouseProject/WarehouseProject.css
new file mode 100644
index 000000000..7951745f0
--- /dev/null
+++ b/public/js/pages/WarehouseProject/WarehouseProject.css
@@ -0,0 +1,14 @@
+@media (min-width: 992px) {
+ .modal-lg, .modal-xl {
+ /*max width either 90% or 1120px*/
+ max-width: min(90vw, 1120px) !important;
+ }
+}
+
+@media (max-width: 992px) {
+ .warehouse-order-modal-positions-entry-container {
+ display: grid;
+ grid-template-columns: 1fr 1fr !important;
+ grid-gap: 10px;
+ }
+}
\ No newline at end of file
diff --git a/public/js/pages/WarehouseProject/WarehouseProject.js b/public/js/pages/WarehouseProject/WarehouseProject.js
new file mode 100644
index 000000000..3bfeb5578
--- /dev/null
+++ b/public/js/pages/WarehouseProject/WarehouseProject.js
@@ -0,0 +1,161 @@
+Vue.component('warehouse-project-modal', {
+ props: {
+ id: { type: [String, Number], required: true },
+ mode: { type: String, default: 'edit' }
+ },
+ template: `
+
+ `,
+ data() {
+ return {
+ window: window,
+ participantsOptions: [
+ { value: 1, text: 'Person A' },
+ { value: 2, text: 'Person B' },
+ { value: 3, text: 'Person C' }
+ // Add more participants as needed
+ ],
+ positionsConfig: {
+ fields: {
+ article: {
+ type: 'autocomplete',
+ label: 'Artikel',
+ apiUrl: '/WarehouseArticle/autoComplete',
+ customFieldReference: 'WarehouseArticle',
+ },
+ hoursRequired: { type: 'input', label: 'Benötigte Stunden', inputType: 'number' },
+ amountRequired: { type: 'input', label: 'Benötigte Menge', inputType: 'number' },
+ description: { type: 'textarea', label: 'Beschreibung' }
+ },
+ validateForm(formData) {
+ const requiredFields = ['article', 'hoursRequired', 'amountRequired'];
+ for (const field of requiredFields) {
+ if (!formData[field]) {
+ window.notify('error', `Bitte füllen Sie ${this.positionsConfig.fields[field].label} aus`);
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ project: {
+ projectNumber: '',
+ description: '',
+ startDate: null,
+ endDate: null,
+ participants: [],
+ additionalParticipants: '',
+ totalSum: 0,
+ positions: [],
+ storageLocation: '',
+ notes: ''
+ }
+ };
+ },
+ async mounted() {
+ if (this.id !== 'create') {
+ const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseProject/getById`, { params: { id: this.id } });
+ this.project = response.data;
+ } else {
+ this.project.projectNumber = await this.generateProjectNumber();
+ }
+ },
+ methods: {
+ async submit() {
+ if (!this.project.description) return window.notify('error', 'Bitte geben Sie eine Beschreibung ein.');
+
+ const url = this.id === 'create'
+ ? `${window.TT_CONFIG["BASE_PATH"]}/WarehouseProject/create`
+ : `${window.TT_CONFIG["BASE_PATH"]}/WarehouseProject/update`;
+
+ const response = await axios.post(url, this.project);
+
+ if (response.data.success) {
+ window.notify('success', response.data.message ?? 'Projekt erfolgreich gespeichert');
+ this.$emit('close');
+ } else {
+ window.notify('error', response.data.errors ? Object.values(response.data.errors).join('
') : response.data.message || 'Ein Fehler ist aufgetreten');
+ }
+ },
+ async fetchArticleData(article) {
+ if (typeof article === 'number') {
+ const response = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseArticle/getById`, { params: { id: article } });
+ this.$refs.positionsManager.updateField('description', response.data.description);
+ }
+ },
+ async generateProjectNumber() {
+ const currentCount = await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseProject/count`);
+ return `PRJ-${new Date().getFullYear()}-${String(currentCount.data + 1).padStart(4, '0')}`;
+ }
+ }
+});
+
+
+Vue.component('warehouse-project', {
+ template: `
+
+ `,
+ data() {
+ return {
+ window: window,
+ projectModalId: null,
+ }
+ },
+});
diff --git a/public/plugins/vue/tt-components/tt-position-manager.js b/public/plugins/vue/tt-components/tt-position-manager.js
index 182f5b04e..7d8996bbd 100644
--- a/public/plugins/vue/tt-components/tt-position-manager.js
+++ b/public/plugins/vue/tt-components/tt-position-manager.js
@@ -33,6 +33,13 @@ Vue.component('tt-positions-manager', {
:api-url="window.TT_CONFIG['BASE_PATH'] + field.apiUrl"
sm
/>
+