Zeiterfassung neues Feature:

Features für Project 7832:
* Das Pickerldatum Zusatzfeld
* Auftrennen PKW und Anhänger
* Dokumente Upload
* Standardsortierung
* Ausgeschieden Flag mit Datum
* zusätzliche migration
This commit is contained in:
Daniel Spitzer
2025-03-10 14:32:45 +01:00
parent c42b409972
commit e6131cda88
5 changed files with 93 additions and 60 deletions

View File

@@ -41,10 +41,16 @@ $cartypes = TimerecordingCarModel::$carTypes;
<h4 class="page-title"><?= $timerecordingcar->brand . "/" . $timerecordingcar->model . " (" . $timerecordingcar->number_plate . ")" ?>
Detail
<span class="ml-2">
<a href="<?= self::getUrl("TimerecordingCar", "edit", ["id" => $timerecordingcar->id, 'returnto' => "detail"]) ?>">
<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>
@@ -58,7 +64,7 @@ $cartypes = TimerecordingCarModel::$carTypes;
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-4">
<div class="col-8">
<h4>Fahrzeug Informationen </h4>
<?php if ($timerecordingcar->retired_date): ?>
<div class="alert alert-danger font-weight-500" role="alert">
@@ -135,48 +141,48 @@ $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="card-body">
<div class="row">
<div class="col-12">
<h4>Dokumente </h4>
<?php if ($timerecordingcarDokuments) : ?>
<div class="col-12 col-lg-4 card-border pr-0 pl-lg-1">
<div class="card">
<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>
<?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>
</div>
<?php endif; ?>
</div>
</div>

View File

@@ -1,8 +1,13 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
if (isset($_GET['returnto']) && $_GET['returnto'] == "detail") {
$cancelUrl = self::getUrl("TimerecordingCar", "Detail", ["id" => $timerecordingcars->id]);
if ($_GET['hash']) {
$hash = $_GET['hash'];
} else {
$cancelUrl = self::getUrl("TimerecordingCar");
$hash = "";
}
if (isset($_GET['returnto']) && $_GET['returnto'] == "detail") {
$cancelUrl = self::getUrl("TimerecordingCar", "Detail", ["id" => $timerecordingcars->id, "hash" => $_GET['hash']]);
} else {
$cancelUrl = self::getUrl("TimerecordingCar") . "#" . $hash;
}
foreach ($timerecordingusers as $timerecordinguser) {
$timerecordingUsers[$timerecordinguser->name] = $timerecordinguser->id;
@@ -43,7 +48,7 @@ $cartypes = TimerecordingCarModel::$carTypes;
<h4 class="header-title mb-2"><?= ($timerecordingcars->id) ? "Fahrzeug bearbeiten" : "Neues Fahrzeug" ?></h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("TimerecordingCar", "save", ["returnto" => $_GET["returnto"]]) ?>">
action="<?= self::getUrl("TimerecordingCar", "save", ["returnto" => $_GET["returnto"], "hash" => $_GET['hash']]) ?>">
<div class="card no-shadow">
<div class="card-body">
<div class="row">
@@ -195,8 +200,8 @@ $cartypes = TimerecordingCarModel::$carTypes;
</div>
<div class="attachment-div mb-2">
<?php foreach ($timerecordingcarDokuments as $timerecordingcarDokument):
$filesize=$timerecordingcarDokument->file_size;
if ($filesize<1024) {
$filesize = $timerecordingcarDokument->file_size;
if ($filesize < 1024) {
$filesize = number_format($filesize, 2) . " B";
} elseif ($filesize < 1024 * 1024) {
$filesize = number_format($filesize / 1024, 2) . " KB";
@@ -204,14 +209,15 @@ $cartypes = TimerecordingCarModel::$carTypes;
$filesize = number_format($filesize / 1024 / 1024, 2) . " MB";
}
$uploadDate = date("d.m.y", $timerecordingcarDokument->file->create);
$mimetype=$timerecordingcarDokument->file->mimetype;
$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?>">
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>
@@ -225,7 +231,7 @@ $cartypes = TimerecordingCarModel::$carTypes;
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>
</div>
<?php endforeach; ?>
</div>
@@ -285,6 +291,7 @@ $cartypes = TimerecordingCarModel::$carTypes;
let requestDocumentUrl = "<?= self::getUrl("File", "download") ?>";
let requestDocumentUploadUrl = "<?= self::getUrl("TimerecordingCar", "api", ['do' => 'uploadDocuments']) ?>";
let requestDocumentDeleteUrl = "<?= self::getUrl("TimerecordingCar", "api", ['do' => 'deleteDocument']) ?>";
let requestRetireUrl = "<?= self::getUrl('TimerecordingCar', 'retire') ?>";
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>plugins/tinymce/tinymce.min.js?<?= $git_merge_ts ?>"></script>

View File

@@ -63,9 +63,9 @@
class="nav-link active"
id="home-tab"
data-toggle="tab"
href="#home"
href="#pkw"
role="tab"
aria-controls="home"
aria-controls="pkw"
aria-selected="true"
>PKW's</a>
</li>
@@ -74,9 +74,9 @@
class="nav-link"
id="profile-tab"
data-toggle="tab"
href="#user-tab"
href="#anhaenger"
role="tab"
aria-controls="user-tab"
aria-controls="anhaenger"
aria-selected="false"
>Anhänger</a>
</li>
@@ -85,11 +85,11 @@
<div class="tab-content" id="myTabContent">
<div
class="tab-pane fade show active"
id="home"
id="pkw"
role="tabpanel"
aria-labelledby="home-tab"
>
<table id="datatable" class="table table-striped table-hover table-sm">
<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>
@@ -168,7 +168,7 @@
</div>
<div
class="tab-pane fade col-12"
id="user-tab"
id="anhaenger"
role="tabpanel"
aria-labelledby="profile-tab"
>
@@ -223,7 +223,7 @@
<tr>
<td>
<a class="<?= ($timerecordingcar->retired) ? 'retired-href' : 'text-underlined' ?>"
href="<?= self::getUrl("TimerecordingCar", "detail", ["id" => $timerecordingcar->id]) ?>"> <?= $timerecordingcar->number_plate ?></a>
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>
@@ -237,7 +237,7 @@
<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
<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;"
@@ -453,6 +453,18 @@
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>

View File

@@ -212,7 +212,16 @@ class TimerecordingCarController extends mfBaseController
$returnUrl = "TimerecordingCar";
$returnAction = "detail";
$returnVariables = array("id" => $id);
if ($this->request->hash) {
$returnVariables['hash'] = $this->request->hash;
}
} else
{
if ($this->request->hash) {
$returnAnker = $this->request->hash;
}
}
TimerecordingCarModel::calcMileage();
if (!$id) {

View File

@@ -68,8 +68,7 @@ $(document).ready(function () {
alert("Bitte wählen Sie ein Datum aus.");
return;
}
window.location.href = "<?= self::getUrl('TimerecordingCar', 'retire', ['id' => $timerecordingcars->id]) ?>"
+ "&retired_date=" + encodeURIComponent(retireDate);
window.location.href = requestRetireUrl + "?id=" + $('#id').val() + "&retired_date=" + encodeURIComponent(retireDate);
});
$('body').on('change', '#files-input', function () {
let fileList = $('#files-input').prop("files");