Zeiterfassungs Update

* neue Migration für Personaladministration (Aktive Verrechnung)
 * Verrechnung Anpassungen Black P.
 * superexpertEnabled Implementation Verrechnung/Personaladministration
 * Personaladministration (Aktive Verrechnung/Zeiterfassung Enddatum)
This commit is contained in:
Spitzer Daniel
2024-04-04 18:05:16 +02:00
parent c3ebfdfd2a
commit acbdb7b2aa
18 changed files with 1507 additions and 92 deletions

View File

@@ -122,6 +122,7 @@
hidesearch = [2, 3, 4, 5, 6, 7, 9, 10];
<?php endif; ?>
$(document).ready(function () {
$('.buttons-excel').closest('div').append('<div ><button id="month-complete" class="btn btn-danger margina">Monats Abschluss</button></div>');
$('.buttons-excel').closest('div').append('<div ><button id="bmd-export" class="btn btn-info margina">BMD Import</button></div>');
$('.buttons-excel').closest('div').append('<div ><button id="bmd-export-nlz" class="btn btn-info margina">BMD NLZ Import</button></div>');
@@ -130,9 +131,19 @@
window.open('<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'generatebmdexport']) ?>&month=' + $('#month').data('month'), '_blank');
});
$('body').on('click', '#bmd-export-nlz', function () {
window.open('<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'generatebmdexportnlz']) ?>&month=' + $('#month').data('month'), '_blank');
});
$('body').on('click', '#month-complete', function () {
if (confirm('Buchung wirklich löschen?')) {
$.post("<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'completemonth']) ?>", {
month: $.trim($('#month').data('month')),
ajax: 1
}).done(function (data) {
window.location.href = "<?= self::getUrl("TimerecordingBilling", "detailClosed", ['month' => $month]) ?>";
});
}
});
});
</script>

View File

