Zeiterfassung neues Feature:
* Auswertungen nicht bebuchter Arbeitstage
This commit is contained in:
@@ -107,6 +107,9 @@ class TimerecordingBillingController extends mfBaseController
|
||||
case "generatebmdexportnlz":
|
||||
$return = $this->generateBmdExport($month, 1);
|
||||
break;
|
||||
case "generateopenworkdays":
|
||||
$return = $this->generateopenworkdays($month);
|
||||
break;
|
||||
case "generatebmdexportclosed":
|
||||
$return = $this->generateBmdExportClosed($month);
|
||||
break;
|
||||
@@ -383,6 +386,37 @@ class TimerecordingBillingController extends mfBaseController
|
||||
exit;
|
||||
}
|
||||
|
||||
protected function generateopenworkdays($month)
|
||||
{
|
||||
$filename = "open_workdays_" . $month . ".csv";
|
||||
$file = fopen("php://output", 'w');
|
||||
header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename=' . $filename);
|
||||
$headerarray = ["Monat", "Mitarbeiter", "Tag"];
|
||||
fputcsv($file, $headerarray, ";");
|
||||
$month = strtotime("01." . $month);
|
||||
//last of month
|
||||
$monthend = date("Y-m-d", strtotime("last day of this month", $month));
|
||||
$monthend = strtotime($monthend . " 23:59:59");
|
||||
$monthbmd = date("n", $month);
|
||||
$timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
|
||||
foreach ($timerecordingsEmolyees as $timerecordingsEmolyee) {
|
||||
unset($bodyarray);
|
||||
if ($timerecordingsEmolyee->bmd_active == 0 || $timerecordingsEmolyee->startdate > $monthend || ($timerecordingsEmolyee->enddate && $timerecordingsEmolyee->enddate < $month)) continue;
|
||||
$user = new User($timerecordingsEmolyee->user_id);
|
||||
$employee_number = (string)$user->getFlag('employee_number');
|
||||
|
||||
$WorkingDays = $this->checkWorkingDays($user->id, $month, $timerecordingsEmolyee);
|
||||
foreach ($WorkingDays as $WorkingDay) {
|
||||
$bodyarray = [date("m-Y", $month), mb_convert_encoding($user->name, 'ISO-8859-1', 'UTF-8'), date("d.m.Y", strtotime($WorkingDay))];
|
||||
fputcsv($file, $bodyarray, ";");
|
||||
}
|
||||
}
|
||||
|
||||
fclose($file);
|
||||
exit;
|
||||
}
|
||||
|
||||
protected function generateBmdExport($month, $nlz = 0, $export = 1)
|
||||
{
|
||||
//create and download csv file
|
||||
@@ -606,8 +640,8 @@ class TimerecordingBillingController extends mfBaseController
|
||||
}
|
||||
if ($timerecording['daysum']) {
|
||||
$data['nlz'] = $timerecording['daysum'];
|
||||
if (strpos($data['nlz'],"Urlaub aufbuchen") !== false) {
|
||||
$holidays=$this->getholidays($timerecording['user_id'], $enddate);
|
||||
if (strpos($data['nlz'], "Urlaub aufbuchen") !== false) {
|
||||
$holidays = $this->getholidays($timerecording['user_id'], $enddate);
|
||||
$data['holidays'] = $holidays;
|
||||
}
|
||||
}
|
||||
@@ -879,4 +913,94 @@ class TimerecordingBillingController extends mfBaseController
|
||||
|
||||
return $holidays_now;
|
||||
}
|
||||
|
||||
protected function checkWorkingDays($user_id, $month, $employee)
|
||||
{
|
||||
$holidays = TimerecordingHolidayModel::getAll();
|
||||
$datamonth = $month;
|
||||
$firstdate = strtotime(date("Y-m-01", $datamonth));
|
||||
$lastdate = strtotime(date("Y-m-t", $datamonth));
|
||||
$daycount = date("t", $datamonth);
|
||||
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
|
||||
|
||||
$startdate = $employee->startdate;
|
||||
if ($employee->enddate) {
|
||||
$enddate = strtotime(date('Y-m-d', $employee->enddate) . " 23:59:59");
|
||||
} else {
|
||||
$enddate = 2208985200;
|
||||
}
|
||||
$bpahours = $employee->bpahours;
|
||||
|
||||
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $user_id]);
|
||||
foreach ($workinghours as $workinghour) {
|
||||
|
||||
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghour->start . ":00");
|
||||
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghour->end . ":00");
|
||||
if (!$workingHours[$workinghour->day]) {
|
||||
$workingHours[$workinghour->day] = $whend - $whstart;
|
||||
} else {
|
||||
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
$workinghourshistory = TimerecordingEmployeeWorkingHourHistoryModel::search(['user_id' => $user_id]);
|
||||
if ($workinghourshistory) {
|
||||
$workingHoursHistory[9732489200] = $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->timestamp;
|
||||
}
|
||||
|
||||
//Lastdate staticmust deleted
|
||||
// $lastdate = strtotime("2024-03-22 23:59:59");
|
||||
// $daycount=22;
|
||||
|
||||
$searchArray = ['user_id' => $user_id, 'start' => $firstdate, 'end' => $lastdate];
|
||||
$timestamp = $firstdate;
|
||||
for ($i = 1; $i <= $daycount; $i++) {
|
||||
$WintertimeCompensation = 0;
|
||||
if (date('I', $timestamp) == 0) {
|
||||
$WintertimeCompensation = 3600;
|
||||
}
|
||||
$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) {
|
||||
$workingHours = $whdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate) && $dDate <= date('Y-m-d', $enddate)) {
|
||||
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||
if ($workingHours[$dDay]) {
|
||||
$workDays[$dDate] = $dDate;
|
||||
}
|
||||
}
|
||||
|
||||
$timestamp = $timestamp + 86400;
|
||||
}
|
||||
$timerecordingC = new TimerecordingController();
|
||||
$timerecordingC = $timerecordingC->getTimerecordingsApi('2', $month, $month, $month, 0, 0, $user_id, 0);
|
||||
foreach ($timerecordingC['workcheck'] as $key => $value) {
|
||||
unset($workDays[$value]);
|
||||
}
|
||||
|
||||
return $workDays;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user