Files
thetool/Layout/default/Timerecording/Index.php
Daniel Spitzer 47a09c9597 Zeiterfassung Update
* Anzeigezeitraum der Jahre erhöht
2026-01-22 13:11:04 +01:00

439 lines
20 KiB
PHP

<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
$daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
$monthger[1] = "Jänner";
$monthger[2] = "Februar";
$monthger[3] = "März";
$monthger[4] = "April";
$monthger[5] = "Mai";
$monthger[6] = "Juni";
$monthger[7] = "Juli";
$monthger[8] = "August";
$monthger[9] = "September";
$monthger[10] = "Oktober";
$monthger[11] = "November";
$monthger[12] = "Dezember";
$time = time();
for ($i = 1; $i <= 25; $i++) {
$kw = date('W', $time);
$year = date('o', $time);
$timestamp_montag = strtotime("{$year}-W{$kw}");
$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;
}
$monthger = [
1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April',
5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August',
9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember'
];
$month = [];
$date = new DateTime('first day of this month');
$time = time();
$timenow = $time;
$time = strtotime('first day of this month', $time);
$time = strtotime('+3 month', $time);
for ($i = 1; $i <= 15; $i++) {
$mon = date('n', $time);
$year = date('Y', $time);
$month[$time] = $monthger[$mon] . " " . $year;
$time = strtotime('-1 month', $time);
}
//$years[time() + 31536000] = date('Y', time() + 31536000);
//$years[time()] = date('Y', time());
//$years[time() - 31536000] = date('Y', time() - 31536000);
$years = [];
$startYear = 2024;
$endYear = date('Y') + 1; // 2026 + 1 = 2027
// Schleife zählt rückwärts: 2027 -> 2026 -> 2025 -> 2024
for ($i = $endYear; $i >= $startYear; $i--) {
// Erstellt einen Timestamp für den 1. Januar des Jahres $i um 00:00:00 Uhr
// mktime(Stunde, Minute, Sekunde, Monat, Tag, Jahr)
$timestamp = mktime(0, 0, 0, 1, 1, $i);
$years[$timestamp] = $i;
}
$closedmonth = strtotime("01." . $timerecordingBilling->month);
$mindate = date("Y-m-d", strtotime("+ 1 Month", $closedmonth));
?>
<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>
.edit-button {
color: #007bff;
cursor: pointer;
}
.approved-open {
background-color: #fdb751 !important;
color: #000;
border-radius: 5px;
}
.approved-closed {
background-color: #96ff68 !important;
color: #000;
border-radius: 5px;
padding-top: 2px;
}
.fa-clock {
color: #ff9b00;
font-size: 15px;
}
.edit-placeholder {
height: 15px;
width: 27px;
display: inline-block;
}
.fa-trash {
cursor: pointer;
}
.text-bold {
font-weight: 500;
color: #000;
}
.text-normal {
color: #000;
}
.fixed-state {
background-color: #d0fbd9;
}
.form-check-label {
margin-top: 2px;
}
.holiday-text {
color: #d70000;
}
.height-unset
{
height: unset;
}
</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">Buchungen</li>
</ol>
</div>
<h4 class="page-title">Buchungen</h4>
</div>
</div>
</div>
<!-- end page title -->
<form class="form-horizontal" method="post"
action="<?= self::getUrl("Timerecording", "save") ?>">
<div class="card">
<div class="card-body">
<input id="id" data-userid="<?= $me->id ?>" type="hidden" name="id" value=""/>
<div class="form-row">
<div class="form-group col-lg-2">
<label class="col-form-label" for="timerecordingCategory_id">Buchungsart</label>
<select id="timerecordingCategory_id" name="timerecordingCategory_id"
class="select2 form-control" required="required">
<?php foreach ($timerecordingCategoriess as $timerecordingCategories):
if ($timerecordingCategories->only_admin == 0) :
?>
<option value="<?= $timerecordingCategories->id ?>"
data-approval="<?= $timerecordingCategories->approval ?>"
data-comment="<?= $timerecordingCategories->require_comment ?>"
data-hourday="<?= $timerecordingCategories->hourday ?>"
data-businesstrip="<?= $timerecordingCategories->businesstrip ?>"
data-homeoffice="<?= ($timerecordingCategories->hourday == 1 && $timerecordingCategories->approval_fibu == 0) ? 1 : 0 ?>"><?= $timerecordingCategories->name ?></option>
</option>
<?php
endif;
endforeach; ?>
</select>
</div>
<div class="form-group col-lg-1">
<label class="col-form-label" for="date">Datum</label>
<div class="form-row">
<div class="col">
<input type="date" min="<?= $mindate ?>" id="date" name="date" class="form-control "
value="<?= date("Y-m-d", time()) ?>"
placeholder="<?= date("d.m.Y", time()); ?>" required="required"/>
</div>
</div>
</div>
<div id="enddate-div" class="form-group col-lg-1" style="display:none">
<label class="col-form-label" for="enddate">bis Datum</label>
<div class="form-row">
<div class="col">
<input type="date" id="enddate" name="enddate" class="form-control "
value=""
placeholder=""/>
</div>
</div>
</div>
<div id="endtime-div" class="col-lg-2">
<div class="form-row">
<div class="form-group col">
<label class=" col-form-label" for="start">Von</label>
<input type="time" id="start" name="start" class="form-control "
value="08:00" placeholder="07:00" required="required"/>
</div>
<div class="form-group col">
<label class=" col-form-label" for="end">Bis</label>
<input type="time" id="end" name="end" class="form-control "
value="15:00" min="08:00" placeholder="15:00" required="required"/>
</div>
</div>
</div>
<div class="form-group col-lg-2">
<label class="col-form-label" for="comment">Anmerkung</label>
<input type="text" id="comment" name="comment" class="form-control"/>
</div>
<div class="form-group col-lg-4" id="div-calc-overtime" style="display:none">
<label class="col-form-label mobile-hide" for="comment">&nbsp;</label>
<div class=" d-block" style="padding: 0.45rem 0.9rem;" id="calc-overtime"></div>
</div>
</div>
<div class="row">
<div class="col-lg-1 mb-2" id="homeoffice-div">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="homeoffice"
id="homeoffice" value="1">
<label class="form-check-label" for="homeoffice">
Homeoffice
</label>
</div>
</div>
<div class="col-lg-2 mb-2 businesstrip-div businesstrip-check-div ">
<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">
Dienstreise > 12KM
</label>
</div>
</div>
<div class="col-lg-2 businesstrip-div">
<input style="display:none" type="text" id="businesstrip_info" name="businesstrip_info"
placeholder="Ort"
class="form-control"/>
</div>
<div class="col-lg-2 car-div car-div-car" style="display:none">
<select id="timerecordingCar_id" name="timerecordingCar_id"
class="select2 form-control">
<option value="">Kein Firmenauto</option>
<?php foreach ($timerecordingCars as $timerecordingCar): ?>
<option value="<?= $timerecordingCar->id ?>"
data-user="<?= $timerecordingCar->user_id ?>"
data-mileagenow="<?= $timerecordingCar->mileage_now ?>"><?= $timerecordingCar->number_plate . " (" . $timerecordingCar->brand . " " . $timerecordingCar->model . ")" ?></option>
</option>
<?php
endforeach; ?>
</select>
</div>
<div class="col-lg-1 car-div " style="display:none">
<input style="" type="number" id="mileage_start" name="mileage_start"
placeholder="KM Start"
class="form-control"/>
</div>
<div class="col-lg-1 car-div" style="display:none">
<input style="" type="number" id="mileage_end" name="mileage_end"
placeholder="KM Ende"
class="form-control"/>
</div>
</div>
<div class=" row mt-2">
<div class="col-lg-3 ">
<button id="submit-button" type="submit" class="btn btn-primary">Speichern</button>
<button id="cancel-button" type="button" class="btn btn-secondary" style="display:none">
Abbrechen
</button>
<button style="display:none" id="auto-workinghours-button" type="button" class="btn btn-dark">
Arbeitswoche verbuchen
</button>
</div>
</div>
</div>
<div class=" row mt-2">
<div class="col-lg-4" id="message-box">
</div>
</div>
</form>
</div>
<div class="card">
<div class="card-body mb-3">
<div class="form-group module-row row mb-3">
<div class="col-6 col-lg-1">
<label class="col-form-label label-calendar" for="lenght">Buchungszeitraum:</label>
</div>
<div class="col-6 col-lg-1 text-center">
<i class="fa-duotone fa-calendar-week display-calendar active-calendar" title="Kalenderwoche"
data-datatype="1"></i> <i class="fa-duotone fa-calendar-days display-calendar"
title="Kalendermonat" data-datatype="2"></i> <i title="Abwesenheiten"
class="fa-duotone fa-calendar-clock display-calendar"
data-datatype="3"></i>
</div>
<div class="col-lg-2">
<div class="form-row">
<div class="col" id="dataweek-col">
<div class="input-group">
<select id="dataweek" class="form-control select2">
<?php foreach ($weeks as $key => $week): ?>
<option value="<?= $key ?>"><?= $week ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col" id="datamonth-col" style="display:none">
<div class="input-group">
<select id="datamonth" class="form-control select2">
<?php foreach ($month as $key => $Month): ?>
<option <?= (date("Y-m", $timenow) == date("Y-m", $key)) ? 'selected="selected"' : '' ?>
value="<?= $key ?>"><?= $Month ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col" id="datayear-col" style="display:none">
<div class="input-group">
<select id="datayear" class="form-control select2">
<?php foreach ($years as $key => $Year): ?>
<option <?= (date('Y', time()) == $Year) ? "selected='selected'" : NULL ?>
value="<?= $key ?>"><?= $Year ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</div>
<div id="dynamictime-div" class="col-lg-3">
<div class="form-row">
<div class="col text-center">
<div class="input-group ">
<label class="col-form-label form-control height-unset"><span class="text-bold">Sollzeit: </span><span id="must-time" class="ml-1 text-normal"></span></label>
</div>
</div>
<div class="col text-center">
<div class="input-group ">
<label class="col-form-label form-control height-unset"><span class="text-bold">Istzeit: </span><span id="is-time" class="ml-1 text-normal"></span></label>
</div>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="form-row">
<div class="col text-center">
<div class="input-group ">
<label class="col-form-label form-control fixed-state height-unset"><span
class="text-bold">Urlaubstage: </span><span id="holidays"
class="ml-1 text-normal"></span></label>
</div>
</div>
<div class="col text-center">
<div class="input-group ">
<label id="plushours-label" class="col-form-label form-control fixed-state height-unset"><span
class="text-bold">Gutzeit: </span><span
id="plushours"
class="ml-1 text-normal"></span></label>
</div>
</div>
</div>
</div>
<div class="col-lg-2" id="AllHours-div" style="display: none">
<div class="form-row">
<div class="col text-center">
<div class="input-group ">
<label class="col-form-label form-control height-unset"><span
class="text-bold">Gesamtzeit: </span><span id="AllHours"
class="ml-1 text-normal"></span></label>
</div>
</div>
</div>
</div>
</div>
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<th style="width: 200px;" class="text-center text-nowrap ">Datum</th>
<th class="text-nowrap edit-width text-center">Von</th>
<th class="text-nowrap edit-width text-center">Bis</th>
<th class="text-nowrap edit-width text-center">Summe</th>
<th class="text-center text-nowrap">Buchungsart</th>
<th class="text-center">Anmerkung</th>
<th class="edit-width"></th>
</tr>
<tr id="filterrow">
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var hidesearch = [1, 2, 3, 6];
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']) ?>";
let checkWorkinghoursUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'checkWorkinghours']) ?>";
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>js/pages/timerecording/index.js?<?= date('U') ?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>