Zeiterfassung update
* Autoausfüllen -> fertiggestellt * Überprüfungen Buchungsüberschneidungen ausgebaut * Abwesenheitskalender Mouseover eingebaut * Abwesenheiten ohne Ende Update -> Gesundmeldung generiert nun ein Update mit Ende auf die Abwesenheit
This commit is contained in:
@@ -37,6 +37,9 @@ class TimerecordingController extends mfBaseController
|
||||
case "getTimerecordings":
|
||||
$return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear);
|
||||
break;
|
||||
case "fillWorkinghours":
|
||||
$return = $this->fillWorkinghours($dataweek);
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -86,6 +89,9 @@ class TimerecordingController extends mfBaseController
|
||||
} else {
|
||||
$userid = $this->me->id;
|
||||
}
|
||||
if (!$endtime) {
|
||||
$endtime = strtotime(date("Y-m-d", $starttime) . " 23:59:00");
|
||||
}
|
||||
|
||||
$searchArray = ['user_id' => $userid, 'starttime' => $starttime, 'endtime' => $endtime];
|
||||
if ($id) {
|
||||
@@ -102,22 +108,67 @@ class TimerecordingController extends mfBaseController
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function updateOpenTimerecording()
|
||||
{
|
||||
$r = $this->request;
|
||||
$date = strtotime($r->date . " 23:59:00");
|
||||
if ($r->user_id) {
|
||||
$userid = $r->user_id;
|
||||
} else {
|
||||
$userid = $this->me->id;
|
||||
}
|
||||
$searchArray = ['user_id' => $userid, 'type' => 'opentimerecording'];
|
||||
$timerecordings = TimerecordingModel::search($searchArray);
|
||||
$timerecordingssave = new Timerecording($timerecordings[0]->id);
|
||||
|
||||
|
||||
$data = [];
|
||||
$data['end'] = $date;
|
||||
$timerecordingssave->update($data);
|
||||
$id = $timerecordingssave->save();
|
||||
if ($timerecordingssave->id) {
|
||||
if ($r->ajax == 1) {
|
||||
$message = "Buchung erfolgreich angelegt";
|
||||
$result['state'] = "success";
|
||||
$result['message'] = "$message";
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
} else {
|
||||
if ($r->ajax == 1) {
|
||||
$message = "Buchung konnte nicht angelegt werden";
|
||||
$result['state'] = "error";
|
||||
$result['error'] = "$message";
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
$enddate = $r->enddate;
|
||||
if (!$enddate && $r->start && $r->end) {
|
||||
$hourday = $r->hourday;
|
||||
|
||||
if ($hourday == 4) {
|
||||
|
||||
$this->updateOpenTimerecording();
|
||||
}
|
||||
|
||||
if ($hourday == 1) {
|
||||
$starttime = strtotime($r->date . " " . $r->start . ":00");
|
||||
$endtime = strtotime($r->date . " " . $r->end . ":00");
|
||||
} elseif ($enddate) {
|
||||
} elseif ($hourday == 2) {
|
||||
$starttime = strtotime($r->date . " 00:00:00");
|
||||
$endtime = strtotime($enddate . " 23:59:00");
|
||||
} else if (!$enddate && !$r->start && !$r->end) {
|
||||
} else if ($hourday == 3) {
|
||||
$starttime = strtotime($r->date . " 00:00:00");
|
||||
$endtime = NULL;
|
||||
}
|
||||
|
||||
|
||||
$result = $this->checkTimerecording($starttime, $endtime, $id);
|
||||
if ($result['state'] == "error") {
|
||||
if ($r->ajax == 1) {
|
||||
@@ -289,6 +340,7 @@ class TimerecordingController extends mfBaseController
|
||||
$year = date('Y', $dataweek);
|
||||
$timestamp_montag = strtotime("{$year}-W{$kw}");
|
||||
$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];
|
||||
|
||||
@@ -367,7 +419,7 @@ class TimerecordingController extends mfBaseController
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
$isSeconds = $isSeconds + $seconds;
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 2) {
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 2 || ($timerecording->timerecordingCategory->hourday == 3 && $timerecording->end)) {
|
||||
$date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end);
|
||||
$datadate = date("Y-m-d", $timerecording->start);
|
||||
$enddate = date("Y-m-d", $timerecording->end);
|
||||
@@ -380,23 +432,61 @@ class TimerecordingController extends mfBaseController
|
||||
} else {
|
||||
$endtimecalc = $timerecording->end;
|
||||
}
|
||||
if ($firstdate > $timerecording->start) {
|
||||
$starttimecalc = $firstdate;
|
||||
} else {
|
||||
$starttimecalc = $timerecording->start;
|
||||
}
|
||||
$summcounter = 0;
|
||||
for ($i = $timerecording->start; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$savecounter = 0;
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
if ($savecounter == 1000) {
|
||||
echo $savecounter;
|
||||
die();
|
||||
}
|
||||
$savecounter++;
|
||||
}
|
||||
$seconds = $summcounter;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) {
|
||||
$date = date("d.m.Y", $timerecording->start);
|
||||
} 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);
|
||||
$start = "-";
|
||||
$end = "-";
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
if ($lastdate < $timerecording->end) {
|
||||
$endtimecalc = $lastdate;
|
||||
} else {
|
||||
$endtimecalc = $timerecording->end;
|
||||
}
|
||||
if ($firstdate > $timerecording->start) {
|
||||
$starttimecalc = $firstdate;
|
||||
} else {
|
||||
$starttimecalc = $timerecording->start;
|
||||
}
|
||||
$summcounter = 0;
|
||||
$savecounter = 0;
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
if ($savecounter == 1000) {
|
||||
echo $savecounter;
|
||||
die();
|
||||
}
|
||||
$savecounter++;
|
||||
}
|
||||
$seconds = $summcounter;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
|
||||
}
|
||||
|
||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||
@@ -410,6 +500,10 @@ class TimerecordingController extends mfBaseController
|
||||
} else {
|
||||
$category = $timerecording->timerecordingCategory->name;
|
||||
}
|
||||
if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
|
||||
$category = $category . "<span class='text-bold ml-2'>(offen)</span>";
|
||||
}
|
||||
|
||||
|
||||
if ($timerecording->completed == 0 && $timerecording->timerecordingCategory->only_admin == 0):
|
||||
if ($timerecording->approved == 0) :
|
||||
@@ -455,6 +549,74 @@ class TimerecordingController extends mfBaseController
|
||||
die();
|
||||
}
|
||||
|
||||
protected function fillWorkinghours($dataweek)
|
||||
{
|
||||
$dataweek = strtotime($dataweek);
|
||||
$employee = TimerecordingEmployeeModel::search(['user_id' => $this->me->id]);
|
||||
if ($employee) {
|
||||
$auto_workinghours = $employee[0]->auto_workinghours;
|
||||
}
|
||||
if ($auto_workinghours == 0) {
|
||||
$result['state'] = "error";
|
||||
$result['error'] = "Automatische Arbeitszeiten sind deaktiviert";
|
||||
echo json_encode($result);
|
||||
die();
|
||||
}
|
||||
|
||||
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $this->me->id]);
|
||||
$holidays = TimerecordingHolidayModel::getAll();
|
||||
foreach ($workinghours as $workinghour) {
|
||||
$workingHours[$workinghour->day][] = array('start' => $workinghour->start, 'end' => $workinghour->end);
|
||||
}
|
||||
foreach ($holidays as $holiday) {
|
||||
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
|
||||
}
|
||||
|
||||
|
||||
$kw = date('W', $dataweek);
|
||||
$year = date('Y', $dataweek);
|
||||
$timestamp_montag = strtotime("{$year}-W{$kw}");
|
||||
$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' => $firstdate, 'end' => $lastdate];
|
||||
$timerecording = TimerecordingModel::search($searchArray);
|
||||
|
||||
|
||||
$daycounter = '0';
|
||||
|
||||
$timestamp = $timestamp_montag;
|
||||
for ($i = 1; $i <= 7; $i++) {
|
||||
$dDate = date('Y-m-d', $timestamp);
|
||||
$dDay = date('w', $timestamp);
|
||||
if (!$holiDay[$dDate]) {
|
||||
if ($workingHours[$dDay]) {
|
||||
foreach ($workingHours[$dDay] as $workingHour) {
|
||||
$starttime = strtotime($dDate . " " . $workingHour['start'] . ":00");
|
||||
$endtime = strtotime($dDate . " " . $workingHour['end'] . ":00");
|
||||
$check = $this->checkTimerecording($starttime, $endtime);
|
||||
if ($check['state'] == "success") {
|
||||
$data = [];
|
||||
$data['user_id'] = $this->me->id;
|
||||
$data['start'] = $starttime;
|
||||
$data['end'] = $endtime;
|
||||
$data['timerecordingCategory_id'] = 1;
|
||||
$data['comment'] = "Automatisch eingetragen";
|
||||
$data['businesstrip'] = 0;
|
||||
$data['businesstrip_info'] = NULL;
|
||||
$timerecordings = TimerecordingModel::create($data);
|
||||
$id = $timerecordings->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$timestamp = $timestamp + 86400;;
|
||||
}
|
||||
}
|
||||
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
@@ -147,7 +147,7 @@ class TimerecordingModel
|
||||
$start = $filter['start'];
|
||||
$end = $filter['end'];
|
||||
if (is_numeric($start) && is_numeric($end)) {
|
||||
$where .= " AND `start` > $start AND `start` < $end ORDER by user_id ASC";
|
||||
$where .= " AND ((`start` >= $start AND `start` <= $end) OR (`end` >= $start AND `end` <= $end) OR `end` is NULL) ORDER by user_id ASC";
|
||||
}
|
||||
}
|
||||
if (array_key_exists("starttime", $filter) && array_key_exists("endtime", $filter)) {
|
||||
@@ -155,11 +155,17 @@ class TimerecordingModel
|
||||
$endtime = $filter['endtime'];
|
||||
$id = $filter['id'];
|
||||
if (is_numeric($starttime) && is_numeric($endtime)) {
|
||||
$where .= " AND ((`start` <= $starttime AND `end` >= $starttime ) || (`start` >= $endtime AND `end` <= $endtime) || (`start` >= $starttime AND `end` >= $starttime AND `start` <= $endtime AND `end` <= $endtime))";
|
||||
$where .= " AND (((`start` <= $starttime AND `end` >= $starttime ) OR (`start` >= $endtime AND `end` <= $endtime) OR (`start` >= $starttime AND `end` >= $starttime AND `start` <= $endtime AND `end` <= $endtime) OR (`start` >= $starttime AND `end` >= $starttime AND `start` <= $endtime AND `end` >= $endtime)) OR ( `start` <= $starttime AND `end` IS NULL)) ORDER by user_id ASC";
|
||||
if ($id && is_numeric($id)) {
|
||||
$where .= " AND `id` != $id";
|
||||
}
|
||||
|
||||
//var_dump($where);exit;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("type", $filter)) {
|
||||
$type = $filter['type'];
|
||||
if ($type === "opentimerecording") {
|
||||
$where .= " AND `end` IS NULL ORDER by start DESC LIMIT 1";
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
@@ -74,10 +74,10 @@ class TimerecordingReportController extends mfBaseController
|
||||
|
||||
$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;
|
||||
if (!$workingHours[$workinghour->user_id][$workinghour->day]) {
|
||||
$workingHours[$workinghour->user_id][$workinghour->day] = $whend - $whstart;
|
||||
} else {
|
||||
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
|
||||
$workingHours[$workinghour->user_id][$workinghour->day] = $workingHours[$workinghour->user_id][$workinghour->day] + $whend - $whstart;
|
||||
}
|
||||
}
|
||||
foreach ($holidays as $holiday) {
|
||||
@@ -89,6 +89,7 @@ class TimerecordingReportController extends mfBaseController
|
||||
$year = date('Y', $dataweek);
|
||||
$timestamp_montag = strtotime("{$year}-W{$kw}");
|
||||
$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 = ['start' => $timestamp_montag, 'end' => $lastdate];
|
||||
|
||||
@@ -164,10 +165,10 @@ 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 == 2) {
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 2 || ($timerecording->timerecordingCategory->hourday == 3 && $timerecording->end)) {
|
||||
$date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end);
|
||||
$datadate = date("Y-m-d", $timerecording->start);
|
||||
$enddate = date("Y-m-d", $timerecording->end);
|
||||
$enddate = date("Y-m-d", $timerecording->end + 7200);
|
||||
$start = "-";
|
||||
$end = "-";
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
@@ -177,23 +178,69 @@ class TimerecordingReportController extends mfBaseController
|
||||
} else {
|
||||
$endtimecalc = $timerecording->end;
|
||||
}
|
||||
|
||||
if ($firstdate > $timerecording->start) {
|
||||
$starttimecalc = $firstdate;
|
||||
} else {
|
||||
$starttimecalc = $timerecording->start;
|
||||
}
|
||||
$summcounter = 0;
|
||||
for ($i = $timerecording->start; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[date("w", $i)];
|
||||
$savecounter = 0;
|
||||
// echo $starttimecalc."<br>";
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;;
|
||||
if ($savecounter == 1000) {
|
||||
echo $savecounter;
|
||||
die();
|
||||
}
|
||||
$savecounter++;
|
||||
}
|
||||
$seconds = $summcounter;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
|
||||
} else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) {
|
||||
$date = date("d.m.Y", $timerecording->start);
|
||||
} 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);
|
||||
$enddatetemp = date("Y-m-d", time());
|
||||
$enddatetemp = strtotime($enddatetemp . " 23:59:59");
|
||||
$enddate = date("Y-m-d", $enddatetemp + 7200);
|
||||
$start = "-";
|
||||
$end = "-";
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
|
||||
if ($lastdate < time()) {
|
||||
$endtimecalc = $lastdate;
|
||||
} else {
|
||||
$endtimecalc = time();
|
||||
}
|
||||
$summcounter = 0;
|
||||
if ($firstdate > $timerecording->start) {
|
||||
$starttimecalc = $firstdate;
|
||||
} else {
|
||||
$starttimecalc = $timerecording->start;
|
||||
}
|
||||
$summcounter = 0;
|
||||
$savecounter = 0;
|
||||
// echo $starttimecalc."<br>";
|
||||
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
|
||||
$holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)];
|
||||
$isSeconds = $isSeconds + $holidaycounter;
|
||||
$summcounter = $summcounter + $holidaycounter;;
|
||||
if ($savecounter == 1000) {
|
||||
echo $savecounter;
|
||||
die();
|
||||
}
|
||||
$savecounter++;
|
||||
}
|
||||
$seconds = $summcounter;
|
||||
$minutes = floor(($seconds % 3600) / 60);
|
||||
$hours = floor($seconds / 3600);
|
||||
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||
|
||||
}
|
||||
|
||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||
@@ -203,10 +250,13 @@ class TimerecordingReportController extends mfBaseController
|
||||
}
|
||||
$edit = "";
|
||||
if ($timerecording->businesstrip == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-2'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} else {
|
||||
$category = $timerecording->timerecordingCategory->name;
|
||||
}
|
||||
if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
|
||||
$category = $category . " <span class='text-bold ml-1'>(Offen)</span>";
|
||||
}
|
||||
|
||||
|
||||
if ($timerecording->completed == 0):
|
||||
@@ -237,6 +287,7 @@ class TimerecordingReportController extends mfBaseController
|
||||
'sum' => array('sum' => $sum, 'order' => $sum),
|
||||
'cstart' => array('cstart' => $datadate, 'order' => $datadate),
|
||||
'cend' => array('cend' => $enddate, 'order' => $enddate),
|
||||
'ccategory' => array('ccategory' => $timerecording->timerecordingCategory->name, 'order' => $timerecording->timerecordingCategory->name),
|
||||
'category' => array('category' => $category, 'order' => $timerecording->timerecordingCategory->name),
|
||||
'comment' => array('comment' => $timerecording->comment, 'order' => $timerecording->comment),
|
||||
'edit' => array('edit' => $edit, 'order' => $edit),
|
||||
|
||||
Reference in New Issue
Block a user