Zeiterfassung Update

* Neues Kategorie Feature (Arbeitszeitverschiebung)
This commit is contained in:
Daniel Spitzer
2025-11-16 19:15:19 +01:00
parent d2bb93b2ba
commit fcccf109dd
4 changed files with 68 additions and 5 deletions

View File

@@ -154,6 +154,44 @@ class TimerecordingController extends mfBaseController
}
}
protected function getWorkingHours($ajax = 0)
{
$r = $this->request;
$date = $r->date;
$starttime = strtotime($date . " 08:00:00");
if ($r->user_id) {
$userid = $r->user_id;
}
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
$realHolidays = TimerecordingHolidayModel::getAll();
foreach ($realHolidays as $realHoliday) {
$realholiDay[date('Y-m-d', $realHoliday->timestamp)] = $realHoliday->timestamp;
}
if ($realholiDay[$date]) {
$result['state'] = "error";
$result['error'] = "Keine Arbeitszeitverschiebung an einem Feiertag möglich";
echo json_encode($result);
die();
}
foreach ($workinghours as $workinghour) {
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghour->start . ":00");
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghour->end . ":00");
if (!$workingHours[$workinghour->day]['time']) {
$workingHours[$workinghour->day]['time'] = $whend - $whstart;
$workingHours[$workinghour->day]['start'] = $workinghour->start;
} else {
$workingHours[$workinghour->day]['time'] = $workingHours[$workinghour->day]['time'] + $whend - $whstart;
}
}
if (!$workingHours[date("w", $starttime)]) {
$result['state'] = "error";
$result['error'] = "Keine Arbeitszeitverschiebung außerhalb von Arbeitstagen möglich";
echo json_encode($result);
die();
}
return $workingHours[date("w", $starttime)];
}
protected function checkWorkingHours($ajax = 0)
{
@@ -298,6 +336,10 @@ class TimerecordingController extends mfBaseController
} else if ($hourday == 8) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = strtotime($r->date . " 23:59:00");
} else if ($hourday == 10) {
$data = $this->getWorkingHours();
$starttime = strtotime($r->date . " " . $data['start'] . ":00");
$endtime = $starttime + $data['time'];
}
if ($hourday != 5 && $hourday != 7 && $hourday != 8 && $hourday != 9) {
@@ -473,9 +515,7 @@ class TimerecordingController extends mfBaseController
$email->setFrom(TT_TIMERECORDING_EMAIL, TT_TIMERECORDING_EMAIL_NAME);
$email->setTo(TT_TIMERECORDING_EMAIL);
$email->send();
}
else if ($timerecordingCategoriess[0]->approval_fibu == "1" && !$r->user_id)
{
} else if ($timerecordingCategoriess[0]->approval_fibu == "1" && !$r->user_id) {
$body = 'Beantrag von: ' . $this->me->name . '
';
$body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . '
@@ -1117,11 +1157,21 @@ class TimerecordingController extends mfBaseController
} else {
$sum = $hoursbpa . " St";
}
} else if ($timerecording->timerecordingCategory->hourday == 10) {
$date = date("d.m.Y", $timerecording->start);
$datadate = date("Y-m-d", $timerecording->start);
$start = "-";
$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)];
}
if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0)) {
$state = '<i class="fa-regular fa-clock mr-1"></i>';
} else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1 )) {
} else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1)) {
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
}
$edit = "";