229 lines
12 KiB
PHP
229 lines
12 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;
|
|
}
|
|
</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="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="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="holidays">Initiale Urlaubstage</label>
|
|
<div class="col-lg-1">
|
|
<input required="required" type="number" id="holidays" name="holidays"
|
|
class="form-control"
|
|
value="<?= $timerecordingemployees->holidays ?>"/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group row">
|
|
<label class="col-lg-2 col-form-label" for="plushours">Initiale Gutstunden</label>
|
|
<div class="col-lg-1">
|
|
<input required="required" type="text" id="plushours" name="plushours"
|
|
class="form-control"
|
|
value="<?= str_replace(".", ",", $timerecordingemployees->plushours / 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 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>
|
|
|
|
<?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 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>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
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;
|
|
|
|
|
|
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();
|
|
});
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|