Merge branch 'spidev' into 'master'

Zeiterfassung

See merge request fronk/thetool!1003
This commit is contained in:
Daniel Spitzer
2025-02-07 11:29:39 +00:00
6 changed files with 603 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ foreach ($days as $key => $day) {
$daysSelect .= '<option value="' . $key . '">' . $day . '</option>';
}
$daysSelect .= "</select>";
?>
<script>
var daysselect = `<?= $daysSelect ?>`;
@@ -29,6 +30,15 @@ $daysSelect .= "</select>";
margin-left: 7px;
margin-top: 8px;
}
.remove-wh-history {
cursor: pointer;
color: #ff0606;
font-size: 17px;
float: right;
margin-left: 7px;
}
</style>
<!-- start page title -->
<div class="row">
@@ -214,6 +224,12 @@ $daysSelect .= "</select>";
<label class="col-form-label" for="workinghours"><span
id="workinghours-text">0 Stunden 0 Minuten</span></label>
</div>
<div class="col-lg-2 text-center">
<button type="button" id="change-workinghours" data-toggle="modal"
data-target="#closeWorkingHoursModal" class="btn btn-danger">
Arbeitszeit Abschluss
</button>
</div>
</div>
<?php
@@ -251,25 +267,113 @@ $daysSelect .= "</select>";
?>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a href="<?= self::getUrl("TimerecordingEmployee") ?>">
<button type="button" class="btn btn-secondary">Abbrechen</button>
</a>
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
</div>
<?php if ($timerecordingworkinghourshistory) : ?>
<div class="card-body">
<div class="card no-shadow">
<div class="card-body">
<div class="row">
<div class="col-lg-6">
<h4 class="header-title mb-2">Arbeitszeiten Historie</h4>
<table id="datatable" class="table table-sm ">
<thead>
<tr>
<th class="text-center">Arbeitszeiten</th>
<th class="text-center">Wochenstunden</th>
<th class="text-center">Bis</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
foreach ($timerecordingworkinghourshistory as $key => $timerecordingworkinghours):
if (!$timerecordingworkinghours['workinghours']) {
$historyworkingkours = '0 Stunden';
$historyworkingkoursText = "keine";
} else {
$historyworkingkoursText = $timerecordingworkinghours['workinghours'];
$hours = $timerecordingworkinghours['workingtime'] / 3600;
$historyworkingkours = $hours . ' Stunden';
}
?>
<tr>
<td class="text-center"><?= $historyworkingkoursText ?></td>
<td class="text-center"><?= $historyworkingkours ?></td>
<td class="text-center"><?= date('d.m.Y', $key) ?></td>
<td><i class="fa-regular fa-circle-minus remove-wh-history" data-id="<?= $timerecordingworkinghours['id'] ?>"></i>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="modal fade" id="closeWorkingHoursModal" tabindex="-1" role="dialog"
aria-labelledby="closeWorkingHoursModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Arbeitszeit abschließen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group row justify-content-center ">
<label class="col-lg-5 col-form-label" for="user_id">Letzter Tag</label>
<div class="col-lg-5">
<input type="date" id="workingHoursCloseDate" class="form-control required">
</div>
</div>
<div class="form-group row justify-content-center ">
<div class="col-lg-12 row justify-content-center"><h4 class="p-0 m-1">Arbeitszeiten</h4></div>
<div class="col-lg-12 row justify-content-center"><h5 class="p-0 m-1"
id="workingHoursTime"></h5></div>
<div id="old-workingHours" class="col-lg-10">
<table class="table table-sm">
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" id="save-close-workingHours">Abschließen</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Abbrechen</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function checktime() {
var sum = 0;
@@ -320,7 +424,83 @@ $daysSelect .= "</select>";
})
$(document).ready(function () {
checktime();
$('#closeWorkingHoursModal').on('shown.bs.modal', function () {
$('#old-workingHours table').empty();
$('#workingHoursCloseDate').val('');
$('#workingHoursTime').text($('#workinghours-text').text());
if ($(".wtime").length > 0) {
$(".wtime").each(function (index) {
var day = $(this).find('select').val();
var start = $(this).find('.timestart').val();
var end = $(this).find('.timeend').val();
var dayname = $(this).find('select option:selected').text();
var html = '<tr><td>' + dayname + '</td><td>' + start + '</td><td>' + end + '</td></tr>';
$('#old-workingHours table').append(html);
});
} else {
$('#old-workingHours table').append('<tr><td class="text-center" colspan="3">Keine Arbeitszeiten</td></tr>');
}
$(".wtime").each(function (index) {
});
})
//old-workingHours
$('body').on('click', '#save-close-workingHours', function () {
let reqworkingHoursSaveUrl = '<?= self::getUrl("TimerecordingEmployee", "api", ['do' => 'saveWorkingHours']) ?>';
let workingHours = [];
$(".wtime").each(function (index) {
var day = $(this).find('select').val();
var start = $(this).find('.timestart').val();
var end = $(this).find('.timeend').val();
workingHours.push({day: day, start: start, end: end});
});
let required = true;
$('.required').each(function () {
if ($(this).val() == '') {
required = false;
$(this).addClass('is-invalid');
} else {
$(this).removeClass('is-invalid');
}
});
if (!required) {
return;
}
$.ajax({
url: reqworkingHoursSaveUrl,
type: 'POST',
data: {
workingHours: workingHours,
enddate: $('#workingHoursCloseDate').val(),
userid: <?= $timerecordinguser[0]->id ?>
},
success: function (data) {
$('#closeWorkingHoursModal').modal('hide');
location.reload();
}
});
});
$('body').on('click', '.remove-wh-history', function () {
let reqworkingHoursSaveUrl = '<?= self::getUrl("TimerecordingEmployee", "api", ['do' => 'deleteWorkingHours']) ?>';
let id = $(this).data('id');
if (!confirm('Arbeitszeitänderung löschen?')) {
return;
}
$.ajax({
url: reqworkingHoursSaveUrl,
type: 'POST',
data: {
id: id,
userid: <?= $timerecordinguser[0]->id ?>
},
success: function (data) {
location.reload();
}
});
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>