Zeiterfassung Update

* Soll zeiten nun vom Startdatum abhängig
 * Neue Summierung der Sollzeiten in der Personalverwaltung
This commit is contained in:
Spitzer Daniel
2024-03-04 11:51:19 +01:00
parent c39f717267
commit cc00f70cd6
4 changed files with 92 additions and 25 deletions

View File

@@ -5,6 +5,14 @@ $type[3] = "Lehrling";
?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
.border-dark {
border-color: #cbcbcb !important;
}
.border-bottom {
border-bottom: 1px dotted #adadad !important;
}
</style>
<!-- start page title -->
<div class="row">
<div class="col-12">
@@ -71,6 +79,14 @@ $type[3] = "Lehrling";
} else {
$sum = "";
}
if ($timerecordingemployees[$timerecordinguser->id]['plushours_now'] < 0) {
$plusHours = $timerecordingemployees[$timerecordinguser->id]['plushours_now'] * -1;
$plusHours = "-" . sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
} else {
$plusHours = $timerecordingemployees[$timerecordinguser->id]['plushours_now'];
$plusHours = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
}
?>
<tr>
@@ -79,9 +95,10 @@ $type[3] = "Lehrling";
<td class="text-center"><?= ($timerecordingemployees[$timerecordinguser->id]['startdate']) ? date("d.m.Y", $timerecordingemployees[$timerecordinguser->id]['startdate']) : "-" ?></td>
<td class="text-center text-nowrap"><?= ($timerecordingworkinghours) ? $timerecordingworkinghours[$timerecordinguser->id]['datetimetext'] : "" ?></td>
<td class="text-center"><?= $sum ?></td>
<td class="text-center"><?= sprintf('%02d:%02d', ($timerecordingemployees[$timerecordinguser->id]['plushours_now']/ 3600),($timerecordingemployees[$timerecordinguser->id]['plushours_now']/ 60 % 60)) ?></td>
<td class="text-center"><?= sprintf('%02d:%02d', ($timerecordingemployees[$timerecordinguser->id]['overtime_now']/ 3600),($timerecordingemployees[$timerecordinguser->id]['overtime_now']/ 60 % 60)) ?></td>
<td class="text-center"><?= ($timerecordingemployees[$timerecordinguser->id]['holidays_now']) ? $timerecordingemployees[$timerecordinguser->id]['holidays_now'].' Tage' : '' ?> </td>
<td class="text-center"
data-order="<?= ($timerecordingemployees[$timerecordinguser->id]['plushours_now']) ? $timerecordingemployees[$timerecordinguser->id]['plushours_now'] : 0 ?>"><?= $plusHours ?></td>
<td class="text-center"><?= sprintf('%02d:%02d', floor($timerecordingemployees[$timerecordinguser->id]['overtime_now'] / 3600), floor($timerecordingemployees[$timerecordinguser->id]['overtime_now'] / 60 % 60)) ?></td>
<td class="text-center"><?= ($timerecordingemployees[$timerecordinguser->id]['holidays_now']) ? $timerecordingemployees[$timerecordinguser->id]['holidays_now'] . ' Tage' : '' ?> </td>
<td class="text-center"><?= ($timerecordingemployees[$timerecordinguser->id]['auto_workinghours'] == '1') ? 'Ja' : 'Nein' ?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<a href="<?= self::getUrl("TimerecordingEmployee", "edit", ['id' => $timerecordingemployees[$timerecordinguser->id]['id'], "userid" => $timerecordinguser->id]) ?>"><i
@@ -100,7 +117,7 @@ $type[3] = "Lehrling";
<script type="text/javascript">
var hidesearch = [3,4,5,6,7,9];
var hidesearch = [3, 4, 5, 6, 7, 9];
$(document).ready(function () {

View File

@@ -369,7 +369,7 @@ class TimerecordingController extends mfBaseController
}
}
protected function updatePlushours($userid)
public function updatePlushours($userid)
{
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
if ($employee) {
@@ -386,7 +386,7 @@ class TimerecordingController extends mfBaseController
$endtime = strtotime($endtime . " 23:59:00");
if ($plushours_timestamp > 0) {
$return = $this->getTimerecordingsApi(5, null, null, null, $plushours_timestamp, $endtime);
$return = $this->getTimerecordingsApi(5, null, null, null, $plushours_timestamp, $endtime, $userid);
$diffTime = $return['is'] - $return['must'];
$plushours_now = $plushours_now + $diffTime;
} else {
@@ -402,22 +402,25 @@ class TimerecordingController extends mfBaseController
}
}
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear, $startime = null, $endtime = null)
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear, $startime = null, $endtime = null, $userid = null)
{
$mustSeconds = 0;
$isSeconds = 0;
$holiDays = 0;
$plusHours = 0;
$startdate=time();
if (!$userid) {
$userid = $this->me->id;
}
$rows = [];
$employee = TimerecordingEmployeeModel::search(['user_id' => $this->me->id]);
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
if ($employee) {
$holiDays = $employee[0]->holidays_now;
$plusHours = $employee[0]->plushours_now;
$auto_workinghours = $employee[0]->auto_workinghours;
$startdate = $employee[0]->startdate;
}
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $this->me->id]);
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
$holidays = TimerecordingHolidayModel::getAll();
foreach ($workinghours as $workinghour) {
@@ -440,7 +443,7 @@ class TimerecordingController extends mfBaseController
$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' => $this->me->id, 'start' => $timestamp_montag, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, 'start' => $timestamp_montag, 'end' => $lastdate];
$daycounter = '0';
@@ -448,7 +451,7 @@ class TimerecordingController extends mfBaseController
for ($i = 1; $i <= 7; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -459,13 +462,13 @@ class TimerecordingController extends mfBaseController
$lastdate = strtotime(date("Y-m-t", $datamonth));
$daycount = date("t", $datamonth);
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
$searchArray = ['user_id' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, '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]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -478,7 +481,7 @@ class TimerecordingController extends mfBaseController
$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' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -498,7 +501,7 @@ class TimerecordingController extends mfBaseController
$timediff = $lastdate - $firstdate;
$daycount = $timediff / 86400;
$daycount = round($daycount, 0, PHP_ROUND_HALF_DOWN);
$searchArray = ['user_id' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -672,9 +675,10 @@ class TimerecordingController extends mfBaseController
return $response;
} else {
if ($plusHours < 0) {
$plusHoursMinutes = $plusHours * -1;
$plusHours = $plusHours * -1;
$plusHours = "-" . sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
} else {
$plusHoursMinutes = $plusHours;
$plusHours = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
}
$json['success'] = true;
@@ -682,7 +686,7 @@ class TimerecordingController extends mfBaseController
$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($plusHoursMinutes / 60 % 60));
$json['time']['plushours'] = $plusHours;
$json['data'] = $rows;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;

View File

@@ -103,6 +103,8 @@ class TimerecordingEmployeeWorkingHourModel
$secondcounter = 0;
while ($data = $db->fetch_array($res)) {
$dayHours[$data['user_id']][$data['day']][] = $data['start'] . " - " . $data['end'];
if ($olduser != $data['user_id']) {
if ($counter > 0) {
$secondcounter = 0;
@@ -121,7 +123,6 @@ class TimerecordingEmployeeWorkingHourModel
if (!$datetimetext) {
$datetimetext = $daysshort[$data['day']];
}
echo $oldstart . $data['start'];
if (($oldstart != $data['start'] || $oldend != $data['end']) && $oldend) {
$datetimetext .= " - " . $daysshort[$oldday] . " " . $oldstart . " - " . $oldend;
$datetimetext .= "<br> " . $daysshort[$data['day']];
@@ -139,6 +140,51 @@ class TimerecordingEmployeeWorkingHourModel
$datetimetext = TimerecordingEmployeeWorkingHourModel::cleardays($datetimetext);
$items[$olduser]['datetimetext'] = $datetimetext;
}
foreach ($dayHours as $key => $dayHour) {
foreach ($dayHour as $key2 => $dayHour2) {
$dayhours[$key][$key2] = implode("<br>", $dayHour2);
}
}
foreach ($dayhours as $key => $dayhour) {
$oldday = false;
$oldstring = false;
$counter = 0;
$oldkey = false;
$oldkey2 = false;
foreach ($dayhour as $key2 => $dayhour2) {
if ($oldday != $key2) {
if ($oldstring != $dayhour2 || $key2!=$oldkey2+1) {
if ($oldkey2) {
$daysitems[$key][$counter]['end'] = $oldkey2;
$counter++;
}
$daysitems[$key][$counter]['start'] = $key2;
}
$daysitems[$key][$counter]['string'] = $dayhour2;
}
$oldkey2 = $key2;
$oldkey = $key;
$oldstring = $dayhour2;
}
$daysitems[$key][$counter]['end'] = $key2;
}
foreach ($daysitems as $key => $daysitem) {
$datetimetext = "";
foreach ($daysitem as $key2 => $daysItem) {
if ($daysItem['start'] != $daysItem['end']) {
$datetimetext .= '<div class="d-table border-bottom border-dark"><div class="d-table-cell w-50 align-middle pr-2 ">' . $daysshort[$daysItem['start']] . "-" . $daysshort[$daysItem['end']] . '</div><div class="d-table-cell">' . $daysItem['string'] . '</div></div>';
} else {
$datetimetext .= '<div class="d-table border-bottom border-dark"><div class="d-table-cell w-50 align-middle pr-2 ">' . $daysshort[$daysItem['start']] . '</div><div class="d-table-cell">' . $daysItem['string'] . '</div></div>';
}
}
$items[$key]['datetimetext'] = $datetimetext;
}
return $items;
}
@@ -153,7 +199,6 @@ class TimerecordingEmployeeWorkingHourModel
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingEmployeeWorkingHour", "*", "$where ");
if ($db->num_rows($res)) {

View File

@@ -331,7 +331,7 @@ class TimerecordingReportController extends mfBaseController
$holiDays = $employee[0]->holidays;
$plusHours = $employee[0]->plushours;
$auto_workinghours = $employee[0]->auto_workinghours;
$startdate = $employee[0]->startdate;
}
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $r->user_id]);
$holidays = TimerecordingHolidayModel::getAll();
@@ -364,7 +364,8 @@ class TimerecordingReportController extends mfBaseController
for ($i = 1; $i <= 7; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -381,7 +382,7 @@ class TimerecordingReportController extends mfBaseController
for ($i = 1; $i <= $daycount; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}