diff --git a/Layout/default/TimerecordingCategories/Form.php b/Layout/default/TimerecordingCategories/Form.php index 8dfae15f3..6e21f051f 100644 --- a/Layout/default/TimerecordingCategories/Form.php +++ b/Layout/default/TimerecordingCategories/Form.php @@ -65,7 +65,8 @@
- approval) echo 'checked="checked"'; ?> + approval) echo 'checked="checked"'; ?> type="checkbox" name="approval" value="1" id="olt">
@@ -75,25 +76,30 @@ Pflichtfeld
- require_comment) echo 'checked="checked"'; ?> + require_comment) echo 'checked="checked"'; ?> type="checkbox" name="require_comment" value="1">
- +
- businesstrip) echo 'checked="checked"'; ?> + businesstrip) echo 'checked="checked"'; ?> type="checkbox" name="businesstrip" value="1">
- +
- only_admin) echo 'checked="checked"'; ?> + only_admin) echo 'checked="checked"'; ?> type="checkbox" name="only_admin" value="1">
@@ -130,6 +136,15 @@ $('form').on('blur', 'input[type=number]', function (e) { $(this).off('wheel.disableScroll') }); + $(document).ready(function () { + $("body").on("change", "#hourday", function () { + if ($(this).val() == 5) { + $("#only_admin").prop("checked", true); + } else { + } + }); + $("#hourday").change(); + }); \ No newline at end of file diff --git a/Layout/default/TimerecordingReport/Index.php b/Layout/default/TimerecordingReport/Index.php index bfbdee064..eb85aa984 100644 --- a/Layout/default/TimerecordingReport/Index.php +++ b/Layout/default/TimerecordingReport/Index.php @@ -92,7 +92,9 @@ $years[time() - 31536000] = date('Y', time() - 31536000); .fixed-state { background-color: #d0fbd9; } - + .form-check-label { + margin-top: 2px; + }
@@ -141,7 +143,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000); data-comment="require_comment ?>" data-hourday="hourday ?>" data-businesstrip="businesstrip ?>" - data-homeoffice="hourday==1) ? 1 : 0 ?>">name ?> + data-homeoffice="hourday == 1) ? 1 : 0 ?>">name ?> @@ -186,6 +188,16 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
+ +
-
+
@@ -326,7 +338,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000); - + diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php index 81d9215e1..b05da577a 100644 --- a/application/Timerecording/TimerecordingController.php +++ b/application/Timerecording/TimerecordingController.php @@ -169,10 +169,14 @@ class TimerecordingController extends mfBaseController } else if ($hourday == 3) { $starttime = strtotime($r->date . " 00:00:00"); $endtime = NULL; + } else if ($hourday == 5) { + $starttime = strtotime($r->date . " 00:00:00"); + $endtime = strtotime($r->date . " 23:59:00"); } - - $result = $this->checkTimerecording($starttime, $endtime, $id); + if ($hourday != 5) { + $result = $this->checkTimerecording($starttime, $endtime, $id); + } if ($result['state'] == "error") { if ($r->ajax == 1) { echo json_encode($result); @@ -208,6 +212,7 @@ class TimerecordingController extends mfBaseController $data['businesstrip'] = $r->businesstrip; $data['businesstrip_info'] = $r->businesstrip_info; $data['homeoffice'] = $r->homeoffice; + $data['days'] = $r->days; if (!$data['businesstrip'] || $data['businesstrip'] == "false") { $data['businesstrip'] = 0; @@ -215,6 +220,9 @@ class TimerecordingController extends mfBaseController if (!$data['homeoffice'] || $data['homeoffice'] == "false") { $data['homeoffice'] = 0; } + if (!$data['days'] || $data['days'] == "false") { + $data['days'] = 0; + } if ($r->businesstrip == 1 && !$r->businesstrip_info) { $result['state'] = "error"; $result['error'] = "Geschäftsreiseinformationen darf nicht leer sein"; @@ -227,16 +235,36 @@ class TimerecordingController extends mfBaseController if (!$data['user_id']) { + if ($r->ajax == 1) { + $result['state'] = "error"; + $result['error'] = "Benutzer darf nicht leer sein"; + echo json_encode($result); + die(); + } $this->layout()->setFlash("Benutzer darf nicht leer sein", "error"); $this->redirect("Timerecording"); + } if ($data['start'] < 1577833200) { + if ($r->ajax == 1) { + $result['state'] = "error"; + $result['error'] = "Ungültige Startzeit"; + echo json_encode($result); + die(); + } $this->layout()->setFlash("Ungültige Startzeit", "error"); $this->redirect("Timerecording"); } if ($data['end'] && $data['end'] < 1577833200) { + if ($r->ajax == 1) { + $result['state'] = "error"; + $result['error'] = "Ungültige Endzeit"; + echo json_encode($result); + die(); + } $this->layout()->setFlash("Ungültige Endzeit", "error"); $this->redirect("Timerecording"); + } if (!$data['timerecordingCategory_id']) { $data['timerecordingCategory_id'] = NULL; @@ -294,7 +322,7 @@ class TimerecordingController extends mfBaseController $email->setTo(TT_TIMERECORDING_EMAIL); $email->send(); } - if ($data['timerecordingCategory_id'] == "3") { + if ($data['timerecordingCategory_id'] == "3" || $timerecordingCategoriess[0]->hourday == "5") { $this->updateHolidays($data['user_id']); } $this->updatePlushours($data['user_id']); @@ -334,6 +362,7 @@ class TimerecordingController extends mfBaseController $holidays_now = $holidays; } $timerecordings = TimerecordingModel::search(['user_id' => $userid, 'start' => $holidays_timestamp, 'timerecordingCategory_id' => 3]); + $timerecordingscorrections = TimerecordingModel::search(['user_id' => $userid, 'start' => $holidays_timestamp, 'days' => 1]); foreach ($timerecordings as $timerecording) { $daycounter = ($timerecording->end - $timerecording->start) / 86400; $daycounter = intval(round($daycounter, 0, PHP_ROUND_HALF_DOWN)); @@ -364,6 +393,10 @@ class TimerecordingController extends mfBaseController $holidays_now--; } } + foreach ($timerecordingscorrections as $timerecordingscorrection) { + $holidays_now = $holidays_now + $timerecordingscorrection->days; + } + if ($holidays_now != $employee->holidays_now) { $employeeupdate = new TimerecordingEmployee($employee->id); $data = []; @@ -635,6 +668,12 @@ class TimerecordingController extends mfBaseController $hours = floor($seconds / 3600); $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes); + } else if ($timerecording->timerecordingCategory->hourday == 5) { + + $start = "-"; + $end = "-"; + $day = $daysgerm[date("w", $timerecording->start)]; + $sum = $timerecording->days . " Tage"; } if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { diff --git a/application/Timerecording/TimerecordingModel.php b/application/Timerecording/TimerecordingModel.php index 39dd00e64..ac35e39e9 100644 --- a/application/Timerecording/TimerecordingModel.php +++ b/application/Timerecording/TimerecordingModel.php @@ -5,6 +5,7 @@ class TimerecordingModel private $user_id; private $start; private $end; + private $days; private $timerecordingCategory_id; private $businesstrip; private $businesstrip_info; @@ -158,6 +159,13 @@ class TimerecordingModel $where .= " AND `start` >= $start AND `timerecordingCategory_id` = $timerecordingCategory_id ORDER by start ASC"; } } + if (array_key_exists("start", $filter) && array_key_exists("days", $filter)) { + $days = $filter['days']; + $start = $filter['start']; + if ($days === 1) { + $where .= " AND `start` >= $start AND `days` !=0 ORDER by start ASC"; + } + } if (array_key_exists("starttime", $filter) && array_key_exists("endtime", $filter)) { diff --git a/application/TimerecordingCategory/TimerecordingCategoryModel.php b/application/TimerecordingCategory/TimerecordingCategoryModel.php index 48fca4b83..5ff7f26f5 100644 --- a/application/TimerecordingCategory/TimerecordingCategoryModel.php +++ b/application/TimerecordingCategory/TimerecordingCategoryModel.php @@ -9,7 +9,7 @@ class TimerecordingCategoryModel private $require_comment; private $only_admin; private $businesstrip; - public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum"); + public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage"); public static $approval_definition = array(0 => "Nein", 1 => "Ja"); public static $require_comment_definition = array(0 => "Nein", 1 => "Ja"); public static $businesstrip_definition = array(0 => "Nein", 1 => "Ja"); diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php index 48b80efbf..94a275036 100644 --- a/application/TimerecordingReport/TimerecordingReportController.php +++ b/application/TimerecordingReport/TimerecordingReportController.php @@ -259,6 +259,12 @@ class TimerecordingReportController extends mfBaseController $hours = floor($seconds / 3600); $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes); + } else if ($timerecording->timerecordingCategory->hourday == 5) { + + $start = "-"; + $end = "-"; + $day = $daysgerm[date("w", $timerecording->start)]; + $sum = $timerecording->days . " Tage"; } if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { @@ -292,6 +298,7 @@ class TimerecordingReportController extends mfBaseController data-businesstrip="' . $timerecording->businesstrip . '" data-businesstripinfo="' . $timerecording->businesstrip_info . '" data-homeoffice="' . $timerecording->homeoffice . '" + data-days="' . $timerecording->days . '" title="Bearbeiten">'; else : $edit .= '
'; @@ -514,6 +521,12 @@ class TimerecordingReportController extends mfBaseController $hours = floor($seconds / 3600); $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes); + } else if ($timerecording->timerecordingCategory->hourday == 5) { + + $start = "-"; + $end = "-"; + $day = $daysgerm[date("w", $timerecording->start)]; + $sum = $timerecording->days . " Tage"; } if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) { diff --git a/db/migrations/20240304141012_timerecording_add_fields_days.php b/db/migrations/20240304141012_timerecording_add_fields_days.php new file mode 100644 index 000000000..3a6705173 --- /dev/null +++ b/db/migrations/20240304141012_timerecording_add_fields_days.php @@ -0,0 +1,31 @@ +getEnvironment() == "thetool") { + $table = $this->table("Timerecording", ["signed" => true]); + $table->addColumn("days", "integer", ["null" => false, "default" => '0', "after" => "end"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("Timerecording")->removeColumn("days")->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/public/js/pages/timerecording/index.js b/public/js/pages/timerecording/index.js index e2bf423bb..62dad2845 100644 --- a/public/js/pages/timerecording/index.js +++ b/public/js/pages/timerecording/index.js @@ -135,7 +135,7 @@ table = $('#datatable').DataTable({ _: "comment.comment", "sort": "comment.order" }, - className: "text-center" + className: "text-left" }, { "data": { _: "edit.edit", diff --git a/public/js/pages/timerecordingReport/index.js b/public/js/pages/timerecordingReport/index.js index b43a83b60..8fc15eedb 100644 --- a/public/js/pages/timerecordingReport/index.js +++ b/public/js/pages/timerecordingReport/index.js @@ -139,7 +139,7 @@ table = $('#datatable').DataTable({ _: "comment.comment", "sort": "comment.order" }, - className: "text-center" + className: "text-left" }, { "data": { _: "edit.edit", @@ -195,7 +195,9 @@ $(document).ready(function () { $(this).prop("required", true); $(this).prop("min", $('#date').val()); $(this).val($('#date').val()); - }) + }); + $('#days-div').hide(); + $('#days').prop("required", false); } else if (parseInt($(this).find(':selected').data('hourday')) === 1) { $("#endtime-div").show(); $("#endtime-div").find('input').each(function () { @@ -207,7 +209,9 @@ $(document).ready(function () { $(this).prop("required", false); $(this).prop("min", ''); $(this).val(''); - }) + }); + $('#days-div').hide(); + $('#days').prop("required", false); } else if (parseInt($(this).find(':selected').data('hourday')) === 3 || parseInt($(this).find(':selected').data('hourday')) === 4) { $("#endtime-div").hide(); $("#endtime-div").find('input').each(function () { @@ -220,7 +224,25 @@ $(document).ready(function () { $(this).prop("required", false); $(this).prop("min", ''); $(this).val(''); - }) + }); + $('#days-div').hide(); + $('#days').prop("required", false); + } else if (parseInt($(this).find(':selected').data('hourday')) === 5) { + $("#endtime-div").hide(); + $("#endtime-div").find('input').each(function () { + $(this).prop("required", false); + $(this).prop("disabled", true); + + }); + $("#enddate-div").hide(); + $("#enddate-div").find('input').each(function () { + $(this).prop("required", false); + $(this).prop("min", ''); + $(this).val(''); + }); + $('#days-div').show(); + $('#days').prop("required", true); + } if (parseInt($(this).find(':selected').data('comment')) === 1) { $('#comment').prop("required", true); @@ -281,6 +303,7 @@ $(document).ready(function () { $('#date').val($(this).data('date')); $('#start').val($(this).data('start')); $('#end').val($(this).data('end')); + $('#days').val($(this).data('days')); $('#enddate').val($(this).data('enddate')); $('#comment').val($(this).data('comment')); if ($(this).data('businesstrip') == 1) { @@ -435,6 +458,7 @@ $(document).ready(function () { enddate: $.trim($('#enddate').val()), start: $.trim($('#start').val()), end: $.trim($('#end').val()), + days: $.trim($('#days').val()), comment: $.trim($('#comment').val()), businesstrip: businesstrip, businesstrip_info: $.trim($('#businesstrip_info').val()),
MitarbeiterMitarbeiter Datum Von Bis