Files
Daniel Spitzer c69d8b84d5 Zeiterfassung Fahrzeugverwaltung neue Features:
* KM-Stand History
* Journal
* Neue Felder
2025-03-14 10:06:47 +01:00

445 lines
23 KiB
PHP

<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
$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);
$cartypes = TimerecordingCarModel::$carTypes;
if ($timerecordingcar->mileage_now && $timerecordingcar->mileage_timestamp) {
$mileagetimestamp = "(" . date("d.m.Y", $timerecordingcar->mileage_timestamp) . ")";
} elseif ($timerecordingcar->mileage_now) {
$mileagetimestamp = "(" . date("d.m.Y", $timerecordingcar->edit) . ")";
} else {
$mileagetimestamp = "";
}
?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= $git_merge_ts ?>" rel="stylesheet"
type="text/css"/>
<link href="<?= self::getResourcePath() ?>css/pages/TimerecordingCar/Form.css?<?= $git_merge_ts ?>" rel="stylesheet"
type="text/css"/>
<style>
table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
padding-right: 10px;
}
.show-milage-history {
cursor: pointer;
}
.fa-duotone.fa-clock-rotate-left:after, .fa-duotone.fa-history:after, .fad.fa-clock-rotate-left:after, .fad.fa-history:after {
content: "\f1da\f1da";
color: #218200;
opacity: 0.7;
}
.del-journal
{
cursor: pointer;
position: absolute;
right: 5px;
top: 5px;
z-index: 2000;
}
.del-mileage-history
{
cursor: pointer;
z-index: 2000;
}
</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("TimerecordingCar") ?>">Fahrzeuge</a>
</li>
<li class="breadcrumb-item active"><?= $timerecordingcar->number_plate ?></li>
</ol>
</div>
<h4 class="page-title"><?= $timerecordingcar->brand . "/" . $timerecordingcar->model . " (" . $timerecordingcar->number_plate . ")" ?>
Detail
<span class="ml-2">
<a href="<?= self::getUrl("TimerecordingCar") ?><?= ($_GET['hash']) ? '#' . $_GET['hash'] : "" ?>">
<button class="btn btn-secondary">zurück</button>
</a>
</span>
<span class="ml-2">
<a href="<?= self::getUrl("TimerecordingCar", "edit", ["id" => $timerecordingcar->id, 'returnto' => "detail", 'hash' => $_GET['hash']]) ?>">
<button class="btn btn-primary">Bearbeiten</button>
</a>
</span>
</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12 col-lg-8 card-border pr-0 pr-lg-1">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-8">
<h4>Fahrzeug Informationen </h4>
<?php if ($timerecordingcar->retired_date): ?>
<div class="alert alert-danger font-weight-500" role="alert">
Fahrzeug ausgeschieden
am <?= date("d.m.Y", $timerecordingcar->retired_date) ?>
von <?= $timerecordingcar->editor->name ?>
</div>
<?php endif; ?>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-6">
<table class="table table-sm">
<tbody>
<tr>
<th class="w-30">Fahrzeugtyp</th>
<td><?= $cartypes[$timerecordingcar->type] ?></td>
</tr>
<tr>
<th class="w-30">Marke</th>
<td><?= $timerecordingcar->brand ?></td>
</tr>
<tr>
<th>Model/Typ</th>
<td><?= $timerecordingcar->model ?></td>
</tr>
<tr>
<th>Fahrzeugverwalter</th>
<td><?= ($timerecordingcar->user_id) ? $timerecordingcar->user->name : "-" ?></td>
</tr>
<tr>
<th>Fahrtenbuch</th>
<td><?= ($timerecordingcar->timerecording) ? "Ja" : "Nein" ?></td>
</tr>
<tr>
<th>Erste §57a nach</th>
<td><?= ($timerecordingcar->first_approval) ? $timerecordingcar->first_approval . " Jahr(en)" : "-" ?></td>
</tr>
<tr>
<th>Erstzulassung</th>
<td><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>
</tr>
<?php if ($timerecordingcar->override_approval) : ?>
<tr>
<th>§57a Korrektur</th>
<td><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->override_approval) : "-" ?></td>
</tr>
<?php endif; ?>
<tr>
<th>Nächste $57a</th>
<td><?= ($timerecordingcar->initial_approval) ? $approval : "-" ?></td>
</tr>
</tbody>
</table>
</div>
<div class="col-12 col-lg-6 card-border">
<div>
<table class="table table-sm">
<tbody>
<tr>
<th>Serviceintervall</th>
<td><?= ($timerecordingcar->service_interval) ?: "-" ?></td>
</tr>
<tr>
<th>Sommerreifen</th>
<td><?= ($timerecordingcar->summer_tires) ?: "-" ?></td>
</tr>
<tr>
<th>Winterreifen</th>
<td><?= ($timerecordingcar->winter_tires) ?: "-" ?></td>
</tr>
<tr>
<th>Reifen engelagert</th>
<td><?= ($timerecordingcar->tires_at) ?: "-" ?></td>
</tr>
<tr>
<th>Motoröl</th>
<td><?= ($timerecordingcar->oil_type) ?: "-" ?></td>
</tr>
<tr>
<th>Werkstätte</th>
<td><?= ($timerecordingcar->service_station) ?: "-" ?></td>
</tr>
<tr>
<th class="w-30">Kilometerstand</th>
<td><?= ($timerecordingcar->mileage_now) ? $timerecordingcar->mileage_now . " KM" : "-" ?> <?= $mileagetimestamp ?> <?= ($timeRecordingCarMileageHistory) ? '<span class="float-right"><i class="fa-solid fa-arrow-up show-milage-history"></i></span> ' : '' ?></td>
</tr>
<?php if ($timeRecordingCarMileageHistory) : ?>
<tbody id="mileagetable" class="border-0" style="display:none;">
<?php foreach ($timeRecordingCarMileageHistory as $timeRecordingCarMileagehistory) : ?>
<tr>
<td></td>
<td><?= $timeRecordingCarMileagehistory->mileage ?> KM
(<?= date("d.m.Y", $timeRecordingCarMileagehistory->mileage_timestamp) ?>)
<span class="float-right"><i data-id="<?= $timeRecordingCarMileagehistory->id ?>" class="fas fa-trash del-mileage-history text-danger"></i></span>
</td>
</tr>
<?php
endforeach;
endif; ?>
</tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-4 card-border pr-0 pl-lg-1">
<?php if ($timerecordingcarDokuments) : ?>
<div class="card mb-2">
<div class="card-body">
<div class="row">
<div class="col-12">
<h4>Dokumente </h4>
</div>
</div>
<?php foreach ($timerecordingcarDokuments as $timerecordingcarDokument) :
$filesize = $timerecordingcarDokument->file_size;
if ($filesize < 1024) {
$filesize = number_format($filesize, 2) . " B";
} elseif ($filesize < 1024 * 1024) {
$filesize = number_format($filesize / 1024, 2) . " KB";
} else {
$filesize = number_format($filesize / 1024 / 1024, 2) . " MB";
}
$uploadDate = date("d.m.y", $timerecordingcarDokument->file->create);
$mimetype = $timerecordingcarDokument->file->mimetype;
if (!array_key_exists($mimetype, $mimetypes)) {
$mimetype = "fa-file";
} else
$mimetype = $mimetypes[$mimetype];
?>
<div class="doc-main-div border-bottom mb-1"
data-name="<?= $timerecordingcarDokument->file->name ?>">
<div class="d-inline-block doc-icon-div"><i
class="fa-duotone fa-solid <?= $mimetype ?>"></i>
</div>
<div class="d-inline-block doc-content-div"
style="margin-left: -3px;"><a
href="<?= self::getUrl("File", "download", ["id" => $timerecordingcarDokument->file_id]) ?>"
target="_blank"><?= $timerecordingcarDokument->file->name ?></a>
</div>
<span class="mt-2px float-right ml-1">(<?= $uploadDate ?>)</span>
<span class="mt-2px float-right"><?= $filesize ?></span>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif;
if ($timerecordingCarJournal) :
?>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12 mb-0">
<h4>Journaleintrag
<div class="d-inline-block ml-1 align-center"><i data-toggle="modal"
data-target="#journalModal"
class="fa-duotone fa-solid fa-clock-rotate-left"></i>
</div>
</h4>
<span class="pl-1"><?= date("d.m.Y", $timerecordingCarJournal[0]->timestamp) ?> (<?= $timerecordingCarJournal[0]->creator->name ?>)</span>
</div>
<div class="col-12 mb-0">
<div class="pl-2 pt-1"><?= nl2br($timerecordingCarJournal[0]->journal) ?></div>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Fahrtenbuch</h4>
</div>
<div class="float-right">
</div>
</div>
</div>
<table id="datatable" class="table table-striped table-hover table-sm">
<thead>
<tr>
<th class="text-center">Startkilometer</th>
<th class="text-center">Endkilometer</th>
<th class="text-center">Kilometer</th>
<th class="text-center">Fahrer</th>
<th class="text-center">Datum</th>
<th class="text-center">Zeit</th>
<th class="text-center">Ort</th>
<th class="edit-width"></th>
</tr>
<tr id="filterrow">
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($timerecordings as $timerecording): ?>
<tr>
<td class="text-center"><?= $timerecording->mileage_start ?> KM</td>
<td class="text-center"><?= $timerecording->mileage_end ?> KM</td>
<td class="text-center"><?= $timerecording->mileage_end - $timerecording->mileage_start ?>
KM
<td class="text-center"><?= $timerecording->user->name ?></td>
<td data-order="<?= $timerecording->start ?>"
class="text-center"><?= date("d.m.Y", $timerecording->start) ?></td>
<td class="text-center"><?= date("H:i", $timerecording->start) . " - " . date("H:i", $timerecording->end) ?></td>
</td>
<td class="text-center"><?= $timerecording->businesstrip_info ?></td>
</td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
<!-- <a href="-->
<?php //= self::getUrl("TimerecordingCar", "edit", ["id" => $timerecordingcar->id]) ?><!--"><i-->
<!-- class="far fa-edit" title="Bearbeiten"></i></a>-->
<!-- <a href="-->
<?php //= self::getUrl("TimerecordingCar", "delete", ["id" => $timerecordingcar->id]) ?><!--"-->
<!-- onclick="if(!confirm('Auto 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>
</div>
</div>
<div class="modal fade" id="journalModal" tabindex="-1" role="dialog" aria-labelledby="journalModalTitle"
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">Journaleinträge</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<?php foreach ($timerecordingCarJournal as $timerecordingjournal): ?>
<div class="card mb-1 mt-1">
<i data-id="<?= $timerecordingjournal->id ?>" class="fas fa-trash del-journal text-danger"></i>
<div class="card-body p-2">
<div class="row">
<div class="col-12 mb-0 pl-1">
<div class="pl-2 pt-1"><?= date("d.m.Y", $timerecordingjournal->timestamp) ?>
(<?= $timerecordingjournal->creator->name ?>)
</div>
</div>
<div class="col-12 mb-0 ">
<div class="pl-2 pt-1"><?= nl2br($timerecordingjournal->journal) ?></div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var hidesearch = [7];
$(document).ready(function () {
$('body').on('click', '.show-milage-history', function () {
if ($(this).hasClass("fa-arrow-up")) {
$('#mileagetable').show();
$(this).removeClass("fa-arrow-up");
$(this).addClass("fa-arrow-down");
} else {
$('#mileagetable').hide();
$(this).removeClass("fa-arrow-down");
$(this).addClass("fa-arrow-up");
}
});
$('body').on('click', '.del-journal', function () {
var id = $(this).data("id");
var thisis = $(this);
if (!confirm("Journaleintrag wirklich löschen?")) {
return false;
}
$.ajax({
url: "<?= self::getUrl("TimerecordingCar", "api",['do'=>'deleteJournal']) ?>",
type: "POST",
data: {id: id},
success: function (data) {
thisis.closest("div").remove();
}
});
});
$('body').on('click', '.del-mileage-history', function () {
var id = $(this).data("id");
var thisis = $(this);
if (!confirm("Kilometerstand wirklich löschen?")) {
return false;
}
$.ajax({
url: "<?= self::getUrl("TimerecordingCar", "api",['do'=>'deleteMilageHistory']) ?>",
type: "POST",
data: {id: id},
success: function (data) {
thisis.closest("tr").remove();
}
});
});
});
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= $git_merge_ts ?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>