Zeiterfassung

Neue Features:
* BP Stunden Aufbuchen/Mindern
* Spezialbuchungen ohne Verechnungstechnische relevanz
This commit is contained in:
Daniel Spitzer
2024-12-29 20:24:36 +01:00
parent 42703dd303
commit 085d8facdc
12 changed files with 151 additions and 27 deletions

View File

@@ -263,6 +263,7 @@ class TimerecordingController extends mfBaseController
{
$r = $this->request;
$id = $r->id;
$oldbpseconds=0;
$enddate = $r->enddate;
$hourday = $r->hourday;
@@ -286,9 +287,12 @@ class TimerecordingController extends mfBaseController
} else if ($hourday == 5) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = strtotime($r->date . " 23:59:00");
} else if ($hourday == 8) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = strtotime($r->date . " 23:59:00");
}
if ($hourday != 5 && $hourday != 7) {
if ($hourday != 5 && $hourday != 7 && $hourday != 8) {
$result = $this->checkTimerecording($starttime, $endtime, $id);
}
if ($result['state'] == "error") {
@@ -304,6 +308,7 @@ class TimerecordingController extends mfBaseController
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$timerecordings = new Timerecording($id);
$oldbpseconds = $timerecordings->hours_bpa;
if (!$timerecordings->id) {
$this->layout()->setFlash("Buchungen nicht gefunden", "error");
$this->redirect("Timerecording");
@@ -326,7 +331,12 @@ class TimerecordingController extends mfBaseController
$data['businesstrip'] = $r->businesstrip;
$data['businesstrip_info'] = $r->businesstrip_info;
$data['homeoffice'] = $r->homeoffice;
$data['days'] = $r->days;
if ($hourday == 8) {
$data['days'] = 0;
$data['hours_bpa'] = $r->days * 60 * 60;
} else {
$data['days'] = $r->days;
}
$data['timerecordingCar_id'] = $r->timerecordingCar_id;
$data['mileage_start'] = $r->mileage_start;
$data['mileage_end'] = $r->mileage_end;
@@ -456,6 +466,9 @@ class TimerecordingController extends mfBaseController
}
$this->updatePlushours($data['user_id']);
TimerecordingCarModel::calcMileage();
if ($data['hours_bpa']) {
$this->updateBpHours($data['user_id'], $data['hours_bpa'], $oldbpseconds);
}
}
if ($mode == "edit") {
@@ -537,6 +550,21 @@ class TimerecordingController extends mfBaseController
}
}
public function updateBpHours($userid, $seconds, $oldseconds = 0)
{
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
if (!$employee) {
return;
}
$employee = $employee[0];
$bpHours = $employee->bpahours;
$employeeupdate = new TimerecordingEmployee($employee->id);
$data = [];
$data['bpahours'] = $bpHours + $seconds - $oldseconds;
$employeeupdate->update($data);
$employeeupdate->save();
}
public function updatePlushours($userid, $enddate = null)
{
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
@@ -957,7 +985,7 @@ class TimerecordingController extends mfBaseController
$edit .= '<i data-id="' . $timerecording->id . '" class="fas fa-trash text-danger delete-item" ></i>';
endif;
if ($datatype == 3 && ($timerecording->timerecordingCategory->hourday == 1 || $timerecording->timerecordingCategory->hourday == 7 || $timerecording->timerecordingCategory->hourday == 5)) {
} else {
} else if ($timerecording->timerecordingCategory->hourday != 8) {
$rows[] = array(
'date' => array('date' => $state . $day . " " . $date, 'order' => $orderdate),
'start' => array('start' => $start, 'order' => $start),
@@ -1102,10 +1130,14 @@ class TimerecordingController extends mfBaseController
$id = $this->request->id;
$timerecordings = new Timerecording($id);
$userid = $timerecordings->user_id;
$oldbpseconds = $timerecordings->hours_bpa;
if (!$timerecordings->id || $timerecordings->id != $id) {
$this->layout()->setFlash("Buchung nicht gefunden.", "error");
$this->redirect("Timerecording");
}
if ($timerecordings->timerecordingCategory->hourday == 8) {
$this->updateBpHours($userid, 0, $oldbpseconds);
}
$timerecordings->delete();
$this->updateHolidays($userid);
$this->updatePlushours($userid);