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
This commit is contained in:
@@ -262,7 +262,7 @@ class TimerecordingController extends mfBaseController
|
||||
}
|
||||
if ($id) {
|
||||
$timerecordingCategoriess = TimerecordingCategoryModel::search(['id' => $data['timerecordingCategory_id']]);
|
||||
if ($timerecordingCategoriess[0]->approval == "1") {
|
||||
if ($timerecordingCategoriess[0]->approval == "1" && !$r->user_id) {
|
||||
$body = 'Beantrag von: ' . $this->me->name . '
|
||||
';
|
||||
$body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . '
|
||||
@@ -286,6 +286,9 @@ class TimerecordingController extends mfBaseController
|
||||
$email->setTo(TT_TIMERECORDING_EMAIL);
|
||||
$email->send();
|
||||
}
|
||||
if ($data['timerecordingCategory_id'] == "3") {
|
||||
$this->updateHolidays($data['user_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "edit") {
|
||||
@@ -303,6 +306,69 @@ class TimerecordingController extends mfBaseController
|
||||
$this->redirect("Timerecording");
|
||||
}
|
||||
|
||||
protected function updateHolidays($userid)
|
||||
{
|
||||
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
|
||||
if ($employee) {
|
||||
$employee = $employee[0];
|
||||
$holidays = $employee->holidays;
|
||||
$holidays_now = $employee->holidays_now;
|
||||
$holidays_timestamp = $employee->holidays_timestamp;
|
||||
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
|
||||
$realHolidays = TimerecordingHolidayModel::getAll();
|
||||
foreach ($realHolidays as $realHoliday) {
|
||||
$realholiDay[date('Y-m-d', $realHoliday->timestamp)] = $realHoliday->timestamp;
|
||||
}
|
||||
if (!$holidays_timestamp) {
|
||||
$holidays_timestamp = $employee->startdate;
|
||||
$holidays_now = $holidays;
|
||||
}
|
||||
$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 = $daycounter * 86400;
|
||||
if (is_int($daycounter)) {
|
||||
for ($i = 86400; $i <= $daycounter; $i = $i + 86400) {
|
||||
$holidayDays[date("Y-m-d", $timerecording->start + $i - 86400)] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
//check if holiday is already in the list
|
||||
foreach ($holidayDays as $key => $holidayDay) {
|
||||
if ($realholiDay[$key]) {
|
||||
|
||||
} else if ($workingHours[date('w', strtotime($key))]) {
|
||||
$holidays_now--;
|
||||
}
|
||||
}
|
||||
if ($holidays_now != $employee->holidays_now) {
|
||||
$employeeupdate = new TimerecordingEmployee($employee->id);
|
||||
$data = [];
|
||||
$data['holidays_now'] = $holidays_now;
|
||||
$employeeupdate->update($data);
|
||||
$employeeupdate->save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function updatePlushours($userid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
|
||||
{
|
||||
@@ -314,8 +380,8 @@ class TimerecordingController extends mfBaseController
|
||||
$rows = [];
|
||||
$employee = TimerecordingEmployeeModel::search(['user_id' => $this->me->id]);
|
||||
if ($employee) {
|
||||
$holiDays = $employee[0]->holidays;
|
||||
$plusHours = $employee[0]->plushours;
|
||||
$holiDays = $employee[0]->holidays_now;
|
||||
$plusHours = $employee[0]->plushours_now;
|
||||
$auto_workinghours = $employee[0]->auto_workinghours;
|
||||
|
||||
}
|
||||
@@ -621,12 +687,14 @@ class TimerecordingController extends mfBaseController
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$timerecordings = new Timerecording($id);
|
||||
$userid = $timerecordings->user_id;
|
||||
if (!$timerecordings->id || $timerecordings->id != $id) {
|
||||
$this->layout()->setFlash("Buchung nicht gefunden.", "error");
|
||||
$this->redirect("Timerecording");
|
||||
}
|
||||
|
||||
$timerecordings->delete();
|
||||
$this->updateHolidays($userid);
|
||||
|
||||
if ($this->request->ajax == 1) {
|
||||
die();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user