Features für Project 7832: * Das Pickerldatum Zusatzfeld * Auftrennen PKW und Anhänger * Dokumente Upload * Standardsortierung * Ausgeschieden Flag mit Datum * zusätzliche migration
471 lines
22 KiB
PHP
471 lines
22 KiB
PHP
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
|
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= $git_merge_ts ?>" rel="stylesheet"
|
|
type="text/css"/>
|
|
<style>
|
|
table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.retired {
|
|
background-color: #780000 !important;
|
|
color: #ffffff !important;
|
|
}
|
|
|
|
.retired-href {
|
|
color: #cfe6ff;
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.retired-href:hover {
|
|
color: #ffffff;
|
|
|
|
}
|
|
|
|
.text-underlined {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
</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">Fahrzeuge</li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Fahrzeuge</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
|
|
<div class="card">
|
|
<div class="card-body mb-3">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="float-left">
|
|
<h4 class="header-title">Liste aller Fahrzeuge</h4>
|
|
</div>
|
|
<div class="float-right">
|
|
<a class="btn btn-primary mb-2" href="<?= self::getUrl("TimerecordingCar", "add") ?>"><i
|
|
class="fas fa-plus"></i> Neues Fahrzeug anlegen</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
|
<li class="nav-item">
|
|
<a
|
|
class="nav-link active"
|
|
id="home-tab"
|
|
data-toggle="tab"
|
|
href="#pkw"
|
|
role="tab"
|
|
aria-controls="pkw"
|
|
aria-selected="true"
|
|
>PKW's</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a
|
|
class="nav-link"
|
|
id="profile-tab"
|
|
data-toggle="tab"
|
|
href="#anhaenger"
|
|
role="tab"
|
|
aria-controls="anhaenger"
|
|
aria-selected="false"
|
|
>Anhänger</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<div class="tab-content" id="myTabContent">
|
|
<div
|
|
class="tab-pane fade show active"
|
|
id="pkw"
|
|
role="tabpanel"
|
|
aria-labelledby="home-tab"
|
|
>
|
|
<table id="datatable" class="table table-striped table-hover table-sm" style="width:100%">
|
|
<thead>
|
|
<tr class="bg-white">
|
|
<th class="text-center">Kennzeichen</th>
|
|
<th class="text-center">Fahrzeugverwalter</th>
|
|
<th class="text-center">Marke</th>
|
|
<th class="text-center">Model/Typ</th>
|
|
<th class="text-center">Erstzulassung</th>
|
|
<th class="text-center">$57a</th>
|
|
<th class="text-center">Fahrtenbuch</th>
|
|
<th class="text-center">KM-Stand</th>
|
|
<th class="text-center">Aktiv</th>
|
|
<th class="edit-width-w70"></th>
|
|
</tr>
|
|
<tr id="filterrow">
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($timerecordingcars as $timerecordingcar):
|
|
if ($timerecordingcar->type == 2) {
|
|
continue;
|
|
}
|
|
$initialApproval = date("Y-m-d H:i:s", $timerecordingcar->initial_approval);
|
|
$initialApprovalMonth = date("m", $timerecordingcar->initial_approval);
|
|
if ($timerecordingcar->override_approval) {
|
|
$overrideApproval = date("Y-m-d H:i:s", $timerecordingcar->override_approval);
|
|
$initialApprovalMonth = date("m", $timerecordingcar->override_approval);
|
|
}
|
|
$firstApproval = strtotime('+' . $timerecordingcar->first_approval . 'years', strtotime($initialApproval));
|
|
if ($firstApproval < time()) {
|
|
$firstApproval = strtotime(date("Y-$initialApprovalMonth-01", time()));
|
|
if ($firstApproval < time()) {
|
|
$firstApproval = strtotime(date("Y-$initialApprovalMonth-01", strtotime('+1 year')));
|
|
}
|
|
}
|
|
$approval = date("m/Y", $firstApproval);
|
|
|
|
?>
|
|
<tr class="<?= ($timerecordingcar->retired) ? 'retired' : '' ?>">
|
|
<td>
|
|
<a class="<?= ($timerecordingcar->retired) ? 'retired-href' : 'text-underlined' ?>"
|
|
href="<?= self::getUrl("TimerecordingCar", "detail", ["id" => $timerecordingcar->id]) ?>"> <?= $timerecordingcar->number_plate ?></a>
|
|
</td>
|
|
<td><?= ($timerecordingcar->user_id) ? $timerecordingcar->user->name : "-" ?></td>
|
|
<td><?= $timerecordingcar->brand ?></td>
|
|
<td><?= $timerecordingcar->model ?></td>
|
|
<td class="text-center"
|
|
data-order="<?= ($timerecordingcar->initial_approval) ? $timerecordingcar->initial_approval : "-" ?>"><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>
|
|
<td class="text-center"
|
|
data-order="<?= ($timerecordingcar->initial_approval) ? $firstApproval : "-" ?>"><?= ($timerecordingcar->initial_approval) ? $approval : "-" ?></td>
|
|
<td class="text-center"><?= ($timerecordingcar->timerecording) ? "Ja" : "Nein" ?></td>
|
|
<td class="text-center"><?= ($timerecordingcar->mileage_now) ? number_format($timerecordingcar->mileage_now, 0, ',', '.') . " KM" : "-" ?>
|
|
<td class="text-center"><?= ($timerecordingcar->retired) ? "Nein" : "Ja" ?></td>
|
|
</td>
|
|
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
|
<a href="<?= self::getUrl("TimerecordingCar", "edit", ["id" => $timerecordingcar->id]) ?>"><i
|
|
class="far fa-edit" title="Bearbeiten"></i></a>
|
|
<a href="<?= self::getUrl("TimerecordingCar", "delete", ["id" => $timerecordingcar->id]) ?>"
|
|
onclick="if(!confirm('Fahrzeug wirklich löschen?')) return false;"
|
|
class="text-danger"
|
|
title="Löschen"><i class="fas fa-trash"></i></a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div
|
|
class="tab-pane fade col-12"
|
|
id="anhaenger"
|
|
role="tabpanel"
|
|
aria-labelledby="profile-tab"
|
|
>
|
|
<table id="datatable2" class="table table-striped table-hover table-sm" style="width:100%">
|
|
<thead>
|
|
<tr class="bg-white">
|
|
<th class="text-center">Kennzeichen</th>
|
|
<th class="text-center">Fahrzeugverwalter</th>
|
|
<th class="text-center">Marke</th>
|
|
<th class="text-center">Model/Typ</th>
|
|
<th class="text-center">Erstzulassung</th>
|
|
<th class="text-center">$57a</th>
|
|
<th class="text-center">Fahrtenbuch</th>
|
|
<th class="text-center">KM-Stand</th>
|
|
<th class="text-center">Aktiv</th>
|
|
<th class="edit-width-w70"></th>
|
|
</tr>
|
|
<tr id="filterrow2">
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($timerecordingcars as $timerecordingcar):
|
|
if ($timerecordingcar->type == 1) {
|
|
continue;
|
|
}
|
|
$initialApproval = date("Y-m-d H:i:s", $timerecordingcar->initial_approval);
|
|
$initialApprovalMonth = date("m", $timerecordingcar->initial_approval);
|
|
if ($timerecordingcar->override_approval) {
|
|
$overrideApproval = date("Y-m-d H:i:s", $timerecordingcar->override_approval);
|
|
$initialApprovalMonth = date("m", $timerecordingcar->override_approval);
|
|
}
|
|
$firstApproval = strtotime('+' . $timerecordingcar->first_approval . 'years', strtotime($initialApproval));
|
|
if ($firstApproval < time()) {
|
|
$firstApproval = strtotime(date("Y-$initialApprovalMonth-01", time()));
|
|
if ($firstApproval < time()) {
|
|
$firstApproval = strtotime(date("Y-$initialApprovalMonth-01", strtotime('+1 year')));
|
|
}
|
|
}
|
|
$approval = date("m/Y", $firstApproval);
|
|
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<a class="<?= ($timerecordingcar->retired) ? 'retired-href' : 'text-underlined' ?>"
|
|
href="<?= self::getUrl("TimerecordingCar", "detail", ["id" => $timerecordingcar->id,"hash" => "anhaenger"]) ?>"> <?= $timerecordingcar->number_plate ?></a>
|
|
</td>
|
|
<td><?= ($timerecordingcar->user_id) ? $timerecordingcar->user->name : "-" ?></td>
|
|
<td><?= $timerecordingcar->brand ?></td>
|
|
<td><?= $timerecordingcar->model ?></td>
|
|
<td class="text-center"
|
|
data-order="<?= ($timerecordingcar->initial_approval) ? $timerecordingcar->initial_approval : "-" ?>"><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>
|
|
<td class="text-center"
|
|
data-order="<?= ($timerecordingcar->initial_approval) ? $firstApproval : "-" ?>"><?= ($timerecordingcar->initial_approval) ? $approval : "-" ?></td>
|
|
<td class="text-center"><?= ($timerecordingcar->timerecording) ? "Ja" : "Nein" ?></td>
|
|
<td class="text-center"><?= ($timerecordingcar->mileage_now) ? number_format($timerecordingcar->mileage_now, 0, ',', '.') . " KM" : "-" ?>
|
|
<td class="text-center"><?= ($timerecordingcar->retired) ? "Nein" : "Ja" ?></td>
|
|
</td>
|
|
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
|
<a href="<?= self::getUrl("TimerecordingCar", "edit", ["id" => $timerecordingcar->id,"hash" => "anhaenger"]) ?>"><i
|
|
class="far fa-edit" title="Bearbeiten"></i></a>
|
|
<a href="<?= self::getUrl("TimerecordingCar", "delete", ["id" => $timerecordingcar->id]) ?>"
|
|
onclick="if(!confirm('Fahrzeug wirklich löschen?')) return false;"
|
|
class="text-danger"
|
|
title="Löschen"><i class="fas fa-trash"></i></a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<h3></h3>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
let table, table2;
|
|
let tableInitialized = false;
|
|
// Variablen definieren, die du ggf. anpassen musst:
|
|
let hidesearchDT = [7, 9];
|
|
|
|
let pageLength = 25;
|
|
let cstmdom = "flBrtip";
|
|
let columndefs = [];
|
|
let columnfilter = [6, 8];
|
|
let columnoptions = '<option value=""></option><option value="Ja">Ja</option><option value="Nein">Nein</option>';
|
|
|
|
// Initialisierung für die erste Tabelle (z. B. PKW's)
|
|
$('#filterrow th').each(function (i) {
|
|
let title = $('#datatable thead th').eq(i).text();
|
|
if (hidesearchDT.includes(i)) {
|
|
// Kein Filter hinzufügen
|
|
} else if (columnfilter.includes(i)) {
|
|
if (i === 8) {
|
|
$(this).html('<select id="selectsearch" style="padding: 0; height: 28px; text-align: center;" class="form-control" data-index="' + i + '"><option value=""></option><option selected="selected" value="Ja">Ja</option><option value="Nein">Nein</option></select>');
|
|
} else {
|
|
$(this).html('<select style="padding: 0; height: 28px; text-align: center;" class="form-control" data-index="' + i + '">' + columnoptions + '</select>');
|
|
}
|
|
} else {
|
|
$(this).html('<input type="text" placeholder="' + title + '" class="form-control" data-index="' + i + '" value="" />');
|
|
}
|
|
});
|
|
|
|
table = $('#datatable').DataTable({
|
|
responsive: {
|
|
breakpoints: [
|
|
{name: 'desktop', width: Infinity},
|
|
{name: 'tablet', width: 1024},
|
|
{name: 'fablet', width: 768},
|
|
{name: 'phone', width: 480}
|
|
]
|
|
},
|
|
pageLength: pageLength,
|
|
buttons: [{
|
|
extend: 'excelHtml5',
|
|
text: 'XLSX Export',
|
|
className: 'btn-success d-none margina d-lg-block',
|
|
exportOptions: {
|
|
columns: ':not(:last-child)',
|
|
format: {
|
|
body: function (data) {
|
|
data = $('<p>' + data + '</p>').text();
|
|
return $.isNumeric(data.replace(',', '.')) ? data.replace(',', '.') : data;
|
|
}
|
|
}
|
|
}
|
|
}],
|
|
columnDefs: columndefs,
|
|
language: {"url": "/datatables/json/german.json?v1"},
|
|
orderCellsTop: true,
|
|
stateSave: true,
|
|
stateDuration: 60 * 60 * 24 * 30,
|
|
stateLoadParams: function (settings, data) {
|
|
data.order = [[2, 'asc'], [1, 'asc']];
|
|
},
|
|
initComplete: function () {
|
|
$('#datatable_filter').append('<i id="clear_cookie" class="fas fa-times clear-fa" title="Filter löschen" aria-hidden="true"></i>');
|
|
$('#clear_cookie').click(function () {
|
|
$('#filterrow input').val('');
|
|
$('#filterrow select').val('');
|
|
table.search('').columns().search('').draw();
|
|
});
|
|
$('#selectsearch').change();
|
|
},
|
|
dom: cstmdom
|
|
});
|
|
|
|
$('#filterrow').on('keyup', 'input', function () {
|
|
table
|
|
.column($(this).data('index'))
|
|
.search(this.value)
|
|
.draw();
|
|
});
|
|
|
|
$('#filterrow').on('change', 'select', function () {
|
|
table
|
|
.column($(this).data('index'))
|
|
.search(this.value)
|
|
.draw();
|
|
});
|
|
let state = table.state.loaded();
|
|
if (state) {
|
|
table.columns().eq(0).each(function (colIdx) {
|
|
var colSearch = state.columns[colIdx].search;
|
|
|
|
if (colSearch.search) {
|
|
|
|
if (colIdx == 8) {
|
|
|
|
} else {
|
|
$('#filterrow').find("[data-index='" + colIdx + "']").val(colSearch.search);
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
table.draw();
|
|
}
|
|
|
|
|
|
// Initialisierung für die zweite Tabelle (z. B. Anhänger)
|
|
$('#filterrow2 th').each(function (i) {
|
|
let title = $('#datatable2 thead th').eq(i).text();
|
|
if (hidesearchDT.includes(i)) {
|
|
// Kein Filter
|
|
} else if (columnfilter.includes(i)) {
|
|
if (i === 8) {
|
|
$(this).html('<select id="selectsearch2" style="padding: 0; height: 28px; text-align: center;" class="form-control" data-index="' + i + '"><option value=""></option><option selected="selected" value="Ja">Ja</option><option value="Nein">Nein</option></select>');
|
|
} else {
|
|
$(this).html('<select style="padding: 0; height: 28px; text-align: center;" class="form-control" data-index="' + i + '">' + columnoptions + '</select>');
|
|
}
|
|
|
|
} else {
|
|
$(this).html('<input type="text" placeholder="' + title + '" class="form-control" data-index="' + i + '" value="" />');
|
|
}
|
|
});
|
|
|
|
table2 = $('#datatable2').DataTable({
|
|
responsive: {
|
|
breakpoints: [
|
|
{name: 'desktop', width: Infinity},
|
|
{name: 'tablet', width: 1024},
|
|
{name: 'fablet', width: 768},
|
|
{name: 'phone', width: 480}
|
|
]
|
|
},
|
|
pageLength: pageLength,
|
|
buttons: [{
|
|
extend: 'excelHtml5',
|
|
text: 'XLSX Export',
|
|
className: 'btn-success d-none margina d-lg-block',
|
|
exportOptions: {
|
|
columns: ':not(:last-child)',
|
|
format: {
|
|
body: function (data) {
|
|
data = $('<p>' + data + '</p>').text();
|
|
return $.isNumeric(data.replace(',', '.')) ? data.replace(',', '.') : data;
|
|
}
|
|
}
|
|
}
|
|
}],
|
|
columnDefs: columndefs,
|
|
language: {"url": "/datatables/json/german.json?v1"},
|
|
orderCellsTop: true,
|
|
stateSave: true,
|
|
stateDuration: 60 * 60 * 24 * 30,
|
|
stateLoadParams: function (settings, data) {
|
|
data.order = [[2, 'asc'], [1, 'asc']];
|
|
},
|
|
initComplete: function () {
|
|
$('#datatable2_filter').append('<i id="clear_cookie2" class="fas fa-times clear-fa" title="Filter löschen" aria-hidden="true"></i>');
|
|
$('#clear_cookie2').click(function () {
|
|
$('#filterrow2 input').val('');
|
|
$('#filterrow2 select').val('');
|
|
table2.search('').columns().search('').draw();
|
|
});
|
|
$('#selectsearch2').change();
|
|
},
|
|
dom: cstmdom
|
|
});
|
|
|
|
$('#filterrow2').on('keyup', 'input', function () {
|
|
table2
|
|
.column($(this).data('index'))
|
|
.search(this.value)
|
|
.draw();
|
|
});
|
|
|
|
$('#filterrow2').on('change', 'select', function () {
|
|
table2
|
|
.column($(this).data('index'))
|
|
.search(this.value)
|
|
.draw();
|
|
});
|
|
let state2 = table2.state.loaded();
|
|
if (state2) {
|
|
table2.columns().eq(0).each(function (colIdx) {
|
|
var colSearch = state2.columns[colIdx].search;
|
|
if (colIdx == 8) {
|
|
|
|
} else {
|
|
$('#filterrow2').find("[data-index='" + colIdx + "']").val(colSearch.search);
|
|
}
|
|
|
|
});
|
|
|
|
table2.draw();
|
|
}
|
|
$(document).ready(function() {
|
|
// Überprüfen, ob ein Hash in der URL vorhanden ist und den entsprechenden Tab aktivieren
|
|
var hash = window.location.hash;
|
|
if (hash) {
|
|
$('#myTab a[href="' + hash + '"]').tab('show');
|
|
}
|
|
|
|
// Beim Wechseln eines Tabs den Hash in der URL aktualisieren
|
|
$('#myTab a').on('show.bs.tab', function(e) {
|
|
window.location.hash = e.target.hash;
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|