Zeiterfassung Update
* Soll zeiten nun vom Startdatum abhängig * Neue Summierung der Sollzeiten in der Personalverwaltung
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user