Files
thetool/Layout/default/TimerecordingBilling/DetailClosed.php
Spi a7bc1ff8a6 Zeiterfassung Update
* ZA Anzeige beim genehmigen gefixt
2024-05-07 14:11:34 +02:00

378 lines
20 KiB
PHP

<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
.fa-arrow-right-from-bracket {
margin-top: 3px;
margin-right: 10px;
color: #2238d1;
cursor: pointer;
}
.filler {
width: 30px;
height: 1px;
}
.filler-0 {
width: 7px;
height: 1px;
}
#overtimeModal .table td, #overtimeModal .table th {
border: none;
}
@media (min-width: 992px) {
.modal-lg, .modal-xl {
max-width: 400px !important;
}
}
</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 active">Zeiterfassung Verrechnung</li>
</ol>
</div>
<h4 id="month" data-month="<?= $month ?>" class="page-title">Verrechnung/Abrechnung <?= $month ?></h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12" id="page-header">
<div class="float-left">
<h4 class="header-title">Liste aller Mitarbeiter</h4>
</div>
</div>
</div>
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<th class="text-center">Mitarbeiter/PersNr.</th>
<th class="text-center">Leistungszeiten</th>
<th class="text-center">Nichtleistungszeiten</th>
<th class="text-center">Istst.(NLZ+LZ)</th>
<th class="text-center">Sollstunden</th>
<th class="text-center">Sollabweichung</th>
<th class="text-center">Mehrstunden</th>
<th class="text-center">Ges. Überst.</th>
<?php if ($me->superexpertEnabled()): ?>
<th class="text-center">Black P. Stunden</th>
<?php endif; ?>
<th title="Mehrstunden 25%" class="text-center">M25</th>
<th title="Überstunden 50%" class="text-center">Ü50</th>
<th title="Überstunden 100%" class="text-center">Ü100</th>
<th class="text-center">Diäten</th>
<th class="text-center">Homeoffice</th>
</tr>
<tr id="filterrow">
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<?php if ($me->superexpertEnabled()): ?>
<th></th>
<?php endif; ?>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($timerecordings as $timerecording):
$user = new User($timerecording->timerecordingEmployee->user->id);
$employee_number = (string)$user->getFlag('employee_number');
unset ($nlz);
if ($timerecording->nlz) {
$nlz_details = json_decode($timerecording->nlz, true);
foreach ($nlz_details as $key => $nlz_detail) {
if ($nlz_detail < 100) {
$nlz .= $key . ": " . $nlz_detail . " Tag(e)<br>";
} else {
$nlz .= $key . ": " . round($nlz_detail / 3600, 2) . " Stunden<br>";
}
}
} else {
$nlz = "";
}
?>
<tr>
<td class="text-nowrap">(<?= $employee_number ?>) <?= $timerecording->timerecordingEmployee->user->name ?> </td>
<td class="text-center"><?= number_format(round($timerecording->ishours / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= $nlz ?></td>
<td class="text-center"><?= number_format(round($timerecording->ishourssum / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= number_format(round($timerecording->musthours / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center overtimeplushours-td" data-overtimeplushours="<?= number_format(round(($timerecording->overtime_plushours) / 3600, 2), "2", ",", ".") ?>"><?= number_format(round(($timerecording->ishourssum-$timerecording->musthours) / 3600, 2), "2", ",", ".") ?> <span class="text-danger font-weight-500"><?= ($timerecording->overtime_plushours) ? "(".number_format(round(($timerecording->overtime_plushours) / 3600, 2), "2", ",", ".").")" : '' ?></span></td>
<td class="text-center"><?= ($timerecording->plushours_all == 0) ? '<div class="filler-0 float-left"></div>' : '' ?><?= number_format(round(($timerecording->plushours_all) / 3600, 2), "2", ",", ".") ?>
<?= ($timerecording->plushours_all > 0) ? '<i class="float-right fa-regular fa-arrow-right-from-bracket change-difference" data-toggle="modal" data-target="#overtimeModal" data-hours="' . number_format(round(($timerecording->plushours_all) / 3600, 2), "2", ",", ".") . '" data-id="' . $timerecording->id . '"></i>' : '<div class="filler float-right"></div>' ?></td>
<td class="text-center"><?= ($timerecording->timerecordingEmployee->overtime_now == 0) ? '<div class="filler-0 float-left"></div>' : '' ?><?= number_format(round($timerecording->timerecordingEmployee->overtime_now / 3600, 2), "2", ",", ".") ?>
<?= ($timerecording->timerecordingEmployee->overtime_now > 0) ? '<i class="float-right fa-regular fa-arrow-right-from-bracket change-overtime" data-toggle="modal" data-target="#overtimeModal" data-hours="' . number_format(round($timerecording->timerecordingEmployee->overtime_now / 3600, 2), "2", ",", ".") . '" data-id="' . $timerecording->id . '"></i>' : '<div class="filler float-right"></div>' ?></td>
<?php if ($me->superexpertEnabled()): ?>
<td class="text-center"><?= number_format(round($timerecording->timerecordingEmployee->bpahours / 3600, 2), "2", ",", ".") ?></td>
<?php endif; ?>
<td class="text-center"><?= number_format(round($timerecording->plushours25 / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= number_format(round($timerecording->overtime50free / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= number_format(round($timerecording->overtime100free / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= number_format($timerecording->diet, 2, ',', '.') . " €" ?></td>
<td class="text-center"><?= $timerecording->homeoffice ?> Tag(e)</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<div class="spinner-big text-info mt-3 ml-5" style="display: none" >
<i class="fas fa-spinner fa-spin spinner-ico font-24 align-middle "></i> <span class="text-dark ml-2 font-weight-500 font-18 d-inline-block">Monatsabschluss wird rückgängig gemacht...</span>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="overtimeModal" tabindex="-1" role="dialog"
aria-labelledby="overtimeModalInfoLabel"
aria-hidden="true" data-id="">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="overtimeModal-title"></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="row">
<div class="col-12">
<table class="table ">
<tr id="overtimes">
</tr>
<tr class="overtime-modal-div" style="display:none">
<th class="align-middle">Gutstundenkonto</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="overtimehours"
id="overtimehours"></td>
</tr>
<tr class="overtime-modal-div" style="display:none">
<th class="align-middle">Mehrstunden 25</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="plushours25"
id="plushours25"></td>
</tr>
<tr>
<th class="align-middle">Überstunden 50</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="overtime50"
id="overtime50"></td>
</tr>
<tr>
<th class="text-nowrap align-middle">Überstunden 100</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="overtime100"
id="overtime100"></td>
</tr>
<?php if ($me->superexpertEnabled()): ?>
<tr>
<th class="text-nowrap align-middle">Blackpig</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="overtimebpa"
id="overtimebpa"></td>
</tr>
<?php endif; ?>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button id="submit-button" data-type="" type="button" class="btn btn-primary" data-dismiss="modal">
Speichern
<button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen
</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var hidesearch = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12];
<?php if ($me->superexpertEnabled()): ?>
hidesearch = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12,13];
<?php endif; ?>
var pageLength = 100;
$(document).ready(function () {
<?php if ($me->superexpertEnabled()): ?>
$('.buttons-excel').closest('div').prepend('<div ><button id="month-abort" class="btn btn-danger margina">Abschluss Abbrechen</button></div>');
<?php endif; ?>
$('.buttons-excel').closest('div').append('<div ><button id="bmd-export" class="btn btn-info margina">BMD Import</button></div>');
$('.buttons-excel').closest('div').append('<div ><button id="bmd-export-nlz" class="btn btn-info margina">BMD NLZ Import</button></div>');
$('body').on('click', '#bmd-export', function () {
window.open('<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'generatebmdexportclosed']) ?>&month=' + $('#month').data('month'), '_blank');
});
$('body').on('click', '#bmd-export-nlz', function () {
window.open('<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'generatebmdexportnlzclosed']) ?>&month=' + $('#month').data('month'), '_blank');
});
$('body').on('click', '#month-complete', function () {
if (confirm('Monat wirklich abschließen?')) {
$.post("<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'completemonth']) ?>", {
month: $.trim($('#month').data('month')),
ajax: 1
}).done(function (data) {
});
}
});
$('#overtimeModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
console.log(button.closest('tr').html());
if (button.hasClass('change-difference')) {
$('#overtimeModal-title').text('Mehrstunden Transfer');
$('#overtimeModal').data('id', button.data('id'));
var overtimeplushours=button.closest('tr').find('.overtimeplushours-td').data('overtimeplushours');
if (overtimeplushours != "0,00") {
var overtimeplushourstext='<span class="text-danger font-weight-500 ml-1">('+ button.closest('tr').find('.overtimeplushours-td').data('overtimeplushours')+ ')</span>';
} else {
var overtimeplushourstext="";
}
$('#overtimes').html('<th>Mehrstunden:</th> <td id="overtime-hours" data-hours="' + button.data('hours') + '">' + button.data('hours') + overtimeplushourstext + '</td>');
$('#submit-button').data('type', 'difference');
$('.overtime-modal-div').show();
}
if (button.hasClass('change-overtime')) {
$('#overtimeModal-title').text('Überstunden Transfer');
$('#overtimes').html('<th>Überstunden:</th> <td id="overtime-hours" data-hours="' + button.data('hours') + '">' + button.data('hours') + '</td>');
$('#submit-button').data('type', 'overtime');
$('#overtimeModal').data('id', button.data('id'));
$('.overtime-modal-div').hide();
}
$('.change-overtime-value').val('');
});
$('body').on('click', '#month-abort', function () {
if (confirm('Monatsabschluss ' + $('#month').data('month') + ' wirklich rückgängig machen?')) {
$('#datatable_wrapper').hide();
$('#page-header').hide();
$('.spinner-big').show();
$.post("<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'abortmonth']) ?>", {
month: $.trim($('#month').data('month')),
ajax: 1
}).done(function (data) {
window.location.href = "<?= self::getUrl("TimerecordingBilling", "detail", ['month' => $month]) ?>";
});
}
});
$('body').on('change', '.change-overtime-value', function () {
//$('#overtime-hours').data('hours') to float
var difference = 0;
$(".change-overtime-value").each(function (index) {
//check if float
var value = $(this).val().replace(",", ".");
// console.log(value);
if (isNaN(parseFloat(value))) {
} else {
difference += parseFloat(value);
}
});
var valdiff = difference - parseFloat($(this).val());
valdiff = Math.round(valdiff * 100) / 100;
console.log("valdif" + valdiff);
var hours = $('#overtime-hours').data('hours').replace(",", ".");
if (parseFloat(hours) < difference) {
difference = difference - parseFloat(hours)
difference = Math.round(difference * 100) / 100;
console.log(difference);
if (valdiff == 0) {
$(this).val(hours);
} else if (valdiff == parseFloat(hours)) {
$(this).val('0');
} else {
var calc = Math.round((hours - valdiff) * 100) / 100
$(this).val(calc);
}
} else {
hours = hours.replace(",", ".");
}
});
$('body').on('click', '#submit-button', function () {
var id = $('#overtimeModal').data('id');
var plushours25 = $('#plushours25').val();
var overtime50 = $('#overtime50').val();
var overtime100 = $('#overtime100').val();
var overtimebpa = $('#overtimebpa').val();
var overtimehours = $('#overtimehours').val();
$.post("<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'saveovertime']) ?>", {
id: id,
type: $(this).data('type'),
plushours25: plushours25,
overtimehours:overtimehours,
overtime50: overtime50,
overtime100: overtime100,
overtimebpa: overtimebpa,
ajax: 1
}).done(function (data) {
window.location.reload();
ö
});
});
//$.post(insertUrl, {
// id: $.trim($('#id').val()),
// timerecordingCategory_id: $.trim($('#timerecordingCategory_id').val()),
// date: $.trim($('#date').val()),
// enddate: $.trim($('#enddate').val()),
// start: $.trim($('#start').val()),
// end: $.trim($('#end').val()),
// comment: $.trim($('#comment').val()),
// businesstrip: businesstrip,
// businesstrip_info: $.trim($('#businesstrip_info').val()),
// timerecordingCar_id: $.trim($('#timerecordingCar_id').val()),
// mileage_start: $.trim($('#mileage_start').val()),
// mileage_end: $.trim($('#mileage_end').val()),
// homeoffice: homeoffice,
// hourday: $.trim($('#timerecordingCategory_id').find(':selected').data('hourday')),
// ajax: 1
//}).done(function (data) {
// if (data.success) {
// window.location.href = '<?php //= self::getUrl("Timerecording") ?>//';
// } else {
// $('#error').html(data.error);
// }
//});
});
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>