diff --git a/Layout/default/Timerecording/Index.php b/Layout/default/Timerecording/Index.php index e2c277573..a0ef105e5 100644 --- a/Layout/default/Timerecording/Index.php +++ b/Layout/default/Timerecording/Index.php @@ -149,7 +149,7 @@ $mindate = date("Y-m-d", strtotime("+ 1 Month", $closedmonth)); data-comment="require_comment ?>" data-hourday="hourday ?>" data-businesstrip="businesstrip ?>" - data-homeoffice="hourday == 1) ? 1 : 0 ?>">name ?> + data-homeoffice="hourday == 1 && $timerecordingCategories->approval_fibu == 0) ? 1 : 0 ?>">name ?>
- +
approval) echo 'checked="checked"'; ?> - type="checkbox" name="approval" value="1" id="olt"> + type="checkbox" name="approval" value="1"> +
+
+
+
+ +
+
+ approval_fibu) echo 'checked="checked"'; ?> + type="checkbox" name="approval_fibu" value="1" >
diff --git a/Layout/default/TimerecordingCategories/Index.php b/Layout/default/TimerecordingCategories/Index.php index 81014cbd4..880ae1fa0 100644 --- a/Layout/default/TimerecordingCategories/Index.php +++ b/Layout/default/TimerecordingCategories/Index.php @@ -41,7 +41,7 @@ Beizeichnung BMD KZ Buchungszeitraum - Genehmigungspflichtig + Genehmigungspf. GF/BH Dienstreisemöglichkeit Anmerkung Pflichtfeld Nur Buchhaltung @@ -66,7 +66,7 @@ name ?> short ?> hourday] ?> - approval] ?> + approval] ." / ".$timerecordingcategoriesapproval[$timerecordingcategories->approval_fibu] ?> businesstrip] ?> require_comment] ?> only_admin] ?> diff --git a/Layout/default/TimerecordingPermitFibu/Index.php b/Layout/default/TimerecordingPermitFibu/Index.php new file mode 100644 index 000000000..a7e83620d --- /dev/null +++ b/Layout/default/TimerecordingPermitFibu/Index.php @@ -0,0 +1,211 @@ + + + + + + + + +
+
+
+
+ +
+

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)]; + } else if ($timerecording->timerecordingCategory->hourday == 6) { + $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)]; + $isSeconds = $isSeconds + $seconds; + } + if ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0) { + $state = ''; + } else if ($timerecording->timerecordingCategory->approval_fibu == 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 ?>comment ?> + 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;"> + + +
+ + +
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/menu.php b/Layout/default/menu.php index 69308eba0..4169b5266 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -41,7 +41,8 @@
  • "> Buchungen
  • "> Abwesenheitskalender
  • can('Fibu')): ?> -
  • "> Freigaben
  • +
  • "> Freigaben Urlaub/ZA
  • +
  • "> Freigaben Buchhaltung
  • "> Auswertung/Korrektur
  • "> Verrechnung
  • "> Reports
  • diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php index a4a697b64..60b64969a 100644 --- a/application/Timerecording/TimerecordingController.php +++ b/application/Timerecording/TimerecordingController.php @@ -474,6 +474,34 @@ class TimerecordingController extends mfBaseController $email->setTo(TT_TIMERECORDING_EMAIL); $email->send(); } + else if ($timerecordingCategoriess[0]->approval_fibu == "1" && !$r->user_id) + { + $body = 'Beantrag von: ' . $this->me->name . ' +'; + $body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . ' +'; + if ($timerecordingCategoriess[0]->hourday == "1") { + $body .= 'von: ' . date("d.m.Y H:i", $data['start']) . ' bis: ' . date("H:i", $data['end']); + } else if ($timerecordingCategoriess[0]->hourday == "2") { + $body .= 'von: ' . date("d.m.Y", $data['start']) . ' bis: ' . date("d.m.Y", $data['end']); + } else if ($timerecordingCategoriess[0]->hourday == "6") { + $body .= 'von: ' . date("d.m.Y H:i", $data['start']) . ' bis: ' . date("H:i", $data['end']); + } + /* + $email = new Emailnotification(); + $email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' erstellt'); + $email->setBody($body); + $email->setFrom(TT_TIMERECORDING_EMAIL, TT_TIMERECORDING_EMAIL_NAME); + $email->setTo($this->me->email); + $email->send(); +*/ + $email = new Emailnotification(); + $email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' erstellt (' . $this->me->name . ')'); + $email->setBody($body); + $email->setFrom(TT_TIMERECORDING_EMAIL_FIBU, TT_TIMERECORDING_EMAIL_FIBU_NAME); + $email->setTo(TT_TIMERECORDING_EMAIL_FIBU); + $email->send(); + } if ($data['timerecordingCategory_id'] == "3" || $timerecordingCategoriess[0]->hourday == "5") { $this->updateHolidays($data['user_id']); } @@ -1091,9 +1119,9 @@ class TimerecordingController extends mfBaseController } } - if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { + if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0)) { $state = ''; - } else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) { + } else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1 )) { $state = ''; } $edit = ""; diff --git a/application/Timerecording/TimerecordingModel.php b/application/Timerecording/TimerecordingModel.php index f4ab93074..1e61bcf60 100644 --- a/application/Timerecording/TimerecordingModel.php +++ b/application/Timerecording/TimerecordingModel.php @@ -125,6 +125,25 @@ class TimerecordingModel } return $items; + } + public static function getAllPermitsFibu() + { + $items = []; + + $db = FronkDB::singleton(); + + $sql = "SELECT Timerecording.* FROM `Timerecording` + INNER JOIN `TimerecordingCategory` ON (`Timerecording`.`timerecordingCategory_id` = `TimerecordingCategory`.`id`) + WHERE `TimerecordingCategory`.`approval_fibu`='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() diff --git a/application/TimerecordingCategory/TimerecordingCategoryController.php b/application/TimerecordingCategory/TimerecordingCategoryController.php index 1b4f115d1..bfa193681 100644 --- a/application/TimerecordingCategory/TimerecordingCategoryController.php +++ b/application/TimerecordingCategory/TimerecordingCategoryController.php @@ -84,6 +84,7 @@ class TimerecordingCategoryController extends mfBaseController $data['short'] = trim($r->short); $data['hourday'] = trim($r->hourday); $data['approval'] = trim($r->approval); + $data['approval_fibu'] = trim($r->approval_fibu); $data['require_comment'] = trim($r->require_comment); $data['only_admin'] = trim($r->only_admin); $data['businesstrip'] = trim($r->businesstrip); diff --git a/application/TimerecordingCategory/TimerecordingCategoryModel.php b/application/TimerecordingCategory/TimerecordingCategoryModel.php index e57ca7191..6bee3d49d 100644 --- a/application/TimerecordingCategory/TimerecordingCategoryModel.php +++ b/application/TimerecordingCategory/TimerecordingCategoryModel.php @@ -6,6 +6,7 @@ class TimerecordingCategoryModel private $short; private $hourday; private $approval; + private $approval_fibu; private $require_comment; private $only_admin; private $businesstrip; diff --git a/application/TimerecordingPermitFibu/TimerecordingPermitFibuController.php b/application/TimerecordingPermitFibu/TimerecordingPermitFibuController.php new file mode 100644 index 000000000..8f9767907 --- /dev/null +++ b/application/TimerecordingPermitFibu/TimerecordingPermitFibuController.php @@ -0,0 +1,123 @@ +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("TimerecordingPermitFibu/Index"); + $timerecordingCategoriess = TimerecordingCategoryModel::getAll(); + $this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess); + $timerecordings = TimerecordingModel::getAllPermitsFibu(); + $this->layout()->set("timerecordings", $timerecordings); + + } + + protected function addAction() + { + + + } + + protected function editAction() + { + + } + + protected function saveAction() + { + } + + protected function sendMail($timerecordings, $type) + { + if ($type == "deny") { + $sendtext = "abgelehnt"; + } else if ($type == "approve") { + $sendtext = "genehmigt"; + } + $user = UserModel::getOne($timerecordings->user_id); + $timerecordingCategoriess = TimerecordingCategoryModel::search(['id' => $timerecordings->timerecordingCategory_id]); + $body = 'Beantrag von: ' . $user->name . ' +'; + $body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . ' +'; + if ($timerecordingCategoriess[0]->hourday == "1") { + $body .= 'von: ' . date("d.m.Y H:i", $timerecordings->start) . ' bis: ' . date("H:i", $timerecordings->end) . ' + +'; + } else if ($timerecordingCategoriess[0]->hourday == "2") { + $body .= 'von: ' . date("d.m.Y", $timerecordings->start) . ' bis: ' . date("d.m.Y", $timerecordings->end) . ' + +'; + } + else if ($timerecordingCategoriess[0]->hourday == "6") { + $body .= 'von: ' . date("d.m.Y H:i", $timerecordings->start) . ' bis: ' . date("H:i", $timerecordings->end) . ' + +'; + } + $body .= ucfirst($sendtext) . ' von: ' . $this->me->name . ' + '; + $email = new Emailnotification(); + $email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' ' . $sendtext); + $email->setBody($body); + $email->setFrom(TT_TIMERECORDING_EMAIL, TT_TIMERECORDING_EMAIL_NAME); + $email->setTo($user->email); + $email->send(); + + $email = new Emailnotification(); + $email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' ' . $sendtext . ' (' . $user->name . ')'); + $email->setBody($body); + $email->setFrom(TT_TIMERECORDING_EMAIL, TT_TIMERECORDING_EMAIL_NAME); + $email->setTo(TT_TIMERECORDING_EMAIL); + $email->send(); + } + + 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("TimerecordingPermitFibu"); + } + $data = []; + $data['approved'] = 1; + $timerecordings->update($data); + $timerecordings->save(); + //$this->sendMail($timerecordings, "approve"); + $this->redirect("TimerecordingPermitFibu"); + } + + protected function denyAction() + { + $id = $this->request->id; + $timerecordings = new Timerecording($id); + if (!$timerecordings->id || $timerecordings->id != $id) { + $this->layout()->setFlash("Buchung nicht gefunden.", "error"); + $this->redirect("TimerecordingPermitFibu"); + } + //$this->sendMail($timerecordings, "deny"); + $timerecordings->delete(); + + + if ($this->request->ajax == 1) { + die(); + } + $this->redirect("TimerecordingPermitFibu"); + } + +} diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php index 6a2676032..6124eb66c 100644 --- a/application/TimerecordingReport/TimerecordingReportController.php +++ b/application/TimerecordingReport/TimerecordingReportController.php @@ -433,9 +433,9 @@ class TimerecordingReportController extends mfBaseController $day = $daysgerm[date("w", $timerecording->start)]; } - if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { + if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0 )|| ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0)) { $state = ''; - } else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) { + } else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1 )) { $state = ''; } $edit = ""; diff --git a/db/migrations/20251026103124_timerecording_category_add_field_approval_fibu.php b/db/migrations/20251026103124_timerecording_category_add_field_approval_fibu.php new file mode 100644 index 000000000..777e1084e --- /dev/null +++ b/db/migrations/20251026103124_timerecording_category_add_field_approval_fibu.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $table = $this->table("TimerecordingCategory", ["signed" => true]); + $table->addColumn("approval_fibu", "integer", ["null" => false, "default" => '0', "after" => "approval"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("TimerecordingCategory")->removeColumn("approval_fibu")->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +}