diff --git a/Layout/default/AddressDB/export.csv.php b/Layout/default/AddressDB/export.csv.php index 4b6fe9cb7..c47597709 100644 --- a/Layout/default/AddressDB/export.csv.php +++ b/Layout/default/AddressDB/export.csv.php @@ -17,7 +17,7 @@ foreach(ADBStatusflagModel::getAll() as $sflag) { } ?> -AddressDB_ID;Extref;Adrcd;OAID;Status Code;Status Name;"";Netzgebiet_Extref;Netzgebiet;Rimo Building External ID;GKZ;Gemeinde;OKZ;Ortschaft;PLZ;SKZ;Strasse;Hausnummer;Grundstueck;GPS Breite;GPS Laenge;Rollout;Rollout_Info;Freigabe;Nutzungseinheiten;GDA-Eigenschaft;Meridian;RW;HW;Sichtbarkeit +AddressDB_ID;Extref;Adrcd;OAID;Status Code;Status Name;"";Netzgebiet_Extref;Netzgebiet;Rimo Building External ID;GKZ;Gemeinde;OKZ;Ortschaft;PLZ;SKZ;Strasse;Hausnummer;Grundstueck;GPS Breite;GPS Laenge;Rollout;Rollout_Info;Freigabe;Nutzungseinheiten;GDA-Eigenschaft;Meridian;RW;HW;Sichtbarkeit;Erstellt;Letzte Bearbeitung -id?>;"extref?>";adrcd?>;"oaid?>";"code?>";"name?>";;"extref?>";"name?>";"rimo_id?>";kennziffer?>;"name?>";kennziffer?>;"name?>";"plz?>";kennziffer?>;"name?>";"hausnummer?>";"grund_nr?>";gps_lat?>;gps_long?>;rollout?>;"rollout_info?>";"";;"gdaeigenschaft?>";"meridian?>";rw?>;hw?>;visibility?> - +id?>;"extref?>";adrcd?>;"oaid?>";"code?>";"name?>";;"extref?>";"name?>";"rimo_id?>";kennziffer?>;"name?>";kennziffer?>;"name?>";"plz?>";kennziffer?>;"name?>";"hausnummer?>";"grund_nr?>";gps_lat?>;gps_long?>;rollout?>;"rollout_info?>";"";;"gdaeigenschaft?>";"meridian?>";rw?>;hw?>;visibility?>;"create)?>";"edit)?>" + + +
+
+
+
+ +
+

id) ? "Emailtemplate bearbeiten" : "Neues Emailtemplate" ?>

+
+
+
+ + +
+
+ +
+
+ +
" enctype="multipart/form-data"> + +
+
+ + + +
+ + +
+ +

Emailtemplate

+ + +
+ + +
+ + + +

Dateianhänge

+
+
+
+ + +
+
+
+ + files) && count($template->files)): ?> +
+
+
+
    + files as $file): ?> +
  • filename?>
  • + +
+
+ +
+
+ + +
+
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + +
+
+ + + +
+
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/Layout/default/Mailtemplate/Index.php b/Layout/default/Mailtemplate/Index.php new file mode 100644 index 000000000..95bd3fc1b --- /dev/null +++ b/Layout/default/Mailtemplate/Index.php @@ -0,0 +1,89 @@ + + + +
+
+
+
+ +
+

Emailtemplates

+
+
+
+ + +
+
+ +
+
+

Filter

+ +
"> +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ + ">Filter zurücksetzen +
+
+
+ +
+
+ + +
+
+
+

Liste aller Emailtemplates

