From 828caa35c9f13e4203316563c73dd5c8129564e6 Mon Sep 17 00:00:00 2001 From: Spitzer Daniel Date: Tue, 9 Jan 2024 16:25:26 +0100 Subject: [PATCH] Mobile Integration,Pop Multiple Networks,DataTables responsible update,Migrations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mobile Integration: * in footer.php js eingefügt damit das mobile Menu funktioniert * in menu.php bzw. app.css neue Klasse eingefügt mobile-hide um in der mobilen Version Menupünkte zu verstecken Pop Multiple Networks * Pops können nun mehrere Netzgebiete haben * Netzgebiete und Pop ansicht angepasst * (Script muss ausgeführt werden um die PopNetwork Table vom Bestand zu befüllen) DataTables responsible update * Datatables update und responsible addon * Diverse Anpassungen für Responsible in: - Pops, Geräte Hersteller, Geräte Typen, Devices, Benutzer Anpassungen auf neu getProperty Migrations * PopNetwork * Poprackmodulepatch --- Layout/default/Timerecording/Index.php | 336 ++++++++++++++++++ .../default/TimerecordingCategories/Form.php | 117 ++++++ .../default/TimerecordingCategories/Index.php | 93 +++++ Layout/default/TimerecordingPermit/Index.php | 290 +++++++++++++++ Layout/default/TimerecordingReport/Index.php | 264 ++++++++++++++ Layout/default/menu.php | 23 +- application/Timerecording/Timerecording.php | 61 ++++ .../Timerecording/TimerecordingController.php | 145 ++++++++ .../Timerecording/TimerecordingModel.php | 148 ++++++++ .../TimerecordingCategory.php | 41 +++ .../TimerecordingCategoryController.php | 141 ++++++++ .../TimerecordingCategoryModel.php | 132 +++++++ .../TimerecordingPermitController.php | 62 ++++ .../TimerecordingReportController.php | 51 +++ .../20240108081420_timerecording.php | 42 +++ .../20240108081441_timerecording_category.php | 39 ++ 16 files changed, 1979 insertions(+), 6 deletions(-) create mode 100644 Layout/default/Timerecording/Index.php create mode 100644 Layout/default/TimerecordingCategories/Form.php create mode 100644 Layout/default/TimerecordingCategories/Index.php create mode 100644 Layout/default/TimerecordingPermit/Index.php create mode 100644 Layout/default/TimerecordingReport/Index.php create mode 100644 application/Timerecording/Timerecording.php create mode 100644 application/Timerecording/TimerecordingController.php create mode 100644 application/Timerecording/TimerecordingModel.php create mode 100644 application/TimerecordingCategory/TimerecordingCategory.php create mode 100644 application/TimerecordingCategory/TimerecordingCategoryController.php create mode 100644 application/TimerecordingCategory/TimerecordingCategoryModel.php create mode 100644 application/TimerecordingPermit/TimerecordingPermitController.php create mode 100644 application/TimerecordingReport/TimerecordingReportController.php create mode 100644 db/migrations/20240108081420_timerecording.php create mode 100644 db/migrations/20240108081441_timerecording_category.php diff --git a/Layout/default/Timerecording/Index.php b/Layout/default/Timerecording/Index.php new file mode 100644 index 000000000..33fdbb3e1 --- /dev/null +++ b/Layout/default/Timerecording/Index.php @@ -0,0 +1,336 @@ + + + + + +
+
+
+
+ +
+

Buchungen

+
+
+
+ +
"> +
+
+ +
+
+ + + + +
+
+ +
+
+ " + placeholder="" required="required"/> +
+
+
+ +
+
+
+ + + + +
+
+ + + + +
+ +
+
+
+ + + +
+
+
+
+ + +
+
+
+ + + +
+
+
+
+
+
+

