Zeiterfassungs Update

* Implementerung Fahrzeugverwaltung
 * neue Buchungsart Fahrtenbuch
 * Diverse Bugfixes
This commit is contained in:
Spitzer Daniel
2024-03-26 08:08:01 +01:00
parent 81e3b1ccd5
commit 025522a740
18 changed files with 1305 additions and 38 deletions

View File

@@ -13,7 +13,6 @@ $monthger[10] = "Oktober";
$monthger[11] = "November";
$monthger[12] = "Dezember";
$time = time();
for ($i = 1; $i <= 25; $i++) {
$kw = date('W', $time);
$year = date('Y', $time);
@@ -196,7 +195,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
</div>
</div>
<div class="col-lg-2 mb-2 businesstrip-div">
<div class="col-lg-2 mb-2 businesstrip-div businesstrip-check-div ">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="businesstrip"
@@ -211,6 +210,30 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
placeholder="Ort"
class="form-control"/>
</div>
<div class="col-lg-2 car-div car-div-car" style="display:none">
<select id="timerecordingCar_id" name="timerecordingCar_id"
class="select2 form-control">
<option value="">Auto auswählen</option>
<?php foreach ($timerecordingCars as $timerecordingCar): ?>
<option value="<?= $timerecordingCar->id ?>"
data-mileagenow="<?= $timerecordingCar->mileage_now ?>"><?= $timerecordingCar->number_plate . " (" . $timerecordingCar->brand." ".$timerecordingCar->model . ")" ?></option>
</option>
<?php
endforeach; ?>
</select>
</div>
<div class="col-lg-1 car-div " style="display:none">
<input style="" type="number" id="mileage_start" name="mileage_start"
placeholder="KM Start"
class="form-control"/>
</div>
<div class="col-lg-1 car-div" style="display:none">
<input style="" type="number" id="mileage_end" name="mileage_end"
placeholder="KM Ende"
class="form-control"/>
</div>
</div>
<div class=" row mt-2">
<div class="col-lg-3 ">

View File

@@ -0,0 +1,199 @@
<?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);
$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);
?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
padding-right: 10px;
}
</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", "edit", ["id" => $timerecordingcar->id, 'returnto' => "detail"]) ?>">
<button class="btn btn-primary">Bearbeiten</button>
</a>
</span>
</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="card">
<div class="card-body mb-3">
<div class="row">
<div class="col-12 col-lg-5 card-border">
<div>
<h4>Fahrzeug Informationen </h4>
</div>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th class="w-30">Marke</th>
<td><?= $timerecordingcar->brand ?></td>
</tr>
<tr>
<th>Model/Typ</th>
<td><?= $timerecordingcar->model ?></td>
</tr>
<tr>
<th>Erste §57a nach</th>
<td><?= ($timerecordingcar->first_approval) ? $timerecordingcar->first_approval . " Jahr(en)" : "-" ?></td>
</tr>
<tr>
<th>Fahrtenbuch</th>
<td><?= ($timerecordingcar->timerecording) ? "Ja" : "Nein" ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-12 col-lg-5 card-border">
<div>
<h4>&nbsp;</h4>
</div>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th>Erstzulassung</th>
<td><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>
</tr>
<tr>
<th>Nächste $57a</th>
<td><?= ($timerecordingcar->initial_approval) ? $approval : "-" ?></td>
</tr>
<tr>
<th class="w-30">Kilometerstand</th>
<td><?= ($timerecordingcar->mileage_now) ? $timerecordingcar->mileage_now . " KM" : "-" ?></td>
</tr>
</tbody>
</table>
</div>
</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>
<script type="text/javascript">
var hidesearch = [7];
$(document).ready(function () {
});
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,151 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
if (isset($_GET['returnto']) && $_GET['returnto'] == "detail") {
$cancelUrl = self::getUrl("TimerecordingCar", "Detail", ["id" => $timerecordingcars->id]);
} else {
$cancelUrl = self::getUrl("TimerecordingCar");
}
?>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<!-- 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"><?= ($timerecordingcars->id) ? "bearbeiten" : "Neu" ?></li>
</ol>
</div>
<h4 class="page-title"><?= ($timerecordingcars->id) ? "Fahrzeug bearbeiten" : "Neues Fahrzeug" ?></h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card bg-light">
<div class="card-body">
<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"]]) ?>">
<div class="card no-shadow">
<div class="card-body">
<input type="hidden" name="id" value="<?= $timerecordingcars->id ?>"/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="number_plate">Kennzeichen *</label>
<div class="col-lg-1">
<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-2 col-form-label" for="brand">Marke *</label>
<div class="col-lg-3">
<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-2 col-form-label" for="model">Model/Typ *</label>
<div class="col-lg-3">
<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-2 col-form-label" for="initial_approval">Erstzulassung</label>
<div class="col-lg-2">
<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-2 col-form-label" for="first_approval">Erste §57a nach</label>
<div class="col-lg-2">
<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-2 col-form-label" for="mileage">Kilometerstand</label>
<div class="col-lg-1">
<input type="number" id="mileage" name="mileage"
class="form-control"
value="<?= $timerecordingcars->mileage ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 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 class="form-group row">
<label class="col-lg-2"></label>
<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>
<script type="text/javascript">
$(".select2").select2({placeholder: ""});
// disable mousewheel on a input number field when in focus
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {
e.preventDefault()
})
});
$('form').on('blur', 'input[type=number]', function (e) {
$(this).off('wheel.disableScroll')
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,120 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
padding-right: 10px;
}
</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>
<table id="datatable" class="table table-striped table-hover table-sm">
<thead>
<tr>
<th class="text-center">Kennzeichen</th>
<th class="text-center">Marke</th>
<th class="text-center">Model/Typ</th>
<th class="text-center">Erstzulassssung</th>
<th class="text-center">$57a</th>
<th class="text-center">Fahrtenbuch</th>
<th class="text-center">Kilometerstand</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 ($timerecordingcars as $timerecordingcar):
$initialApproval = date("Y-m-d H:i:s", $timerecordingcar->initial_approval);
$initialApprovalMonth = date("m", $timerecordingcar->initial_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 href="<?= self::getUrl("TimerecordingCar", "detail", ["id" => $timerecordingcar->id]) ?>"> <?= $timerecordingcar->number_plate ?></a>
</td>
<td><?= $timerecordingcar->brand ?></td>
<td><?= $timerecordingcar->model ?></td>
<td class="text-center"><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>
<td class="text-center"><?= ($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>
<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>
</div>
</div>
<script type="text/javascript">
var hidesearch = [7];
var columnfilter = [5];
var columnoptions = '<option value=""></option><option value="Ja">Ja</option><option value="Nein">Nein</option>';
$(document).ready(function () {
});
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -121,7 +121,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
<input id="id" type="hidden" name="id" value=""/>
<div class="form-row">
<div class="form-group col-lg-2">
<label class="col-form-label" for="user_id">Buchungsart</label>
<label class="col-form-label" for="user_id">Mitarbeiter</label>
<select id="user_id_select" name="user_id"
class="select2 form-control" required="required">
@@ -220,7 +220,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
</label>
</div>
</div>
<div class="col-lg-2 mb-2 businesstrip-div">
<div class="col-lg-2 mb-2 businesstrip-div businesstrip-check-div ">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="businesstrip"
@@ -235,6 +235,31 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
placeholder="Ort"
class="form-control"/>
</div>
<div class="col-lg-2 car-div car-div-car" style="display:none">
<select id="timerecordingCar_id" name="timerecordingCar_id"
class="select2 form-control">
<option value="">Auto auswählen</option>
<?php foreach ($timerecordingCars as $timerecordingCar): ?>
<option value="<?= $timerecordingCar->id ?>"
data-mileagenow="<?= $timerecordingCar->mileage_now ?>"><?= $timerecordingCar->number_plate . " (" . $timerecordingCar->brand." ".$timerecordingCar->model . ")" ?></option>
</option>
<?php
endforeach; ?>
</select>
</div>
<div class="col-lg-1 car-div " style="display:none">
<input style="" type="text" id="mileage_start" name="mileage_start"
placeholder="KM Start"
class="form-control"/>
</div>
<div class="col-lg-1 car-div" style="display:none">
<input style="" type="text" id="mileage_end" name="mileage_end"
placeholder="KM Ende"
class="form-control"/>
</div>
</div>
<div class=" row mt-2">

View File

@@ -40,9 +40,11 @@
<?php if ($me->can('Fibu')): ?>
<li><a href="<?=self::getUrl("TimerecordingPermit")?>"><i class="far fa-fw fa-calendar-check text-info"></i> Freigaben</a></li>
<li><a href="<?=self::getUrl("TimerecordingReport")?>"><i class="far fa-fw fa-chart-pie text-info"></i> Auswertung/Korrektur</a></li>
<li><a href="<?=self::getUrl("TimerecordingBilling")?>"><i class="far fa-fw fa-money-bill-1-wave text-info"></i> Verrechnung</a></li>
<li><a href="<?=self::getUrl("TimerecordingCategory")?>"><i class="far fa-fw fa-list text-info"></i> Buchungsarten</a></li>
<li><a href="<?=self::getUrl("TimerecordingHoliday")?>"><i class="far fa-fw fa-umbrella-beach text-info"></i> Feiertage</a></li>
<li><a href="<?=self::getUrl("TimerecordingEmployee")?>"><i class="far fa-fw fa-user text-info"></i> Personaladministration</a></li>
<li><a href="<?=self::getUrl("TimerecordingCar")?>"><i class="far fa-fw fa-sharp fa-regular fa-cars text-info"></i> Fahrzeugverwaltung</a></li>
<?php endif; ?>
</ul>
</li>
@@ -96,6 +98,9 @@
<?php if($me->is(["Admin","netowner","lineplanner","lineworker"]) && $me->can("Linework")): ?><li><a href="<?=self::getUrl("Linework")?>"><i class="fas fa-fw fa-ethernet text-info"></i> Leitungsbau</a></li><?php endif; ?>
<?php if($me->is(["Admin","netowner","netoperator","lineworker"]) && $me->can("Patching")): ?><li class="has-sub-submenu"><a href="<?=self::getUrl("Patching")?>"><i class="fas fa-fw fa-plug text-info"></i> Patchungen</a></li><?php endif; ?>
<?php if($me->is(["Admin","netowner","pipeplanner","lineplanner","pipeworker","netoperator","lineworker"]) && $me->can("Filestore")): ?><li><a href="<?=self::getUrl("Filestore")?>"><i class="fas fa-fw fa-file text-info"></i> Dateiablage</a></li><?php endif; ?>
<!-- //Vorbereitend für Faserplanung --><?php //if($me->is(["Admin","netowner","pipeplanner","pipeplanner"]) && $me->is("employee")): ?><!--<li><a href="--><?php //=self::getUrl("FiberPlanDispatcher")?><!--"><i class="fas fa-building-circle-arrow-right text-info"></i> Verteiler und Schächte</a></li>--><?php //endif; ?>
<!-- //Vorbereitend für Faserplanung --><?php //if($me->is(["Admin","netowner","lineplanner","lineworker"]) && $me->is("employee")): ?><!--<li><a href="--><?php //=self::getUrl("FiberPlanPipe")?><!--"><i class="fas fa-pipe text-info pl-1"></i> Rohrverzeichnis</a></li>--><?php //endif; ?>
<!-- //Vorbereitend für Faserplanung --><?php //if($me->is(["Admin","netowner","lineplanner","lineworker"]) && $me->is("employee")): ?><!--<li><a href="--><?php //=self::getUrl("FiberPlanCable")?><!--"><i class="fas fa-pipe text-info pl-1"></i> Kabelverzeichnis</a></li>--><?php //endif; ?>
</ul>
</li>
<?php endif; ?>

View File

@@ -6,7 +6,8 @@ class Timerecording extends mfBaseModel
private $creator;
private $user;
private $timerecordingCategory;
private $timerecordingCar;
public function getProperty($name)

View File

@@ -22,7 +22,9 @@ class TimerecordingController extends mfBaseController
$this->updateHolidays($this->me->id);
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$timerecordingCars = TimerecordingCarModel::search(['timerecording' => 1]);
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
$this->layout()->set("timerecordingCars", $timerecordingCars);
$this->layout()->setTemplate("Timerecording/Index");
}
@@ -206,13 +208,12 @@ class TimerecordingController extends mfBaseController
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
$plushours = $employee[0]->plushours_now * 1.25;
$overtime = $employee[0]->overtime * 1.5;
$overtime = $employee[0]->overtime_now * 1.5;
$overtimesum = $plushours + $overtime;
if ($overtimesum < $isTime) {
if ($overtimesum < 0) {
$overtimesum = 0;
}
$result['state'] = "error";
$result['error'] = "Maximal verfügbarer ZA: " . sprintf('%02dh:%02dm', floor($overtimesum / 3600), floor($overtimesum / 60 % 60)) . ".";
echo json_encode($result);
@@ -221,7 +222,7 @@ class TimerecordingController extends mfBaseController
if ($plushours >= $isTime) {
$isTime = $isTime * 0.8;
$return['hours'] = $isTime;
} elseif ($plushours <= 0) {
} elseif ($plushours == 0) {
$isTime = $isTime * 0.66666666666666666666666666666667;
$return ['hours_overtime'] = $isTime;
} else {
@@ -265,7 +266,7 @@ class TimerecordingController extends mfBaseController
$this->updateOpenTimerecording();
}
$data = [];
if ($hourday == 1 || $hourday == 6) {
if ($hourday == 1 || $hourday == 6 || $hourday == 7) {
$starttime = strtotime($r->date . " " . $r->start . ":00");
$endtime = strtotime($r->date . " " . $r->end . ":00");
if ($hourday == 6) {
@@ -282,7 +283,7 @@ class TimerecordingController extends mfBaseController
$endtime = strtotime($r->date . " 23:59:00");
}
if ($hourday != 5) {
if ($hourday != 5 && $hourday != 7) {
$result = $this->checkTimerecording($starttime, $endtime, $id);
}
if ($result['state'] == "error") {
@@ -321,6 +322,19 @@ class TimerecordingController extends mfBaseController
$data['businesstrip_info'] = $r->businesstrip_info;
$data['homeoffice'] = $r->homeoffice;
$data['days'] = $r->days;
$data['timerecordingCar_id'] = $r->timerecordingCar_id;
$data['mileage_start'] = $r->mileage_start;
$data['mileage_end'] = $r->mileage_end;
if (!$data['timerecordingCar_id']) {
$data['timerecordingCar_id'] = NULL;
}
if (!$data['mileage_start']) {
$data['mileage_start'] = NULL;
}
if (!$data['mileage_end']) {
$data['mileage_end'] = NULL;
}
if (!$data['businesstrip'] || $data['businesstrip'] == "false") {
$data['businesstrip'] = 0;
@@ -436,6 +450,7 @@ class TimerecordingController extends mfBaseController
$this->updateHolidays($data['user_id']);
}
$this->updatePlushours($data['user_id']);
TimerecordingCarModel::calcMileage();
}
if ($mode == "edit") {
@@ -828,6 +843,16 @@ class TimerecordingController extends mfBaseController
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
} else if ($timerecording->timerecordingCategory->hourday == 7) {
$date = date("d.m.Y", $timerecording->start);
$datadate = date("Y-m-d", $timerecording->start);
$start = date("H:i", $timerecording->start);
$end = date("H:i", $timerecording->end);
$seconds = $timerecording->end - $timerecording->start;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -836,8 +861,17 @@ class TimerecordingController extends mfBaseController
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
}
$edit = "";
if ($timerecording->businesstrip == 1) {
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
if ($timerecording->timerecordingCategory->hourday == 7) {
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>(" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM) (Zielort: " . $timerecording->businesstrip_info . ")</span>";
} else if ($timerecording->businesstrip == 1) {
if ($timerecording->timerecordingCar) {
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
$car = " (" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM)";
} else {
$car = "";
}
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>$car (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
} else if ($timerecording->homeoffice == 1) {
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Homeoffice)</span>";
} else {
@@ -860,13 +894,16 @@ class TimerecordingController extends mfBaseController
data-businesstrip="' . $timerecording->businesstrip . '"
data-businesstripinfo="' . $timerecording->businesstrip_info . '"
data-homeoffice="' . $timerecording->homeoffice . '"
data-car="' . $timerecording->timerecordingCar_id . '"
data-mileagestart="' . $timerecording->mileage_start . '"
data-mileageend="' . $timerecording->mileage_end . '"
title="Bearbeiten"></i>';
else :
$edit .= '<div class="edit-placeholder"></div>';
endif;
$edit .= '<i data-id="' . $timerecording->id . '" class="fas fa-trash text-danger delete-item" ></i>';
endif;
if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
if ($datatype == 3 && ($timerecording->timerecordingCategory->hourday == 1 || $timerecording->timerecordingCategory->hourday == 7 || $timerecording->timerecordingCategory->hourday == 5)) {
} else {
$rows[] = array(
'date' => array('date' => $state . $day . " " . $date, 'order' => $orderdate),

View File

@@ -11,6 +11,10 @@ class TimerecordingModel
private $timerecordingCategory_id;
private $businesstrip;
private $businesstrip_info;
private $timerecordingCar_id;
private $mileage_start;
private $mileage_end;
private $homeoffice;
private $comment;
private $approved;
@@ -174,7 +178,20 @@ class TimerecordingModel
$where .= " AND `start` >= $start AND `days` !=0 ORDER by start ASC";
}
}
if (array_key_exists("timerecordingCar_id", $filter)) {
$timerecordingCar = $filter['timerecordingCar_id'];
if (is_numeric($timerecordingCar)) {
$where .= " AND `timerecordingCar_id` = $timerecordingCar ORDER by mileage_end DESC LIMIT 1";
}
}
if (array_key_exists("timerecordingCar_id_all", $filter)) {
$timerecordingCar = $filter['timerecordingCar_id_all'];
if (is_numeric($timerecordingCar)) {
$where .= " AND `timerecordingCar_id` = $timerecordingCar ORDER by mileage_start ASC";
}
}
if (array_key_exists("starttime", $filter) && array_key_exists("endtime", $filter)) {
$starttime = $filter['starttime'];

View File

@@ -0,0 +1,59 @@
<?php
class TimerecordingCar extends mfBaseModel
{
private $editor;
private $creator;
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,173 @@
<?php
class TimerecordingCarController 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("TimerecordingCar/Index");
$timerecordingcars = TimerecordingCarModel::getAll();
$this->layout()->set("timerecordingcars", $timerecordingcars);
}
protected function detailAction()
{
$timerecordingcarid = $this->request->id;
$this->layout()->setTemplate("TimerecordingCar/Detail");
$timerecordingcar = TimerecordingCarModel::getOne($timerecordingcarid);
$this->layout()->set("timerecordingcar", $timerecordingcar);
$timerecordings = TimerecordingModel::search(["timerecordingCar_id_all" => $timerecordingcarid]);
$this->layout()->set("timerecordings", $timerecordings);
}
protected function addAction()
{
$this->layout()->setTemplate("TimerecordingCar/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Auto nicht gefunden", "error");
$this->redirect("TimerecordingCar");
}
$timerecordingcars = new TimerecordingCar($id);
if ($timerecordingcars->id != $id) {
$this->layout()->setFlash("Auto nicht gefunden", "error");
$this->redirect("TimerecordingCar");
}
$this->layout()->set("timerecordingcars", $timerecordingcars);
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";
$timerecordingcars = new TimerecordingCar($id);
if (!$timerecordingcars->id) {
$this->layout()->setFlash("Autos nicht gefunden", "error");
$this->redirect("TimerecordingCar");
}
} else {
$mode = "add";
}
$data = [];
$data['number_plate'] = trim($r->number_plate);
$data['brand'] = trim($r->brand);
$data['model'] = trim($r->model);
$data['mileage'] = trim($r->mileage);
$data['initial_approval'] = strtotime($r->initial_approval);
$data['timerecording'] = $r->timerecording;
$data['first_approval'] = trim($r->first_approval);
if (!$data['initial_approval']) {
$data['initial_approval'] = null;
}
if (!$data['timerecording']) {
$data['timerecording'] = 0;
}
if (!$data['mileage']) {
$data['mileage'] = null;
}
if (!$data['first_approval'] || trim($data['first_approval']) == "") {
$data['first_approval'] = null;
}
if (!$data['number_plate']) {
$this->layout()->setFlash("Kennzeichen darf nicht leer sein", "error");
$this->redirect("TimerecordingCar");
}
if (!$data['brand']) {
$this->layout()->setFlash("Marke darf nicht leer sein", "error");
$this->redirect("TimerecordingCar");
}
if (!$data['model']) {
$this->layout()->setFlash("Model/Typ darf nicht leer sein", "error");
$this->redirect("TimerecordingCar");
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$timerecordingcars->update($data);
} else {
$timerecordingcars = TimerecordingCarModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordingcars->save();
$returnUrl = "TimerecordingCar";
$returnAction = "Index";
$returnVariables = array();
$returnAnker = "";
if ($this->request->returnto == "detail") {
$returnUrl = "TimerecordingCar";
$returnAction = "detail";
$returnVariables = array("id" => $id);
}
TimerecordingCarModel::calcMileage();
if (!$id) {
$this->layout()->setFlash("Auto konnte nicht angelegt werden", "error");
$this->redirect("TimerecordingCar");
}
if ($mode == "edit") {
$this->layout()->setFlash("Auto erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Auto erfolgreich angelegt", "success");
}
$this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordingcars = new TimerecordingCar($id);
if (!$timerecordingcars->id || $timerecordingcars->id != $id) {
$this->layout()->setFlash("Auto nicht gefunden.", "error");
$this->redirect("TimerecordingCar");
}
$timerecordingcars->delete();
$this->redirect("TimerecordingCar");
}
}

View File

@@ -0,0 +1,156 @@
<?php
class TimerecordingCarModel
{
private $number_plate;
private $brand;
private $model;
private $mileage;
private $mileage_now;
private $mileage_timestamp;
private $initial_approval;
private $first_approval;
private $timerecording;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new TimerecordingCar();
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("TimerecordingCar", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCar($data);
}
return $item;
}
public static function calcMileage()
{
$TimerecordingCars = self::getAll();
foreach ($TimerecordingCars as $TimerecordingCar) {
$timerecording = TimerecordingModel::search(["timerecordingCar_id" => $TimerecordingCar->id]);
if (!$timerecording) {
if ($TimerecordingCar->mileage_now != $TimerecordingCar->mileage) {
$TimerecordingCar->mileage_now = $TimerecordingCar->mileage;
$TimerecordingCar->save();
}
} else {
if (!$TimerecordingCar->mileage_now || $TimerecordingCar->mileage_now < $timerecording[0]->mileage_end) {
$TimerecordingCar->mileage_now = $timerecording[0]->mileage_end;
$TimerecordingCar->save();
} else if ($timerecording[0]->mileage_end < $TimerecordingCar->mileage) {
$TimerecordingCar->mileage_now = $TimerecordingCar->mileage;
$TimerecordingCar->save();
}
}
}
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingCar", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCar($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingCar", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCar($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("TimerecordingCar", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCar($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("timerecording", $filter)) {
$timerecording = $filter['timerecording'];
if (is_numeric($timerecording)) {
$where .= " AND timerecording=$timerecording";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -9,7 +9,7 @@ class TimerecordingCategoryModel
private $require_comment;
private $only_admin;
private $businesstrip;
public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage", 6 => "ZA Uhrzeit (von/bis)");
public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage", 6 => "ZA Uhrzeit (von/bis)", 7 => "Fahrtenbuch (von/bis)");
public static $approval_definition = array(0 => "Nein", 1 => "Ja");
public static $require_comment_definition = array(0 => "Nein", 1 => "Ja");
public static $businesstrip_definition = array(0 => "Nein", 1 => "Ja");

View File

@@ -25,6 +25,8 @@ class TimerecordingReportController extends mfBaseController
$this->layout()->set("timerecordingusers", $timerecordingusers);
$timerecordings = TimerecordingModel::getAll();
$this->layout()->set("timerecordings", $timerecordings);
$timerecordingCars = TimerecordingCarModel::search(['timerecording' => 1]);
$this->layout()->set("timerecordingCars", $timerecordingCars);
}
protected function apiAction()
@@ -57,7 +59,7 @@ class TimerecordingReportController extends mfBaseController
$this->returnJson($data);
}
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
public function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
{
$mustSeconds = 0;
$isSeconds = 0;
@@ -290,6 +292,16 @@ class TimerecordingReportController extends mfBaseController
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
} else if ($timerecording->timerecordingCategory->hourday == 7) {
$date = date("d.m.Y", $timerecording->start);
$datadate = date("Y-m-d", $timerecording->start);
$start = date("H:i", $timerecording->start);
$end = date("H:i", $timerecording->end);
$seconds = $timerecording->end - $timerecording->start;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -298,8 +310,17 @@ class TimerecordingReportController extends mfBaseController
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
}
$edit = "";
if ($timerecording->businesstrip == 1) {
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
if ($timerecording->timerecordingCategory->hourday == 7) {
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>(" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM) (Zielort: " . $timerecording->businesstrip_info . ")</span>";
} else if ($timerecording->businesstrip == 1) {
if ($timerecording->timerecordingCar) {
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
$car = " (" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM)";
} else {
$car = "";
}
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>$car (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
} else if ($timerecording->homeoffice == 1) {
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Homeoffice)</span>";
} else {
@@ -322,15 +343,18 @@ class TimerecordingReportController extends mfBaseController
data-userid="' . $timerecording->user_id . '"
data-businesstrip="' . $timerecording->businesstrip . '"
data-businesstripinfo="' . $timerecording->businesstrip_info . '"
data-homeoffice="' . $timerecording->homeoffice . '"
data-days="' . $timerecording->days . '"
data-homeoffice="' . $timerecording->homeoffice . '"
data-days="' . $timerecording->days . '"
data-car="' . $timerecording->timerecordingCar_id . '"
data-mileagestart="' . $timerecording->mileage_start . '"
data-mileageend="' . $timerecording->mileage_end . '"
title="Bearbeiten"></i>';
else :
$edit .= '<div class="edit-placeholder"></div>';
endif;
$edit .= '<i data-id="' . $timerecording->id . '" class="fas fa-trash text-danger delete-item" ></i>';
endif;
if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
if ($datatype == 3 && ($timerecording->timerecordingCategory->hourday == 1 || $timerecording->timerecordingCategory->hourday == 7 || $timerecording->timerecordingCategory->hourday == 5)) {
} else {
$rows[] = array(
'user' => array('user' => $timerecording->user->name, 'order' => $timerecording->user->name),
@@ -363,23 +387,28 @@ class TimerecordingReportController extends mfBaseController
}
protected function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear)
public function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear, $user_id = NULL, $ajax = 1)
{
$r = $this->request;
$mustSeconds = 0;
$isSeconds = 0;
$holiDays = 0;
$plusHours = 0;
$daysum = array();
if (!$user_id) {
$user_id = $r->user_id;
}
$rows = [];
$employee = TimerecordingEmployeeModel::search(['user_id' => $r->user_id]);
$employee = TimerecordingEmployeeModel::search(['user_id' => $user_id]);
if ($employee) {
$holiDays = $employee[0]->holidays;
$plusHours = $employee[0]->plushours;
$auto_workinghours = $employee[0]->auto_workinghours;
$startdate = $employee[0]->startdate;
}
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $r->user_id]);
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $user_id]);
$holidays = TimerecordingHolidayModel::getAll();
foreach ($workinghours as $workinghour) {
@@ -402,7 +431,7 @@ class TimerecordingReportController extends mfBaseController
$timestamp_sonntag = strtotime("{$year}-W{$kw}-7");
$firstdate = strtotime(date("Y-m-d", $timestamp_montag) . " 00:00:00");
$lastdate = strtotime(date("Y-m-d", $timestamp_sonntag) . ' 23:59:59');
$searchArray = ['user_id' => $r->user_id, 'start' => $timestamp_montag, 'end' => $lastdate];
$searchArray = ['user_id' => $user_id, 'start' => $timestamp_montag, 'end' => $lastdate];
$daycounter = '0';
@@ -422,7 +451,7 @@ class TimerecordingReportController extends mfBaseController
$lastdate = strtotime(date("Y-m-t", $datamonth));
$daycount = date("t", $datamonth);
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
$searchArray = ['user_id' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $user_id, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -441,7 +470,7 @@ class TimerecordingReportController extends mfBaseController
$lastdate = strtotime(date("Y-12-31 23:59:59", $datayear));
$daycount = date("t", $datamonth);
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
$searchArray = ['user_id' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
$searchArray = ['user_id' => $user_id, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -462,6 +491,7 @@ class TimerecordingReportController extends mfBaseController
$timerecordingcategories = TimerecordingCategoryModel::getAll();
$timerecordings = TimerecordingModel::search($searchArray);
$responsecount = count($timerecordings);
foreach ($timerecordings as $timerecording):
$state = "";
@@ -500,10 +530,18 @@ class TimerecordingReportController extends mfBaseController
}
$summcounter = 0;
$savecounter = 0;
$sumdays = 0;
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
$holidaycounter = $workingHours[date("w", $i)];
$isSeconds = $isSeconds + $holidaycounter;
$summcounter = $summcounter + $holidaycounter;
$daycheck = date("Y-m-d", $i);
if (!$holiDay[$daycheck]) {
if ($holidaycounter) {
$isSeconds = $isSeconds + $holidaycounter;
$summcounter = $summcounter + $holidaycounter;
$sumdays++;
}
}
if ($savecounter == 1000) {
echo $savecounter;
die();
@@ -513,8 +551,18 @@ class TimerecordingReportController extends mfBaseController
$seconds = $summcounter;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
// $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
if ($sumdays == 1 || $sumdays == 0) {
$sum = $sumdays . " Tag";
} else if ($sumdays > 1) {
$sum = $sumdays . " Tage";
}
if (!$daysum[$timerecording->timerecordingCategory->short]) {
$daysum[$timerecording->timerecordingCategory->short] = $sumdays;
} else {
$daysum[$timerecording->timerecordingCategory->short] = $daysum[$timerecording->timerecordingCategory->short] + $sumdays;
}
} else if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
$date = date("d.m.Y", $timerecording->start) . " - " . $daysgerm[date("w", time())] . " " . date("d.m.Y", time());;
$datadate = date("Y-m-d", $timerecording->start);
@@ -554,6 +602,18 @@ class TimerecordingReportController extends mfBaseController
$end = "-";
$day = $daysgerm[date("w", $timerecording->start)];
$sum = $timerecording->days . " Tage";
} else if ($timerecording->timerecordingCategory->hourday == 6) {
$date = date("d.m.Y", $timerecording->start);
$datadate = date("Y-m-d", $timerecording->start);
$start = date("H:i", $timerecording->start);
$end = date("H:i", $timerecording->end);
// $seconds = $timerecording->hours;
$seconds = $timerecording->end - $timerecording->start;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -600,11 +660,17 @@ class TimerecordingReportController extends mfBaseController
$json['time']['must'] = sprintf('%02dh:%02dm', floor($mustSeconds / 3600), floor($mustSeconds / 60 % 60));
$json['time']['holidays'] = $holiDays;
$json['time']['plushours'] = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
$json['time']['daysum'] = $daysum;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;
$json = json_encode($json);
echo trim($json);
die();
if ($ajax == 1) {
$json = json_encode($json);
echo trim($json);
die();
} else {
return $json;
}
}
protected function addAction()

View File

@@ -0,0 +1,40 @@
<?php
use Phinx\Migration\AbstractMigration;
final class TimerecordingCar extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table("TimerecordingCar", ["signed" => true]);
$table->addColumn("number_plate", "string", ["null" => false]);
$table->addColumn("brand", "text", ["null" => true]);
$table->addColumn("model", "text", ["null" => true]);
$table->addColumn("mileage", "integer", ["null" => true]);
$table->addColumn("mileage_now", "integer", ["null" => true]);
$table->addColumn("mileage_timestamp", "integer", ["null" => true]);
$table->addColumn("initial_approval", "integer", ["null" => true]);
$table->addColumn("timerecording", "integer", ["default" => 1]);
$table->addColumn("create_by", "integer", ["null" => false]);
$table->addColumn("edit_by", "integer", ["null" => false]);
$table->addColumn("create", "integer", ["null" => false]);
$table->addColumn("edit", "integer", ["null" => false]);
$table->save();
}
if ($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$this->table("TimerecordingCar")->drop()->save();
}
if ($this->getEnvironment() == "addressdb") {
}
}
}
?>

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class TimerecordingAddFieldsCar extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table("Timerecording", ["signed" => true]);
$table->addColumn("timerecordingCar_id", "integer", ["null" => true, "default" => NULL, "after" => "businesstrip_info"]);
$table->addColumn("mileage_start", "integer", ["null" => true, "default" => NULL, "after" => "timerecordingCar"]);
$table->addColumn("mileage_end", "integer", ["null" => true, "default" => NULL, "after" => "mileage_start"]);
$table->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if ($this->getEnvironment() == "thetool") {
$this->table("Timerecording")->removeColumn("timerecordingCar")->save();
$this->table("Timerecording")->removeColumn("mileage_start")->save();
$this->table("Timerecording")->removeColumn("mileage_end")->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}

View File

@@ -223,7 +223,25 @@ $(document).ready(function () {
$(this).prop("min", '');
$(this).val('');
})
} else if (parseInt($(this).find(':selected').data('hourday')) === 7) {
$("#endtime-div").show();
$("#endtime-div").find('input').each(function () {
$(this).prop("required", true);
$(this).prop("disabled", false);
});
$("#enddate-div").hide();
$("#enddate-div").find('input').each(function () {
$(this).prop("required", false);
$(this).prop("min", '');
$(this).val('');
})
$('#businesstrip_info').val('');
$('#businesstrip_info').show();
$('.car-div-car').show();
}
if (parseInt($(this).find(':selected').data('comment')) === 1) {
$('#comment').prop("required", true);
} else {
@@ -235,11 +253,28 @@ $(document).ready(function () {
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
$('#businesstrip_info').hide();
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('#timerecordingCar_id').val('').change();
$('.car-div').hide();
} else if (parseInt($(this).find(':selected').data('hourday')) === 7) {
$('.businesstrip-div').show();
$('.businesstrip-check-div').hide();
$('#businesstrip').prop("checked", true);
$('#businesstrip_info').show();
$('#businesstrip_info').prop('required', true);
$('#homeoffice-div').hide();
} else {
$('.businesstrip-div').hide();
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
$('#timerecordingCar_id').val('').change();
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('.car-div').hide();
$('#businesstrip_info').hide();
}
if (parseInt($(this).find(':selected').data('homeoffice')) === 1) {
@@ -306,12 +341,25 @@ $(document).ready(function () {
$('#businesstrip_info').show();
$('#businesstrip_info').prop('required', true);
$('#homeoffice-div').hide();
$('#timerecordingCar_id').val('').change();
}
if ($(this).data('homeoffice') == 1) {
$('.businesstrip-div').hide();
$('#homeoffice').prop("checked", true);
$('#homeoffice-div').show();
}
if ($(this).data('car')) {
$('#timerecordingCar_id').val($(this).data('car')).change();
if ($(this).data('mileagestart')) {
$('.car-div').show();
$('.car-div').find('input').prop("required", true);
$('#mileage_start').val($(this).data('mileagestart'));
$('#mileage_end').val($(this).data('mileageend'));
} else {
}
}
$('.alert-success').remove();
window.scrollTo(0, 0);
});
@@ -324,8 +372,14 @@ $(document).ready(function () {
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
$('#businesstrip_info').hide();
$('#businesstrip_info').prop("required", false);
$('#homeoffice').prop("checked", false);
$('.car-div').hide();
$('.car-div').find('input').val('');
$('.car-div').find('input').prop("required", false);
$('#timerecordingCar_id').val('').change();
$('#timerecordingCategory_id').change();
});
$("body").on("change", "#dataweek,#datamonth,#datayear", function () {
@@ -362,7 +416,7 @@ $(document).ready(function () {
$('#businesstrip_info').prop('required', true);
$('#homeoffice').prop('checked', false);
$('#homeoffice-div').hide();
$('.car-div-car').show();
} else {
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
@@ -376,6 +430,10 @@ $(document).ready(function () {
if ($(this).prop('checked') == true) {
$('#businesstrip').prop('checked', false);
$('.businesstrip-div').hide();
$('#timerecordingCar_id').val('');
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('.car-div').hide();
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
$('#businesstrip_info').prop('required', false);
@@ -414,6 +472,19 @@ $(document).ready(function () {
});
$("body").on("change", "#timerecordingCar_id", function () {
if ($('#timerecordingCar_id').val() == "") {
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('.car-div').hide();
$('.car-div-car').show();
} else {
$('.car-div').show();
$('.car-div').find('input').prop("required", true);
$('#mileage_start').val($(this).find(':selected').data('mileagenow'));
}
});
$("body").on("click", ".delete-item", function () {
if (confirm('Buchung wirklich löschen?')) {
$.post(deleteUrl, {
@@ -430,12 +501,16 @@ $(document).ready(function () {
$('#alert-box').remove();
var businesstrip = false;
var homeoffice = false;
var car = false;
if ($('#businesstrip').prop('checked') == true) {
businesstrip = 1;
}
if ($('#homeoffice').prop('checked') == true) {
homeoffice = 1;
}
if ($.trim($('#timerecordingCar_id').val())) {
car = 1;
}
$.post(insertUrl, {
id: $.trim($('#id').val()),
timerecordingCategory_id: $.trim($('#timerecordingCategory_id').val()),
@@ -446,6 +521,9 @@ $(document).ready(function () {
comment: $.trim($('#comment').val()),
businesstrip: businesstrip,
businesstrip_info: $.trim($('#businesstrip_info').val()),
timerecordingCar_id: $.trim($('#timerecordingCar_id').val()),
mileage_start: $.trim($('#mileage_start').val()),
mileage_end: $.trim($('#mileage_end').val()),
homeoffice: homeoffice,
hourday: $.trim($('#timerecordingCategory_id').find(':selected').data('hourday')),
ajax: 1
@@ -459,10 +537,13 @@ $(document).ready(function () {
<h5><i class="icon fas fa-check"></i> Erfolgreich</h5>
` + result.message + `</div>
</div>`);
$('#businesstrip').prop('checked', false);
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
$('#businesstrip_info').prop('required', false);
if ($.trim($('#mileage_start').val())) {
$('#timerecordingCar_id').find(':selected').data('mileagenow', $.trim($('#mileage_end').val()));
}
if (car == 1) {
$('#timerecordingCar_id').val('').change();
}
}
if (result.state === "error") {
$('.wrapper .container-fluid').prepend(`<div id="alert-box" class="row">

View File

@@ -250,6 +250,22 @@ $(document).ready(function () {
$('#days-div').show();
$('#days').prop("required", true);
} else if (parseInt($(this).find(':selected').data('hourday')) === 7) {
$("#endtime-div").show();
$("#endtime-div").find('input').each(function () {
$(this).prop("required", true);
$(this).prop("disabled", false);
});
$("#enddate-div").hide();
$("#enddate-div").find('input').each(function () {
$(this).prop("required", false);
$(this).prop("min", '');
$(this).val('');
})
$('#businesstrip_info').val('');
$('#businesstrip_info').show();
$('.car-div-car').show();
}
if (parseInt($(this).find(':selected').data('comment')) === 1) {
$('#comment').prop("required", true);
@@ -262,10 +278,25 @@ $(document).ready(function () {
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
$('#businesstrip_info').hide();
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('#timerecordingCar_id').val('').change();
$('.car-div').hide();
} else if (parseInt($(this).find(':selected').data('hourday')) === 7) {
$('.businesstrip-div').show();
$('.businesstrip-check-div').hide();
$('#businesstrip').prop("checked", true);
$('#businesstrip_info').show();
$('#businesstrip_info').prop('required', true);
$('#homeoffice-div').hide();
} else {
$('.businesstrip-div').hide();
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
$('#timerecordingCar_id').val('').change();
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('.car-div').hide();
$('#businesstrip_info').hide();
}
@@ -342,12 +373,25 @@ $(document).ready(function () {
$('#businesstrip_info').show();
$('#businesstrip_info').prop('required', true);
$('#homeoffice-div').hide();
$('#timerecordingCar_id').val('').change();
}
if ($(this).data('homeoffice') == 1) {
$('.businesstrip-div').hide();
$('#homeoffice').prop("checked", true);
$('#homeoffice-div').show();
}
if ($(this).data('car')) {
$('#timerecordingCar_id').val($(this).data('car')).change();
if ($(this).data('mileagestart')) {
$('.car-div').show();
$('.car-div').find('input').prop("required", true);
$('#mileage_start').val($(this).data('mileagestart'));
$('#mileage_end').val($(this).data('mileageend'));
} else {
}
}
$('.alert-success').remove();
window.scrollTo(0, 0);
});
@@ -365,6 +409,10 @@ $(document).ready(function () {
$('#businesstrip_info').val('');
$('#businesstrip_info').hide();
$('#homeoffice').prop("checked", false);
$('.car-div').hide();
$('.car-div').find('input').val('');
$('.car-div').find('input').prop("required", false);
$('#timerecordingCar_id').val('').change();
$('#timerecordingCategory_id').change();
});
@@ -431,7 +479,7 @@ $(document).ready(function () {
$('#businesstrip_info').prop('required', true);
$('#homeoffice').prop('checked', false);
$('#homeoffice-div').hide();
$('.car-div-car').show();
} else {
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
@@ -445,6 +493,10 @@ $(document).ready(function () {
if ($(this).prop('checked') == true) {
$('#businesstrip').prop('checked', false);
$('.businesstrip-div').hide();
$('#timerecordingCar_id').val('');
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('.car-div').hide();
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
$('#businesstrip_info').prop('required', false);
@@ -456,6 +508,19 @@ $(document).ready(function () {
});
$("body").on("change", "#timerecordingCar_id", function () {
if ($('#timerecordingCar_id').val() == "") {
$('.car-div').find('input').prop("required", false);
$('.car-div').find('input').val('');
$('.car-div').hide();
$('.car-div-car').show();
} else {
$('.car-div').show();
$('.car-div').find('input').prop("required", true);
$('#mileage_start').val($(this).find(':selected').data('mileagenow'));
}
});
$("body").on("click", ".delete-item", function () {
if (confirm('Buchung wirklich löschen?')) {
$.post(deleteUrl, {
@@ -474,12 +539,16 @@ $(document).ready(function () {
userid = $('#user_id_select').val();
var businesstrip = false;
var homeoffice = false;
var car = false;
if ($('#businesstrip').prop('checked') == true) {
businesstrip = 1;
}
if ($('#homeoffice').prop('checked') == true) {
homeoffice = 1;
}
if ($.trim($('#timerecordingCar_id').val())) {
car = 1;
}
$.post(insertUrl, {
id: $.trim($('#id').val()),
user_id: userid,
@@ -492,6 +561,9 @@ $(document).ready(function () {
comment: $.trim($('#comment').val()),
businesstrip: businesstrip,
businesstrip_info: $.trim($('#businesstrip_info').val()),
timerecordingCar_id: $.trim($('#timerecordingCar_id').val()),
mileage_start: $.trim($('#mileage_start').val()),
mileage_end: $.trim($('#mileage_end').val()),
homeoffice: homeoffice,
hourday: $.trim($('#timerecordingCategory_id').find(':selected').data('hourday')),
ajax: 1
@@ -505,6 +577,12 @@ $(document).ready(function () {
<h5><i class="icon fas fa-check"></i> Erfolgreich</h5>
` + result.message + `</div>
</div>`);
if ($.trim($('#mileage_start').val())) {
$('#timerecordingCar_id').find(':selected').data('mileagenow', $.trim($('#mileage_end').val()));
}
if (car == 1) {
$('#timerecordingCar_id').val('').change();
}
$('#businesstrip').prop('checked', false);
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');