Zeiterfassung Update/Bugfix
* TimerecordingReportController.php verweist in einer gewissen Datenbank-Eintragskonstellation auf einen ungültigen Array Index. Hab die gesamtsollzeitberechnung temporär ausgeschalten * Neu Migration (Vorbereiten der DB auf eigenes Ü-Zeitkonto) * Kalender Feiertagsdescription angepasst * Geburtstage nun möglich in Personaladministration und Kalender * Initiale Überstunden sind nun möglich * Berechnung Urlaubstage nun exakt
This commit is contained in:
@@ -41,6 +41,9 @@ class TimerecordingReportController extends mfBaseController
|
||||
case "getTimerecordings":
|
||||
$return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear);
|
||||
break;
|
||||
case "getTimerecordingsTimes":
|
||||
$return = $this->getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear);
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -307,6 +310,244 @@ class TimerecordingReportController extends mfBaseController
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
protected function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear)
|
||||
{
|
||||
$r = $this->request;
|
||||
$mustSeconds = 0;
|
||||
$isSeconds = 0;
|
||||
$holiDays = 0;
|
||||
$plusHours = 0;
|
||||
|
||||
$rows = [];
|
||||
$employee = TimerecordingEmployeeModel::search(['user_id' => $r->user_id]);
|
||||
if ($employee) {
|
||||
$holiDays = $employee[0]->holidays;
|
||||
$plusHours = $employee[0]->plushours;
|
||||
$auto_workinghours = $employee[0]->auto_workinghours;
|
||||
|
||||
}
|
||||
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $r->user_id]);
|
||||
$holidays = TimerecordingHolidayModel::getAll();
|
||||
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]) {
|
||||
$workingHours[$workinghour->day] = $whend - $whstart;
|
||||
} else {
|
||||
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
foreach ($holidays as $holiday) {
|
||||
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
|
||||
}
|
||||
|
||||
if ($datatype == 1) {
|
||||
$kw = date('W', $dataweek);
|
||||
$year = date('Y', $dataweek);
|
||||
$timestamp_montag = strtotime("{$year}-W{$kw}");
|
||||
$timestamp_sonntag = strtotime("{$year}-W{$kw}-7");
|
||||
$firstdate = strtotime(date("Y-m-d", $timestamp_montag) . " 00:00:00");
|
||||
$lastdate = strtotime(date("Y-m-d", $timestamp_sonntag) . ' 23:59:59');
|
||||
$searchArray = ['user_id' => $r->user_id, 'start' => $timestamp_montag, 'end' => $lastdate];
|
||||
|
||||
$daycounter = '0';
|
||||
|
||||
$timestamp = $timestamp_montag;
|
||||
for ($i = 1; $i <= 7; $i++) {
|
||||
$dDate = date('Y-m-d', $timestamp);
|
||||
$dDay = date('w', $timestamp);
|
||||
if (!$holiDay[$dDate]) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
}
|
||||
|
||||
$timestamp = $timestamp + 86400;
|
||||
}
|
||||
} else if ($datatype == 2) {
|
||||
$firstdate = strtotime(date("Y-m-01", $datamonth));
|
||||
$lastdate = strtotime(date("Y-m-t", $datamonth));
|
||||
$daycount = date("t", $datamonth);
|
||||
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
|
||||
$searchArray = ['user_id' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
|
||||
$timestamp = $firstdate;
|
||||
|
||||
for ($i = 1; $i <= $daycount; $i++) {
|
||||
$dDate = date('Y-m-d', $timestamp);
|
||||
$dDay = date('w', $timestamp);
|
||||
if (!$holiDay[$dDate]) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
}
|
||||
|
||||
$timestamp = $timestamp + 86400;
|
||||
}
|
||||
|
||||
|
||||
} else if ($datatype == 3) {
|
||||
$firstdate = strtotime(date("Y-01-01", $datayear));
|
||||
$lastdate = strtotime(date("Y-12-31 23:59:59", $datayear));
|
||||
$daycount = date("t", $datamonth);
|
||||
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
|
||||
$searchArray = ['user_id' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
|
||||
$timestamp = $firstdate;
|
||||
|
||||
for ($i = 1; $i <= $daycount; $i++) {
|
||||
$dDate = date('Y-m-d', $timestamp);
|
||||
$dDay = date('w', $timestamp);
|
||||
if (!$holiDay[$dDate]) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
}
|
||||
|
||||
$timestamp = $timestamp + 86400;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
||||
$timerecordingcategories = TimerecordingCategoryModel::getAll();
|
||||
|
||||
$timerecordings = TimerecordingModel::search($searchArray);
|
||||
$responsecount = count($timerecordings);
|
||||
foreach ($timerecordings as $timerecording):
|
||||
$state = "";
|
||||
$enddate = "";
|
||||
$sum = "-";
|
||||
$day = "";
|
||||
$orderdate = $timerecording->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)];
|
||||
$isSeconds = $isSeconds + $seconds;
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 2 || ($timerecording->timerecordingCategory->hourday == 3 && $timerecording->end)) {
|
||||
$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)];
|
||||
|
||||
if ($lastdate < $timerecording->end) {
|
||||
$endtimecalc = $lastdate;
|
||||
} else {
|
||||
$endtimecalc = $timerecording->end;
|
||||
}
|
||||
if ($firstdate > $timerecording->start) {
|
||||
$starttimecalc = $firstdate;
|
||||
} else {
|
||||
$starttimecalc = $timerecording->start;
|
||||
}
|
||||
$summcounter = 0;
|
||||
$savecounter = 0;
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
if ($savecounter == 1000) {
|
||||
echo $savecounter;
|
||||
die();
|
||||
}
|
||||
$savecounter++;
|
||||
}
|
||||
$seconds = $summcounter;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
|
||||
$date = date("d.m.Y", $timerecording->start) . " - " . $daysgerm[date("w", time())] . " " . date("d.m.Y", time());;
|
||||
$datadate = date("Y-m-d", $timerecording->start);
|
||||
$start = "-";
|
||||
$end = "-";
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
if ($lastdate < $timerecording->end) {
|
||||
$endtimecalc = $lastdate;
|
||||
} else {
|
||||
$endtimecalc = $timerecording->end;
|
||||
}
|
||||
if ($firstdate > $timerecording->start) {
|
||||
$starttimecalc = $firstdate;
|
||||
} else {
|
||||
$starttimecalc = $timerecording->start;
|
||||
}
|
||||
$summcounter = 0;
|
||||
$savecounter = 0;
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
if ($savecounter == 1000) {
|
||||
echo $savecounter;
|
||||
die();
|
||||
}
|
||||
$savecounter++;
|
||||
}
|
||||
$seconds = $summcounter;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
|
||||
}
|
||||
|
||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||
$state = '<i class="fa-regular fa-clock mr-1"></i>';
|
||||
} else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) {
|
||||
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
||||
}
|
||||
$edit = "";
|
||||
if ($timerecording->businesstrip == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-2'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} else {
|
||||
$category = $timerecording->timerecordingCategory->name;
|
||||
}
|
||||
if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
|
||||
$category = $category . "<span class='text-bold ml-2'>(offen)</span>";
|
||||
}
|
||||
|
||||
|
||||
if ($timerecording->completed == 0 && $timerecording->timerecordingCategory->only_admin == 0):
|
||||
if ($timerecording->approved == 0) :
|
||||
$edit = '<i class="far fa-edit edit-button" data-id="' . $timerecording->id . '"
|
||||
data-date="' . $datadate . '"
|
||||
data-category="' . $timerecording->timerecordingCategory->id . '"
|
||||
data-start="' . $start . '"
|
||||
data-end="' . $end . '"
|
||||
data-enddate="' . $enddate . '"
|
||||
data-comment="' . $timerecording->comment . '"
|
||||
data-businesstrip="' . $timerecording->businesstrip . '"
|
||||
data-businesstripinfo="' . $timerecording->businesstrip_info . '"
|
||||
title="Bearbeiten"></i>';
|
||||
else :
|
||||
$edit .= '<div class="edit-placeholder"></div>';
|
||||
endif;
|
||||
$edit .= '<i data-id="' . $timerecording->id . '" class="fas fa-trash text-danger delete-item" ></i>';
|
||||
endif;
|
||||
if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
|
||||
} else {
|
||||
|
||||
}
|
||||
endforeach;
|
||||
$json['success'] = true;
|
||||
$json['time']['auto_workinghours'] = $auto_workinghours;
|
||||
$json['time']['is'] = sprintf('%02dh:%02dm', floor($isSeconds / 3600), floor($isSeconds / 60 % 60));
|
||||
$json['time']['must'] = sprintf('%02dh:%02dm', floor($mustSeconds / 3600), floor($mustSeconds / 60 % 60));
|
||||
$json['time']['holidays'] = $holiDays;
|
||||
$json['time']['plushours'] = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
|
||||
$json['recordsFiltered'] = $responsecount;
|
||||
$json['recordsTotal'] = $responsecount;
|
||||
$json = json_encode($json);
|
||||
echo trim($json);
|
||||
die();
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user