+
+ + + + + + + + + + + + + + + + + + + +
NameBetreffErstelltBearbeitet
name?>subject?>edit)?> (editor->name?>)create)?> (creator->name?>) + $template->id])?>"> + $template->id])?>" class="text-danger" onclick="if(!confirm('Emailtemplate wirklich löschen?')) return false;" title="Emailtemplate Löschen"> +
+
+
+ +
+
+ + diff --git a/application/ADBHausnummer/ADBHausnummer.php b/application/ADBHausnummer/ADBHausnummer.php index 0a7314804..73c98fe66 100644 --- a/application/ADBHausnummer/ADBHausnummer.php +++ b/application/ADBHausnummer/ADBHausnummer.php @@ -49,7 +49,24 @@ class ADBHausnummer extends mfBaseModel { $this->log->debug(__METHOD__.": Want new Hausnummer (".$this->id.") Status ".$new_status_code); $new_status = ADBStatusModel::getFirst(["code" => $new_status_code]); - if(!$new_status) return false; + + if(!$new_status) { + // try flag + $flag = ADBStatusflagModel::getFirst(["code" => $new_status_code]); + if(!$flag) return false; + + $this->log->debug(__METHOD__.": Statuscode $new_status_code is Flag"); + $flag_value = ADBHausnummerStatusflagValueModel::getFirst(["flag_id" => $flag->id, "hausnummer_id" => $this->id]); + if(!$flag_value) { + $flag_value = ADBHausnummerStatusflagValueModel::create([ + "hausnummer_id" => $this->id, + "flag_id" => $flag->id + ]); + } + $flag_value->value = 1; + $flag_value->save(); + return true; + } $old_status = $this->getProperty("status"); if($old_status->code < $new_status->code) { diff --git a/application/AddressDB/AddressDB.php b/application/AddressDB/AddressDB.php index fdc9eb32f..6aa50b865 100644 --- a/application/AddressDB/AddressDB.php +++ b/application/AddressDB/AddressDB.php @@ -167,6 +167,8 @@ class AddressDB { } + + break; } return true; diff --git a/application/Mailtemplate/Mailtemplate.php b/application/Mailtemplate/Mailtemplate.php new file mode 100644 index 000000000..2460ef5c5 --- /dev/null +++ b/application/Mailtemplate/Mailtemplate.php @@ -0,0 +1,46 @@ +$name == null) { + + if($name == "creator") { + $user = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($user) { + $this->creator = $user; + return $this->creator; + } + $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 = new User($this->edit_by); + return $this->editor; + } + + $classname = ucfirst($name); + $idfield = $name."_id"; + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-".$this->$idfield); + if(!$this->$name) { + $this->$name = new $classname($this->$idfield); + } + + if($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-".$this->$name->id, $this->$name); + return $this->$name; + } else { + return null; + } + } + + return $this->$name; + } +} \ No newline at end of file diff --git a/application/Mailtemplate/MailtemplateController.php b/application/Mailtemplate/MailtemplateController.php new file mode 100644 index 000000000..ee8472061 --- /dev/null +++ b/application/Mailtemplate/MailtemplateController.php @@ -0,0 +1,105 @@ +needlogin=true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me",$me); + + if(!$me->is(["Admin"])) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() { + if($this->request->resetFilter) { + unset($_SESSION[MFAPPNAME.'-Mailtemplate-filter']); + } + + $filter = []; + if(is_array($this->request->filter)) { + $filter = $this->request->filter; + $_SESSION[MFAPPNAME.'-Mailtemplate-filter'] = $filter; + } else { + if(array_key_exists(MFAPPNAME.'-Mailtemplate-filter', $_SESSION) && count($_SESSION[MFAPPNAME.'-Mailtemplate-filter'])) { + $filter = $_SESSION[MFAPPNAME.'-Mailtemplate-filter']; + } + } + + $this->layout->set("filter", $filter); + $filter = $this->getPreparedFilter($filter); + + + // pagination defaults + $pagination = []; + $pagination['start'] = 0; + $pagination['count'] = 20; + $pagination['maxItems'] = 0; + + if(is_numeric($this->request->s)) { + $pagination['start'] = intval($this->request->s); + } + + $pagination['maxItems'] = MailtemplateModel::count($filter); + $this->layout()->set("pagination", $pagination); + + $templates = MailtemplateModel::search($filter, $pagination); + $this->layout()->set("templates", $templates); + } + + private function getPreparedFilter($filter) { + $new_filter = []; + + foreach($filter as $name => $value) { + $new_filter[$name] = $value; + } + + return $new_filter; + } + + protected function addAction() { + $this->layout()->setTemplate("Mailtemplate/Form"); + + } + + protected function editAction() { + $id = $this->request->id; + $template = new Mailtemplate($id); + if(!$template->id) { + $this->layout()->setFlash("Emailtemplate nicht gefunden.", "error"); + $this->redirect("Mailtemplate"); + } + + $this->layout()->set("template", $template); + + return $this->addAction(); + } + + protected function saveAction() { + $r = $this->request; + var_dump($r->get());exit; + $id = $r->id; + + if(is_numeric($id) && $id > 0) { + $mode = "edit"; + $template = new Mailtemplate($id); + if(!$template->id) { + $this->layout()->setFlash("Emailtemplate nicht gefunden", "error"); + $this->redirect("Mailtemplate"); + } + } else { + $mode = "add"; + } + + $data = []; + $data["name"] = $r->name; + $data["subject"] = $r->subject; + //$data[""] = $r->; + //$data[""] = $r->; + //$data[""] = $r->; + + } +} \ No newline at end of file diff --git a/application/Mailtemplate/MailtemplateModel.php b/application/Mailtemplate/MailtemplateModel.php new file mode 100644 index 000000000..eafa850f0 --- /dev/null +++ b/application/Mailtemplate/MailtemplateModel.php @@ -0,0 +1,139 @@ + $value) { + if(property_exists(get_called_class(), $field)) { + $model ->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if($model->create_by === null) { + $model->create_by = $me->id; + } + if($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("Mailtemplate", "*", "1 = 1 ORDER BY name"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Mailtemplate($data); + } + } + return $items; + + } + + public static function getFirst($filter = []) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("Mailtemplate", "*", "$where ORDER BY name LIMIT 1"); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Mailtemplate($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function count($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) as cnt FROM `Mailtemplate` + WHERE $where + "; + + mfLoghandler::singleton()->debug($sql); + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + + public static function search($filter, $limit=false) { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + + $sql = "SELECT Mailtemplate.* FROM `Mailtemplate` + WHERE $where + ORDER BY name + "; + + mfLoghandler::singleton()->debug($sql); + if(is_array($limit) && count($limit)) { + if(is_numeric($limit['start']) && is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['start'].", ".$limit['count']; + } elseif(is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['count']; + } + } + + $res = $db->query($sql); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new Mailtemplate($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + $db = FronkDB::singleton(); + + //var_dump($filter);exit; + if(array_key_exists("name", $filter)) { + $name = $db->escape($filter['name']); + if($name) { + $where .= " AND Mailtemplate.`name` = '$name'"; + } + } + + if(array_key_exists("subject", $filter)) { + $subject = $db->escape($filter['subject']); + if($subject) { + $where .= " AND Mailtemplate.`subject` = '$subject'"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/db/migrations/20240822153505_create_mailtemplate.php b/db/migrations/20240822153505_create_mailtemplate.php new file mode 100644 index 000000000..ef5d08a52 --- /dev/null +++ b/db/migrations/20240822153505_create_mailtemplate.php @@ -0,0 +1,40 @@ +getEnvironment() == "thetool") { + $table = $this->table("Mailtemplate"); + $table->addColumn("name", "string", ["null" => false, "limit" => 255]); + $table->addColumn("description", "string", ["null" => true, "default" => true, "limit" => 1024]); + $table->addColumn("subject", "string", ["null" => false, "limit" => 255]); + $table->addColumn("body", "text", ["null" => false]); + $table->addColumn("note", "text", ["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("Mailtemplate")->drop()->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +}