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
* Berechnung der Mehrstunden nun exakt
This commit is contained in:
Spitzer Daniel
2024-02-26 22:11:23 +01:00
parent 09b4aade1c
commit 5501c381ef
3 changed files with 90 additions and 19 deletions

View File

@@ -197,6 +197,7 @@ class TimerecordingController extends mfBaseController
} else {
$data['user_id'] = $this->me->id;
}
$data['start'] = $starttime;
$data['end'] = $endtime;
$data['timerecordingCategory_id'] = trim($r->timerecordingCategory_id);
@@ -289,6 +290,7 @@ class TimerecordingController extends mfBaseController
if ($data['timerecordingCategory_id'] == "3") {
$this->updateHolidays($data['user_id']);
}
$this->updatePlushours($data['user_id']);
}
if ($mode == "edit") {
@@ -326,7 +328,7 @@ class TimerecordingController extends mfBaseController
$timerecordings = TimerecordingModel::search(['user_id' => $userid, 'start' => $holidays_timestamp, 'timerecordingCategory_id' => 3]);
foreach ($timerecordings as $timerecording) {
$daycounter = ($timerecording->end - $timerecording->start) / 86400;
$daycounter=intval(round($daycounter,0,PHP_ROUND_HALF_DOWN));
$daycounter = intval(round($daycounter, 0, PHP_ROUND_HALF_DOWN));
$daycounter = $daycounter * 86400;
if (is_int($daycounter)) {
for ($i = 86400; $i <= $daycounter; $i = $i + 86400) {
@@ -367,10 +369,35 @@ class TimerecordingController extends mfBaseController
protected function updatePlushours($userid)
{
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
if ($employee) {
$employee = $employee[0];
$plushours = $employee->plushours;
$plushours_now = $employee->plushours_now;
$plushours_timestamp = $employee->plushours_timestamp;
if (!$plushours_timestamp) {
$plushours_timestamp = $employee->startdate;
$plushours_now = $plushours;
}
$endtime = time() - 86400;
$endtime = date("Y-m-d", $endtime);
$endtime = strtotime($endtime . " 23:59:00");
$return = $this->getTimerecordingsApi(5, null, null, null, $plushours_timestamp, $endtime);
$diffTime = $return['is'] - $return['must'];
$plushours_now = $plushours_now + $diffTime;
if ($employee->plushours_now != $diffTime) {
$employeeupdate = new TimerecordingEmployee($employee->id);
$data = [];
$data['plushours_now'] = $plushours_now;
$employeeupdate->update($data);
$employeeupdate->save();
}
}
}
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear, $startime = null, $endtime = null)
{
$mustSeconds = 0;
$isSeconds = 0;
@@ -460,6 +487,26 @@ class TimerecordingController extends mfBaseController
}
} else if ($datatype == 5) {
$firstdate = $startime;
$lastdate = $endtime;
$timediff = $lastdate - $firstdate;
$daycount = $timediff / 86400;
$daycount = round($daycount, 0, PHP_ROUND_HALF_DOWN);
$searchArray = ['user_id' => $this->me->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;
}
}
@@ -601,23 +648,35 @@ class TimerecordingController extends mfBaseController
);
}
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['data'] = $rows;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;
$json = json_encode($json);
echo trim($json);
die();
if ($datatype == 5) {
$response['is'] = $isSeconds;
$response['must'] = $mustSeconds;
return $response;
} else {
if ($plusHours < 0) {
$plusHoursMinutes = $plusHours * -1;
} else {
$plusHoursMinutes = $plusHours;
}
$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($plusHoursMinutes / 60 % 60));
$json['data'] = $rows;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;
$json = json_encode($json);
echo trim($json);
die();
}
}
protected function fillWorkinghours($dataweek)
{
$dataweek = strtotime($dataweek);
$employee = TimerecordingEmployeeModel::search(['user_id' => $this->me->id]);
if ($employee) {
$auto_workinghours = $employee[0]->auto_workinghours;
@@ -651,7 +710,7 @@ class TimerecordingController extends mfBaseController
$daycounter = '0';
$update = false;
$timestamp = $timestamp_montag;
for ($i = 1; $i <= 7; $i++) {
$dDate = date('Y-m-d', $timestamp);
@@ -663,6 +722,7 @@ class TimerecordingController extends mfBaseController
$endtime = strtotime($dDate . " " . $workingHour['end'] . ":00");
$check = $this->checkTimerecording($starttime, $endtime);
if ($check['state'] == "success") {
$update = 1;
$data = [];
$data['user_id'] = $this->me->id;
$data['start'] = $starttime;
@@ -681,6 +741,10 @@ class TimerecordingController extends mfBaseController
$timestamp = $timestamp + 86400;;
}
if ($update) {
$this->updatePlushours($this->me->id);
$this->updateHolidays($this->me->id);
}
}
protected function deleteAction()
@@ -694,6 +758,7 @@ class TimerecordingController extends mfBaseController
}
$timerecordings->delete();
$this->updateHolidays($userid);
$this->updatePlushours($userid);
if ($this->request->ajax == 1) {
die();