@@ -0,0 +1,325 @@
<?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>
.fa-arrow-right-from-bracket {
margin-top: 3px;
margin-right: 10px;
color: #2238d1;
cursor: pointer;
}
.filler {
width: 30px;
height: 1px;
}
.filler-0 {
width: 7px;
height: 1px;
}
#overtimeModal .table td, #overtimeModal .table th {
border: none;
}
@media (min-width: 992px) {
.modal-lg, .modal-xl {
max-width: 400px !important;
}
}
</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">Zeiterfassung Verrechnung</li>
</ol>
</div>
<h4 id="month" data-month="<?= $month ?>" class="page-title">Verrechnung/Abrechnung <?= $month ?></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 Mitarbeiter</h4>
</div>
</div>
</div>
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<th class="text-center">Mitarbeiter/PersNr.</th>
<th class="text-center">Leistungszeiten</th>
<th class="text-center">Nichtleistungszeiten</th>
<th class="text-center">Iststunden (NLZ+LZ)</th>
<th class="text-center">Sollstunden</th>
<th class="text-center">Sollabweichung</th>
<th class="text-center">Gesamt Überstunden</th>
<?php if ($me->superexpertEnabled()): ?>
<th class="text-center">Black P. Stunden</th>
<?php endif; ?>
<th class="text-center">Ü50</th>
<th class="text-center">Ü100</th>
<th class="text-center">Diäten</th>
<th class="text-center">Homeoffice</th>
</tr>
<tr id="filterrow">
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<?php if ($me->superexpertEnabled()): ?>
<th></th>
<?php endif; ?>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($timerecordings as $timerecording):
$user = new User($timerecording->timerecordingEmployee->user->id);
$employee_number = (string)$user->getFlag('employee_number');
unset ($nlz);
if ($timerecording->nlz) {
$nlz_details = json_decode($timerecording->nlz, true);
foreach ($nlz_details as $key => $nlz_detail) {
if ($nlz_detail < 100) {
$nlz .= $key . ": " . $nlz_detail . " Tag(e)<br>";
} else {
$nlz .= $key . ": " . round($nlz_detail / 3600, 2) . " Stunden<br>";
}
}
} else {
$nlz = "";
}
?>
<tr>
<td class="text-nowrap">(<?= $employee_number ?>
) <?= $timerecording->timerecordingEmployee->user->name ?> </td>
<td class="text-center"><?= number_format(round($timerecording->ishours / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= $nlz ?></td>
<td class="text-center"><?= number_format(round($timerecording->ishourssum / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= number_format(round($timerecording->musthours / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= (($timerecording->ishourssum - $timerecording->musthours) == 0) ? '<div class="filler-0 float-left"></div>' : '' ?><?= number_format(round(($timerecording->ishourssum - $timerecording->musthours) / 3600, 2), "2", ",", ".") ?>
<?= (($timerecording->ishourssum - $timerecording->musthours) > 0) ? '<i class="float-right fa-regular fa-arrow-right-from-bracket change-difference" data-toggle="modal" data-target="#overtimeModal" data-hours="' . number_format(round(($timerecording->ishourssum - $timerecording->musthours) / 3600, 2), "2", ",", ".") . '" data-id="' . $timerecording->id . '"></i>' : '<div class="filler float-right"></div>' ?></td>
<td class="text-center"><?= ($timerecording->timerecordingEmployee->overtime_now == 0) ? '<div class="filler-0 float-left"></div>' : '' ?><?= number_format(round($timerecording->timerecordingEmployee->overtime_now / 3600, 2), "2", ",", ".") ?>
<?= ($timerecording->timerecordingEmployee->overtime_now > 0) ? '<i class="float-right fa-regular fa-arrow-right-from-bracket change-overtime" data-toggle="modal" data-target="#overtimeModal" data-hours="' . number_format(round($timerecording->timerecordingEmployee->overtime_now / 3600, 2), "2", ",", ".") . '" data-id="' . $timerecording->id . '"></i>' : '<div class="filler float-right"></div>' ?></td>
<?php if ($me->superexpertEnabled()): ?>
<td class="text-center"><?= number_format(round($timerecording->timerecordingEmployee->bpahours / 3600, 2), "2", ",", ".") ?></td>
<?php endif; ?>
<td class="text-center"><?= number_format(round($timerecording->overtime50free / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= number_format(round($timerecording->overtime100free / 3600, 2), "2", ",", ".") ?></td>
<td class="text-center"><?= number_format($timerecording->diet, 2, ',', '.') . " €" ?></td>
<td class="text-center"><?= $timerecording->homeoffice ?> Tag(e)</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal fade" id="overtimeModal" tabindex="-1" role="dialog"
aria-labelledby="overtimeModalInfoLabel"
aria-hidden="true" data-id="">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="overtimeModal-title"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-12">
<table class="table ">
<tr id="overtimes">
</tr>
<tr>
<th class="align-middle">Überstunden 50</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="overtime50"
id="overtime50"></td>
</tr>
<tr>
<th class="text-nowrap align-middle">Überstunden 100</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="overtime100"
id="overtime100"></td>
</tr>
<?php if ($me->superexpertEnabled()): ?>
<tr>
<th class="text-nowrap align-middle">Blackpig</th>
<td><input type="number" step="any" class="form-control change-overtime-value"
name="overtimebpa"
id="overtimebpa"></td>
</tr>
<?php endif; ?>
</table>
</div>
</div>
</div>
<div class="modal-footer">
<button id="submit-button" data-type="" type="button" class="btn btn-primary" data-dismiss="modal">
Speichern
<button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen
</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var hidesearch = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
<?php if ($me->superexpertEnabled()): ?>
hidesearch = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
<?php endif; ?>
$(document).ready(function () {
// $('.buttons-excel').closest('div').append('<div ><button id="month-complete" class="btn btn-danger margina">Monats Abschluss</button></div>');
$('.buttons-excel').closest('div').append('<div ><button id="bmd-export" class="btn btn-info margina">BMD Import</button></div>');
$('.buttons-excel').closest('div').append('<div ><button id="bmd-export-nlz" class="btn btn-info margina">BMD NLZ Import</button></div>');
$('body').on('click', '#bmd-export', function () {
window.open('<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'generatebmdexportclosed']) ?>&month=' + $('#month').data('month'), '_blank');
});
$('body').on('click', '#bmd-export-nlz', function () {
window.open('<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'generatebmdexportnlzclosed']) ?>&month=' + $('#month').data('month'), '_blank');
});
$('body').on('click', '#month-complete', function () {
if (confirm('Buchung wirklich löschen?')) {
$.post("<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'completemonth']) ?>", {
month: $.trim($('#month').data('month')),
ajax: 1
}).done(function (data) {
});
}
});
$('#overtimeModal').on('shown.bs.modal', function (event) {
var button = $(event.relatedTarget);
if (button.hasClass('change-difference')) {
$('#overtimeModal-title').text('Mehrstunden Transfer');
$('#overtimeModal').data('id', button.data('id'));
$('#overtimes').html('<th>Mehrstunden:</th> <td id="overtime-hours" data-hours="' + button.data('hours') + '">' + button.data('hours') + ' (6,5)</td>');
$('#submit-button').data('type', 'difference');
}
if (button.hasClass('change-overtime')) {
$('#overtimeModal-title').text('Überstunden Transfer');
$('#overtimes').html('<th>Überstunden:</th> <td id="overtime-hours" data-hours="' + button.data('hours') + '">' + button.data('hours') + '</td>');
$('#submit-button').data('type', 'overtime');
$('#overtimeModal').data('id', button.data('id'));
}
$('.change-overtime-value').val('');
});
$('body').on('change', '.change-overtime-value', function () {
//$('#overtime-hours').data('hours') to float
var difference = 0;
$(".change-overtime-value").each(function (index) {
//check if float
var value = $(this).val().replace(",", ".");
// console.log(value);
if (isNaN(parseFloat(value))) {
} else {
difference += parseFloat(value);
}
});
var valdiff = difference - parseFloat($(this).val());
valdiff = Math.round(valdiff * 100) / 100;
console.log("valdif" + valdiff);
var hours = $('#overtime-hours').data('hours').replace(",", ".");
if (parseFloat(hours) < difference) {
difference = difference - parseFloat(hours)
difference = Math.round(difference * 100) / 100;
console.log(difference);
if (valdiff == 0) {
$(this).val(hours);
} else if (valdiff == parseFloat(hours)) {
$(this).val('0');
} else {
var calc = Math.round((hours - valdiff) * 100) / 100
$(this).val(calc);
}
} else {
hours = hours.replace(",", ".");
}
});
$('body').on('click', '#submit-button', function () {
var id = $('#overtimeModal').data('id');
var overtime50 = $('#overtime50').val();
var overtime100 = $('#overtime100').val();
var overtimebpa = $('#overtimebpa').val();
$.post("<?= self::getUrl("TimerecordingBilling", "api", ['do' => 'saveovertime']) ?>", {
id: id,
type: $(this).data('type'),
overtime50: overtime50,
overtime100: overtime100,
overtimebpa: overtimebpa,
ajax: 1
}).done(function (data) {
window.location.reload();
});
});
//$.post(insertUrl, {
// id: $.trim($('#id').val()),
// timerecordingCategory_id: $.trim($('#timerecordingCategory_id').val()),
// date: $.trim($('#date').val()),
// enddate: $.trim($('#enddate').val()),
// start: $.trim($('#start').val()),
// end: $.trim($('#end').val()),
// 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
//}).done(function (data) {
// if (data.success) {
// window.location.href = '<?php //= self::getUrl("Timerecording") ?>//';
// } else {
// $('#error').html(data.error);
// }
//});
});
</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

@@ -1,77 +1,94 @@
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.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 active">Zeiterfassung Verrechnung</li>
</ol>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.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 active">Zeiterfassung Verrechnung</li>
</ol>
</div>
<h4 class="page-title">Zeiterfassung Verrechnung/Abrechnung</h4>
</div>
<h4 class="page-title">Zeiterfassung Verrechnung/Abrechnung</h4>
</div>
</div>
</div>
<!-- end page title -->
<!-- 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 Abrechnungsmonate</h4>
<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 Abrechnungsmonate</h4>
</div>
</div>
</div>
</div>
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<th class="text-center">Monat</th>
<th class="text-center">Abgeschlossen</th>
<th class="text-center">Abgeschlossen am</th>
<th class="text-center">Abgeschlossen von</th>
</tr>
<tr id="filterrow">
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($months as $month): ?>
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<td class="text-center"><a href="<?= self::getUrl("TimerecordingBilling", "detail", ["month" => $month]) ?>"> <?= $month ?></a></td>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<th class="text-center">Monat</th>
<th class="text-center">Abgeschlossen</th>
<th class="text-center">Abgeschlossen am</th>
<th class="text-center">Abgeschlossen von</th>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<tr id="filterrow">
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
foreach ($months as $month):
if ($timerecordingbillings[ltrim($month, "0")]) {
$closetime = $timerecordingbillings[ltrim($month, "0")]->closetime;
$closetime = date("d.m.Y H:i", $closetime);
$closer = $timerecordingbillings[ltrim($month, "0")]->creator->name;
$closed = "Ja";
} else {
$closetime = "";
$closer = "";
$closed = "Nein";
}
?>
<tr>
<td class="text-center"><a
href="<?= self::getUrl("TimerecordingBilling", "detail", ["month" => $month]) ?>"> <?= $month ?></a>
</td>
<td class="text-center"><?= $closed ?></td>
<td class="text-center"><?= $closetime ?></td>
<td class="text-center"><?= $closer ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var hidesearch = [7];
<script type="text/javascript">
var hidesearch = [7];
$(document).ready(function () {
$(document).ready(function () {
});
</script>
<script type="text/javascript"
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
});
</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

@@ -67,10 +67,11 @@ $approval = date("m/Y", $firstApproval);
<td><?= ($timerecordingcar->first_approval) ? $timerecordingcar->first_approval . " Jahr(en)" : "-" ?></td>
</tr>
<tr>
<th>Fahrtenbuch</th>
<td><?= ($timerecordingcar->timerecording) ? "Ja" : "Nein" ?></td>
<th>Fahrzeugverwalter</th>
<td><?= ($timerecordingcar->user_id) ? $timerecordingcar->user->name : "-" ?></td>
</tr>
</tbody>
</table>
</div>
@@ -85,6 +86,10 @@ $approval = date("m/Y", $firstApproval);
<div>
<table class="table table-sm">
<tbody>
<tr>
<th>Fahrtenbuch</th>
<td><?= ($timerecordingcar->timerecording) ? "Ja" : "Nein" ?></td>
</tr>
<tr>
<th>Erstzulassung</th>
<td><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>

View File

@@ -4,6 +4,10 @@ if (isset($_GET['returnto']) && $_GET['returnto'] == "detail") {
} else {
$cancelUrl = self::getUrl("TimerecordingCar");
}
foreach ($timerecordingusers as $timerecordinguser) {
$timerecordingUsers[$timerecordinguser->name] = $timerecordinguser->id;
}
ksort($timerecordingUsers);
?>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
@@ -46,6 +50,20 @@ if (isset($_GET['returnto']) && $_GET['returnto'] == "detail") {
value="<?= $timerecordingcars->number_plate ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="brand">Fahrzeugverwalter</label>
<div class="col-lg-2">
<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-2 col-form-label" for="brand">Marke *</label>
<div class="col-lg-3">

View File

@@ -41,6 +41,7 @@
<thead>
<tr>
<th class="text-center">Kennzeichen</th>
<th class="text-center">Fahrzeugverwalter</th>
<th class="text-center">Marke</th>
<th class="text-center">Model/Typ</th>
<th class="text-center">Erstzulassssung</th>
@@ -58,6 +59,7 @@
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@@ -78,6 +80,7 @@
<td>
<a href="<?= self::getUrl("TimerecordingCar", "detail", ["id" => $timerecordingcar->id]) ?>"> <?= $timerecordingcar->number_plate ?></a>
</td>
<td><?= ($timerecordingcar->user_id) ? $timerecordingcar->user->name : "-" ?></td>
<td><?= $timerecordingcar->brand ?></td>
<td><?= $timerecordingcar->model ?></td>
<td class="text-center"><?= ($timerecordingcar->initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?></td>
@@ -105,9 +108,9 @@
<script type="text/javascript">
var hidesearch = [7];
var hidesearch = [8];
var columnfilter = [5];
var columnfilter = [6];
var columnoptions = '<option value=""></option><option value="Ja">Ja</option><option value="Nein">Nein</option>';
$(document).ready(function () {

View File

@@ -0,0 +1,60 @@
<?php
class TimerecordingBilling extends mfBaseModel
{
private $editor;
private $creator;
private $timerecordingEmployee;
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

@@ -26,10 +26,31 @@ class TimerecordingBillingController extends mfBaseController
$months[] = date("m.Y", $month);
$month = strtotime("+1 month", $month);
}
$timerecordingBillings = TimerecordingBillingModel::getAll();
foreach ($timerecordingBillings as $timerecordingBilling) {
$timerecordingbillings[$timerecordingBilling->month] = $timerecordingBilling;
echo $timerecordingBilling->month;
}
$this->layout()->set("months", $months);
$this->layout()->set("timerecordingbillings", $timerecordingbillings);
$this->layout()->setTemplate("TimerecordingBilling/Index");
}
protected function detailClosedAction($timerecordingBilling)
{
$r = $this->request;
$month = $r->get("month");
$month = strtotime("01." . $month);
$timerecordings = TimerecordingBillingEmployeeModel::search(["timerecordingBilling_id" => $timerecordingBilling[0]->id]);
$this->layout()->setTemplate("TimerecordingBilling/DetailClosed");
$this->layout()->set("month", date("m.Y", $month));
$this->layout()->set("timerecordings", $timerecordings);
}
protected function detailAction()
{
$r = $this->request;
@@ -37,21 +58,26 @@ class TimerecordingBillingController extends mfBaseController
if (!$month) {
$this->redirect("TimerecordingBilling");
}
$month = strtotime("01." . $month);
$timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
foreach ($timerecordingsEmolyees as $timerecordingsEmolyee) {
if ($timerecordingsEmolyee->bmd_active == 0) continue;
$user = new User($timerecordingsEmolyee->user_id);
$employee_number = (string)$user->getFlag('employee_number');
$timerecordingReport = new TimerecordingReportController();
$timerecordings[$timerecordingsEmolyee->user_id]['user_id'] = $timerecordingsEmolyee->user_id;
$timerecordings[$timerecordingsEmolyee->user_id]['user_name'] = $timerecordingsEmolyee->user->name;
$timerecordings[$timerecordingsEmolyee->user_id]['employee_number'] = $employee_number;
$timerecordings[$timerecordingsEmolyee->user_id]['data'] = $timerecordingReport->getTimerecordingsTimes('2', $month, $month, $month, $timerecordingsEmolyee->user_id, 0);
$timerecordingBilling = TimerecordingBillingModel::search(["month" => $month]);
if ($timerecordingBilling) {
$this->detailclosedAction($timerecordingBilling);
} else {
$month = strtotime("01." . $month);
$timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
foreach ($timerecordingsEmolyees as $timerecordingsEmolyee) {
if ($timerecordingsEmolyee->bmd_active == 0) continue;
$user = new User($timerecordingsEmolyee->user_id);
$employee_number = (string)$user->getFlag('employee_number');
$timerecordingReport = new TimerecordingReportController();
$timerecordings[$timerecordingsEmolyee->user_id]['user_id'] = $timerecordingsEmolyee->user_id;
$timerecordings[$timerecordingsEmolyee->user_id]['user_name'] = $timerecordingsEmolyee->user->name;
$timerecordings[$timerecordingsEmolyee->user_id]['employee_number'] = $employee_number;
$timerecordings[$timerecordingsEmolyee->user_id]['data'] = $timerecordingReport->getTimerecordingsTimes('2', $month, $month, $month, $timerecordingsEmolyee->user_id, 0);
}
$this->layout()->set("timerecordings", $timerecordings);
$this->layout()->setTemplate("TimerecordingBilling/Detail");
$this->layout()->set("month", date("m.Y", $month));
}
$this->layout()->set("timerecordings", $timerecordings);
$this->layout()->setTemplate("TimerecordingBilling/Detail");
$this->layout()->set("month", date("m.Y", $month));
}
protected function apiAction()
@@ -68,6 +94,18 @@ class TimerecordingBillingController extends mfBaseController
case "generatebmdexportnlz":
$return = $this->generateBmdExport($month, 1);
break;
case "generatebmdexportclosed":
$return = $this->generateBmdExportClosed($month);
break;
case "generatebmdexportnlzclosed":
$return = $this->generateBmdExportClosed($month, 1);
break;
case "completemonth":
$return = $this->completemonth($month);
break;
case "saveovertime":
$return = $this->saveovertime();
break;
default:
$return = false;
}
@@ -93,13 +131,73 @@ class TimerecordingBillingController extends mfBaseController
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
//var_dump($r->get());exit;
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$timerecordingbillings = new TimerecordingBilling($id);
if (!$timerecordingbillings->id) {
$this->layout()->setFlash("Timerecording nicht gefunden", "error");
$this->redirect("TimerecordingBilling");
}
} else {
$mode = "add";
}
$data = [];
$data['month'] = trim($r->month);
$data['closetime'] = time();
if (!$data['month']) {
$data['month'] = NULL;
}
if (!$data['closetime']) {
$data['closetime'] = NULL;
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$timerecordingbillings->update($data);
} else {
$timerecordingbillings = TimerecordingBillingModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordingbillings->save();
if (!$id) {
$this->layout()->setFlash("Timerecording konnte nicht angelegt werden", "error");
$this->redirect("TimerecordingBilling");
}
if ($mode == "edit") {
// $this->layout()->setFlash("Timerecording erfolgreich geändert", "success");
} else if ($mode = "add") {
// $this->layout()->setFlash("Timerecording erfolgreich angelegt", "success");
}
return $id;
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordingbillings = new TimerecordingBilling($id);
if (!$timerecordingbillings->id || $timerecordingbillings->id != $id) {
$this->layout()->setFlash("Timerecording nicht gefunden.", "error");
$this->redirect("TimerecordingBilling");
}
$timerecordingbillings->delete();
$this->redirect("TimerecordingBilling");
}
protected function generateBmdLine()
@@ -107,13 +205,14 @@ class TimerecordingBillingController extends mfBaseController
}
protected function generateBmdExport($month, $nlz = 0)
protected function generateBmdExportClosed($month, $nlz = 0)
{
//create and download csv file
$filename = "BMDExport_" . $month . ".csv";
$filename = "import_bmd_" . $month . ".csv";
$file = fopen("php://output", 'w');
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $filename);
$monthbmd = date("n", strtotime("01." . $month));
$companybmd = "1";
if ($nlz == 0) {
$headerarray = ["Monat", "Firma", "Mitarbeiter", "Lohnart", "Menge", "Satz", "Betrag", "Kostenstelle", "NLZ-Kennzeichen", "NLZ Von-Datum", "NLZ Bis-Datum"];
fputcsv($file, $headerarray, ";");
@@ -121,7 +220,96 @@ class TimerecordingBillingController extends mfBaseController
$headerarray = ["Firma", "Mitarbeiter", "DV-Nr", "Art", "Sonderzeit", "Verarbeitungs-KZ", "Von", "Bis", "Verwaltung", "Bezahlt"];
fputcsv($file, $headerarray, ";");
}
$billing = TimerecordingBillingModel::search(["month" => $month]);
$timerecordingBillingEmployees = TimerecordingBillingEmployeeModel::search(["timerecordingBilling_id" => $billing[0]->id]);
foreach ($timerecordingBillingEmployees as $timerecordingBillingEmployee) {
if ($timerecordingBillingEmployee->timerecordingEmployee->bmd_active == 0) continue;
$user = new User($timerecordingBillingEmployee->timerecordingEmployee->user_id);
$employee_number = (string)$user->getFlag('employee_number');
$employeetypesbmd = TimerecordingEmployeeModel::$employeetypesbmd;
$employee_type = $employeetypesbmd[$timerecordingBillingEmployee->timerecordingEmployee->type];
if ($nlz == 0) {
$hours = $timerecordingBillingEmployee->ishours / 3600;
$hours = round($hours, 2);
$hours = str_replace(".", ",", $hours);
if ($hours > 0) {
$bodyarray = [$monthbmd, "1", $employee_number, $employee_type, $hours, "", "", "", "", "", ""];
fputcsv($file, $bodyarray, ";");
}
if ($timerecordingBillingEmployee->overtime50free > 0) {
$overtime50free = $timerecordingBillingEmployee->overtime50free / 3600;
$overtime50free = round($overtime50free, 2);
$overtime50free = str_replace(".", ",", $overtime50free);
$bodyarray = [$monthbmd, "1", $employee_number, "3110", $overtime50free, "", "", "", "", "", ""];
fputcsv($file, $bodyarray, ";");
}
if ($timerecordingBillingEmployee->overtime100free > 0) {
$overtime100free = $timerecordingBillingEmployee->overtime100free / 3600;
$overtime100free = round($overtime100free, 2);
$overtime100free = str_replace(".", ",", $overtime100free);
$bodyarray = [$monthbmd, "1", $employee_number, "3150", $overtime100free, "", "", "", "", "", ""];
fputcsv($file, $bodyarray, ";");
}
if ($timerecordingBillingEmployee->homeoffice > 0) {
$homeoffice = $timerecordingBillingEmployee->homeoffice;
$homeoffice = round($homeoffice, 2);
$homeoffice = str_replace(".", ",", $homeoffice);
$bodyarray = [$monthbmd, "1", $employee_number, "7590", $homeoffice, "", "", "", "", "", ""];
fputcsv($file, $bodyarray, ";");
}
} else {
if ($timerecordingBillingEmployee->nlz_detail) {
foreach (json_decode($timerecordingBillingEmployee->nlz_detail, true) as $nlztime) {
$bodyarray = [$companybmd, $employee_number, 1, $nlztime['categoryshort'], $nlztime['catExtended'], "3", $nlztime['start'], $nlztime['end'], $nlztime['time'], $nlztime['pay']];
fputcsv($file, $bodyarray, ";");
}
}
}
if ($timerecordingBillingEmployee->diet > 0 && $nlz == 0) {
$dietsum = round($timerecordingBillingEmployee->diet, 2);
$dietsum = str_replace(".", ",", $dietsum);
$bodyarray = [$monthbmd, $companybmd, $employee_number, "2500", "", "", $dietsum, "", "", "", ""];
fputcsv($file, $bodyarray, ";");
}
}
fclose($file);
exit;
}
protected function generateBmdExport($month, $nlz = 0, $export = 1)
{
//create and download csv file
if ($export == 1) {
$filename = "import_bmd_" . $month . ".csv";
$file = fopen("php://output", 'w');
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $filename);
}
if ($export == 1) {
if ($nlz == 0) {
$headerarray = ["Monat", "Firma", "Mitarbeiter", "Lohnart", "Menge", "Satz", "Betrag", "Kostenstelle", "NLZ-Kennzeichen", "NLZ Von-Datum", "NLZ Bis-Datum"];
fputcsv($file, $headerarray, ";");
} else {
$headerarray = ["Firma", "Mitarbeiter", "DV-Nr", "Art", "Sonderzeit", "Verarbeitungs-KZ", "Von", "Bis", "Verwaltung", "Bezahlt"];
fputcsv($file, $headerarray, ";");
}
}
$month = strtotime("01." . $month);
//last of month
$monthend = date("Y-m-d", strtotime("last day of this month", $month));
$monthend = strtotime($monthend . " 23:59:59");
$monthbmd = date("n", $month);
$companybmd = "1";
$timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
@@ -133,6 +321,12 @@ class TimerecordingBillingController extends mfBaseController
$employee_type = $employeetypesbmd[$timerecordingsEmolyee->type];
$timerecordingReport = new TimerecordingReportController();
$timerecording = $timerecordingReport->getTimerecordingsTimes('2', $month, $month, $month, $timerecordingsEmolyee->user_id, 0);
if ($export == 0) {
$reponse[$employee_number]['employee_id'] = $timerecordingsEmolyee->id;
$reponse[$employee_number]['homeoffice'] = $timerecording['time']['homeoffice'];
$reponse[$employee_number]['istimeall'] = $timerecording['time']['isorder'];
$reponse[$employee_number]['musttime'] = $timerecording['time']['mustorder'];
}
foreach ($timerecording['time']['isclean'] as $key => $value) {
$hours = $value;
@@ -141,8 +335,12 @@ class TimerecordingBillingController extends mfBaseController
$hours = round($hours, 2);
$hours = str_replace(".", ",", $hours);
if (strpos($key, ',') !== false && $nlz == 0) {
$bodyarray = [$monthbmd, $companybmd, $employee_number, $employee_type, $hours, "", "", "", "", "", ""];
fputcsv($file, $bodyarray, ";");
if ($export == 1) {
$bodyarray = [$monthbmd, $companybmd, $employee_number, $employee_type, $hours, "", "", "", "", "", ""];
fputcsv($file, $bodyarray, ";");
} else {
$reponse[$employee_number]['istime'] = $value;
}
} else if (strpos($key, ',') === false && $nlz == 1) {
}
@@ -151,13 +349,34 @@ class TimerecordingBillingController extends mfBaseController
if ($timerecording['time']['diet'] > 0 && $nlz == 0) {
$dietsum = round($timerecording['time']['diet'], 2);
$dietsum = str_replace(".", ",", $dietsum);
$bodyarray = [$monthbmd, $companybmd, $employee_number, "2500", "", "", $dietsum, "", "", "", ""];
fputcsv($file, $bodyarray, ";");
if ($export == 1) {
$dietsum = str_replace(".", ",", $dietsum);
$bodyarray = [$monthbmd, $companybmd, $employee_number, "2500", "", "", $dietsum, "", "", "", ""];
fputcsv($file, $bodyarray, ";");
} else {
$reponse[$employee_number]['diet'] = $dietsum;
}
}
if (!empty($timerecording['time']['nlztimes']) && $nlz == 1) {
if (!empty($timerecording['time']['nlztimes']) && ($nlz == 1 || $export == 0)) {
foreach ($timerecording['time']['nlztimes'] as $nlztime) {
if (strtotime($nlztime['start']) < $month) {
$nlztime['start'] = date("d.m.Y", $month);
}
if ((strtotime($nlztime['end']) + 84599) > $monthend) {
$nlztime['end'] = date("d.m.Y", $monthend);
}
if (strpos($nlztime['categoryshort'], '6-') !== false) {
$catExtended = explode("-", $nlztime['categoryshort']);
$catExtended = $catExtended[1];
$nlztime['categoryshort'] = "6";
} else {
$catExtended = "";
}
if ($nlztime['minutes']) {
$timesecounds = $nlztime['minutes'];
$time = $nlztime['minutes'] / 60;
$time = round($time, 2);
$time = str_replace(".", ",", $time);
@@ -168,19 +387,162 @@ class TimerecordingBillingController extends mfBaseController
}
} else {
$time = "";
$pay = "";
if (empty($catExtended)) {
$time = "";
$timesecounds = "";
$pay = "";
} else {
//calc days from $nlztime['start'] to $nlztime['end']
$start = strtotime($nlztime['start']);
$end = strtotime($nlztime['end']);
$time = ($end - $start);
$timesecounds = $time;
$time = $time / 86400 + 1;
$time = round($time, 0);
if ($nlztime['unpaid'] == "0") {
$pay = $time;
} else {
$pay = 0;
}
}
}
if ($export == 1) {
$bodyarray = [$companybmd, $employee_number, 1, $nlztime['categoryshort'], $catExtended, "3", $nlztime['start'], $nlztime['end'], $time, $pay];
fputcsv($file, $bodyarray, ";");
} else {
$reponse[$employee_number]['nlz'][] = array("categoryshort" => $nlztime['categoryshort'], "catExtended" => $catExtended, "start" => $nlztime['start'], "end" => $nlztime['end'], "time" => $time, "pay" => $pay);
}
$bodyarray = [$companybmd, $employee_number, 1, $nlztime['categoryshort'], "", "3", $nlztime['start'], $nlztime['end'], $time, $pay];
fputcsv($file, $bodyarray, ";");
}
if ($export == 0) {
$reponse[$employee_number]['daysum'] = json_encode($timerecording['time']['daysum']);
}
}
}
if ($export == 1) {
fclose($file);
exit;
} else {
return $reponse;
}
die();
}
protected function completemonth($month)
{
$id = $this->saveAction();
$user = new User($timerecordingsEmolyee->user_id);
$employee_number = (string)$user->getFlag('employee_number');
$timerecordings = $this->generateBmdExport($month, 0, 0);
foreach ($timerecordings as $employeenumber => $timerecording) {
$data = [];
$data['timerecordingBilling_id'] = $id;
$data['timerecordingEmployee_id'] = $timerecording['employee_id'];
$data['musthours'] = $timerecording['musttime'];
if ($timerecording['istime']) {
$data['ishours'] = $timerecording['istime'];
} else {
$data['ishours'] = 0;
}
$data['ishourssum'] = $timerecording['istimeall'];
$data['diet'] = $timerecording['diet'];
if ($timerecording['nlz']) {
$data['nlz_detail'] = json_encode($timerecording['nlz']);
}
if ($timerecording['daysum']) {
$data['nlz'] = $timerecording['daysum'];
}
if ($timerecording['homeoffice']) {
$data['homeoffice'] = $timerecording['homeoffice'];
}
if (!$data['diet']) {
$data['diet'] = 0;
}
$timerecordingbillingemployee = TimerecordingBillingEmployeeModel::create($data);
$timerecordingbillingemployee->save();
}
$result['state'] = "success";
echo json_encode($result);
die();
}
protected function saveovertime()
{
$id = $this->request->id;
$type = $this->request->type;
$timerecordingbillingsemployee = new TimerecordingBillingEmployee($id);
if ($type == "overtime") {
$sum = 0;
$data = [];
if ($this->request->overtime50) {
$data['overtime50free'] = $timerecordingbillingsemployee->overtime50free + $this->request->overtime50 * 3600;
$sum += $this->request->overtime50 * 3600;
}
if ($this->request->overtime100) {
$data['overtime100free'] = $timerecordingbillingsemployee->overtime100free + $this->request->overtime100 * 3600;
$sum += $this->request->overtime100 * 3600;
}
if ($this->request->overtimebpa) {
$timerecordingbillingsemployee->timerecordingEmployee->id;
$timerecordingEmployee = new TimerecordingEmployee($timerecordingbillingsemployee->timerecordingEmployee->id);
$dataemployee = [];
$dataemployee['bpahours'] = $timerecordingEmployee->bpahours + $this->request->overtimebpa * 3600;
$sum += $this->request->overtimebpa * 3600;
$timerecordingEmployee->update($dataemployee);
$timerecordingEmployee->save();
}
if ($data) {
$timerecordingbillingsemployee->update($data);
$timerecordingbillingsemployee->save();
$timerecordingbillingsemployee->timerecordingEmployee->id;
$timerecordingEmployee = new TimerecordingEmployee($timerecordingbillingsemployee->timerecordingEmployee->id);
$dataemployee = [];
$dataemployee['overtime_now'] = $timerecordingEmployee->overtime_now - $sum;
$dataemployee['overtime'] = $timerecordingEmployee->overtime - $sum;
$timerecordingEmployee->update($dataemployee);
$timerecordingEmployee->save();
}
} else if ($type == "difference") {
$sum = 0;
$data = [];
if ($this->request->overtime50) {
$data['overtime50free'] = $timerecordingbillingsemployee->overtime50free + $this->request->overtime50 * 3600;
$sum += $this->request->overtime50 * 3600;
}
if ($this->request->overtime100) {
$data['overtime100free'] = $timerecordingbillingsemployee->overtime100free + $this->request->overtime100 * 3600;
$sum += $this->request->overtime100 * 3600;
}
if ($this->request->overtimebpa) {
$timerecordingbillingsemployee->timerecordingEmployee->id;
$timerecordingEmployee = new TimerecordingEmployee($timerecordingbillingsemployee->timerecordingEmployee->id);
$dataemployee = [];
$dataemployee['bpahours'] = $timerecordingEmployee->bpahours + $this->request->overtimebpa * 3600;
$sum += $this->request->overtimebpa * 3600;
$timerecordingEmployee->update($dataemployee);
$timerecordingEmployee->save();
}
if ($sum > 0) {
$data['ishourssum'] = $timerecordingbillingsemployee->ishourssum - $sum;
$timerecordingbillingsemployee->update($data);
$timerecordingbillingsemployee->save();
}
}
$response['state'] = "success";
echo json_encode($response);
die();
}
}

View File

@@ -4,5 +4,125 @@ class TimerecordingBillingModel
{
public static $dieatBase = 26.4;
public static $excludeEmployees = [1000, 1001, 9999, 4, 5, 6, 7, 8, 9, 10];
private $month;
private $closetime;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new TimerecordingBilling();
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("TimerecordingBilling", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingBilling($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingBilling", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingBilling($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingBilling", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingBilling($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("TimerecordingBilling", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingBilling($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("month", $filter)) {
$month = $filter['month'];
if ($month) {
$where .= " AND month=$month";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,61 @@
<?php
class TimerecordingBillingEmployee extends mfBaseModel
{
private $editor;
private $creator;
private $timerecordingBilling;
private $timerecordingEmployee;
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,172 @@
<?php
class TimerecordingBillingEmployeeController 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("TimerecordingBillingEmployee/Index");
$timerecordingbillingemployees = TimerecordingBillingEmployeeModel::getAll();
$this->layout()->set("timerecordingbillingemployees", $timerecordingbillingemployees);
}
protected function addAction()
{
$timerecordingBillingEmployees = TimerecordingBillingEmployeeModel::getAll();
$this->layout()->set("timerecordingBillingEmployees", $timerecordingBillingEmployees);
$timerecordingEmployees = TimerecordingEmployeeModel::getAll();
$this->layout()->set("timerecordingEmployees", $timerecordingEmployees);
$this->layout()->setTemplate("TimerecordingBillingEmployee/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("fdfsdf nicht gefunden", "error");
$this->redirect("TimerecordingBillingEmployee");
}
$timerecordingbillingemployees = new TimerecordingBillingEmployee($id);
if ($timerecordingbillingemployees->id != $id) {
$this->layout()->setFlash("fdfsdf nicht gefunden", "error");
$this->redirect("TimerecordingBillingEmployee");
}
$this->layout()->set("timerecordingbillingemployees", $timerecordingbillingemployees);
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";
$timerecordingbillingemployees = new TimerecordingBillingEmployee($id);
if (!$timerecordingbillingemployees->id) {
$this->layout()->setFlash("dfsdfsdfds nicht gefunden", "error");
$this->redirect("TimerecordingBillingEmployee");
}
} else {
$mode = "add";
}
$data = [];
$data['timerecordingBillingEmployee_id'] = trim($r->timerecordingBillingEmployee_id);
$data['timerecordingEmployee_id'] = trim($r->timerecordingEmployee_id);
$data['type'] = trim($r->type);
$data['ishours'] = trim($r->ishours);
$data['overtime25'] = trim($r->overtime25);
$data['plushours50'] = trim($r->plushours50);
$data['plushours50free'] = trim($r->plushours50free);
$data['plushours100'] = trim($r->plushours100);
$data['plushours100free'] = trim($r->plushours100free);
$data['homeoffice'] = trim($r->homeoffice);
$data['diet'] = trim($r->diet);
$data['nlz'] = trim($r->nlz);
$data['nlz_detail'] = trim($r->nlz_detail);
if (!$data['timerecordingBillingEmployee_id']) {
$data['timerecordingBillingEmployee_id'] = NULL;
}
if (!$data['timerecordingEmployee_id']) {
$data['timerecordingEmployee_id'] = NULL;
}
if (!$data['type']) {
$data['type'] = NULL;
}
if (!$data['ishours']) {
$data['ishours'] = NULL;
}
if (!$data['overtime25']) {
$data['overtime25'] = NULL;
}
if (!$data['plushours50']) {
$data['plushours50'] = NULL;
}
if (!$data['plushours50free']) {
$data['plushours50free'] = NULL;
}
if (!$data['plushours100']) {
$data['plushours100'] = NULL;
}
if (!$data['plushours100free']) {
$data['plushours100free'] = NULL;
}
if (!$data['homeoffice']) {
$data['homeoffice'] = NULL;
}
if ($data['diet'] == NULL) {
$data['diet'] = 0;
}
if (!$data['nlz']) {
$data['nlz'] = NULL;
}
if (!$data['nlz_detail']) {
$data['nlz_detail'] = NULL;
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$timerecordingbillingemployees->update($data);
} else {
$timerecordingbillingemployees = TimerecordingBillingEmployeeModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordingbillingemployees->save();
if (!$id) {
$this->layout()->setFlash("fdfsdf konnte nicht angelegt werden", "error");
$this->redirect("TimerecordingBillingEmployee");
}
if ($mode == "edit") {
$this->layout()->setFlash("fdfsdf erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("fdfsdf erfolgreich angelegt", "success");
}
$this->redirect("TimerecordingBillingEmployee");
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordingbillingemployees = new TimerecordingBillingEmployee($id);
if (!$timerecordingbillingemployees->id || $timerecordingbillingemployees->id != $id) {
$this->layout()->setFlash("fdfsdf nicht gefunden.", "error");
$this->redirect("TimerecordingBillingEmployee");
}
$timerecordingbillingemployees->delete();
$this->redirect("TimerecordingBillingEmployee");
}
}

View File

@@ -0,0 +1,139 @@
<?php
class TimerecordingBillingEmployeeModel
{
private $timerecordingBilling_id;
private $timerecordingEmployee_id;
private $musthours;
private $type;
private $ishours;
private $ishourssum;
private $overtime25;
private $plushours50;
private $plushours50free;
private $plushours100;
private $plushours100free;
private $homeoffice;
private $diet;
private $nlz;
private $nlz_detail;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new TimerecordingBillingEmployee();
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("TimerecordingBillingEmployee", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingBillingEmployee($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingBillingEmployee", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingBillingEmployee($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingBillingEmployee", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingBillingEmployee($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("TimerecordingBillingEmployee", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingBillingEmployee($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("timerecordingBilling_id", $filter)) {
$timerecordingBilling_id = $filter['timerecordingBilling_id'];
if (is_numeric($timerecordingBilling_id)) {
$where .= " AND timerecordingBilling_id='$timerecordingBilling_id'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -2,6 +2,7 @@
class TimerecordingCar extends mfBaseModel
{
private $user;
private $editor;
private $creator;

View File

@@ -38,7 +38,8 @@ class TimerecordingCarController extends mfBaseController
protected function addAction()
{
$timerecordingusers = UserModel::search(['employee' => 'true']);
$this->layout()->set("timerecordingusers", $timerecordingusers);
$this->layout()->setTemplate("TimerecordingCar/Form");
}
@@ -58,6 +59,7 @@ class TimerecordingCarController extends mfBaseController
$this->redirect("TimerecordingCar");
}
$this->layout()->set("timerecordingcars", $timerecordingcars);
return $this->addAction();
}
@@ -80,6 +82,7 @@ class TimerecordingCarController extends mfBaseController
$data = [];
$data['number_plate'] = trim($r->number_plate);
$data['user_id'] = trim($r->user_id);
$data['brand'] = trim($r->brand);
$data['model'] = trim($r->model);
$data['mileage'] = trim($r->mileage);
@@ -88,6 +91,9 @@ class TimerecordingCarController extends mfBaseController
$data['first_approval'] = trim($r->first_approval);
if (!$data['user_id']) {
$data['user_id'] = null;
}
if (!$data['initial_approval']) {
$data['initial_approval'] = null;
}

View File

@@ -2,6 +2,7 @@
class TimerecordingCarModel
{
private $user_id;
private $number_plate;
private $brand;
private $model;

View File

@@ -0,0 +1,35 @@
<?php
use Phinx\Migration\AbstractMigration;
final class TimerecordingBilling extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table("TimerecordingBilling", ["signed" => true]);
$table->addColumn("month", "string", ["null" => false]);
$table->addColumn("closetime", "integer", ["null" => false]);
$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("TimerecordingBilling")->drop()->save();
}
if ($this->getEnvironment() == "addressdb") {
}
}
}
?>

View File

@@ -0,0 +1,48 @@
<?php
use Phinx\Migration\AbstractMigration;
final class TimerecordingBillingEmployee extends AbstractMigration
{
public function up(): void
{
if ($this->getEnvironment() == "thetool") {
$table = $this->table("TimerecordingBillingEmployee", ["signed" => true]);
$table->addColumn("timerecordingBilling_id", "integer", ["null" => false]);
$table->addColumn("timerecordingEmployee_id", "integer", ["null" => false]);
$table->addColumn("musthours", "integer", ["null" => false]);
$table->addColumn("ishours", "integer", ["null" => false]);
$table->addColumn("ishourssum", "integer", ["null" => false]);
$table->addColumn("plushours25", "integer", ["null" => false, "default" => "0"]);
$table->addColumn("overtime50", "integer", ["null" => false, "default" => "0"]);
$table->addColumn("overtime50free", "integer", ["null" => false, "default" => "0"]);
$table->addColumn("overtime100", "integer", ["null" => false, "default" => "0"]);
$table->addColumn("overtime100free", "integer", ["null" => false, "default" => "0"]);
$table->addColumn("homeoffice", "integer", ["null" => false, "default" => "0"]);
$table->addColumn("diet", "decimal", ["null" => false, "default" => "0", "precision" => 10, "scale" => 2]);
$table->addColumn("nlz", "text", ["null" => true]);
$table->addColumn("nlz_detail", "text", ["null" => true]);
$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("TimerecordingBillingEmployee")->drop()->save();
}
if ($this->getEnvironment() == "addressdb") {
}
}
}
?>

View File

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