Files
Daniel Spitzer e4a1e2a85e Zeiterfassung Update
* Nachtzulage wurde in der Personaladministration hinzugefügt
* Bei der Verrechnung werden Ü100 wenn Nachtzulage aktiv ist anders bewertet
2025-10-11 18:29:53 +02:00

543 lines
30 KiB
PHP

<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
$daysSelect = '<select required="required" name="day[]" class="select2 form-control" readonly="readonly" >';
foreach ($days as $key => $day) {
$daysSelect .= '<option value="' . $key . '">' . $day . '</option>';
}
$daysSelect .= "</select>";
?>
<script>
var daysselect = `<?= $daysSelect ?>`;
</script>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
.fa-circle-plus {
color: #00b125;
cursor: pointer;
font-size: 17px;
float: right;
}
.remove-workinghours {
cursor: pointer;
color: #ff0606;
font-size: 17px;
float: right;
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">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
</li>
<li class="breadcrumb-item"><a
href="<?= self::getUrl("TimerecordingEmployee") ?>">Personaladministration</a></li>
<li class="breadcrumb-item active"><?= ($timerecordingemployees->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title"><?= ($timerecordingemployees->id) ? "Personaladministration" : "Personaladministration" ?></h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card bg-light">
<div class="card-body">
<h4 class="header-title mb-2"><?= ($timerecordingemployees->id) ? "Personaladministration" : "Personaladministration" ?></h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("TimerecordingEmployee", "save") ?>">
<div class="card no-shadow">
<div class="card-body">
<input type="hidden" name="id" value="<?= $timerecordingemployees->id ?>"/>
<div class="card no-shadow">
<div class="card-body">
<h3>Allgemein</h3>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="bmd_active">Aktive Verrechnung</label>
<div class="col-lg-3">
<div class="form-check">
<input id="bmd_active"
class="form-check-input" <?php if ($timerecordingemployees->bmd_active) echo 'checked="checked"'; ?>
type="checkbox" name="bmd_active" value="1"/>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="user_id">Mitarbeiter *</label>
<div class="col-lg-3">
<select required="required" id="user_id" name="user_id"
class="select2 form-control">
<option value="<?= $timerecordinguser[0]->id ?>"><?= $timerecordinguser[0]->name ?></option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="type">Vertragsart *</label>
<div class="col-lg-3">
<select class="select2 form-control " name="type" id="type">
<option value="1" <?= ($timerecordingemployees->type == '1') ? "selected='selected'" : "" ?>>
Angestellter
</option>
<option value="2" <?= ($timerecordingemployees->type == '2') ? "selected='selected'" : "" ?>>
Arbeiter
</option>
<option value="3" <?= ($timerecordingemployees->type == '3') ? "selected='selected'" : "" ?>>
Lehrling
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="startdate">Startdatum
Zeiterfassung</label>
<div class="col-lg-2">
<input required="required" type="date" id="startdate" name="startdate"
class="form-control"
value="<?= ($timerecordingemployees->startdate) ? date('Y-m-d', $timerecordingemployees->startdate) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="enddate">Enddatum
Zeiterfassung</label>
<div class="col-lg-2">
<input type="date" id="enddate" name="enddate"
class="form-control"
value="<?= ($timerecordingemployees->enddate) ? date('Y-m-d', $timerecordingemployees->enddate) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="birthday">Geburtstag</label>
<div class="col-lg-2">
<input type="date" id="birthday" name="birthday"
class="form-control"
value="<?= ($timerecordingemployees->birthday) ? date('Y-m-d', $timerecordingemployees->birthday) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="insurance_number">SV-Nummer (4
stellig)</label>
<div class="col-lg-1">
<input type="number" id="insurance_number" name="insurance_number"
class="form-control" max="9999"
value="<?= ($timerecordingemployees->insurance_number) ?: "" ?>"/>
</div>
</div>
<?php if ($me->superexpertEnabled()): ?>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="bpahours">Black Pig
Stunden</label>
<div class="col-lg-1">
<input required="required" type="text" id="bpahours" name="bpahours"
class="form-control"
value="<?= str_replace(".", ",", $timerecordingemployees->bpahours / 3600) ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="bpahours_value">Black Pig
Bewertung</label>
<div class="col-lg-1">
<input required="required" type="text" id="bpahours_value"
name="bpahours_value"
class="form-control"
value="<?= str_replace(".", ",", $timerecordingemployees->bpahours_value) ?>"/>
</div>
</div>
<?php endif; ?>
<div class="form-group row" style="display:none">
<label class="col-lg-2 col-form-label" for="holidays">Initiale
Urlaubstage</label>
<div class="col-lg-1">
<input type="number" id="holidays" name="holidays"
class="form-control"
value="<?= $timerecordingemployees->holidays ?>"/>
</div>
</div>
<div class="form-group row" style="">
<label class="col-lg-2 col-form-label" for="plushours">Initiale
Gutstunden</label>
<div class="col-lg-1">
<input type="text" id="plushours" name="plushours"
class="form-control"
value="<?= str_replace(".", ",", $timerecordingemployees->plushours / 3600) ?>"/>
</div>
</div>
<div class="form-group row" style="">
<label class="col-lg-2 col-form-label" for="overtime">Initiale
Überstunden</label>
<div class="col-lg-1">
<input type="text" id="overtime" name="overtime"
class="form-control"
value="<?= str_replace(".", ",", $timerecordingemployees->overtime / 3600) ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="auto_workinghours">Schnellbuchung</label>
<div class="col-lg-3">
<div class="form-check">
<input id="auto_workinghours"
class="form-check-input" <?php if ($timerecordingemployees->auto_workinghours) echo 'checked="checked"'; ?>
type="checkbox" name="auto_workinghours" value="1"/>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="auto_workinghours">Jobrad</label>
<div class="col-lg-3">
<div class="form-check">
<input id="jobbike"
class="form-check-input" <?php if ($timerecordingemployees->jobbike) echo 'checked="checked"'; ?>
type="checkbox" name="jobbike" value="1"/>
</div>
</div>
</div>
<?php if ($me->superexpertEnabled()): ?>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="bmd_active">Nur im Admin-Mode sichtbar</label>
<div class="col-lg-3">
<div class="form-check">
<input id="only_admin"
class="form-check-input" <?php if ($timerecordingemployees->only_admin) echo 'checked="checked"'; ?>
type="checkbox" name="only_admin" value="1"/>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
<div class="card no-shadow">
<div class="card-body">
<h3>Arbeitszeiten</h3>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="auto_workinghours">Nacht Zulage</label>
<div class="col-lg-3">
<div class="form-check">
<input id="night_allowance"
class="form-check-input" <?php if ($timerecordingemployees->night_allowance) echo 'checked="checked"'; ?>
type="checkbox" name="night_allowance" value="1"/>
</div>
</div>
</div>
<div id="workinghours_div">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="workinghours">Sollzeiten
Arbeitswoche <i
class="fa-regular fa-circle-plus add-workinghours"></i></label>
<div class="col-lg-2 text-center">
<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
if ($timerecordingworkinghours):
foreach ($timerecordingworkinghours as $timerecordingworkinghour): ?>
<div class="form-group row wtime">
<div class="col-lg-2">
<i class="fa-regular fa-circle-minus remove-workinghours"></i>
</div>
<div class="col-lg-2">
<select required="required" name="day[]"
class="select2 form-control"
readonly="readonly">
<?php foreach ($days as $key => $day) : ?>
<option value="<?= $key ?>" <?= ($key == $timerecordingworkinghour->day) ? "selected='selected'" : "" ?>><?= $day ?></option>';
<?php endforeach;
?>
</select>
</div>
<div class="col-lg-1">
<input type="time" name="timestart[]"
class="form-control timestart"
value="<?= $timerecordingworkinghour->start ?>"
required="required"/>
</div>
<div class="col-lg-1">
<input required="required" type="time" name="timeend[]"
class="form-control timeend"
value="<?= $timerecordingworkinghour->end ?>"/>
</div>
</div>
<?php
endforeach;
endif
?>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<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;
$(".wtime").each(function (index) {
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;
sum = sum + differenz;
});
var timenew = Math.floor(sum / 3600) + ' Stunden ' + Math.floor((sum % 3600) / 60) + ' Minuten';
$('#workinghours-text').text(timenew);
}
$(".select2").select2({placeholder: ""});
// disable mousewheel on a input number field when in focus
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {
e.preventDefault()
})
});
$('form').on('blur', 'input[type=number]', function (e) {
$(this).off('wheel.disableScroll')
});
$("#workinghours_div").on("change", "input", function () {
checktime();
});
$("body").on("click", ".remove-workinghours", function () {
$(this).closest('.form-group').remove();
checktime();
});
$("body").on("click", ".add-workinghours", function () {
$('#workinghours_div').append(`<div class="form-group row wtime"><div class="col-lg-2"><i class="fa-regular fa-circle-minus remove-workinghours"></i></div><div class="col-lg-2">` +
daysselect + `</div><div class="col-lg-1"><input type="time" name="timestart[]" class="form-control timestart"
value="07:00" required="required" /></div><div class="col-lg-1"><input required="required" type="time" name="timeend[]" class="form-control timeend"
value="15:00" /></div>`);
checktime();
$(".select2").select2({placeholder: ""});
})
$(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"); ?>