Merge branch 'spidev' into 'master'

Zeiterfassung Fahrzeugverwaltung neue Features:

See merge request fronk/thetool!1114
This commit is contained in:
Daniel Spitzer
2025-03-13 20:28:59 +00:00
15 changed files with 1237 additions and 234 deletions

View File

@@ -14,7 +14,13 @@ if ($firstApproval < time()) {
}
$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"/>
@@ -24,6 +30,15 @@ $cartypes = TimerecordingCarModel::$carTypes;
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;
}
</style>
<!-- start page title -->
<div class="row">
@@ -92,13 +107,32 @@ $cartypes = TimerecordingCarModel::$carTypes;
<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>Fahrzeugverwalter</th>
<td><?= ($timerecordingcar->user_id) ? $timerecordingcar->user->name : "-" ?></td>
<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>
@@ -109,30 +143,49 @@ $cartypes = TimerecordingCarModel::$carTypes;
<table class="table table-sm">
<tbody>
<tr>
<th>Fahrtenbuch</th>
<td><?= ($timerecordingcar->timerecording) ? "Ja" : "Nein" ?></td>
<th>Serviceintervall</th>
<td><?= ($timerecordingcar->service_interval) ?: "-" ?></td>
</tr>
<tr>
<th>Erstzulassung</th>
<td><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>
<th>Sommerreifen</th>
<td><?= ($timerecordingcar->summer_tires) ?: "-" ?></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>
<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" : "-" ?></td>
<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) ?>
)
</td>
</tr>
<?php
endforeach;
endif; ?>
</tbody>
</tbody>
</table>
</div>
@@ -141,9 +194,10 @@ $cartypes = TimerecordingCarModel::$carTypes;
</div>
</div>
</div>
<?php if ($timerecordingcarDokuments) : ?>
<div class="col-12 col-lg-4 card-border pr-0 pl-lg-1">
<div class="card">
<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">
@@ -182,8 +236,30 @@ $cartypes = TimerecordingCarModel::$carTypes;
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<?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>
@@ -261,14 +337,61 @@ $cartypes = TimerecordingCarModel::$carTypes;
</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">
<div class="card-body ">
<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");
}
});
});
</script>
<script type="text/javascript"

View File

