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:
Spitzer Daniel
2024-02-22 14:53:48 +01:00
parent cdbf9de6fe
commit 1fee0b1eef
11 changed files with 426 additions and 43 deletions

View File

@@ -206,10 +206,8 @@ $pagination_entity_name = "Pops";
markers[building.id] = marker;
});
console.log(all_coords);
// calculate center position
mapCenterPos = GetCenterFromDegrees(all_coords);
console.log(mapCenterPos);
buildingMap.setView(mapCenterPos, 12);
return true;
@@ -228,7 +226,6 @@ $pagination_entity_name = "Pops";
filter: filter
}, function (success) {
if (success.status == "OK") {
console.log(success);
if (Array.isArray(success.result.buildings)) {
buildings = success.result.buildings;

View File

@@ -18,7 +18,7 @@ for ($i = 1; $i <= 25; $i++) {
$kw = date('W', $time);
$year = date('Y', $time);
$timestamp_montag = strtotime("{$year}-W{$kw}");
$timestamp_freitag = strtotime("{$year}-W{$kw}-5");
$timestamp_freitag = strtotime("{$year}-W{$kw}-7");
$weeks[$time] = "KW" . $kw . " " . $year . " (" . date('d.m', $timestamp_montag) . "-" . date('d.m', $timestamp_freitag) . ")";
$time = $time - 604800;
}
@@ -179,14 +179,14 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
</div>
<div class="row" id="businesstrip-div">
<div class="row" id="businesstrip-div">
<div class="col-lg-2 mb-2">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="businesstrip"
id="businesstrip" value="1">
<label class="form-check-label" for="businesstrip" >
<label class="form-check-label" for="businesstrip">
Dienstreise > 12KM
</label>
</div>
@@ -204,7 +204,9 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
Abbrechen
</button>
<button style="display:none" id="auto-workinghours-button" type="button" class="btn btn-dark">Arbeitswoche verbuchen</button>
<button style="display:none" id="auto-workinghours-button" type="button" class="btn btn-dark">
Arbeitswoche verbuchen
</button>
</div>
</div>
</div>
@@ -340,7 +342,9 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
let insertUrl = "<?= self::getUrl("Timerecording", "save") ?>";
let deleteUrl = "<?= self::getUrl("Timerecording", "delete") ?>";
let requestUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'getTimerecordings']) ?>";
let autoWorkinghoursUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'fillWorkinghours']) ?>";
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>js/pages/timerecording/index.js?<?= date('U') ?>"></script>

View File

@@ -4,6 +4,16 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
.fc-event {
border-radius: 2px;
border: none;
cursor: move;
font-size: 13px;
margin: 3px 7px;
padding: 3px 5px;
text-align: center;
}
.fc-toolbar {
@media (max-width: 767px) {
flex-direction: column;
@@ -25,6 +35,123 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
.fc .fc-button-primary:not(:disabled).fc-button-active:focus, .fc .fc-button-primary:not(:disabled):active:focus {
box-shadow: none;
}
.popper, .tooltip {
position: absolute;
z-index: 9999;
/* background: #FFC107; */
color: #0f5be9;
width: auto;
/* border-radius: 3px; */
/* box-shadow: 0 0 1px rgba(0, 0, 0, 0.5); */
padding: 10px;
text-align: center;
opacity: 0.9;
}
.tooltip-inner {
max-width: 500px;
padding: 0.4rem 0.8rem;
color: #fff;
text-align: center;
background-color: #2c3e50;
border-radius: 0.2rem;
}
.style5 .tooltip {
background: #1E252B;
color: #FFFFFF;
max-width: 200px;
width: auto;
font-size: .8rem;
padding: .5em 1em;
}
.popper .popper__arrow,
.tooltip .tooltip-arrow {
width: 0;
height: 0;
border-style: solid;
position: absolute;
margin: 5px;
}
.tooltip .tooltip-arrow,
.popper .popper__arrow {
border-color: #FFC107;
}
.style5 .tooltip .tooltip-arrow {
border-color: #1E252B;
}
.popper[x-placement^="top"],
.tooltip[x-placement^="top"] {
margin-bottom: 5px;
}
.popper[x-placement^="top"] .popper__arrow,
.tooltip[x-placement^="top"] .tooltip-arrow {
border-width: 5px 5px 0 5px;
border-left-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
bottom: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
.popper[x-placement^="bottom"],
.tooltip[x-placement^="bottom"] {
margin-top: 5px;
}
.tooltip[x-placement^="bottom"] .tooltip-arrow,
.popper[x-placement^="bottom"] .popper__arrow {
border-width: 0 5px 5px 5px;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: transparent;
top: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
.tooltip[x-placement^="right"],
.popper[x-placement^="right"] {
margin-left: 5px;
}
.popper[x-placement^="right"] .popper__arrow,
.tooltip[x-placement^="right"] .tooltip-arrow {
border-width: 5px 5px 5px 0;
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
left: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
.popper[x-placement^="left"],
.tooltip[x-placement^="left"] {
margin-right: 5px;
}
.popper[x-placement^="left"] .popper__arrow,
.tooltip[x-placement^="left"] .tooltip-arrow {
border-width: 5px 0 5px 5px;
border-top-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
right: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
</style>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/moment/moment.min.js?<?= date('U') ?>"></script>
@@ -34,6 +161,9 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
src="<?= self::getResourcePath() ?>assets/js/calendar/moment/index.global.min.js?<?= date('U') ?>"></script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/locales-all.global.min.js?<?= date('U') ?>"></script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/calendar/tooltip.min.js?<?= date('U') ?>"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
let requestUrl = "<?= self::getUrl("TimerecordingReport", "api", ['do' => 'getTimerecordings', 'datatype' => '3', 'datayear' => time()]) ?>";
@@ -75,15 +205,13 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
backgroundColor: bgcolors[colorcount],
start: value.cstart.cstart,
end: value.cend.cend,
title: value.category.category + " " + value.user.user,
description: value.category.category + " " + value.user.user
title: value.ccategory.ccategory + " " + value.user.user,
description: value.ccategory.ccategory + " " + value.user.user
});
oldname = value.user.user;
cindex++;
});
console.log(holidays);
var initialLocaleCode = 'en';
var calendarEl = document.getElementById('fullcalendar');
var containerEl = document.getElementById('external-events');
@@ -103,8 +231,6 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
events: holiDays
};
var holidayEvents = {
id: 5,
backgroundColor: 'rgba(0,204,204,.25)',
@@ -112,8 +238,6 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
textColor: '#000',
events: holidays
};
var initialLocaleCode = 'en';
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
@@ -123,6 +247,14 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth'
},
eventDidMount: function (info) {
var tooltip = new Tooltip(info.el, {
title: info.event.extendedProps.description,
placement: 'top',
trigger: 'hover',
container: 'body'
});
},
editable: true,
droppable: true, // this allows things to be dropped onto the calendar
fixedWeekCount: true,
@@ -132,7 +264,7 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
hiddenDays: [],
navLinks: 'true',
events: [],
height: 700,
height: 800,
eventSources: [holidayEvents, birthdayEvents]
});
calendar.render();

View File

@@ -186,7 +186,6 @@ $daysSelect .= "</select>";
function checktime() {
var sum = 0;
$(".wtime").each(function (index) {
console.log($(this).find('.timeend').val());
var newdatestart = new Date('2020/01/01 ' + $(this).find('.timestart').val() + ':00');
var newdateend = new Date('2020/01/01 ' + $(this).find('.timeend').val() + ':00');
var differenz = (newdateend - newdatestart) / 1000;

View File

@@ -23,7 +23,7 @@ for ($i = 1; $i <= 25; $i++) {
$kw = date('W', $time);
$year = date('Y', $time);
$timestamp_montag = strtotime("{$year}-W{$kw}");
$timestamp_freitag = strtotime("{$year}-W{$kw}-5");
$timestamp_freitag = strtotime("{$year}-W{$kw}-7");
$weeks[$time] = "KW" . $kw . " " . $year . " (" . date('d.m', $timestamp_montag) . "-" . date('d.m', $timestamp_freitag) . ")";
$time = $time - 604800;

View File

@@ -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;

View File

@@ -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";
}
}
//

View File

@@ -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),

File diff suppressed because one or more lines are too long

View File

@@ -315,6 +315,32 @@ $(document).ready(function () {
}
});
$("body").on("click", "#auto-workinghours-button", function () {
const date = new Date($('#date').val());
var day = date.getDay(),
diff = date.getDate() - day + (day == 0 ? -6 : 1);
diff = date.getDate() - day + (day == 0 ? -6 : 1);
var monday = new Date(date.setDate(diff));
monday = monday.getTime();
monday = new Date(monday);
monday = monday.toLocaleDateString('de-DE');
//last day of week
var sunday = new Date(date.setDate(diff + 6));
sunday = sunday.getTime();
sunday = new Date(sunday);
sunday = sunday.toLocaleDateString('de-DE');
if (confirm('Sollen die Arbeitszeiten von ' + monday + ' bis ' + sunday + ' automatisch eingetragen werden?')) {
$.post(autoWorkinghoursUrl, {
dataweek: $.trim($('#date').val()),
ajax: 1
}).done(function (data) {
table.ajax.reload();
});
}
});
$("body").on("click", ".delete-item", function () {
if (confirm('Buchung wirklich löschen?')) {
@@ -344,6 +370,7 @@ $(document).ready(function () {
comment: $.trim($('#comment').val()),
businesstrip: businesstrip,
businesstrip_info: $.trim($('#businesstrip_info').val()),
hourday: $.trim($('#timerecordingCategory_id').find(':selected').data('hourday')),
ajax: 1
}).done(function (data) {
var result = $.parseJSON(data);
@@ -376,5 +403,6 @@ $(document).ready(function () {
table.ajax.reload();
});
});
$('#timerecordingCategory_id').change();
})
;

View File

@@ -350,14 +350,11 @@ $(document).ready(function () {
e.preventDefault();
$('#alert-box').remove();
var userid;
if ($.trim($('#id').val())) {
userid = $('#user_id_input').val();
}
userid = $('#user_id_select').val();
var businesstrip = false;
if ($('#businesstrip').prop('checked') == true) {
businesstrip = 1;
}
$.post(insertUrl, {
id: $.trim($('#id').val()),
user_id: userid,
@@ -369,6 +366,7 @@ $(document).ready(function () {
comment: $.trim($('#comment').val()),
businesstrip: businesstrip,
businesstrip_info: $.trim($('#businesstrip_info').val()),
hourday: $.trim($('#timerecordingCategory_id').find(':selected').data('hourday')),
ajax: 1
}).done(function (data) {
var result = $.parseJSON(data);
@@ -404,5 +402,6 @@ $(document).ready(function () {
table.ajax.reload(null, false);
});
});
$('#timerecordingCategory_id').change();
})
;