Zeiterfassung Fahrzeugverwaltung neue Features:

* KM-Stand History
* Journal
* Neue Felder
This commit is contained in:
Daniel Spitzer
2025-03-14 10:06:47 +01:00
parent 93987b4341
commit c69d8b84d5
6 changed files with 160 additions and 7 deletions

View File

@@ -39,6 +39,19 @@ if ($timerecordingcar->mileage_now && $timerecordingcar->mileage_timestamp) {
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">
@@ -178,8 +191,8 @@ if ($timerecordingcar->mileage_now && $timerecordingcar->mileage_timestamp) {
<tr>
<td></td>
<td><?= $timeRecordingCarMileagehistory->mileage ?> KM
(<?= date("d.m.Y", $timeRecordingCarMileagehistory->mileage_timestamp) ?>
)
(<?= 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
@@ -351,7 +364,8 @@ if ($timerecordingcar->mileage_now && $timerecordingcar->mileage_timestamp) {
<?php foreach ($timerecordingCarJournal as $timerecordingjournal): ?>
<div class="card mb-1 mt-1">
<div class="card-body ">
<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) ?>
@@ -392,6 +406,36 @@ if ($timerecordingcar->mileage_now && $timerecordingcar->mileage_timestamp) {
}
});
$('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"

View File

@@ -32,6 +32,12 @@ class TimerecordingCarController extends mfBaseController
case "deleteDocument":
$return = $this->deleteDocument();
break;
case "deleteJournal":
$return = $this->deleteJournal();
break;
case "deleteMilageHistory":
$return = $this->deleteMilageHistory();
break;
default:
$return = false;
}
@@ -57,7 +63,7 @@ class TimerecordingCarController extends mfBaseController
{
$timerecordingcarid = $this->request->id;
$timeRecordingCarMileageHistory = TimerecordingCarMileageHistoryModel::search(["timerecordingCar_id" => $timerecordingcarid]);
$timerecordingCarJournal=TimerecordingCarJournalModel::search(["timerecordingCar_id" => $timerecordingcarid]);
$timerecordingCarJournal = TimerecordingCarJournalModel::search(["timerecordingCar_id" => $timerecordingcarid]);
$mimetypes = TimerecordingCarDocumentsModel::$mimetypes;
$timerecordingcarDokuments = TimerecordingCarDocumentsModel::search(["timerecordingCar_id" => $timerecordingcarid]);
$this->layout()->set("mimetypes", $mimetypes);
@@ -373,4 +379,42 @@ class TimerecordingCarController extends mfBaseController
$timerecordingCarDokument->delete();
}
protected function deleteJournal()
{
$r = $this->request;
$id = $r->id;
$timerecordingCarJournal = new TimerecordingCarJournal($id);
$data = [];
$data['deleted'] = 1;
$data['edit_by'] = $this->me->id;
$timerecordingCarJournal->update($data);
$id = $timerecordingCarJournal->save();
if (!$id) {
} else {
$result["success"] = true;
echo json_encode($result);
die();
}
}
protected function deleteMilageHistory()
{
$r = $this->request;
$id = $r->id;
$timerecordingCarMileageHistory = new TimerecordingCarMileageHistory($id);
$data = [];
$data['deleted'] = 1;
$data['edit_by'] = $this->me->id;
$timerecordingCarMileageHistory->update($data);
$id = $timerecordingCarMileageHistory->save();
if (!$id) {
} else {
$result["success"] = true;
echo json_encode($result);
die();
}
}
}

View File

@@ -5,6 +5,8 @@ class TimerecordingCarJournalModel
private $timerecordingCar_id;
private $journal;
private $timestamp;
private $deleted;
private $edit_by;
public static function find($data)
@@ -116,7 +118,7 @@ class TimerecordingCarJournalModel
if (array_key_exists("timerecordingCar_id", $filter)) {
$timerecordingCar_id = $filter['timerecordingCar_id'];
if (is_numeric($timerecordingCar_id)) {
$where .= " AND timerecordingCar_id=$timerecordingCar_id";
$where .= " AND timerecordingCar_id=$timerecordingCar_id AND deleted =0";
}
}

View File

@@ -5,6 +5,7 @@ class TimerecordingCarMileageHistoryModel
private $timerecordingCar_id;
private $mileage;
private $mileage_timestamp;
private $deleted;
private $create_by;
private $edit_by;
private $create;
@@ -120,7 +121,7 @@ class TimerecordingCarMileageHistoryModel
if (array_key_exists("timerecordingCar_id", $filter)) {
$timerecordingCar_id = $filter['timerecordingCar_id'];
if (is_numeric($timerecordingCar_id)) {
$where .= " AND timerecordingCar_id=$timerecordingCar_id";
$where .= " AND timerecordingCar_id=$timerecordingCar_id AND deleted=0";
}
}

View File

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

View File

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