@@ -17,6 +17,11 @@ ksort($timerecordingUsers);
$cartypes = TimerecordingCarModel::$carTypes;
?>
<style>
.journal-textarea {
height: 213px !important;
}
</style>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= $git_merge_ts ?>" rel="stylesheet"
type="text/css"/>
<link href="<?= self::getResourcePath() ?>css/pages/TimerecordingCar/Form.css?<?= $git_merge_ts ?>" rel="stylesheet"
@@ -52,219 +57,302 @@ $cartypes = TimerecordingCarModel::$carTypes;
<div class="card no-shadow">
<div class="card-body">
<div class="row">
<div class="col-lg-5">
<input type="hidden" id="id" name="id" value="<?= $timerecordingcars->id ?>"/>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="brand">Fahrzeugtyp *</label>
<div class="col-lg-4">
<select id="type_select" name="type"
class="select2 form-control" required="required">
<?php foreach ($cartypes as $key => $cartype): ?>
<option <?= ($timerecordingcars->type == $key) ? 'selected="selected"' : "" ?>
value="<?= $key ?>"><?= $cartype ?></option>
<?php
endforeach; ?>
</select>
</div>
<div class="col-lg-4">
<div class="card">
<div class="card-body">
<input type="hidden" id="id" name="id"
value="<?= $timerecordingcars->id ?>"/>
<div class="form-group row">
<label class="col-lg-5 col-form-label" for="brand">Fahrzeugtyp
*</label>
<div class="col-lg-6">
<select id="type_select" name="type"
class="select2 form-control" required="required">
<?php foreach ($cartypes as $key => $cartype): ?>
<option <?= ($timerecordingcars->type == $key) ? 'selected="selected"' : "" ?>
value="<?= $key ?>"><?= $cartype ?></option>
<?php
endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="number_plate">Kennzeichen
*</label>
<div class="col-lg-3">
<input required="required" type="text" id="number_plate"
name="number_plate"
class="form-control"
value="<?= $timerecordingcars->number_plate ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="brand">Fahrzeugverwalter</label>
<div class="col-lg-4">
<select id="user_id_select" name="user_id"
class="select2 form-control" required="required">
<option value="-">&nbsp</option>
<?php foreach ($timerecordingUsers as $key => $timerecordingUser): ?>
<option <?= ($timerecordingcars->user_id == $timerecordingUser) ? 'selected="selected"' : "" ?>
value="<?= $timerecordingUser ?>"><?= $key ?></option>
<?php
endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label" for="number_plate">Kennzeichen
*</label>
<div class="col-lg-7">
<input required="required" type="text" id="number_plate"
name="number_plate"
class="form-control"
value="<?= $timerecordingcars->number_plate ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="brand">Fahrzeugverwalter</label>
<div class="col-lg-6">
<select id="user_id_select" name="user_id"
class="select2 form-control" required="required">
<option value="-">&nbsp</option>
<?php foreach ($timerecordingUsers as $key => $timerecordingUser): ?>
<option <?= ($timerecordingcars->user_id == $timerecordingUser) ? 'selected="selected"' : "" ?>
value="<?= $timerecordingUser ?>"><?= $key ?></option>
<?php
endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="brand">Marke *</label>
<div class="col-lg-4">
<input required="required" type="text" id="brand" name="brand"
class="form-control"
value="<?= $timerecordingcars->brand ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="model">Model/Typ *</label>
<div class="col-lg-4">
<input required="required" type="text" id="model" name="model"
class="form-control"
value="<?= $timerecordingcars->model ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label"
for="initial_approval">Erstzulassung</label>
<div class="col-lg-3">
<input type="month" id="initial_approval"
name="initial_approval"
class="form-control"
value="<?= ($timerecordingcars->initial_approval) ? date('Y-m', $timerecordingcars->initial_approval) : "" ?>"/>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label" for="brand">Marke *</label>
<div class="col-lg-6">
<input required="required" type="text" id="brand" name="brand"
class="form-control"
value="<?= $timerecordingcars->brand ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label" for="model">Model/Typ
*</label>
<div class="col-lg-7">
<input required="required" type="text" id="model" name="model"
class="form-control"
value="<?= $timerecordingcars->model ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="initial_approval">Erstzulassung</label>
<div class="col-lg-5">
<input type="month" id="initial_approval"
name="initial_approval"
class="form-control"
value="<?= ($timerecordingcars->initial_approval) ? date('Y-m', $timerecordingcars->initial_approval) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label"
for="initial_approval">§57 Korrektur</label>
<div class="col-lg-3">
<input type="month" id="override_approval"
name="override_approval"
class="form-control"
value="<?= ($timerecordingcars->override_approval) ? date('Y-m', $timerecordingcars->override_approval) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="initial_approval">§57 Korrektur</label>
<div class="col-lg-5">
<input type="month" id="override_approval"
name="override_approval"
class="form-control"
value="<?= ($timerecordingcars->override_approval) ? date('Y-m', $timerecordingcars->override_approval) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="first_approval">Erste §57a
nach</label>
<div class="col-lg-3">
<select id="first_approval" name="first_approval"
class="select2 form-control">
<option value=" ">&nbsp;</option>
<option value="1" <?= ($timerecordingcars->first_approval == "1") ? "selected='selected'" : "" ?>>
1 Jahr
</option>
<option value="2" <?= ($timerecordingcars->first_approval == "2") ? "selected='selected'" : "" ?>>
2 Jahren
</option>
<option value="3" <?= ($timerecordingcars->first_approval == "3") ? "selected='selected'" : "" ?>>
3 Jahren
</option>
<option value="4" <?= ($timerecordingcars->first_approval == "4") ? "selected='selected'" : "" ?>>
4 Jahren
</option>
<option value="5" <?= ($timerecordingcars->first_approval == "5") ? "selected='selected'" : "" ?>>
5 Jahren
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label" for="mileage">Kilometerstand</label>
<div class="col-lg-2">
<input type="number" id="mileage" name="mileage"
class="form-control"
value="<?= $timerecordingcars->mileage ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-4 col-form-label"
for="timerecording">Digitales Fahrtenbuch</label>
<div class="col-lg-3">
<div class="form-check">
<input id="timerecording"
class="form-check-input" <?= ($timerecordingcars->timerecording) ? 'checked="checked"' : '' ?>
type="checkbox" name="timerecording" value="1"/>
<div class="form-group row">
<label class="col-lg-5 col-form-label" for="first_approval">Erste
§57a
nach</label>
<div class="col-lg-5">
<select id="first_approval" name="first_approval"
class="select2 form-control">
<option value=" ">&nbsp;</option>
<option value="1" <?= ($timerecordingcars->first_approval == "1") ? "selected='selected'" : "" ?>>
1 Jahr
</option>
<option value="2" <?= ($timerecordingcars->first_approval == "2") ? "selected='selected'" : "" ?>>
2 Jahren
</option>
<option value="3" <?= ($timerecordingcars->first_approval == "3") ? "selected='selected'" : "" ?>>
3 Jahren
</option>
<option value="4" <?= ($timerecordingcars->first_approval == "4") ? "selected='selected'" : "" ?>>
4 Jahren
</option>
<option value="5" <?= ($timerecordingcars->first_approval == "5") ? "selected='selected'" : "" ?>>
5 Jahren
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="mileage">Kilometerstand</label>
<div class="col-lg-3 form-group">
<input type="number" id="mileage" name="mileage"
class="form-control"
value="<?= $timerecordingcars->mileage ?>"/>
</div>
<div class="col-lg-4 form-group">
<input type="date" id="mileage_timestamp" name="mileage_timestamp"
class="form-control"
value=""/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="timerecording">Digitales Fahrtenbuch</label>
<div class="col-lg-3">
<div class="form-check">
<input id="timerecording"
class="form-check-input" <?= ($timerecordingcars->timerecording) ? 'checked="checked"' : '' ?>
type="checkbox" name="timerecording" value="1"/>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-7">
<!-- <div class="form-group row">-->
<!-- <label class="col-lg-2 col-form-label" for="timerecording">Journal</label>-->
<!-- <div class="col-lg-10">-->
<!-- <textarea class="form-control eventmodal-input" id="description"-->
<!-- rows="2"></textarea>-->
<!-- </div>-->
<!-- </div>-->
<div id="documents" class="row mt-2 mb-2 justify-content-center">
<div class="col-6" id="ducuments" data-newkey="">
<label class="col-form-label fw-medium">Dokumente</label>
<div class="input-group mb-2">
<div class="custom-file">
<input type="file" class="custom-file-input" id="files-input"
name="files[]"
multiple>
<label class="custom-file-label" for="files-input"
aria-describedby="">Datei(en) auswählen oder
hereinziehen</label>
<div class="col-lg-4">
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="timerecording">Serviceintervall</label>
<div class="col-lg-5">
<input type="text" id="service_interval" name="service_interval"
class="form-control"
value="<?= $timerecordingcars->service_interval ?>"/>
</div>
</div>
<div class="attachment-div mb-2">
<?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"
data-name="<?= $timerecordingcarDokument->file->name ?>"
data-id="<?= $timerecordingcarDokument->id ?>">
<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="float-right"><i
title="<?= $timerecordingcarDokument->file->name ?>"
class="fas fa-trash fa-del-document ml-2"></i></span>
<span class="float-right ml-1">(<?= $uploadDate ?>)</span>
<span class="float-right"><?= $filesize ?></span>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="timerecording">Sommerreifen</label>
<div class="col-lg-7">
<input type="text" id="summer_tires" name="summer_tires"
class="form-control"
value="<?= $timerecordingcars->summer_tires ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="timerecording">Winterreifen</label>
<div class="col-lg-7">
<input type="text" id="winter_tires" name="winter_tires"
class="form-control"
value="<?= $timerecordingcars->winter_tires ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="timerecording">Reifen eingelagert</label>
<div class="col-lg-7">
<input type="text" id="tires_at" name="tires_at"
class="form-control"
value="<?= $timerecordingcars->tires_at ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="timerecording">Motoröl</label>
<div class="col-lg-7">
<input type="text" id="oil_type" name="oil_type"
class="form-control"
value="<?= $timerecordingcars->oil_type ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="timerecording">Werkstätte</label>
<div class="col-lg-7">
<input type="text" id="service_station" name="service_station"
class="form-control"
value="<?= $timerecordingcars->service_station ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-5 col-form-label"
for="journal">Journaleintrag
<input type="date" id="journal_timestamp" name="journal_timestamp" class="form-control col-9 mt-1" value=""/>
</label>
<div class="col-lg-7">
<textarea cols="9" name="journal" id="journal"
class="form-control journal-textarea"><?= $timerecordingcars->service_station ?></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card">
<div class="card-body">
<div id="documents" class="row justify-content-center">
<div class="col-11" id="ducuments" data-newkey="">
<label class="col-form-label fw-medium">Dokumente</label>
<div class="input-group mb-2">
<div class="custom-file">
<input type="file" class="custom-file-input"
id="files-input"
name="files[]"
multiple>
<label class="custom-file-label" for="files-input"
aria-describedby="">Datei(en) auswählen oder
hereinziehen</label>
</div>
<?php endforeach; ?>
</div>
</div>
<div class="attachment-div mb-2">
<?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"
data-name="<?= $timerecordingcarDokument->file->name ?>"
data-id="<?= $timerecordingcarDokument->id ?>">
<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="float-right"><i
title="<?= $timerecordingcarDokument->file->name ?>"
class="fas fa-trash fa-del-document ml-2"></i></span>
<span class="float-right ml-1">(<?= $uploadDate ?>)</span>
<span class="float-right"><?= $filesize ?></span>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group row">
<div class="col-lg-2 mb-1 mb-sm-1">
<?php if ($timerecordingcars->id && !$timerecordingcars->retired): ?>
<button type="button" class="btn btn-danger" data-toggle="modal"
data-target="#retireModal">
Fahrzeug ausscheiden
</button>
<?php endif; ?>
</div>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a href="<?= $cancelUrl ?>">
<button type="button" class="btn btn-secondary">Abbrechen</button>
</a>
</div>
</div>
</form>
</div>
</div>
<div class="form-group row">
<div class="col-lg-2 mb-1 mb-sm-1">
<?php if ($timerecordingcars->id && !$timerecordingcars->retired): ?>
<button type="button" class="btn btn-danger" data-toggle="modal"
data-target="#retireModal">
Fahrzeug ausscheiden
</button>
<?php endif; ?>
</div>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a href="<?= $cancelUrl ?>">
<button type="button" class="btn btn-secondary">Abbrechen</button>
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="retireModal" tabindex="-1" role="dialog" aria-labelledby="retireModalLabel"
aria-hidden="true">

View File

@@ -97,11 +97,12 @@
<th class="text-center">Marke</th>
<th class="text-center">Model/Typ</th>
<th class="text-center">Erstzulassung</th>
<th class="text-center">$57a Korrektur</th>
<th class="text-center">$57a</th>
<th class="text-center">Fahrtenbuch</th>
<th class="text-center">KM-Stand</th>
<th class="text-center text-nowrap">KM-Stand</th>
<th class="text-center">Aktiv</th>
<th class="edit-width-w70"></th>
<th class="edit-width-min"></th>
</tr>
<tr id="filterrow">
<th></th>
@@ -114,6 +115,7 @@
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@@ -147,13 +149,15 @@
<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->override_approval) ? $timerecordingcar->override_approval : "-" ?>"><?= ($timerecordingcar->override_approval) ? date("m/Y", $timerecordingcar->override_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;">
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;" class="text-center">
<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]) ?>"
@@ -180,11 +184,12 @@
<th class="text-center">Marke</th>
<th class="text-center">Model/Typ</th>
<th class="text-center">Erstzulassung</th>
<th class="text-center">$57a Korrektur</th>
<th class="text-center">$57a</th>
<th class="text-center">Fahrtenbuch</th>
<th class="text-center">KM-Stand</th>
<th class="text-center text-nowrap">KM-Stand</th>
<th class="text-center">Aktiv</th>
<th class="edit-width-w70"></th>
<th class="edit-width-min"></th>
</tr>
<tr id="filterrow2">
<th></th>
@@ -197,6 +202,7 @@
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@@ -230,13 +236,15 @@
<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->override_approval) ? $timerecordingcar->override_approval : "-" ?>"><?= ($timerecordingcar->override_approval) ? date("m/Y", $timerecordingcar->override_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;">
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;" class="text-center">
<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]) ?>"
@@ -264,12 +272,12 @@
let table, table2;
let tableInitialized = false;
// Variablen definieren, die du ggf. anpassen musst:
let hidesearchDT = [7, 9];
let hidesearchDT = [8, 10];
let pageLength = 25;
let cstmdom = "flBrtip";
let columndefs = [];
let columnfilter = [6, 8];
let columndefs = [{"orderable": false, "targets": 10}];
let columnfilter = [7, 9];
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)
@@ -278,7 +286,7 @@
if (hidesearchDT.includes(i)) {
// Kein Filter hinzufügen
} else if (columnfilter.includes(i)) {
if (i === 8) {
if (i === 9) {
$(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>');
@@ -352,8 +360,8 @@
if (colSearch.search) {
if (colIdx == 8) {
if (colIdx == 9) {
$('#filterrow').find("[data-index='" + colIdx + "']").val('Ja');
} else {
$('#filterrow').find("[data-index='" + colIdx + "']").val(colSearch.search);
}
@@ -362,6 +370,7 @@
});
table.draw();
$('#selectsearch').change();
}
@@ -371,7 +380,7 @@
if (hidesearchDT.includes(i)) {
// Kein Filter
} else if (columnfilter.includes(i)) {
if (i === 8) {
if (i === 9) {
$(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>');
@@ -443,8 +452,8 @@
if (state2) {
table2.columns().eq(0).each(function (colIdx) {
var colSearch = state2.columns[colIdx].search;
if (colIdx == 8) {
if (colIdx == 9) {
$('#filterrow').find("[data-index='" + colIdx + "']").val('Ja');
} else {
$('#filterrow2').find("[data-index='" + colIdx + "']").val(colSearch.search);
}
@@ -452,6 +461,7 @@
});
table2.draw();
$('#selectsearch2').change();
}
$(document).ready(function() {
// Überprüfen, ob ein Hash in der URL vorhanden ist und den entsprechenden Tab aktivieren

View File

@@ -56,10 +56,14 @@ class TimerecordingCarController extends mfBaseController
protected function detailAction()
{
$timerecordingcarid = $this->request->id;
$timeRecordingCarMileageHistory = TimerecordingCarMileageHistoryModel::search(["timerecordingCar_id" => $timerecordingcarid]);
$timerecordingCarJournal=TimerecordingCarJournalModel::search(["timerecordingCar_id" => $timerecordingcarid]);
$mimetypes = TimerecordingCarDocumentsModel::$mimetypes;
$timerecordingcarDokuments = TimerecordingCarDocumentsModel::search(["timerecordingCar_id" => $timerecordingcarid]);
$this->layout()->set("mimetypes", $mimetypes);
$this->layout()->set("timerecordingcarDokuments", $timerecordingcarDokuments);
$this->layout()->set("timeRecordingCarMileageHistory", $timeRecordingCarMileageHistory);
$this->layout()->set("timerecordingCarJournal", $timerecordingCarJournal);
$this->layout()->setTemplate("TimerecordingCar/Detail");
$timerecordingcar = TimerecordingCarModel::getOne($timerecordingcarid);
$this->layout()->set("timerecordingcar", $timerecordingcar);
@@ -127,6 +131,7 @@ class TimerecordingCarController extends mfBaseController
protected function saveAction()
{
$r = $this->request;
$journal = trim($r->journal);
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
@@ -143,6 +148,12 @@ class TimerecordingCarController extends mfBaseController
$data = [];
$data['number_plate'] = trim($r->number_plate);
$data['user_id'] = trim($r->user_id);
$data['service_interval'] = trim($r->service_interval);
$data['tires_at'] = trim($r->tires_at);
$data['summer_tires'] = trim($r->summer_tires);
$data['winter_tires'] = trim($r->winter_tires);
$data['oil_type'] = trim($r->oil_type);
$data['service_station'] = trim($r->service_station);
$data['type'] = trim($r->type);
$data['brand'] = trim($r->brand);
$data['model'] = trim($r->model);
@@ -157,6 +168,24 @@ class TimerecordingCarController extends mfBaseController
if (!$data['user_id'] || $data['user_id'] == "-") {
$data['user_id'] = null;
}
if (!$data['service_interval']) {
$data['service_interval'] = null;
}
if (!$data['tires_at']) {
$data['tires_at'] = null;
}
if (!$data['summer_tires']) {
$data['summer_tires'] = null;
}
if (!$data['winter_tires']) {
$data['winter_tires'] = null;
}
if (!$data['oil_type']) {
$data['oil_type'] = null;
}
if (!$data['service_station']) {
$data['service_station'] = null;
}
if (!$data['initial_approval']) {
$data['initial_approval'] = null;
}
@@ -193,17 +222,51 @@ class TimerecordingCarController extends mfBaseController
// var_dump($upload);
// exit;
if ($mode == "edit") {
if ($timerecordingcars->mileage_now != $data['mileage']) {
$mileage_timestamp = $r->mileage_timestamp;
if (!$mileage_timestamp) {
$data['mileage_timestamp'] = time();
} else {
$data['mileage_timestamp'] = strtotime($mileage_timestamp);
}
$datamileageHistory = [];
$datamileageHistory['timerecordingCar_id'] = $timerecordingcars->id;
$datamileageHistory['mileage'] = $timerecordingcars->mileage_now;
if ($timerecordingcars->mileage_timestamp) {
$datamileageHistory['mileage_timestamp'] = $timerecordingcars->mileage_timestamp;
} else {
$datamileageHistory['mileage_timestamp'] = $timerecordingcars->edit;
}
$timerecordingcarsMilageHistory = TimerecordingCarMileageHistoryModel::create($datamileageHistory);
$timerecordingcarsMilageHistory->save();
}
$timerecordingcars->update($data);
} else {
if ($data['mileage'] != null) {
$data['mileage_timestamp'] = time();
}
$timerecordingcars = TimerecordingCarModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordingcars->save();
if ($journal) {
$journal_timestamp = $r->journal_timestamp;
$dataJournal = [];
$dataJournal['timerecordingCar_id'] = $id;
$dataJournal['journal'] = $journal;
if ($journal_timestamp) {
$dataJournal['timestamp'] = strtotime($journal_timestamp);
} else {
$dataJournal['timestamp'] = time();
}
$timerecordingcarJournal = TimerecordingCarJournalModel::create($dataJournal);
$timerecordingcarJournal->save();
}
$returnUrl = "TimerecordingCar";
$returnAction = "Index";
$returnVariables = array();
@@ -216,8 +279,7 @@ class TimerecordingCarController extends mfBaseController
$returnVariables['hash'] = $this->request->hash;
}
} else
{
} else {
if ($this->request->hash) {
$returnAnker = $this->request->hash;

View File

@@ -15,6 +15,12 @@ class TimerecordingCarModel
private $first_approval;
private $timerecording;
private $retired;
private $service_interval;
private $tires_at;
private $summer_tires;
private $winter_tires;
private $oil_type;
private $service_station;
private $retired_date;
private $edit_by;

View File

@@ -0,0 +1,60 @@
<?php
class TimerecordingCarJournal extends mfBaseModel
{
private $editor;
private $creator;
private $TimerecordingCar;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if ($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
if ($this->creator === null) {
$this->creator = new User($this->create_by);
if ($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
}
}
return $this->creator;
}
if ($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
if ($this->editor === null) {
$this->editor = new User($this->edit_by);
if ($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name . "_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
if (!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if ($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,131 @@
<?php
class TimerecordingCarJournalController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("TimerecordingCarJournal/Index");
$timerecordingcarjournals = TimerecordingCarJournalModel::getAll();
$this->layout()->set("timerecordingcarjournals", $timerecordingcarjournals);
}
protected function addAction()
{
$TimerecordingCars=TimerecordingCarModel::getAll();
$this->layout()->set("TimerecordingCars", $TimerecordingCars);
$this->layout()->setTemplate("TimerecordingCarJournal/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("g nicht gefunden", "error");
$this->redirect("TimerecordingCarJournal");
}
$timerecordingcarjournals = new TimerecordingCarJournal($id);
if ($timerecordingcarjournals->id != $id) {
$this->layout()->setFlash("g nicht gefunden", "error");
$this->redirect("TimerecordingCarJournal");
}
$this->layout()->set("timerecordingcarjournals", $timerecordingcarjournals);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$timerecordingcarjournals = new TimerecordingCarJournal($id);
if (!$timerecordingcarjournals->id) {
$this->layout()->setFlash("g nicht gefunden", "error");
$this->redirect("TimerecordingCarJournal");
}
} else {
$mode = "add";
}
$data = [];
$data['TimerecordingCar_id'] = trim($r->TimerecordingCar_id);
$data['journal'] = trim($r->journal);
$data['timestamp'] = trim($r->timestamp);
if (!$data['TimerecordingCar_id']) {
$data['TimerecordingCar_id']=NULL;
}
if (!$data['journal']) {
$data['journal']=NULL;
}
if (!$data['timestamp']) {
$data['timestamp']=NULL;
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$timerecordingcarjournals->update($data);
} else {
$timerecordingcarjournals = TimerecordingCarJournalModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordingcarjournals->save();
if (!$id) {
$this->layout()->setFlash("g konnte nicht angelegt werden", "error");
$this->redirect("TimerecordingCarJournal");
}
if ($mode == "edit") {
$this->layout()->setFlash("g erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("g erfolgreich angelegt", "success");
}
$this->redirect("TimerecordingCarJournal");
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordingcarjournals = new TimerecordingCarJournal($id);
if (!$timerecordingcarjournals->id || $timerecordingcarjournals->id != $id) {
$this->layout()->setFlash("g nicht gefunden.", "error");
$this->redirect("TimerecordingCarJournal");
}
$timerecordingcarjournals->delete();
$this->redirect("TimerecordingCarJournal");
}
}

View File

@@ -0,0 +1,127 @@
<?php
class TimerecordingCarJournalModel
{
private $timerecordingCar_id;
private $journal;
private $timestamp;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new TimerecordingCarJournal();
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
if (substr($field, 0, 5) == "vlan_" && !$value) {
$model->$field = null;
continue;
}
$model->$field = $value;
}
}
$me = mfValuecache::singleton()->get("me");
if (!$me) {
$me = new User();
$me->loadMe();
mfValuecache::singleton()->set("me", $me);
}
if ($model->create_by === null) {
$model->create_by = $me->id;
}
if ($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id)
{
if (!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingCarJournal", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCarJournal($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingCarJournal", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCarJournal($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingCarJournal", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCarJournal($data);
if ($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingCarJournal", "*", "$where ORDER by timestamp DESC");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCarJournal($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("timerecordingCar_id", $filter)) {
$timerecordingCar_id = $filter['timerecordingCar_id'];
if (is_numeric($timerecordingCar_id)) {
$where .= " AND timerecordingCar_id=$timerecordingCar_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,60 @@
<?php
class TimerecordingCarMileageHistory extends mfBaseModel
{
private $editor;
private $creator;
private $TimerecordingCar;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if ($name == "creator") {
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
if ($this->creator === null) {
$this->creator = new User($this->create_by);
if ($this->creator->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
}
}
return $this->creator;
}
if ($name == "editor") {
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
if ($this->editor === null) {
$this->editor = new User($this->edit_by);
if ($this->editor->id) {
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
}
}
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name . "_id";
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
if (!$this->$name) {
$this->$name = new $classname($this->$idfield);
}
if ($this->$name->id) {
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,129 @@
<?php
class TimerecordingCarMileageHistoryController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("TimerecordingCarMileageHistory/Index");
$timerecordingcarmileagehistorys = TimerecordingCarMileageHistoryModel::getAll();
$this->layout()->set("timerecordingcarmileagehistorys", $timerecordingcarmileagehistorys);
}
protected function addAction()
{
$TimerecordingCars=TimerecordingCarModel::getAll();
$this->layout()->set("TimerecordingCars", $TimerecordingCars);
$this->layout()->setTemplate("TimerecordingCarMileageHistory/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Kilometer History nicht gefunden", "error");
$this->redirect("TimerecordingCarMileageHistory");
}
$timerecordingcarmileagehistorys = new TimerecordingCarMileageHistory($id);
if ($timerecordingcarmileagehistorys->id != $id) {
$this->layout()->setFlash("Kilometer History nicht gefunden", "error");
$this->redirect("TimerecordingCarMileageHistory");
}
$this->layout()->set("timerecordingcarmileagehistorys", $timerecordingcarmileagehistorys);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$timerecordingcarmileagehistorys = new TimerecordingCarMileageHistory($id);
if (!$timerecordingcarmileagehistorys->id) {
$this->layout()->setFlash("Kilometer History nicht gefunden", "error");
$this->redirect("TimerecordingCarMileageHistory");
}
} else {
$mode = "add";
}
$data = [];
$data['TimerecordingCar_id'] = trim($r->TimerecordingCar_id);
$data['mileage'] = trim($r->mileage);
if (!$data['TimerecordingCar_id']) {
$this->layout()->setFlash("Fahrzeug darf nicht leer sein", "error");
$this->redirect("TimerecordingCarMileageHistory");
}
if (!$data['mileage']) {
$this->layout()->setFlash("Kilometer darf nicht leer sein", "error");
$this->redirect("TimerecordingCarMileageHistory");
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$timerecordingcarmileagehistorys->update($data);
} else {
$timerecordingcarmileagehistorys = TimerecordingCarMileageHistoryModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordingcarmileagehistorys->save();
if (!$id) {
$this->layout()->setFlash("Kilometer History konnte nicht angelegt werden", "error");
$this->redirect("TimerecordingCarMileageHistory");
}
if ($mode == "edit") {
$this->layout()->setFlash("Kilometer History erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Kilometer History erfolgreich angelegt", "success");
}
$this->redirect("TimerecordingCarMileageHistory");
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordingcarmileagehistorys = new TimerecordingCarMileageHistory($id);
if (!$timerecordingcarmileagehistorys->id || $timerecordingcarmileagehistorys->id != $id) {
$this->layout()->setFlash("Kilometer History nicht gefunden.", "error");
$this->redirect("TimerecordingCarMileageHistory");
}
$timerecordingcarmileagehistorys->delete();
$this->redirect("TimerecordingCarMileageHistory");
}
}

View File

@@ -0,0 +1,131 @@
<?php
class TimerecordingCarMileageHistoryModel
{
private $timerecordingCar_id;
private $mileage;
private $mileage_timestamp;
private $create_by;
private $edit_by;
private $create;
private $edit;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new TimerecordingCarMileageHistory();
foreach ($data as $field => $value) {
if (property_exists(get_called_class(), $field)) {
if (substr($field, 0, 5) == "vlan_" && !$value) {
$model->$field = null;
continue;
}
$model->$field = $value;
}
}
$me = mfValuecache::singleton()->get("me");
if (!$me) {
$me = new User();
$me->loadMe();
mfValuecache::singleton()->set("me", $me);
}
if ($model->create_by === null) {
$model->create_by = $me->id;
}
if ($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getOne($id)
{
if (!is_numeric($id) || !$id) {
throw new Exception("Invalid number", 400);
}
$item = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingCarMileageHistory", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCarMileageHistory($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingCarMileageHistory", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCarMileageHistory($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingCarMileageHistory", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCarMileageHistory($data);
if ($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function search($filter)
{
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingCarMileageHistory", "*", "$where ORDER by mileage_timestamp DESC");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCarMileageHistory($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("timerecordingCar_id", $filter)) {
$timerecordingCar_id = $filter['timerecordingCar_id'];
if (is_numeric($timerecordingCar_id)) {
$where .= " AND timerecordingCar_id=$timerecordingCar_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -9,7 +9,7 @@ final class TimerecordingCarJournal extends AbstractMigration
if ($this->getEnvironment() == "thetool") {
$table = $this->table("TimerecordingCarJournal", ["signed" => true]);
$table->addColumn("TimerecordingCar_id", "integer", ["null" => true]);
$table->addColumn("timerecordingCar_id", "integer", ["null" => true]);
$table->addColumn("journal", "text", ["null" => false]);
$table->addColumn("create_by", "integer", ["null" => false]);
$table->addColumn("edit_by", "integer", ["null" => false]);

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class TimerecordingCarAddFieldsDetails extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("TimerecordingCar", ["signed" => true]);
$table->addColumn("service_interval", "text", ["null" => true, "default" => NULL, "after" => "user_id"]);
$table->addColumn("tires_at", "text", ["null" => true, "default" => NULL, "after" => "service_interval"]);
$table->addColumn("summer_tires", "text", ["null" => true, "default" => NULL, "after" => "tires_at"]);
$table->addColumn("winter_tires", "text", ["null" => true, "default" => NULL, "after" => "summer_tires"]);
$table->addColumn("oil_type", "text", ["null" => true, "default" => NULL, "after" => "winter_tires"]);
$table->addColumn("service_station", "text", ["null" => true, "default" => NULL, "after" => "oil_type"]);
$table->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("TimerecordingCar")->removeColumn("service_interval")->save();
$this->table("TimerecordingCar")->removeColumn("tires_at")->save();
$this->table("TimerecordingCar")->removeColumn("summer_tires")->save();
$this->table("TimerecordingCar")->removeColumn("winter_tires")->save();
$this->table("TimerecordingCar")->removeColumn("oil_type")->save();
$this->table("TimerecordingCar")->removeColumn("service_station")->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class TimerecordingCarJournalAddTimestamp extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table("TimerecordingCarJournal", ["signed" => true]);
$table->addColumn("timestamp", "integer", ["null" => false, "after" => "journal"]);
$table->update();
}
if ($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$this->table("TimerecordingCarJournal")->removeColumn("timestamp")->save();
}
if ($this->getEnvironment() == "addressdb") {
}
}
}

View File

@@ -58,6 +58,10 @@ table.dataTable > tbody > tr.child span.dtr-data {
width: 70px;
}
.edit-width-min {
min-width: 55px;
}
.edit-width-medium {
width: 90px;
}