Zeiterfassung

* Feature Implementation Arbeitszeitänderungen mit History für alle möglichen historischen Berechnungen und Auswertung fertigstellung
This commit is contained in:
Daniel Spitzer
2025-02-08 20:56:29 +01:00
parent c38a9919b6
commit 6ed34fe676
3 changed files with 197 additions and 1 deletions

View File

@@ -528,8 +528,36 @@ class TimerecordingController extends mfBaseController
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
}
}
$workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $userid]);
if ($workinghourshistory) {
$workingHoursHistory[2147483500]=$workingHours;
foreach ($workinghourshistory as $workinghourhistory) {
$whenddate = $workinghourhistory->enddate;
$workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true);
foreach ($workinghourhistoryhours as $workinghourhistoryhour) {
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['start'] . ":00");
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['end'] . ":00");
if (!$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']]) {
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $whend - $whstart;
} else {
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] + $whend - $whstart;
}
}
}
}
//check if holiday is already in the list
foreach ($holidayDays as $key => $holidayDay) {
if ($workingHoursHistory)
{
foreach ($workingHoursHistory as $whkey => $whdata) {
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
$timestamp = strtotime($key);
if ($whtimestamp >= $timestamp)
{
$workingHours = $whdata;
}
}
}
if (($realholiDay[$key])) {
} else if ($workingHours[date('w', strtotime($key))]) {
@@ -605,6 +633,7 @@ class TimerecordingController extends mfBaseController
if ($plushours_timestamp > 0) {
$return = $this->getTimerecordingsApi(5, null, null, null, $plushours_timestamp, $endtime, $userid);
// echo $return['is'] ." ". $return['must'].PHP_EOL;
$diffTime = $return['is'] - $return['must'];
$plushours_now = $plushours_now + $diffTime;
} else {
@@ -681,6 +710,25 @@ class TimerecordingController extends mfBaseController
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
}
}
$workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $userid]);
if ($workinghourshistory) {
$workingHoursHistory[2147483500]=$workingHours;
foreach ($workinghourshistory as $workinghourhistory) {
$whenddate = $workinghourhistory->enddate;
$workinghourhistoryhours = json_decode($workinghourhistory->workinghours, true);
foreach ($workinghourhistoryhours as $workinghourhistoryhour) {
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['start'] . ":00");
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghourhistoryhour['end'] . ":00");
if (!$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']]) {
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $whend - $whstart;
} else {
$workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] = $workingHoursHistory[$whenddate][$workinghourhistoryhour['day']] + $whend - $whstart;
}
}
}
}
foreach ($holidays as $holiday) {
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->description;
}
@@ -704,6 +752,18 @@ class TimerecordingController extends mfBaseController
}
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
$dDay = date('w', $timestamp + $WintertimeCompensation);
if ($workingHoursHistory)
{
foreach ($workingHoursHistory as $whkey => $whdata) {
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
if ($whtimestamp >= $timestamp)
{
unset($workingHours);
$workingHours = $whdata;
}
}
}
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
} elseif ($holiDay[$dDate]) {
@@ -727,6 +787,18 @@ class TimerecordingController extends mfBaseController
}
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
$dDay = date('w', $timestamp + $WintertimeCompensation);
if ($workingHoursHistory)
{
foreach ($workingHoursHistory as $whkey => $whdata) {
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
if ($whtimestamp >= $timestamp)
{
unset($workingHours);
$workingHours = $whdata;
}
}
}
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
} elseif ($holiDay[$dDate]) {
@@ -749,6 +821,18 @@ class TimerecordingController extends mfBaseController
}
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
$dDay = date('w', $timestamp + $WintertimeCompensation);
if ($workingHoursHistory)
{
foreach ($workingHoursHistory as $whkey => $whdata) {
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
if ($whtimestamp >= $timestamp)
{
unset($workingHours);
$workingHours = $whdata;
}
}
}
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
} elseif ($holiDay[$dDate]) {
@@ -770,9 +854,23 @@ class TimerecordingController extends mfBaseController
if (date('I', $timestamp) == 0) {
$WintertimeCompensation = 3600;
}
if ($workingHoursHistory)
{
foreach ($workingHoursHistory as $whkey => $whdata) {
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
if ($whtimestamp >= $timestamp)
{
unset($workingHours);
$workingHours = $whdata;
// echo date('Y-m-d 23:59:59', $whkey).PHP_EOL;
}
}
}
$dDate = date('Y-m-d', $timestamp + $WintertimeCompensation);
$dDay = date('w', $timestamp + $WintertimeCompensation);
if (!$holiDay[$dDate]) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -828,6 +926,17 @@ class TimerecordingController extends mfBaseController
$savecounter = 0;
$sumdays = 0;
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
if ($workingHoursHistory)
{
foreach ($workingHoursHistory as $whkey => $whdata) {
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
if ($whtimestamp >= $i)
{
unset($workingHours);
$workingHours = $whdata;
}
}
}
$holidaycounter = $workingHours[date("w", $i)];
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {
@@ -877,6 +986,17 @@ class TimerecordingController extends mfBaseController
$savecounter = 0;
// echo $starttimecalc."<br>";
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
if ($workingHoursHistory)
{
foreach ($workingHoursHistory as $whkey => $whdata) {
$whtimestamp = strtotime(date('Y-m-d 23:59:59', $whkey));
if ($whtimestamp >= $i)
{
unset($workingHours);
$workingHours = $whdata;
}
}
}
$holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)];
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {