Merge branch 'spidev' into 'master'

Zeiterfassung Update

See merge request fronk/thetool!276
This commit is contained in:
Frank Schubert
2024-03-05 13:07:07 +00:00
16 changed files with 515 additions and 87 deletions
@@ -169,10 +169,14 @@ class TimerecordingController extends mfBaseController
} else if ($hourday == 3) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = NULL;
} else if ($hourday == 5) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = strtotime($r->date . " 23:59:00");
}
$result = $this->checkTimerecording($starttime, $endtime, $id);
if ($hourday != 5) {
$result = $this->checkTimerecording($starttime, $endtime, $id);
}
if ($result['state'] == "error") {
if ($r->ajax == 1) {
echo json_encode($result);
@@ -207,10 +211,18 @@ class TimerecordingController extends mfBaseController
$data['comment'] = trim($r->comment);
$data['businesstrip'] = $r->businesstrip;
$data['businesstrip_info'] = $r->businesstrip_info;
$data['homeoffice'] = $r->homeoffice;
$data['days'] = $r->days;
if (!$data['businesstrip'] || $data['businesstrip'] == "false") {
$data['businesstrip'] = 0;
}
if (!$data['homeoffice'] || $data['homeoffice'] == "false") {
$data['homeoffice'] = 0;
}
if (!$data['days'] || $data['days'] == "false") {
$data['days'] = 0;
}
if ($r->businesstrip == 1 && !$r->businesstrip_info) {
$result['state'] = "error";
$result['error'] = "Geschäftsreiseinformationen darf nicht leer sein";
@@ -223,16 +235,36 @@ class TimerecordingController extends mfBaseController
if (!$data['user_id']) {
if ($r->ajax == 1) {
$result['state'] = "error";
$result['error'] = "Benutzer darf nicht leer sein";
echo json_encode($result);
die();
}
$this->layout()->setFlash("Benutzer darf nicht leer sein", "error");
$this->redirect("Timerecording");
}
if ($data['start'] < 1577833200) {
if ($r->ajax == 1) {
$result['state'] = "error";
$result['error'] = "Ungültige Startzeit";
echo json_encode($result);
die();
}
$this->layout()->setFlash("Ungültige Startzeit", "error");
$this->redirect("Timerecording");
}
if ($data['end'] && $data['end'] < 1577833200) {
if ($r->ajax == 1) {
$result['state'] = "error";
$result['error'] = "Ungültige Endzeit";
echo json_encode($result);
die();
}
$this->layout()->setFlash("Ungültige Endzeit", "error");
$this->redirect("Timerecording");
}
if (!$data['timerecordingCategory_id']) {
$data['timerecordingCategory_id'] = NULL;
@@ -290,7 +322,7 @@ class TimerecordingController extends mfBaseController
$email->setTo(TT_TIMERECORDING_EMAIL);
$email->send();
}
if ($data['timerecordingCategory_id'] == "3") {
if ($data['timerecordingCategory_id'] == "3" || $timerecordingCategoriess[0]->hourday == "5") {
$this->updateHolidays($data['user_id']);
}
$this->updatePlushours($data['user_id']);
@@ -325,10 +357,12 @@ class TimerecordingController extends mfBaseController
$realholiDay[date('Y-m-d', $realHoliday->timestamp)] = $realHoliday->timestamp;
}
if (!$holidays_timestamp) {
$holidays_timestamp = $employee->startdate;
//$holidays_timestamp = $employee->startdate;
$holidays_timestamp = strtotime('2024-01-01 00:00:00');
$holidays_now = $holidays;
}
$timerecordings = TimerecordingModel::search(['user_id' => $userid, 'start' => $holidays_timestamp, 'timerecordingCategory_id' => 3]);
$timerecordingscorrections = TimerecordingModel::search(['user_id' => $userid, 'start' => $holidays_timestamp, 'days' => 1]);
foreach ($timerecordings as $timerecording) {
$daycounter = ($timerecording->end - $timerecording->start) / 86400;
$daycounter = intval(round($daycounter, 0, PHP_ROUND_HALF_DOWN));
@@ -359,6 +393,10 @@ class TimerecordingController extends mfBaseController
$holidays_now--;
}
}
foreach ($timerecordingscorrections as $timerecordingscorrection) {
$holidays_now = $holidays_now + $timerecordingscorrection->days;
}
if ($holidays_now != $employee->holidays_now) {
$employeeupdate = new TimerecordingEmployee($employee->id);
$data = [];
@@ -369,7 +407,7 @@ class TimerecordingController extends mfBaseController
}
}
protected function updatePlushours($userid)
public function updatePlushours($userid)
{
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
if ($employee) {
@@ -386,7 +424,7 @@ class TimerecordingController extends mfBaseController
$endtime = strtotime($endtime . " 23:59:00");
if ($plushours_timestamp > 0) {
$return = $this->getTimerecordingsApi(5, null, null, null, $plushours_timestamp, $endtime);
$return = $this->getTimerecordingsApi(5, null, null, null, $plushours_timestamp, $endtime, $userid);
$diffTime = $return['is'] - $return['must'];
$plushours_now = $plushours_now + $diffTime;
} else {
@@ -402,22 +440,25 @@ class TimerecordingController extends mfBaseController
}
}
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear, $startime = null, $endtime = null)
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear, $startime = null, $endtime = null, $userid = null)
{
$mustSeconds = 0;
$isSeconds = 0;
$holiDays = 0;
$plusHours = 0;
$startdate = time();
if (!$userid) {
$userid = $this->me->id;
}
$rows = [];
$employee = TimerecordingEmployeeModel::search(['user_id' => $this->me->id]);
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
if ($employee) {
$holiDays = $employee[0]->holidays_now;
$plusHours = $employee[0]->plushours_now;
$auto_workinghours = $employee[0]->auto_workinghours;
$startdate = $employee[0]->startdate;
}
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $this->me->id]);
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
$holidays = TimerecordingHolidayModel::getAll();
foreach ($workinghours as $workinghour) {
@@ -440,7 +481,7 @@ class TimerecordingController 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' => $this->me->id, 'start' => $timestamp_montag, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, 'start' => $timestamp_montag, 'end' => $lastdate];
$daycounter = '0';
@@ -448,7 +489,7 @@ class TimerecordingController extends mfBaseController
for ($i = 1; $i <= 7; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -459,13 +500,13 @@ class TimerecordingController 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' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -478,7 +519,7 @@ class TimerecordingController 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' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -498,7 +539,7 @@ class TimerecordingController extends mfBaseController
$timediff = $lastdate - $firstdate;
$daycount = $timediff / 86400;
$daycount = round($daycount, 0, PHP_ROUND_HALF_DOWN);
$searchArray = ['user_id' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $userid, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -524,6 +565,7 @@ class TimerecordingController extends mfBaseController
$state = "";
$enddate = "";
$sum = "-";
$day = "";
$orderdate = $timerecording->start;
if ($timerecording->timerecordingCategory->hourday == 1) {
@@ -538,6 +580,7 @@ class TimerecordingController extends mfBaseController
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
} 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);
@@ -557,10 +600,17 @@ class TimerecordingController 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();
@@ -570,19 +620,28 @@ class TimerecordingController 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";
}
} 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 < $timerecording->end) {
if ($lastdate < time()) {
$endtimecalc = $lastdate;
} else {
$endtimecalc = $timerecording->end;
$endtimecalc = time();
}
$summcounter = 0;
if ($firstdate > $timerecording->start) {
$starttimecalc = $firstdate;
} else {
@@ -590,10 +649,14 @@ class TimerecordingController extends mfBaseController
}
$summcounter = 0;
$savecounter = 0;
// echo $starttimecalc."<br>";
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
$holidaycounter = $workingHours[date("w", $i)];
$isSeconds = $isSeconds + $holidaycounter;
$summcounter = $summcounter + $holidaycounter;
$holidaycounter = $workingHours[$timerecording->user_id][date("w", $i)];
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {
$isSeconds = $isSeconds + $holidaycounter;
$summcounter = $summcounter + $holidaycounter;;
}
if ($savecounter == 1000) {
echo $savecounter;
die();
@@ -605,6 +668,24 @@ class TimerecordingController extends mfBaseController
$hours = floor($seconds / 3600);
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
} else if ($timerecording->timerecordingCategory->hourday == 5) {
$date = date("d.m.Y", $timerecording->start);
$start = "-";
$end = "-";
$day = $daysgerm[date("w", $timerecording->start)];
if ($timerecording->days > 0) {
if ($timerecording->days == 1) {
$sum = "+" . $timerecording->days . " Tag";
} else {
$sum = "+" . $timerecording->days . " Tage";
}
} else {
if ($timerecording->days == -1) {
$sum = $timerecording->days . " Tag";
} else {
$sum = $timerecording->days . " Tage";
}
}
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -614,7 +695,9 @@ class TimerecordingController 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 if ($timerecording->homeoffice == 1) {
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Homeoffice)</span>";
} else {
$category = $timerecording->timerecordingCategory->name;
}
@@ -634,6 +717,7 @@ class TimerecordingController extends mfBaseController
data-comment="' . $timerecording->comment . '"
data-businesstrip="' . $timerecording->businesstrip . '"
data-businesstripinfo="' . $timerecording->businesstrip_info . '"
data-homeoffice="' . $timerecording->homeoffice . '"
title="Bearbeiten"></i>';
else :
$edit .= '<div class="edit-placeholder"></div>';
@@ -659,9 +743,10 @@ class TimerecordingController extends mfBaseController
return $response;
} else {
if ($plusHours < 0) {
$plusHoursMinutes = $plusHours * -1;
$plusHours = $plusHours * -1;
$plusHours = "-" . sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
} else {
$plusHoursMinutes = $plusHours;
$plusHours = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
}
$json['success'] = true;
@@ -669,7 +754,7 @@ class TimerecordingController extends mfBaseController
$json['time']['is'] = sprintf('%02dh:%02dm', floor($isSeconds / 3600), floor($isSeconds / 60 % 60));
$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($plusHoursMinutes / 60 % 60));
$json['time']['plushours'] = $plusHours;
$json['data'] = $rows;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;
@@ -5,9 +5,11 @@ class TimerecordingModel
private $user_id;
private $start;
private $end;
private $days;
private $timerecordingCategory_id;
private $businesstrip;
private $businesstrip_info;
private $homeoffice;
private $comment;
private $approved;
private $completed;
@@ -157,6 +159,13 @@ class TimerecordingModel
$where .= " AND `start` >= $start AND `timerecordingCategory_id` = $timerecordingCategory_id ORDER by start ASC";
}
}
if (array_key_exists("start", $filter) && array_key_exists("days", $filter)) {
$days = $filter['days'];
$start = $filter['start'];
if ($days === 1) {
$where .= " AND `start` >= $start AND `days` !=0 ORDER by start ASC";
}
}
if (array_key_exists("starttime", $filter) && array_key_exists("endtime", $filter)) {
@@ -164,10 +173,11 @@ class TimerecordingModel
$endtime = $filter['endtime'];
$id = $filter['id'];
if (is_numeric($starttime) && is_numeric($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` = $endtime )) OR ( `start` <= $starttime AND `end` IS NULL)) ORDER by user_id ASC";
if ($id && is_numeric($id)) {
$where .= " AND `id` != $id";
}
$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` = $endtime )) OR ( `start` <= $starttime AND `end` IS NULL)) ORDER by user_id ASC";
//var_dump($where);exit;
}
}
@@ -11,7 +11,7 @@ class TimerecordingCalendarController extends mfBaseController
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->can(["Fibu"])) {
if (!$me->is(["employee"])) {
$this->redirect("Dashboard");
}
}
@@ -9,7 +9,7 @@ class TimerecordingCategoryModel
private $require_comment;
private $only_admin;
private $businesstrip;
public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum");
public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage");
public static $approval_definition = array(0 => "Nein", 1 => "Ja");
public static $require_comment_definition = array(0 => "Nein", 1 => "Ja");
public static $businesstrip_definition = array(0 => "Nein", 1 => "Ja");
@@ -103,6 +103,8 @@ class TimerecordingEmployeeWorkingHourModel
$secondcounter = 0;
while ($data = $db->fetch_array($res)) {
$dayHours[$data['user_id']][$data['day']][] = $data['start'] . " - " . $data['end'];
if ($olduser != $data['user_id']) {
if ($counter > 0) {
$secondcounter = 0;
@@ -121,7 +123,6 @@ class TimerecordingEmployeeWorkingHourModel
if (!$datetimetext) {
$datetimetext = $daysshort[$data['day']];
}
echo $oldstart . $data['start'];
if (($oldstart != $data['start'] || $oldend != $data['end']) && $oldend) {
$datetimetext .= " - " . $daysshort[$oldday] . " " . $oldstart . " - " . $oldend;
$datetimetext .= "<br> " . $daysshort[$data['day']];
@@ -139,6 +140,51 @@ class TimerecordingEmployeeWorkingHourModel
$datetimetext = TimerecordingEmployeeWorkingHourModel::cleardays($datetimetext);
$items[$olduser]['datetimetext'] = $datetimetext;
}
foreach ($dayHours as $key => $dayHour) {
foreach ($dayHour as $key2 => $dayHour2) {
$dayhours[$key][$key2] = implode("<br>", $dayHour2);
}
}
foreach ($dayhours as $key => $dayhour) {
$oldday = false;
$oldstring = false;
$counter = 0;
$oldkey = false;
$oldkey2 = false;
foreach ($dayhour as $key2 => $dayhour2) {
if ($oldday != $key2) {
if ($oldstring != $dayhour2 || $key2!=$oldkey2+1) {
if ($oldkey2) {
$daysitems[$key][$counter]['end'] = $oldkey2;
$counter++;
}
$daysitems[$key][$counter]['start'] = $key2;
}
$daysitems[$key][$counter]['string'] = $dayhour2;
}
$oldkey2 = $key2;
$oldkey = $key;
$oldstring = $dayhour2;
}
$daysitems[$key][$counter]['end'] = $key2;
}
foreach ($daysitems as $key => $daysitem) {
$datetimetext = "";
foreach ($daysitem as $key2 => $daysItem) {
if ($daysItem['start'] != $daysItem['end']) {
$datetimetext .= '<div class="d-table border-bottom border-dark"><div class="d-table-cell w-50 align-middle pr-2 ">' . $daysshort[$daysItem['start']] . "-" . $daysshort[$daysItem['end']] . '</div><div class="d-table-cell">' . $daysItem['string'] . '</div></div>';
} else {
$datetimetext .= '<div class="d-table border-bottom border-dark"><div class="d-table-cell w-50 align-middle pr-2 ">' . $daysshort[$daysItem['start']] . '</div><div class="d-table-cell">' . $daysItem['string'] . '</div></div>';
}
}
$items[$key]['datetimetext'] = $datetimetext;
}
return $items;
}
@@ -153,7 +199,6 @@ class TimerecordingEmployeeWorkingHourModel
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingEmployeeWorkingHour", "*", "$where ");
if ($db->num_rows($res)) {
@@ -11,7 +11,7 @@ class TimerecordingReportController extends mfBaseController
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->can(["Fibu"])) {
if (!$me->is(["employee"])) {
$this->redirect("Dashboard");
}
}
@@ -41,7 +41,7 @@ class TimerecordingReportController extends mfBaseController
case "getTimerecordings":
$return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear);
break;
case "getTimerecordingsTimes":
case "getTimerecordingsTimes":
$return = $this->getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear);
break;
default:
@@ -103,7 +103,7 @@ class TimerecordingReportController extends mfBaseController
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
// $mustSeconds = $mustSeconds + $workingHours[$dDay];
// $mustSeconds = $mustSeconds + $workingHours[$dDay];
}
$timestamp = $timestamp + 86400;
@@ -120,7 +120,7 @@ class TimerecordingReportController extends mfBaseController
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
// $mustSeconds = $mustSeconds + $workingHours[$dDay];
// $mustSeconds = $mustSeconds + $workingHours[$dDay];
}
$timestamp = $timestamp + 86400;
}
@@ -189,11 +189,18 @@ class TimerecordingReportController extends mfBaseController
}
$summcounter = 0;
$savecounter = 0;
$sumdays = 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;;
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {
if ($holidaycounter) {
$isSeconds = $isSeconds + $holidaycounter;
$summcounter = $summcounter + $holidaycounter;
$sumdays++;
}
}
if ($savecounter == 1000) {
echo $savecounter;
die();
@@ -203,7 +210,12 @@ 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";
}
} else if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
$date = date("d.m.Y", $timerecording->start) . " - " . $daysgerm[date("w", time())] . " " . date("d.m.Y", time());;
@@ -231,8 +243,11 @@ class TimerecordingReportController extends mfBaseController
// 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;;
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {
$isSeconds = $isSeconds + $holidaycounter;
$summcounter = $summcounter + $holidaycounter;;
}
if ($savecounter == 1000) {
echo $savecounter;
die();
@@ -244,6 +259,25 @@ class TimerecordingReportController extends mfBaseController
$hours = floor($seconds / 3600);
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
} else if ($timerecording->timerecordingCategory->hourday == 5) {
$date = date("d.m.Y", $timerecording->start);
$start = "-";
$end = "-";
$day = $daysgerm[date("w", $timerecording->start)];
if ($timerecording->days > 0) {
if ($timerecording->days == 1) {
$sum = "+" . $timerecording->days . " Tag";
} else {
$sum = "+" . $timerecording->days . " Tage";
}
} else {
if ($timerecording->days == -1) {
$sum = $timerecording->days . " Tag";
} else {
$sum = $timerecording->days . " Tage";
}
}
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -254,6 +288,8 @@ class TimerecordingReportController extends mfBaseController
$edit = "";
if ($timerecording->businesstrip == 1) {
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (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 {
$category = $timerecording->timerecordingCategory->name;
}
@@ -274,6 +310,8 @@ 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 . '"
title="Bearbeiten"></i>';
else :
$edit .= '<div class="edit-placeholder"></div>';
@@ -294,6 +332,8 @@ class TimerecordingReportController extends mfBaseController
'category' => array('category' => $category, 'order' => $timerecording->timerecordingCategory->name),
'comment' => array('comment' => $timerecording->comment, 'order' => $timerecording->comment),
'edit' => array('edit' => $edit, 'order' => $edit),
'hourday' => array('hourday' => $timerecording->timerecordingCategory->hourday, 'order' => $timerecording->timerecordingCategory->hourday),
);
}
endforeach;
@@ -325,7 +365,7 @@ class TimerecordingReportController extends mfBaseController
$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]);
$holidays = TimerecordingHolidayModel::getAll();
@@ -358,7 +398,8 @@ class TimerecordingReportController extends mfBaseController
for ($i = 1; $i <= 7; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -375,7 +416,7 @@ class TimerecordingReportController extends mfBaseController
for ($i = 1; $i <= $daycount; $i++) {
$dDate = date('Y-m-d', $timestamp);
$dDay = date('w', $timestamp);
if (!$holiDay[$dDate]) {
if (!$holiDay[$dDate] && $dDate >= date('Y-m-d', $startdate)) {
$mustSeconds = $mustSeconds + $workingHours[$dDay];
}
@@ -495,6 +536,12 @@ class TimerecordingReportController extends mfBaseController
$hours = floor($seconds / 3600);
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
} else if ($timerecording->timerecordingCategory->hourday == 5) {
$start = "-";
$end = "-";
$day = $daysgerm[date("w", $timerecording->start)];
$sum = $timerecording->days . " Tage";
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {