Merge branch 'spidev' into 'master'

Zeiterfassung Update

See merge request fronk/thetool!350
This commit is contained in:
Daniel Spitzer
2024-04-29 18:18:58 +00:00
5 changed files with 93 additions and 8 deletions

View File

@@ -89,6 +89,10 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
.form-check-label {
margin-top: 2px;
}
.holiday-text
{
color: #d70000;
}
</style>
<!-- start page title -->

View File

@@ -139,7 +139,7 @@
month: $.trim($('#month').data('month')),
ajax: 1
}).done(function (data) {
window.location.href = "<?= self::getUrl("TimerecordingBilling", "detailClosed", ['month' => $month]) ?>";
window.location.href = "<?= self::getUrl("TimerecordingBilling", "detail", ['month' => $month]) ?>";
});
}

View File

@@ -599,6 +599,7 @@ class TimerecordingController extends mfBaseController
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear, $startime = null, $endtime = null, $userid = null)
{
$holidayrows = [];
$mustSeconds = 0;
$isSeconds = 0;
$holiDays = 0;
@@ -635,7 +636,7 @@ class TimerecordingController extends mfBaseController
}
}
foreach ($holidays as $holiday) {
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->description;
}
if ($datatype == 1) {
@@ -655,6 +656,8 @@ class TimerecordingController extends mfBaseController
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
} elseif ($holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$holidayrows[$timestamp] = $holiDay[$dDate];
}
$timestamp = $timestamp + 86400;
@@ -672,6 +675,8 @@ class TimerecordingController extends mfBaseController
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
} elseif ($holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$holidayrows[$timestamp] = $holiDay[$dDate];
}
$timestamp = $timestamp + 86400;
}
@@ -683,11 +688,13 @@ class TimerecordingController extends mfBaseController
$searchArray = ['user_id' => $userid, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
for ($i = 1; $i <= 366; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
} elseif ($holiDay[$dDate]) {
$holidayrows[$timestamp] = $holiDay[$dDate];
}
$timestamp = $timestamp + 86400;
}
@@ -928,6 +935,18 @@ class TimerecordingController extends mfBaseController
);
}
endforeach;
foreach ($holidayrows as $key => $holidayrow) {
$day = $daysgerm[date("w", $key)];
$rows[] = array(
'date' => array('date' => '<span class="text-bold holiday-text">'.$day." ".date("d.m.Y",$key).'</span>', 'order' => $key),
'start' => array('start' => "-", 'order' => "-"),
'end' => array('end' => "-", 'order' => "-"),
'sum' => array('sum' => "-", 'order' => "-"),
'category' => array('category' => '<span class="text-bold holiday-text">Feiertag <i class="far fa-fw fa-umbrella-beach "></i></span>', 'order' => 'Feiertag'),
'comment' => array('comment' => '<span class="text-bold holiday-text">'.$holidayrow.'</span>', 'order' => $holidayrow),
'edit' => array('edit' => "", 'order' => ""),
);
}
if ($datatype == 5) {
$response['is'] = $isSeconds;
$response['must'] = $mustSeconds;

View File

@@ -386,6 +386,69 @@ class TimerecordingReportController extends mfBaseController
die();
}
private function checkOvertime($timerecording)
{
$start = $timerecording->start;
$end = $timerecording->end;
$O50free = 0;
$O50pfl = 0;
$O100free = 0;
$O100pfl = 0;
$O100end = strtotime(date('Y-m-d', $start) . " 06:00:00");
$O100start = strtotime(date('Y-m-d', $start) . " 22:00:00");
$holidays = TimerecordingHolidayModel::getAll();
foreach ($holidays as $holiday) {
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
}
$start = $timerecording->start;
$end = $timerecording->end;
$startday = date('Y-m-d', $start);
if (date('w', $start) == 0 || $holiDay[$startday]) {
$O100free = $O100free + $timerecording->end - $timerecording->start;
} else {
if ($start < $O100end || $start > $O100start || $end < $O100end || $end > $O100start) {
$sum = $end - $start;
if ($sum >= 10800) {
if ($start < $O100end) {
$O100free = $O100free + $O100end - $start;
}
if ($end >= $O100start) {
$O100free = $O100free + $end - $O100start;
}
if (date('w', $start) == 6) {
if ($sum != $O100free) {
$O50free = $O50free + $sum - $O100free;
}
}
} else {
if ($start < $O100end) {
$O100pfl = $O100pfl + $O100end - $start;
}
if ($end >= $O100start) {
$O100pfl = $O100pfl + $end - $O100start;
}
if (date('w', $start) == 6) {
if ($sum != $O100free) {
$O50free = $O50free + $sum - $O100free;
}
}
}
} else {
if (date('w', $start) == 6) {
$O50free = $O50free + $end - $start;
}
}
}
$response['O100free'] = $O100free;
$response['O100pfl'] = $O100pfl;
$response['O50free'] = $O50free;
$response['O50pfl'] = $O50pfl;
$response['sum'] = $O100free + $O100pfl + $O50free + $O50pfl;
return $response;
}
public function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear, $user_id = NULL, $ajax = 1)
{
@@ -567,7 +630,6 @@ class TimerecordingReportController extends mfBaseController
$isSecondscleanarray[$timerecording->timerecordingCategory->short] = $seconds;
}
if ($timerecording->timerecordingCategory->short != "1000,1200,1400") {
if (!$daysum[$timerecording->timerecordingCategory->name]) {
$daysum[$timerecording->timerecordingCategory->name] = $seconds;
@@ -581,6 +643,10 @@ class TimerecordingReportController extends mfBaseController
$nlzTimes[$timerecording->id]['unpaid'] = $timerecording->timerecordingCategory->unpaid;
$nlzTimes[$timerecording->id]['category'] = $timerecording->timerecordingCategory->name;
$nlzTimes[$timerecording->id]['categoryshort'] = $timerecording->timerecordingCategory->short;
} else {
$overtimes = $this->checkOvertime($timerecording);
$isSecondscleanarray[$timerecording->timerecordingCategory->short] = $isSecondscleanarray[$timerecording->timerecordingCategory->short] - $overtimes['sum'];
$isSeconds = $isSeconds - $overtimes['sum'];
}
} 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);

View File

@@ -87,10 +87,6 @@ table = $('#datatable').DataTable({
d.datayear = $('#datayear').val();
},
"dataSrc": function (json) {
$('#is-time').text(json.time.is);
$('#must-time').text(json.time.must);
$('#holidays').text(json.time.holidays);
$('#plushours').text(json.time.plushours);
$('#selectsearch').change();
return json.data;
}