Liste aller Buchungen

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + start; + if ($timerecording->timerecordingCategory->hourday == 1) { + $date = date("d.m.Y", $timerecording->start); + $datadate = date("Y-m-d", $timerecording->start); + $start = date("H:i", $timerecording->start); + $end = date("H:i", $timerecording->end); + $seconds = $timerecording->end - $timerecording->start; + $minutes = floor(($seconds % 3600) / 60); + $hours = floor($seconds / 3600); + $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes); + $day = $daysgerm[date("w", $timerecording->start)]; + } else if ($timerecording->timerecordingCategory->hourday == 2) { + $date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end); + $datadate = date("Y-m-d", $timerecording->start); + $enddate = date("Y-m-d", $timerecording->end); + $start = "-"; + $end = "-"; + $day=$daysgerm[date("w", $timerecording->start)]; + } else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) { + $date = date("d.m.Y", $timerecording->start); + $datadate = date("Y-m-d", $timerecording->start); + $start = "-"; + $end = "-"; + $day = $daysgerm[date("w", $timerecording->start)]; + } + + if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { + $state = ''; + } else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) { + $state = ''; + } + ?> + + + + + + + + + + + +
DatumVonBisSummeBuchungsartAnmerkung
timerecordingCategory->name ?>commend ?> + completed == 0): + if ($timerecording->approved == 0) : ?> + + +
+ + $timerecording->id]) ?>" + onclick="if(!confirm('Buchung wirklich löschen?')) return false;" class="text-danger" + title="Löschen"> + +
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingCategories/Form.php b/Layout/default/TimerecordingCategories/Form.php new file mode 100644 index 000000000..f7ca11247 --- /dev/null +++ b/Layout/default/TimerecordingCategories/Form.php @@ -0,0 +1,117 @@ + + + + +
+
+
+
+ +
+

id) ? "Zeiterfassung Buchungsart bearbeiten" : "Neue Zeiterfassung Buchungsart" ?>

+
+
+
+ +
+
+ +
+
+

id) ? "Zeiterfassung Buchungsart bearbeiten" : "Neue Zeiterfassung Buchungsart" ?>

+ +
"> +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+
+ approval) echo 'checked="checked"'; ?> + type="checkbox" name="approval" value="1" id="olt"> +
+
+
+
+ +
+
+ require_comment) echo 'checked="checked"'; ?> + type="checkbox" name="require_comment" value="1" id="olt"> +
+
+
+
+
+
+ +
+ + "> + + +
+
+ + +
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingCategories/Index.php b/Layout/default/TimerecordingCategories/Index.php new file mode 100644 index 000000000..37747edcf --- /dev/null +++ b/Layout/default/TimerecordingCategories/Index.php @@ -0,0 +1,93 @@ + + + + +
+
+
+
+ +
+

Zeiterfassung Buchungsarten

+
+
+
+ + + +
+
+
+
+
+

Liste aller Zeiterfassung Buchungsarten

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BeizeichnungBMD KZBuchungszeitraumGenehmigungspflichtigAnmerkung Pflichtfeld
name ?>short ?>hourday] ?>approval] ?>require_comment] ?> + $timerecordingcategories->id]) ?>"> + $timerecordingcategories->id]) ?>" + onclick="if(!confirm('Zeiterfassung Kategorie wirklich löschen?')) return false;" class="text-danger" + title="Löschen"> +
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingPermit/Index.php b/Layout/default/TimerecordingPermit/Index.php new file mode 100644 index 000000000..ad5045ded --- /dev/null +++ b/Layout/default/TimerecordingPermit/Index.php @@ -0,0 +1,290 @@ + + + + + + +
+
+
+
+ +
+

Buchungen

+
+
+
+ +
+
+
+
+
+

Liste aller Buchungen

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + start; + if ($timerecording->timerecordingCategory->hourday == 1) { + $date = date("d.m.Y", $timerecording->start); + $datadate = date("Y-m-d", $timerecording->start); + $start = date("H:i", $timerecording->start); + $end = date("H:i", $timerecording->end); + $seconds = $timerecording->end - $timerecording->start; + $minutes = floor(($seconds % 3600) / 60); + $hours = floor($seconds / 3600); + $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes); + $day = $daysgerm[date("w", $timerecording->start)]; + } else if ($timerecording->timerecordingCategory->hourday == 2) { + $date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end); + $datadate = date("Y-m-d", $timerecording->start); + $enddate = date("Y-m-d", $timerecording->end); + $start = "-"; + $end = "-"; + $day=$daysgerm[date("w", $timerecording->start)]; + } else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) { + $date = date("d.m.Y", $timerecording->start); + $datadate = date("Y-m-d", $timerecording->start); + $start = "-"; + $end = "-"; + $day = $daysgerm[date("w", $timerecording->start)]; + } + + if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { + $state = ''; + } else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) { + $state = ''; + } + $approved = 'Offen'; + if ($timerecording->approved == 1) $approved = 'Genehmigt'; + $completed = 'Genehmigt'; +// if ($timerecording->completed == 1) $completed = 'Genehmigt'; + ?> + + + + + + + + + + + + + +
DatumMitarbeiterVonBisSummeBuchungsartAnmerkungFreigabe
user->name ?>timerecordingCategory->name ?>commend ?> + completed == 0): + if ($timerecording->approved == 0) : ?> + $timerecording->id]) ?>" + onclick="if(!confirm('Buchung genehmigen?')) return false;"> + $timerecording->id]) ?>" + onclick="if(!confirm('Buchung wirklich ablehnen?')) return false;" + class="text-danger" + title="Ablehnen"> + +
+ + id + ?> + + timerecordingCategory->id + ?> + + + + + $timerecording->id]) + ?> + + + +
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingReport/Index.php b/Layout/default/TimerecordingReport/Index.php new file mode 100644 index 000000000..5eaac5630 --- /dev/null +++ b/Layout/default/TimerecordingReport/Index.php @@ -0,0 +1,264 @@ + + + + + +
+
+
+
+ +
+

Buchungen

+
+
+
+ +
+
+
+
+
+

