Zeiterfassungs Update
* Implementerung Fahrzeugverwaltung * neue Buchungsart Fahrtenbuch * Diverse Bugfixes
This commit is contained in:
@@ -25,6 +25,8 @@ class TimerecordingReportController extends mfBaseController
|
||||
$this->layout()->set("timerecordingusers", $timerecordingusers);
|
||||
$timerecordings = TimerecordingModel::getAll();
|
||||
$this->layout()->set("timerecordings", $timerecordings);
|
||||
$timerecordingCars = TimerecordingCarModel::search(['timerecording' => 1]);
|
||||
$this->layout()->set("timerecordingCars", $timerecordingCars);
|
||||
}
|
||||
|
||||
protected function apiAction()
|
||||
@@ -57,7 +59,7 @@ class TimerecordingReportController extends mfBaseController
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
|
||||
public function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
|
||||
{
|
||||
$mustSeconds = 0;
|
||||
$isSeconds = 0;
|
||||
@@ -290,6 +292,16 @@ class TimerecordingReportController extends mfBaseController
|
||||
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
$isSeconds = $isSeconds + $seconds;
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 7) {
|
||||
$date = date("d.m.Y", $timerecording->start);
|
||||
$datadate = date("Y-m-d", $timerecording->start);
|
||||
$start = date("H:i", $timerecording->start);
|
||||
$end = date("H:i", $timerecording->end);
|
||||
$seconds = $timerecording->end - $timerecording->start;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
}
|
||||
|
||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||
@@ -298,8 +310,17 @@ class TimerecordingReportController extends mfBaseController
|
||||
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
||||
}
|
||||
$edit = "";
|
||||
if ($timerecording->businesstrip == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
if ($timerecording->timerecordingCategory->hourday == 7) {
|
||||
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>(" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM) (Zielort: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} else if ($timerecording->businesstrip == 1) {
|
||||
if ($timerecording->timerecordingCar) {
|
||||
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
|
||||
$car = " (" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM)";
|
||||
} else {
|
||||
$car = "";
|
||||
}
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>$car (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} else if ($timerecording->homeoffice == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Homeoffice)</span>";
|
||||
} else {
|
||||
@@ -322,15 +343,18 @@ class TimerecordingReportController extends mfBaseController
|
||||
data-userid="' . $timerecording->user_id . '"
|
||||
data-businesstrip="' . $timerecording->businesstrip . '"
|
||||
data-businesstripinfo="' . $timerecording->businesstrip_info . '"
|
||||
data-homeoffice="' . $timerecording->homeoffice . '"
|
||||
data-days="' . $timerecording->days . '"
|
||||
data-homeoffice="' . $timerecording->homeoffice . '"
|
||||
data-days="' . $timerecording->days . '"
|
||||
data-car="' . $timerecording->timerecordingCar_id . '"
|
||||
data-mileagestart="' . $timerecording->mileage_start . '"
|
||||
data-mileageend="' . $timerecording->mileage_end . '"
|
||||
title="Bearbeiten"></i>';
|
||||
else :
|
||||
$edit .= '<div class="edit-placeholder"></div>';
|
||||
endif;
|
||||
$edit .= '<i data-id="' . $timerecording->id . '" class="fas fa-trash text-danger delete-item" ></i>';
|
||||
endif;
|
||||
if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
|
||||
if ($datatype == 3 && ($timerecording->timerecordingCategory->hourday == 1 || $timerecording->timerecordingCategory->hourday == 7 || $timerecording->timerecordingCategory->hourday == 5)) {
|
||||
} else {
|
||||
$rows[] = array(
|
||||
'user' => array('user' => $timerecording->user->name, 'order' => $timerecording->user->name),
|
||||
@@ -363,23 +387,28 @@ class TimerecordingReportController extends mfBaseController
|
||||
}
|
||||
|
||||
|
||||
protected function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear)
|
||||
public function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear, $user_id = NULL, $ajax = 1)
|
||||
{
|
||||
$r = $this->request;
|
||||
$mustSeconds = 0;
|
||||
$isSeconds = 0;
|
||||
$holiDays = 0;
|
||||
$plusHours = 0;
|
||||
$daysum = array();
|
||||
if (!$user_id) {
|
||||
$user_id = $r->user_id;
|
||||
}
|
||||
|
||||
|
||||
$rows = [];
|
||||
$employee = TimerecordingEmployeeModel::search(['user_id' => $r->user_id]);
|
||||
$employee = TimerecordingEmployeeModel::search(['user_id' => $user_id]);
|
||||
if ($employee) {
|
||||
$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]);
|
||||
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $user_id]);
|
||||
$holidays = TimerecordingHolidayModel::getAll();
|
||||
foreach ($workinghours as $workinghour) {
|
||||
|
||||
@@ -402,7 +431,7 @@ class TimerecordingReportController 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' => $r->user_id, 'start' => $timestamp_montag, 'end' => $lastdate];
|
||||
$searchArray = ['user_id' => $user_id, 'start' => $timestamp_montag, 'end' => $lastdate];
|
||||
|
||||
$daycounter = '0';
|
||||
|
||||
@@ -422,7 +451,7 @@ class TimerecordingReportController 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' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
|
||||
$searchArray = ['user_id' => $user_id, 'start' => $firstdate, 'end' => $lastdate];
|
||||
$timestamp = $firstdate;
|
||||
|
||||
for ($i = 1; $i <= $daycount; $i++) {
|
||||
@@ -441,7 +470,7 @@ class TimerecordingReportController 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' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
|
||||
$searchArray = ['user_id' => $user_id, 'start' => $firstdate, 'end' => $lastdate];
|
||||
$timestamp = $firstdate;
|
||||
|
||||
for ($i = 1; $i <= $daycount; $i++) {
|
||||
@@ -462,6 +491,7 @@ class TimerecordingReportController extends mfBaseController
|
||||
$timerecordingcategories = TimerecordingCategoryModel::getAll();
|
||||
|
||||
$timerecordings = TimerecordingModel::search($searchArray);
|
||||
|
||||
$responsecount = count($timerecordings);
|
||||
foreach ($timerecordings as $timerecording):
|
||||
$state = "";
|
||||
@@ -500,10 +530,18 @@ class TimerecordingReportController extends mfBaseController
|
||||
}
|
||||
$summcounter = 0;
|
||||
$savecounter = 0;
|
||||
$sumdays = 0;
|
||||
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
$daycheck = date("Y-m-d", $i);
|
||||
if (!$holiDay[$daycheck]) {
|
||||
if ($holidaycounter) {
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
$sumdays++;
|
||||
}
|
||||
}
|
||||
if ($savecounter == 1000) {
|
||||
echo $savecounter;
|
||||
die();
|
||||
@@ -513,8 +551,18 @@ class TimerecordingReportController extends mfBaseController
|
||||
$seconds = $summcounter;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
// $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
if ($sumdays == 1 || $sumdays == 0) {
|
||||
$sum = $sumdays . " Tag";
|
||||
} else if ($sumdays > 1) {
|
||||
$sum = $sumdays . " Tage";
|
||||
}
|
||||
|
||||
if (!$daysum[$timerecording->timerecordingCategory->short]) {
|
||||
$daysum[$timerecording->timerecordingCategory->short] = $sumdays;
|
||||
} else {
|
||||
$daysum[$timerecording->timerecordingCategory->short] = $daysum[$timerecording->timerecordingCategory->short] + $sumdays;
|
||||
}
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
|
||||
$date = date("d.m.Y", $timerecording->start) . " - " . $daysgerm[date("w", time())] . " " . date("d.m.Y", time());;
|
||||
$datadate = date("Y-m-d", $timerecording->start);
|
||||
@@ -554,6 +602,18 @@ class TimerecordingReportController extends mfBaseController
|
||||
$end = "-";
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
$sum = $timerecording->days . " Tage";
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 6) {
|
||||
$date = date("d.m.Y", $timerecording->start);
|
||||
$datadate = date("Y-m-d", $timerecording->start);
|
||||
$start = date("H:i", $timerecording->start);
|
||||
$end = date("H:i", $timerecording->end);
|
||||
// $seconds = $timerecording->hours;
|
||||
$seconds = $timerecording->end - $timerecording->start;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
$isSeconds = $isSeconds + $seconds;
|
||||
}
|
||||
|
||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||
@@ -600,11 +660,17 @@ class TimerecordingReportController extends mfBaseController
|
||||
$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['time']['daysum'] = $daysum;
|
||||
$json['recordsFiltered'] = $responsecount;
|
||||
$json['recordsTotal'] = $responsecount;
|
||||
$json = json_encode($json);
|
||||
echo trim($json);
|
||||
die();
|
||||
|
||||
if ($ajax == 1) {
|
||||
$json = json_encode($json);
|
||||
echo trim($json);
|
||||
die();
|
||||
} else {
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
|
||||
Reference in New Issue
Block a user