Liste aller Buchungen

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + start; + if ($timerecording->timerecordingCategory->hourday == 1) { + $date = date("d.m.Y", $timerecording->start); + $datadate = date("Y-m-d", $timerecording->start); + $start = date("H:i", $timerecording->start); + $end = date("H:i", $timerecording->end); + $seconds = $timerecording->end - $timerecording->start; + $minutes = floor(($seconds % 3600) / 60); + $hours = floor($seconds / 3600); + $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes); + $day = $daysgerm[date("w", $timerecording->start)]; + } else if ($timerecording->timerecordingCategory->hourday == 2) { + $date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end); + $datadate = date("Y-m-d", $timerecording->start); + $enddate = date("Y-m-d", $timerecording->end); + $start = "-"; + $end = "-"; + $day = $daysgerm[date("w", $timerecording->start)]; + } else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) { + $date = date("d.m.Y", $timerecording->start); + $datadate = date("Y-m-d", $timerecording->start); + $start = "-"; + $end = "-"; + $day = $daysgerm[date("w", $timerecording->start)]; + } + + if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { + $state = ''; + } else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) { + $state = ''; + } + $completed = 'Nein'; + if ($timerecording->completed == 1) $completed = 'Ja'; + + ?> + + + + + + + + + + +completed == 0): +// if ($timerecording->approved == 0) : ?> +id ?> + +timerecordingCategory->id ?> + + + + + + + + $timerecording->id]) ?> + + + + + + + +
DatumMitarbeiterVonBisSummeBuchungsartAnmerkungVerbucht
user->name ?>timerecordingCategory->name ?>commend ?>
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/menu.php b/Layout/default/menu.php index 137750cc2..831cb3181 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -29,7 +29,18 @@ - + is("employee")): ?> +
  • Zeiterfassung
    + +
  • + is(["Admin"]) || ($me->is("netowner") && $me->hasGwrNetworks())): ?>
  • @@ -54,7 +65,7 @@ is(["Admin"]) || ($me->is("netowner") && $me->hasGwrNetworks())): ?>
  • "> GWR / AddressDB
  • - + is(["Admin"])): ?>
  • "> Open Access IDs
  • "> Technologien
  • @@ -64,8 +75,8 @@ - - + + is(["Admin","netowner","lineplanner","pipeplanner","pipeworker","lineworker"])): ?>
  • @@ -104,7 +115,7 @@
  • - + is(["Admin","netowner","salespartner"]) || $me->can(["Order", "Preorder"])): ?>
  • @@ -134,7 +145,7 @@
  • --> - + diff --git a/application/Timerecording/Timerecording.php b/application/Timerecording/Timerecording.php new file mode 100644 index 000000000..86c9aeade --- /dev/null +++ b/application/Timerecording/Timerecording.php @@ -0,0 +1,61 @@ +$name == null) { + + if (!$this->id) { + return null; + } + + 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); + 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/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php new file mode 100644 index 000000000..0996afd98 --- /dev/null +++ b/application/Timerecording/TimerecordingController.php @@ -0,0 +1,145 @@ +needlogin = true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me", $me); + + if (!$me->is(["employee"])) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() + { + $this->layout()->setTemplate("Timerecording/Index"); + $timerecordingCategoriess = TimerecordingCategoryModel::getAll(); + $this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess); + $timerecordings = TimerecordingModel::search(['user_id' => $this->me->id]); + $this->layout()->set("timerecordings", $timerecordings); + } + + protected function addAction() + { + $timerecordingCategoriess = TimerecordingCategoryModel::getAll(); + $this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess); + $this->layout()->setTemplate("Timerecording/Form"); + } + + protected function editAction() + { + $id = $this->request->id; + + if (!is_numeric($id) || !$id) { + $this->layout()->setFlash("Buchung nicht gefunden", "error"); + $this->redirect("Timerecording"); + } + + $timerecordings = new Timerecording($id); + if ($timerecordings->id != $id) { + $this->layout()->setFlash("Buchung nicht gefunden", "error"); + $this->redirect("Timerecording"); + } + + + $this->layout()->set("timerecordings", $timerecordings); + return $this->addAction(); + } + + protected function saveAction() + { + $r = $this->request; + $id = $r->id; + $enddate = $r->enddate; + if (!$enddate && $r->start && $r->end) { + $starttime = strtotime($r->date . " " . $r->start . ":00"); + $endtime = strtotime($r->date . " " . $r->end . ":00"); + } elseif ($enddate) { + $starttime = strtotime($r->date . " 00:00:00"); + $endtime = strtotime($enddate . " 23:59:00"); + } else if (!$enddate && !$r->start && !$r->end) { + $starttime = strtotime($r->date . " 00:00:00"); + $endtime = NULL; + } + + if (is_numeric($id) && $id > 0) { + $mode = "edit"; + $timerecordings = new Timerecording($id); + if (!$timerecordings->id) { + $this->layout()->setFlash("Buchungen nicht gefunden", "error"); + $this->redirect("Timerecording"); + } + } else { + $mode = "add"; + } + + $data = []; + $data['user_id'] = $this->me->id; + $data['start'] = $starttime; + $data['end'] = $endtime; + $data['timerecordingCategory_id'] = trim($r->timerecordingCategory_id); + $data['commend'] = trim($r->commend); + + if (!$data['user_id']) { + $this->layout()->setFlash("Benutzer darf nicht leer sein", "error"); + $this->redirect("Timerecording"); + } + if ($data['start'] < 1577833200) { + $this->layout()->setFlash("Ungültige Startzeit", "error"); + $this->redirect("Timerecording"); + } + if ($data['end'] && $data['end'] < 1577833200) { + $this->layout()->setFlash("Ungültige Endzeit", "error"); + $this->redirect("Timerecording"); + } + if (!$data['timerecordingCategory_id']) { + $data['timerecordingCategory_id'] = NULL; + } + if (!$data['commend']) { + $data['commend'] = NULL; + } + + if ($mode == "edit") { + $timerecordings->update($data); + + } else { + $timerecordings = TimerecordingModel::create($data); + } +// var_dump($filestore); +// exit; + $id = $timerecordings->save(); + + if (!$id) { + $this->layout()->setFlash("Buchung konnte nicht angelegt werden", "error"); + $this->redirect("Timerecording"); + } + + if ($mode == "edit") { + $this->layout()->setFlash("Buchung erfolgreich geändert", "success"); + } else if ($mode = "add") { + $this->layout()->setFlash("Buchung erfolgreich angelegt", "success"); + } + $this->redirect("Timerecording"); + } + + + protected function deleteAction() + { + $id = $this->request->id; + $timerecordings = new Timerecording($id); + if (!$timerecordings->id || $timerecordings->id != $id) { + $this->layout()->setFlash("Buchung nicht gefunden.", "error"); + $this->redirect("Timerecording"); + } + + $timerecordings->delete(); + $this->redirect("Timerecording"); + } + +} diff --git a/application/Timerecording/TimerecordingModel.php b/application/Timerecording/TimerecordingModel.php new file mode 100644 index 000000000..f8b6b8039 --- /dev/null +++ b/application/Timerecording/TimerecordingModel.php @@ -0,0 +1,148 @@ + $value) { + if (property_exists(get_called_class(), $field)) { + if (substr($field, 0, 5) == "vlan_" && !$value) { + $model->$field = null; + continue; + } + $model->$field = $value; + } + } + + $me = mfValuecache::singleton()->get("me"); + if (!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::singleton()->set("me", $me); + } + + 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 getOne($id) + { + if (!is_numeric($id) || !$id) { + throw new Exception("Invalid number", 400); + } + $item = []; + $db = FronkDB::singleton(); + + $res = $db->select("Timerecording", "*", "id=$id LIMIT 1"); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Timerecording($data); + } + return $item; + } + + public static function getAll() + { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("Timerecording", "*", "1=1"); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new Timerecording($data); + } + } + return $items; + + } + public static function getAllPermits() + { + $items = []; + + $db = FronkDB::singleton(); + + $sql = "SELECT Timerecording.* FROM `Timerecording` + INNER JOIN `TimerecordingCategory` ON (`Timerecording`.`timerecordingCategory_id` = `TimerecordingCategory`.`id`) + WHERE `TimerecordingCategory`.`approval`='1'"; + + $res = $db->query($sql); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new Timerecording($data); + } + } + return $items; + + } + + public static function getFirst() + { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("Timerecording", "*", "$where "); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new Timerecording($data); + if ($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function search($filter) + { + $items = []; + $db = FronkDB::singleton(); + $where = self::getSqlFilter($filter); + $res = $db->select("Timerecording", "*", "$where"); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new Timerecording($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) + { + $where = "1=1 "; + + if (array_key_exists("user_id", $filter)) { + $userid = $filter['user_id']; + if (is_numeric($userid)) { + $where .= " AND user_id=$userid"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} diff --git a/application/TimerecordingCategory/TimerecordingCategory.php b/application/TimerecordingCategory/TimerecordingCategory.php new file mode 100644 index 000000000..c3166ba7c --- /dev/null +++ b/application/TimerecordingCategory/TimerecordingCategory.php @@ -0,0 +1,41 @@ +$name == null) { + + if (!$this->id) { + return null; + } + + if ($name == "creator") { + $this->creator = new User($this->create_by); + return $this->creator; + } + + if ($name == "editor") { + $this->editor = new User($this->edit_by); + return $this->editor; + } + + $classname = ucfirst($name); + $idfield = $name . "_id"; + $this->$name = new $classname($this->$idfield); + + if ($this->$name->id) { + return $this->$name; + } else { + return null; + } + } + + return $this->$name; + } + +} \ No newline at end of file diff --git a/application/TimerecordingCategory/TimerecordingCategoryController.php b/application/TimerecordingCategory/TimerecordingCategoryController.php new file mode 100644 index 000000000..7237ea75c --- /dev/null +++ b/application/TimerecordingCategory/TimerecordingCategoryController.php @@ -0,0 +1,141 @@ +needlogin = true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me", $me); + + if (!$me->can(["Fibu"])) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() + { + + $this->layout()->setTemplate("TimerecordingCategories/Index"); + $timerecordingcategoriesapproval = TimerecordingCategoryModel::$approval_definition; + $timerecordingcategorieshourday = TimerecordingCategoryModel::$hourday_definition; + $timerecordingcategoriesrequire_comment = TimerecordingCategoryModel::$require_comment_definition; + $timerecordingcategoriess = TimerecordingCategoryModel::getAll(); + $this->layout()->set("timerecordingcategoriesrequire_comment", $timerecordingcategoriesrequire_comment); + $this->layout()->set("timerecordingcategorieshourday", $timerecordingcategorieshourday); + $this->layout()->set("timerecordingcategoriesapproval", $timerecordingcategoriesapproval); + $this->layout()->set("timerecordingcategoriess", $timerecordingcategoriess); + + } + + protected function addAction() + { + $timerecordingcategorieshourday = TimerecordingCategoryModel::$hourday_definition; + $this->layout()->set("timerecordingcategorieshourday", $timerecordingcategorieshourday); + $this->layout()->setTemplate("TimerecordingCategories/Form"); + + } + + protected function editAction() + { + $id = $this->request->id; + + if (!is_numeric($id) || !$id) { + $this->layout()->setFlash("Zeiterfassung Kategorie nicht gefunden", "error"); + $this->redirect("TimerecordingCategory"); + } + + $timerecordingcategoriess = new TimerecordingCategory($id); + if ($timerecordingcategoriess->id != $id) { + $this->layout()->setFlash("Zeiterfassung Kategorie nicht gefunden", "error"); + $this->redirect("TimerecordingCategory"); + } + $timerecordingcategorieshourday = TimerecordingCategoryModel::$hourday_definition; + $this->layout()->set("timerecordingcategorieshourday", $timerecordingcategorieshourday); + $this->layout()->set("timerecordingcategoriess", $timerecordingcategoriess); + return $this->addAction(); + } + + protected function saveAction() + { + $r = $this->request; + $id = $r->id; + //var_dump($r->get());exit; + if (is_numeric($id) && $id > 0) { + $mode = "edit"; + $timerecordingcategoriess = new TimerecordingCategory($id); + if (!$timerecordingcategoriess->id) { + $this->layout()->setFlash("Zeiterfassung Kategorien nicht gefunden", "error"); + $this->redirect("TimerecordingCategory"); + } + } else { + $mode = "add"; + } + + $data = []; + $data['name'] = trim($r->name); + $data['short'] = trim($r->short); + $data['hourday'] = trim($r->hourday); + $data['approval'] = trim($r->approval); + $data['require_comment'] = trim($r->require_comment); + + + if (!$data['name']) { + $data['name'] = NULL; + } + if (!$data['short']) { + $data['short'] = NULL; + } + if (!$data['approval']) { + $data['approval'] = 0; + } + if (!$data['require_comment']) { + $data['require_comment'] = 0; + } + +// var_dump($_FILES); +// var_dump($upload); +// exit; + + + if ($mode == "edit") { + $timerecordingcategoriess->update($data); + + } else { + $timerecordingcategoriess = TimerecordingCategoryModel::create($data); + } +// var_dump($filestore); +// exit; + $id = $timerecordingcategoriess->save(); + + if (!$id) { + $this->layout()->setFlash("Zeiterfassung Kategorie konnte nicht angelegt werden", "error"); + $this->redirect("TimerecordingCategory"); + } + + if ($mode == "edit") { + $this->layout()->setFlash("Zeiterfassung Kategorie erfolgreich geändert", "success"); + } else if ($mode = "add") { + $this->layout()->setFlash("Zeiterfassung Kategorie erfolgreich angelegt", "success"); + } + $this->redirect("TimerecordingCategory"); + } + + + protected function deleteAction() + { + $id = $this->request->id; + $timerecordingcategoriess = new TimerecordingCategory($id); + if (!$timerecordingcategoriess->id || $timerecordingcategoriess->id != $id) { + $this->layout()->setFlash("Zeiterfassung Kategorie nicht gefunden.", "error"); + $this->redirect("TimerecordingCategory"); + } + + $timerecordingcategoriess->delete(); + $this->redirect("TimerecordingCategory"); + } + +} diff --git a/application/TimerecordingCategory/TimerecordingCategoryModel.php b/application/TimerecordingCategory/TimerecordingCategoryModel.php new file mode 100644 index 000000000..88aedcecb --- /dev/null +++ b/application/TimerecordingCategory/TimerecordingCategoryModel.php @@ -0,0 +1,132 @@ + "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum"); + public static $approval_definition = array(0 => "Nein", 1 => "Ja"); + public static $require_comment_definition = array(0 => "Nein", 1 => "Ja"); + + public static function find($data) + { + + } + + public static function create(array $data) + { + $model = new TimerecordingCategory(); + + foreach ($data as $field => $value) { + if (property_exists(get_called_class(), $field)) { + if (substr($field, 0, 5) == "vlan_" && !$value) { + $model->$field = null; + continue; + } + $model->$field = $value; + } + } + + $me = mfValuecache::singleton()->get("me"); + if (!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::singleton()->set("me", $me); + } + + 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 getOne($id) + { + if (!is_numeric($id) || !$id) { + throw new Exception("Invalid number", 400); + } + $item = []; + $db = FronkDB::singleton(); + + $res = $db->select("timerecordingCategory", "*", "id=$id LIMIT 1"); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new TimerecordingCategory($data); + } + return $item; + } + + public static function getAll() + { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("TimerecordingCategory", "*", "1=1"); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new TimerecordingCategory($data); + } + } + return $items; + + } + + + public static function getFirst() + { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("TimerecordingCategory", "*", "$where "); + if ($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new TimerecordingCategory($data); + if ($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function search($filter) + { + $items = []; + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $res = $db->select("TimerecordingCategory", "*", "$where"); + if ($db->num_rows($res)) { + while ($data = $db->fetch_object($res)) { + $items[] = new TimerecordingCategory($data); + } + } + return $items; + } + + private static function getSqlFilter($filter) + { + $where = "1=1 "; + + //var_dump($filter);exit; + if (array_key_exists("network_id", $filter)) { + $networkid = $filter['network_id']; + if (is_numeric($networkid)) { + $where .= " AND network_id=$networkid"; + } + } + + //var_dump($filter, $where);exit; + return $where; + } + +} diff --git a/application/TimerecordingPermit/TimerecordingPermitController.php b/application/TimerecordingPermit/TimerecordingPermitController.php new file mode 100644 index 000000000..6b9025d78 --- /dev/null +++ b/application/TimerecordingPermit/TimerecordingPermitController.php @@ -0,0 +1,62 @@ +needlogin = true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me", $me); + + if (!$me->can(["Fibu"])) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() + { + + $this->layout()->setTemplate("TimerecordingPermit/Index"); + $timerecordingCategoriess = TimerecordingCategoryModel::getAll(); + $this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess); + $timerecordings = TimerecordingModel::getAllPermits(); + $this->layout()->set("timerecordings", $timerecordings); + + } + + protected function addAction() + { + + + } + + protected function editAction() + { + + } + + protected function saveAction() + { + } + + + protected function approveAction() + { + $id = $this->request->id; + $timerecordings = new Timerecording($id); + if (!$timerecordings->id || $timerecordings->id != $id) { + $this->layout()->setFlash("Buchung nicht gefunden.", "error"); + $this->redirect("TimerecordingPermit"); + } + $data = []; + $data['approved'] = 1; + $timerecordings->update($data); + $timerecordings->save(); + + $this->redirect("TimerecordingPermit"); + } + +} diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php new file mode 100644 index 000000000..6d5396b79 --- /dev/null +++ b/application/TimerecordingReport/TimerecordingReportController.php @@ -0,0 +1,51 @@ +needlogin = true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me", $me); + + if (!$me->can(["Fibu"])) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() + { + + $this->layout()->setTemplate("TimerecordingReport/Index"); + $timerecordingCategoriess = TimerecordingCategoryModel::getAll(); + $this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess); + $timerecordings = TimerecordingModel::getAll(); + $this->layout()->set("timerecordings", $timerecordings); + + } + + protected function addAction() + { + + + } + + protected function editAction() + { + + } + + protected function saveAction() + { + } + + + protected function deleteAction() + { + + } + +} diff --git a/db/migrations/20240108081420_timerecording.php b/db/migrations/20240108081420_timerecording.php new file mode 100644 index 000000000..d24a2ab34 --- /dev/null +++ b/db/migrations/20240108081420_timerecording.php @@ -0,0 +1,42 @@ +getEnvironment() == "thetool") { + $timerecording = $this->table("Timerecording", ["signed" => true]); + $timerecording->addColumn("user_id", "integer", ["null" => false])->addIndex(["user_id"]); + $timerecording->addColumn("start", "integer", ["null" => true]); + $timerecording->addColumn("end", "integer", ["null" => true]); + $timerecording->addColumn("timerecordingCategory_id", "integer", ["null" => false]); + $timerecording->addColumn("commend", "text", ["null" => true]); + $timerecording->addColumn("approved", "integer", ["null" => false, "default" => "0"]); + $timerecording->addColumn("completed", "integer", ["null" => false, "default" => "0"]); + $timerecording->addColumn("create_by", "integer", ["null" => false]); + $timerecording->addColumn("edit_by", "integer", ["null" => false]); + $timerecording->addColumn("create", "integer", ["null" => false]); + $timerecording->addColumn("edit", "integer", ["null" => false]); + $timerecording->save(); + } + + if ($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if ($this->getEnvironment() == "thetool") { + $this->table("Timerecording")->drop()->save(); + } + + if ($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/db/migrations/20240108081441_timerecording_category.php b/db/migrations/20240108081441_timerecording_category.php new file mode 100644 index 000000000..bb3361cd5 --- /dev/null +++ b/db/migrations/20240108081441_timerecording_category.php @@ -0,0 +1,39 @@ +getEnvironment() == "thetool") { + $timerecordingCategory = $this->table("TimerecordingCategory", ["signed" => true]); + $timerecordingCategory->addColumn("name", "text", ["null" => false]); + $timerecordingCategory->addColumn("short", "string", ["null" => true, "limit" => 64]); + $timerecordingCategory->addColumn("hourday", "integer", ["null" => false, "default" => "1", "comment" => "1:Stunden/2:Tage/3:Startdatum/4:Enddatum"]); + $timerecordingCategory->addColumn("approval", "integer", ["null" => false, "default" => "0"]); + $timerecordingCategory->addColumn("require_comment", "integer", ["null" => false, "default" => "0"]); + $timerecordingCategory->addColumn("create_by", "integer", ["null" => false]); + $timerecordingCategory->addColumn("edit_by", "integer", ["null" => false]); + $timerecordingCategory->addColumn("create", "integer", ["null" => false]); + $timerecordingCategory->addColumn("edit", "integer", ["null" => false]); + $timerecordingCategory->save(); + } + + if ($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if ($this->getEnvironment() == "thetool") { + $this->table("TimerecordingCategory")->drop()->save(); + } + + if ($this->getEnvironment() == "addressdb") { + + } + } +}