Zeiterfassung Anpassungen
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||||
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
|
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= MFAPPFILE_VERSION ?>" rel="stylesheet"
|
||||||
type="text/css"/>
|
type="text/css"/>
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||||
<link href="<?=self::getResourcePath()?>assets/css/select2-cstm.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
|
<link href="<?=self::getResourcePath()?>assets/css/select2-cstm.css?<?= MFAPPFILE_VERSION ?>" rel="stylesheet" type="text/css" />
|
||||||
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet" type="text/css"/>
|
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= MFAPPFILE_VERSION ?>" rel="stylesheet" type="text/css"/>
|
||||||
<?php
|
<?php
|
||||||
foreach ($devicetypes as $devicetype) {
|
foreach ($devicetypes as $devicetype) {
|
||||||
$deviceTypes[$devicetype->id] = $devicetype->devicemanufactor->name . " " . $devicetype->name;
|
$deviceTypes[$devicetype->id] = $devicetype->devicemanufactor->name . " " . $devicetype->name;
|
||||||
|
|||||||
@@ -1,5 +1,35 @@
|
|||||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
|
||||||
$daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
$daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
||||||
|
$monthger[1] = "Jänner";
|
||||||
|
$monthger[2] = "Februar";
|
||||||
|
$monthger[3] = "März";
|
||||||
|
$monthger[4] = "April";
|
||||||
|
$monthger[5] = "Mai";
|
||||||
|
$monthger[6] = "Juni";
|
||||||
|
$monthger[7] = "Juli";
|
||||||
|
$monthger[8] = "August";
|
||||||
|
$monthger[9] = "September";
|
||||||
|
$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);
|
||||||
|
$timestamp_montag = strtotime("{$year}-W{$kw}");
|
||||||
|
$timestamp_freitag = strtotime("{$year}-W{$kw}-5");
|
||||||
|
|
||||||
|
$weeks[$time] = "KW" . $kw . " " . $year . " (" . date('d.m', $timestamp_montag) . "-" . date('d.m', $timestamp_freitag) . ")";
|
||||||
|
$time = $time - 604800;
|
||||||
|
}
|
||||||
|
$time = time();
|
||||||
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
|
$mon = date('n', $time);
|
||||||
|
$year = date('Y', $time);
|
||||||
|
$month[$time] = $monthger[$mon] . " " . $year;
|
||||||
|
$time = strtotime('-1 month', $time);
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
|
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
|
||||||
type="text/css"/>
|
type="text/css"/>
|
||||||
@@ -31,10 +61,21 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
|||||||
|
|
||||||
.edit-placeholder {
|
.edit-placeholder {
|
||||||
height: 15px;
|
height: 15px;
|
||||||
width: 19px;
|
width: 27px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fa-trash {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-bold {
|
||||||
|
font-weight: 500;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.text-normal {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<!-- start page title -->
|
<!-- start page title -->
|
||||||
@@ -64,12 +105,16 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
|||||||
|
|
||||||
<select id="timerecordingCategory_id" name="timerecordingCategory_id"
|
<select id="timerecordingCategory_id" name="timerecordingCategory_id"
|
||||||
class="select2 form-control" required="required">
|
class="select2 form-control" required="required">
|
||||||
<?php foreach ($timerecordingCategoriess as $timerecordingCategories): ?>
|
<?php foreach ($timerecordingCategoriess as $timerecordingCategories):
|
||||||
|
if ($timerecordingCategories->only_admin == 0) :
|
||||||
|
?>
|
||||||
<option value="<?= $timerecordingCategories->id ?>"
|
<option value="<?= $timerecordingCategories->id ?>"
|
||||||
data-approval="<?= $timerecordingCategories->approval ?>"
|
data-approval="<?= $timerecordingCategories->approval ?>"
|
||||||
data-comment="<?= $timerecordingCategories->require_comment ?>"
|
data-comment="<?= $timerecordingCategories->require_comment ?>"
|
||||||
data-hourday="<?= $timerecordingCategories->hourday ?>"><?= $timerecordingCategories->name ?></option>
|
data-hourday="<?= $timerecordingCategories->hourday ?>"><?= $timerecordingCategories->name ?></option>
|
||||||
<?php endforeach; ?>
|
<?php
|
||||||
|
endif;
|
||||||
|
endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -126,6 +171,11 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class=" row mt-2">
|
||||||
|
<div class="col-lg-4" id="message-box">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -133,14 +183,58 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
|||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body mb-3">
|
<div class="card-body mb-3">
|
||||||
<div class="row">
|
<div class="form-group module-row row mb-3">
|
||||||
<div class="col-12">
|
<div class="col-6 col-lg-1">
|
||||||
<div class="float-left">
|
<label class="col-form-label label-calendar" for="lenght">Buchungszeitraum:</label>
|
||||||
<h4 class="header-title">Liste aller Buchungen</h4>
|
</div>
|
||||||
|
<div class="col-6 col-lg-1 text-center">
|
||||||
|
<i class="fa-regular fa-calendar-week display-calendar active-calendar" title="Kalenderwoche"
|
||||||
|
data-datatype="1"></i> <i class="fa-regular fa-calendar-days display-calendar"
|
||||||
|
title="Kalendermonat" data-datatype="2"></i>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col" id="dataweek-col">
|
||||||
|
<div class="input-group">
|
||||||
|
<select id="dataweek" class="form-control select2">
|
||||||
|
<?php foreach ($weeks as $key => $week): ?>
|
||||||
|
<option value="<?= $key ?>"><?= $week ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col" id="datamonth-col" style="display:none">
|
||||||
|
<div class="input-group">
|
||||||
|
<select id="datamonth" class="form-control select2">
|
||||||
|
<?php foreach ($month as $key => $Month): ?>
|
||||||
|
<option value="<?= $key ?>"><?= $Month ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="col text-center">
|
||||||
|
<div class="input-group ">
|
||||||
|
<label class="col-form-label form-control"><span
|
||||||
|
class="text-bold">Sollzeit: </span><span id="must-time"
|
||||||
|
class="ml-1 text-normal"></span></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col text-center">
|
||||||
|
<div class="input-group ">
|
||||||
|
<label class="col-form-label form-control"><span class="text-bold">Istzeit: </span><span
|
||||||
|
id="is-time"
|
||||||
|
class="ml-1 text-normal"></span></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<table id="datatable" class="table table-hover table-sm">
|
<table id="datatable" class="table table-hover table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -163,72 +257,6 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
|
||||||
foreach ($timerecordings as $timerecording):
|
|
||||||
$state = "";
|
|
||||||
$enddate = "";
|
|
||||||
$sum = "-";
|
|
||||||
$day = "";
|
|
||||||
$orderdate = $timerecording->start;
|
|
||||||
if ($timerecording->timerecordingCategory->hourday == 1) {
|
|
||||||
$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)];
|
|
||||||
} else if ($timerecording->timerecordingCategory->hourday == 2) {
|
|
||||||
$date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end);
|
|
||||||
$datadate = date("Y-m-d", $timerecording->start);
|
|
||||||
$enddate = date("Y-m-d", $timerecording->end);
|
|
||||||
$start = "-";
|
|
||||||
$end = "-";
|
|
||||||
$day=$daysgerm[date("w", $timerecording->start)];
|
|
||||||
} else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) {
|
|
||||||
$date = date("d.m.Y", $timerecording->start);
|
|
||||||
$datadate = date("Y-m-d", $timerecording->start);
|
|
||||||
$start = "-";
|
|
||||||
$end = "-";
|
|
||||||
$day = $daysgerm[date("w", $timerecording->start)];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
|
||||||
$state = '<i class="fa-regular fa-clock mr-1"></i>';
|
|
||||||
} else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) {
|
|
||||||
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr class="">
|
|
||||||
<td data-order="<?= $orderdate ?>" class="text-nowrap "><?= $state ?><?= $day . " " . $date ?></td>
|
|
||||||
<td class="text-nowrap text-center"><?= $start ?></td>
|
|
||||||
<td class="text-nowrap text-center"><?= $end ?></td>
|
|
||||||
<td class="text-nowrap text-center"><?= $sum ?></td>
|
|
||||||
<td class="text-nowrap"><?= $timerecording->timerecordingCategory->name ?></td>
|
|
||||||
<td><?= $timerecording->commend ?></td>
|
|
||||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
|
||||||
<?php if ($timerecording->completed == 0):
|
|
||||||
if ($timerecording->approved == 0) : ?>
|
|
||||||
<i class="far fa-edit edit-button" data-id="<?= $timerecording->id ?>"
|
|
||||||
data-date="<?= $datadate ?>"
|
|
||||||
data-category="<?= $timerecording->timerecordingCategory->id ?>"
|
|
||||||
data-start="<?= $start ?>"
|
|
||||||
data-end="<?= $end ?>"
|
|
||||||
data-enddate="<?= $enddate ?>"
|
|
||||||
data-commend="<?= $timerecording->commend ?>"
|
|
||||||
title="Bearbeiten"></i>
|
|
||||||
<?php else : ?>
|
|
||||||
<div class="edit-placeholder"></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<a href="<?= self::getUrl("Timerecording", "delete", ["id" => $timerecording->id]) ?>"
|
|
||||||
onclick="if(!confirm('Buchung wirklich löschen?')) return false;" class="text-danger"
|
|
||||||
title="Löschen"><i class="fas fa-trash"></i></a>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -241,96 +269,14 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var hidesearch = [1, 2, 3, 6];
|
var hidesearch = [1, 2, 3, 6];
|
||||||
|
let insertUrl = "<?= self::getUrl("Timerecording", "save") ?>";
|
||||||
|
let deleteUrl = "<?= self::getUrl("Timerecording", "delete") ?>";
|
||||||
|
let requestUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'getTimerecordings']) ?>";
|
||||||
|
|
||||||
$(document).ready(function () {
|
|
||||||
$(".select2").select2();
|
|
||||||
|
|
||||||
$("body").on("change", "#timerecordingCategory_id", function () {
|
|
||||||
if (parseInt($(this).find(':selected').data('hourday')) === 2) {
|
|
||||||
$("#endtime-div").hide();
|
|
||||||
$("#endtime-div").find('input').each(function () {
|
|
||||||
$(this).prop("required", false);
|
|
||||||
});
|
|
||||||
$("#enddate-div").show();
|
|
||||||
$("#enddate-div").find('input').each(function () {
|
|
||||||
$(this).prop("required", true);
|
|
||||||
$(this).prop("min", $('#date').val());
|
|
||||||
$(this).val($('#date').val());
|
|
||||||
})
|
|
||||||
} else if (parseInt($(this).find(':selected').data('hourday')) === 1) {
|
|
||||||
$("#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('');
|
|
||||||
})
|
|
||||||
} else if (parseInt($(this).find(':selected').data('hourday')) === 3 || parseInt($(this).find(':selected').data('hourday')) === 4) {
|
|
||||||
$("#endtime-div").hide();
|
|
||||||
$("#endtime-div").find('input').each(function () {
|
|
||||||
$(this).prop("required", false);
|
|
||||||
$(this).prop("disabled", true);
|
|
||||||
|
|
||||||
});
|
|
||||||
$("#enddate-div").hide();
|
|
||||||
$("#enddate-div").find('input').each(function () {
|
|
||||||
$(this).prop("required", false);
|
|
||||||
$(this).prop("min", '');
|
|
||||||
$(this).val('');
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (parseInt($(this).find(':selected').data('comment')) === 1) {
|
|
||||||
$('#commend').prop("required", true);
|
|
||||||
} else {
|
|
||||||
$('#commend').prop("required", false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$("body").on("change", "#date", function () {
|
|
||||||
if ($('#enddate-div').css('display') === "block") {
|
|
||||||
if ($('#date').val() > $('#enddate').val()) {
|
|
||||||
$('#enddate').prop("min", $('#date').val());
|
|
||||||
$('#enddate').val($('#date').val());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$("body").on("change", "#date", function () {
|
|
||||||
if ($('#endtime').css('display') === "block") {
|
|
||||||
if ($('#start').val() > $('#end').val()) {
|
|
||||||
console.log('größer');
|
|
||||||
$('#end').prop("min", $('#start').val());
|
|
||||||
$('#end').val($('#start').val());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("body").on("click", ".edit-button", function () {
|
|
||||||
$('#submit-button').hide().removeClass('btn-primary').addClass('btn-danger').show();
|
|
||||||
$('#submit-button').text('Ändern');
|
|
||||||
$('#cancel-button').show();
|
|
||||||
$('#timerecordingCategory_id').val($(this).data('category')).change();
|
|
||||||
$('#id').val($(this).data('id'));
|
|
||||||
$('#date').val($(this).data('date'));
|
|
||||||
$('#start').val($(this).data('start'));
|
|
||||||
$('#end').val($(this).data('end'));
|
|
||||||
$('#enddate').val($(this).data('enddate'));
|
|
||||||
$('#commend').val($(this).data('commend'));
|
|
||||||
$('.alert-success').remove();
|
|
||||||
window.scrollTo(0, 0);
|
|
||||||
});
|
|
||||||
$("body").on("click", "#cancel-button", function () {
|
|
||||||
$('#submit-button').hide().removeClass('btn-danger').addClass('btn-primary').show();
|
|
||||||
$('#submit-button').text('Speichern');
|
|
||||||
$('#cancel-button').hide();
|
|
||||||
$('#id').val('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
src="<?= self::getResourcePath() ?>assets/js/datatables-std.js?<?= date('U') ?>"></script>
|
src="<?= self::getResourcePath() ?>js/pages/timerecording/index.js?<?= date('U') ?>"></script>
|
||||||
|
|
||||||
|
|
||||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="approval">Genehmigungspflichtig</label>
|
<label class="col-lg-2 col-form-label" for="approval">Genehmigungspflichtig</label>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" <?php if ($timerecordingcategoriess->approval) echo 'checked="checked"'; ?>
|
<input id="approval" class="form-check-input" <?php if ($timerecordingcategoriess->approval) echo 'checked="checked"'; ?>
|
||||||
type="checkbox" name="approval" value="1" id="olt">
|
type="checkbox" name="approval" value="1" id="olt">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
Pflichtfeld</label>
|
Pflichtfeld</label>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" <?php if ($timerecordingcategoriess->require_comment) echo 'checked="checked"'; ?>
|
<input id="require_comment" class="form-check-input" <?php if ($timerecordingcategoriess->require_comment) echo 'checked="checked"'; ?>
|
||||||
type="checkbox" name="require_comment" value="1">
|
type="checkbox" name="require_comment" value="1">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="only_admin">Nur für Buchhaltung zu buchen</label>
|
<label class="col-lg-2 col-form-label" for="only_admin">Nur für Buchhaltung zu buchen</label>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" <?php if ($timerecordingcategoriess->only_admin) echo 'checked="checked"'; ?>
|
<input id="only_admin" class="form-check-input" <?php if ($timerecordingcategoriess->only_admin) echo 'checked="checked"'; ?>
|
||||||
type="checkbox" name="only_admin" value="1">
|
type="checkbox" name="only_admin" value="1">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
219
Layout/default/TimerecordingEmployee/Form.php
Normal file
219
Layout/default/TimerecordingEmployee/Form.php
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
|
||||||
|
$daysSelect = '<select required="required" name="day[]" class="select2 form-control" readonly="readonly" >';
|
||||||
|
foreach ($days as $key => $day) {
|
||||||
|
$daysSelect .= '<option value="' . $key . '">' . $day . '</option>';
|
||||||
|
}
|
||||||
|
$daysSelect .= "</select>";
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
var daysselect = `<?= $daysSelect ?>`;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
|
||||||
|
type="text/css"/>
|
||||||
|
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
|
||||||
|
type="text/css"/>
|
||||||
|
<style>
|
||||||
|
.fa-circle-plus {
|
||||||
|
color: #00b125;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 17px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remove-workinghours {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #ff0606;
|
||||||
|
font-size: 17px;
|
||||||
|
float: right;
|
||||||
|
margin-left: 7px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
</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("TimerecordingEmployee") ?>">Personaladministration</a></li>
|
||||||
|
<li class="breadcrumb-item active"><?= ($timerecordingemployees->id) ? "bearbeiten" : "Neu" ?></li>
|
||||||
|
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<h4 class="page-title"><?= ($timerecordingemployees->id) ? "Personaladministration" : "Personaladministration" ?></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"><?= ($timerecordingemployees->id) ? "Personaladministration" : "Personaladministration" ?></h4>
|
||||||
|
|
||||||
|
<form class="form-horizontal" method="post"
|
||||||
|
action="<?= self::getUrl("TimerecordingEmployee", "save") ?>">
|
||||||
|
<div class="card no-shadow">
|
||||||
|
<div class="card-body">
|
||||||
|
<input type="hidden" name="id" value="<?= $timerecordingemployees->id ?>"/>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label" for="user_id">Mitarbeiter *</label>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<select required="required" id="user_id" name="user_id"
|
||||||
|
class="select2 form-control">
|
||||||
|
<option value="<?= $timerecordinguser[0]->id ?>"><?= $timerecordinguser[0]->name ?></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label" for="holidays">Initiale Urlaubstage</label>
|
||||||
|
<div class="col-lg-1">
|
||||||
|
<input required="required" type="number" id="holidays" name="holidays"
|
||||||
|
class="form-control"
|
||||||
|
value="<?= $timerecordingemployees->holidays ?>"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label" for="plushours">Initiale Gutstunden</label>
|
||||||
|
<div class="col-lg-1">
|
||||||
|
<input required="required" type="text" id="plushours" name="plushours"
|
||||||
|
class="form-control"
|
||||||
|
value="<?= str_replace(".", ",", $timerecordingemployees->plushours / 3600) ?>"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label"
|
||||||
|
for="auto_workinghours">Schnellbuchung</label>
|
||||||
|
<div class="col-lg-3">
|
||||||
|
<div class="form-check">
|
||||||
|
<input id="auto_workinghours"
|
||||||
|
class="form-check-input" <?php if ($timerecordingemployees->auto_workinghours) echo 'checked="checked"'; ?>
|
||||||
|
type="checkbox" name="auto_workinghours" value="1"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="workinghours_div">
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-lg-2 col-form-label" for="workinghours">Sollzeiten
|
||||||
|
Arbeitswoche <i
|
||||||
|
class="fa-regular fa-circle-plus add-workinghours"></i></label>
|
||||||
|
<div class="col-lg-2 text-center">
|
||||||
|
<label class="col-form-label" for="workinghours"><span
|
||||||
|
id="workinghours-text">0 Stunden 0 Minuten</span></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ($timerecordingworkinghours):
|
||||||
|
|
||||||
|
foreach ($timerecordingworkinghours as $timerecordingworkinghour): ?>
|
||||||
|
<div class="form-group row wtime">
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<i class="fa-regular fa-circle-minus remove-workinghours"></i>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-2">
|
||||||
|
<select required="required" name="day[]"
|
||||||
|
class="select2 form-control"
|
||||||
|
readonly="readonly">
|
||||||
|
<?php foreach ($days as $key => $day) : ?>
|
||||||
|
<option value="<?= $key ?>" <?= ($key == $timerecordingworkinghour->day) ? "selected='selected'" : "" ?>><?= $day ?></option>';
|
||||||
|
<?php endforeach;
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-1">
|
||||||
|
<input type="time" name="timestart[]" class="form-control timestart"
|
||||||
|
value="<?= $timerecordingworkinghour->start ?>"
|
||||||
|
required="required"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-1">
|
||||||
|
<input required="required" type="time" name="timeend[]"
|
||||||
|
class="form-control timeend"
|
||||||
|
value="<?= $timerecordingworkinghour->end ?>"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
endforeach;
|
||||||
|
endif
|
||||||
|
?>
|
||||||
|
|
||||||
|
</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="<?= self::getUrl("TimerecordingEmployee") ?>">
|
||||||
|
<button type="button" class="btn btn-secondary">Abbrechen</button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
function checktime() {
|
||||||
|
var sum = 0;
|
||||||
|
$(".wtime").each(function (index) {
|
||||||
|
console.log($(this).find('.timeend').val());
|
||||||
|
var newdatestart = new Date('2020/01/01 ' + $(this).find('.timestart').val() + ':00');
|
||||||
|
var newdateend = new Date('2020/01/01 ' + $(this).find('.timeend').val() + ':00');
|
||||||
|
var differenz = (newdateend - newdatestart) / 1000;
|
||||||
|
|
||||||
|
|
||||||
|
sum = sum + differenz;
|
||||||
|
});
|
||||||
|
var timenew = Math.floor(sum / 3600) + ' Stunden ' + Math.floor((sum % 3600) / 60) + ' Minuten';
|
||||||
|
|
||||||
|
$('#workinghours-text').text(timenew);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$(".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')
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$("#workinghours_div").on("change", "input", function () {
|
||||||
|
checktime();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$("body").on("click", ".remove-workinghours", function () {
|
||||||
|
$(this).closest('.form-group').remove();
|
||||||
|
checktime();
|
||||||
|
|
||||||
|
});
|
||||||
|
$("body").on("click", ".add-workinghours", function () {
|
||||||
|
$('#workinghours_div').append(`<div class="form-group row wtime"><div class="col-lg-2"><i class="fa-regular fa-circle-minus remove-workinghours"></i></div><div class="col-lg-2">` +
|
||||||
|
daysselect + `</div><div class="col-lg-1"><input type="time" name="timestart[]" class="form-control timestart"
|
||||||
|
value="07:00" required="required" /></div><div class="col-lg-1"><input required="required" type="time" name="timeend[]" class="form-control timeend"
|
||||||
|
value="15:00" /></div>`);
|
||||||
|
checktime();
|
||||||
|
$(".select2").select2({placeholder: ""});
|
||||||
|
})
|
||||||
|
$(document).ready(function () {
|
||||||
|
checktime();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>
|
||||||
94
Layout/default/TimerecordingEmployee/Index.php
Normal file
94
Layout/default/TimerecordingEmployee/Index.php
Normal file
@@ -0,0 +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">Personaladministration</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<h4 class="page-title">Personaladministration</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 Personaladministration</h4>
|
||||||
|
</div>
|
||||||
|
<div class="float-right">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<table id="datatable" class="table table-striped table-hover table-sm">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center">Mitarbeiter</th>
|
||||||
|
<th class="text-center">Sollzeiten</th>
|
||||||
|
<th class="text-center">Sollstunden</th>
|
||||||
|
<th class="text-center edit-width">Schnellbuchung</th>
|
||||||
|
<th class="edit-width"></th>
|
||||||
|
</tr>
|
||||||
|
<tr id="filterrow">
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($timerecordingusers as $timerecordinguser):
|
||||||
|
if ($timerecordingworkinghours) {
|
||||||
|
$seconds = $timerecordingworkinghours[$timerecordinguser->id]['secondcounter'];
|
||||||
|
$minutes = floor(($seconds % 3600) / 60);
|
||||||
|
$hours = floor($seconds / 3600);
|
||||||
|
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
|
||||||
|
} else {
|
||||||
|
$sum = "";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><?= $timerecordinguser->name ?></td>
|
||||||
|
<td class="text-center"><?= ($timerecordingworkinghours) ? $timerecordingworkinghours[$timerecordinguser->id]['datetimetext'] : "" ?></td>
|
||||||
|
<td class="text-center"><?= $sum ?></td>
|
||||||
|
<td class="text-center"><?= ($timerecordingemployees[$timerecordinguser->id]['auto_workinghours'] == '1') ? 'Ja' : 'Nein' ?></td>
|
||||||
|
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||||
|
<a href="<?= self::getUrl("TimerecordingEmployee", "edit", ['id'=> $timerecordingemployees[$timerecordinguser->id]['id'],"userid" => $timerecordinguser->id]) ?>"><i
|
||||||
|
class="far fa-edit" title="Bearbeiten"></i></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var hidesearch = [4];
|
||||||
|
|
||||||
|
$(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"); ?>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<label class="col-lg-2 col-form-label" for="timestamp">Datum *</label>
|
<label class="col-lg-2 col-form-label" for="timestamp">Datum *</label>
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<input required="required" type="date" id="timestamp" name="timestamp" class="form-control"
|
<input required="required" type="date" id="timestamp" name="timestamp" class="form-control"
|
||||||
value="<?= date("Y-m-d",$timerecordingholidays->timestamp) ?>"/>
|
value="<?= ($timerecordingholidays->timestamp) ? date("Y-m-d",$timerecordingholidays->timestamp) : date("Y-m-d",time()) ?>"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|||||||
60
application/LoggingCommunication/LoggingCommunication.php
Normal file
60
application/LoggingCommunication/LoggingCommunication.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class LoggingCommunication extends mfBaseModel
|
||||||
|
{
|
||||||
|
private $user;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class LoggingCommunicationController 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("LoggingCommunication/Index");
|
||||||
|
$loggingcommunications = LoggingCommunicationModel::getAll();
|
||||||
|
$this->layout()->set("loggingcommunications", $loggingcommunications);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addAction()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->layout()->setTemplate("LoggingCommunication/Form");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function editAction()
|
||||||
|
{
|
||||||
|
$id = $this->request->id;
|
||||||
|
|
||||||
|
if (!is_numeric($id) || !$id) {
|
||||||
|
$this->layout()->setFlash("Logging nicht gefunden", "error");
|
||||||
|
$this->redirect("LoggingCommunication");
|
||||||
|
}
|
||||||
|
|
||||||
|
$loggingcommunications = new LoggingCommunication($id);
|
||||||
|
if ($loggingcommunications->id != $id) {
|
||||||
|
$this->layout()->setFlash("Logging nicht gefunden", "error");
|
||||||
|
$this->redirect("LoggingCommunication");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->layout()->set("loggingcommunications", $loggingcommunications);
|
||||||
|
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";
|
||||||
|
$loggingcommunications = new LoggingCommunication($id);
|
||||||
|
if (!$loggingcommunications->id) {
|
||||||
|
$this->layout()->setFlash("Logging nicht gefunden", "error");
|
||||||
|
$this->redirect("LoggingCommunication");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$mode = "add";
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data['type'] = trim($r->type);
|
||||||
|
$data['message'] = trim($r->message);
|
||||||
|
$data['response'] = trim($r->response);
|
||||||
|
|
||||||
|
|
||||||
|
if (!$data['type']) {
|
||||||
|
$data['type']=NULL;
|
||||||
|
}
|
||||||
|
if (!$data['message']) {
|
||||||
|
$data['message']=NULL;
|
||||||
|
}
|
||||||
|
if (!$data['response']) {
|
||||||
|
$data['response']=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// var_dump($_FILES);
|
||||||
|
// var_dump($upload);
|
||||||
|
// exit;
|
||||||
|
|
||||||
|
|
||||||
|
if ($mode == "edit") {
|
||||||
|
$loggingcommunications->update($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$loggingcommunications = LoggingCommunicationModel::create($data);
|
||||||
|
}
|
||||||
|
// var_dump($filestore);
|
||||||
|
// exit;
|
||||||
|
$id = $loggingcommunications->save();
|
||||||
|
|
||||||
|
if (!$id) {
|
||||||
|
$this->layout()->setFlash("Logging konnte nicht angelegt werden", "error");
|
||||||
|
$this->redirect("LoggingCommunication");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mode == "edit") {
|
||||||
|
$this->layout()->setFlash("Logging erfolgreich geändert", "success");
|
||||||
|
} else if ($mode = "add") {
|
||||||
|
$this->layout()->setFlash("Logging erfolgreich angelegt", "success");
|
||||||
|
}
|
||||||
|
$this->redirect("LoggingCommunication");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function deleteAction()
|
||||||
|
{
|
||||||
|
$id = $this->request->id;
|
||||||
|
$loggingcommunications = new LoggingCommunication($id);
|
||||||
|
if (!$loggingcommunications->id || $loggingcommunications->id != $id) {
|
||||||
|
$this->layout()->setFlash("Logging nicht gefunden.", "error");
|
||||||
|
$this->redirect("LoggingCommunication");
|
||||||
|
}
|
||||||
|
|
||||||
|
$loggingcommunications->delete();
|
||||||
|
$this->redirect("LoggingCommunication");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
130
application/LoggingCommunication/LoggingCommunicationModel.php
Normal file
130
application/LoggingCommunication/LoggingCommunicationModel.php
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class LoggingCommunicationModel
|
||||||
|
{
|
||||||
|
private $type;
|
||||||
|
private $recipient;
|
||||||
|
private $message;
|
||||||
|
private $response;
|
||||||
|
private $create_by;
|
||||||
|
private $edit_by;
|
||||||
|
|
||||||
|
|
||||||
|
public static function find($data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create(array $data)
|
||||||
|
{
|
||||||
|
$model = new LoggingCommunication();
|
||||||
|
|
||||||
|
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("LoggingCommunication", "*", "id=$id LIMIT 1");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new LoggingCommunication($data);
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAll()
|
||||||
|
{
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$res = $db->select("LoggingCommunication", "*", "1=1");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new LoggingCommunication($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFirst()
|
||||||
|
{
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$res = $db->select("LoggingCommunication", "*", "$where ");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new LoggingCommunication($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("LoggingCommunication", "*", "$where");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new LoggingCommunication($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getSqlFilter($filter)
|
||||||
|
{
|
||||||
|
$where = "1=1 ";
|
||||||
|
|
||||||
|
//var_dump($filter);exit;
|
||||||
|
if (array_key_exists("network_id", $filter)) {
|
||||||
|
$networkid = $filter['network_id'];
|
||||||
|
if (is_numeric($networkid)) {
|
||||||
|
$where .= " AND network_id=$networkid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($filter, $where);exit;
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,13 +18,38 @@ class TimerecordingController extends mfBaseController
|
|||||||
|
|
||||||
protected function indexAction()
|
protected function indexAction()
|
||||||
{
|
{
|
||||||
$this->layout()->setTemplate("Timerecording/Index");
|
|
||||||
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
|
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
|
||||||
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
|
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
|
||||||
$timerecordings = TimerecordingModel::search(['user_id' => $this->me->id]);
|
$this->layout()->setTemplate("Timerecording/Index");
|
||||||
$this->layout()->set("timerecordings", $timerecordings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function apiAction()
|
||||||
|
{
|
||||||
|
$do = $this->request->do;
|
||||||
|
$datatype = $this->request->datatype;
|
||||||
|
$dataweek = $this->request->dataweek;
|
||||||
|
$datamonth = $this->request->datamonth;
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
switch ($do) {
|
||||||
|
case "getTimerecordings":
|
||||||
|
$return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$return = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_array($return) || !count($return)) {
|
||||||
|
$data = ["status" => "error"];
|
||||||
|
$this->returnJson($data);
|
||||||
|
}
|
||||||
|
$data['status'] = "OK";
|
||||||
|
$data['result'] = $return;
|
||||||
|
$this->returnJson($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function addAction()
|
protected function addAction()
|
||||||
{
|
{
|
||||||
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
|
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
|
||||||
@@ -52,6 +77,22 @@ class TimerecordingController extends mfBaseController
|
|||||||
return $this->addAction();
|
return $this->addAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function checkTimerecording($starttime, $endtime, $id = NULL)
|
||||||
|
{
|
||||||
|
$searchArray = ['user_id' => $this->me->id, 'starttime' => $starttime, 'endtime' => $endtime];
|
||||||
|
if ($id) {
|
||||||
|
$searchArray['id'] = $id;
|
||||||
|
}
|
||||||
|
$timerecordings = TimerecordingModel::search($searchArray);
|
||||||
|
if ($timerecordings) {
|
||||||
|
$result['state'] = "error";
|
||||||
|
$result['error'] = "Zeitüberschneidung mit anderer Buchung";
|
||||||
|
} else {
|
||||||
|
$result['state'] = "success";
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
protected function saveAction()
|
protected function saveAction()
|
||||||
{
|
{
|
||||||
$r = $this->request;
|
$r = $this->request;
|
||||||
@@ -68,6 +109,17 @@ class TimerecordingController extends mfBaseController
|
|||||||
$endtime = NULL;
|
$endtime = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result = $this->checkTimerecording($starttime, $endtime, $id);
|
||||||
|
if ($result['state'] == "error") {
|
||||||
|
if ($r->ajax == 1) {
|
||||||
|
echo json_encode($result);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$this->layout()->setFlash($result['error'], "error");
|
||||||
|
$this->redirect("Timerecording");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (is_numeric($id) && $id > 0) {
|
if (is_numeric($id) && $id > 0) {
|
||||||
$mode = "edit";
|
$mode = "edit";
|
||||||
$timerecordings = new Timerecording($id);
|
$timerecordings = new Timerecording($id);
|
||||||
@@ -110,25 +162,204 @@ class TimerecordingController extends mfBaseController
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
$timerecordings = TimerecordingModel::create($data);
|
$timerecordings = TimerecordingModel::create($data);
|
||||||
|
|
||||||
}
|
}
|
||||||
// var_dump($filestore);
|
// var_dump($filestore);
|
||||||
// exit;
|
// exit;
|
||||||
$id = $timerecordings->save();
|
$id = $timerecordings->save();
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->layout()->setFlash("Buchung konnte nicht angelegt werden", "error");
|
$message = "Buchung konnte nicht angelegt werden";
|
||||||
|
if ($r->ajax == 1) {
|
||||||
|
$result['state'] = "error";
|
||||||
|
$result['error'] = $message;
|
||||||
|
echo json_encode($result);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$this->layout()->setFlash($message, "error");
|
||||||
$this->redirect("Timerecording");
|
$this->redirect("Timerecording");
|
||||||
|
|
||||||
|
}
|
||||||
|
if ($id) {
|
||||||
|
$timerecordingCategoriess = TimerecordingCategoryModel::search(['id' => $data['timerecordingCategory_id']]);
|
||||||
|
if ($timerecordingCategoriess[0]->approval == "1") {
|
||||||
|
$body = 'Beantrag von: ' . $this->me->name . '
|
||||||
|
';
|
||||||
|
$body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . '
|
||||||
|
';
|
||||||
|
if ($timerecordingCategoriess[0]->hourday == "1") {
|
||||||
|
$body .= 'von: ' . date("d.m.Y H:i", $data['start']) . ' bis: ' . date("H:i", $data['end']);
|
||||||
|
} else if ($timerecordingCategoriess[0]->hourday == "2") {
|
||||||
|
$body .= 'von: ' . date("d.m.Y", $data['start']) . ' bis: ' . date("d.m.Y", $data['end']);
|
||||||
|
}
|
||||||
|
$email = new Emailnotification();
|
||||||
|
$email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' erstellt');
|
||||||
|
$email->setBody($body);
|
||||||
|
$email->setFrom('zeiterfassung@xinon.at', 'Xinon Zeiterfassung');
|
||||||
|
$email->setTo('daniel.spitzer@inode.at');
|
||||||
|
$email->send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mode == "edit") {
|
if ($mode == "edit") {
|
||||||
$this->layout()->setFlash("Buchung erfolgreich geändert", "success");
|
$message = "Buchung erfolgreich geändert";
|
||||||
} else if ($mode = "add") {
|
} else if ($mode = "add") {
|
||||||
$this->layout()->setFlash("Buchung erfolgreich angelegt", "success");
|
$message = "Buchung erfolgreich angelegt";
|
||||||
}
|
}
|
||||||
|
if ($r->ajax == 1) {
|
||||||
|
$result['state'] = "success";
|
||||||
|
$result['message'] = "$message";
|
||||||
|
echo json_encode($result);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$this->layout()->setFlash($message, "success");
|
||||||
$this->redirect("Timerecording");
|
$this->redirect("Timerecording");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getTimerecordingsApi($datatype, $dataweek, $datamonth)
|
||||||
|
{
|
||||||
|
$mustSeconds = 0;
|
||||||
|
$isSeconds=0;
|
||||||
|
$rows = [];
|
||||||
|
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $this->me->id]);
|
||||||
|
$holidays= TimerecordingHolidayModel::getAll();
|
||||||
|
foreach ($workinghours as $workinghour) {
|
||||||
|
|
||||||
|
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghour->start . ":00");
|
||||||
|
$whend = strtotime(date('Y-m-d', time()) . " " . $workinghour->end . ":00");
|
||||||
|
if (!$workingHours[$workinghour->day]) {
|
||||||
|
$workingHours[$workinghour->day] = $whend - $whstart;
|
||||||
|
} else {
|
||||||
|
$workingHours[$workinghour->day] = $workingHours[$workinghour->day] + $whend - $whstart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($holidays as $holiday) {
|
||||||
|
$holiDay[date('Y-m-d', $holiday->timestamp)] = $holiday->timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($datatype == 1) {
|
||||||
|
$kw = date('W', $dataweek);
|
||||||
|
$year = date('Y', $dataweek);
|
||||||
|
$timestamp_montag = strtotime("{$year}-W{$kw}");
|
||||||
|
$timestamp_sonntag = strtotime("{$year}-W{$kw}-7");
|
||||||
|
$timestamp_sonntag = strtotime(date("Y-m-d", $timestamp_sonntag) . ' 23:59:59');
|
||||||
|
$searchArray = ['user_id' => $this->me->id, 'start' => $timestamp_montag, 'end' => $timestamp_sonntag];
|
||||||
|
|
||||||
|
$daycounter = '0';
|
||||||
|
|
||||||
|
$timestamp = $timestamp_montag;
|
||||||
|
for ($i = 1; $i <= 7; $i++) {
|
||||||
|
$dDate = date('Y-m-d', $timestamp);
|
||||||
|
$dDay = date('w', $timestamp);
|
||||||
|
if (!$holiDay[$dDate]) {
|
||||||
|
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||||
|
}
|
||||||
|
|
||||||
|
$timestamp = $timestamp + 86400;
|
||||||
|
}
|
||||||
|
} else if ($datatype == 2) {
|
||||||
|
$firstdate = strtotime(date("Y-m-01", $datamonth));
|
||||||
|
$lastdate = strtotime(date("Y-m-t", $datamonth));
|
||||||
|
$daycount=date("t", $datamonth);
|
||||||
|
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
|
||||||
|
$searchArray = ['user_id' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
|
||||||
|
$timestamp = $firstdate;
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $daycount; $i++) {
|
||||||
|
$dDate = date('Y-m-d', $timestamp);
|
||||||
|
$dDay = date('w', $timestamp);
|
||||||
|
if (!$holiDay[$dDate]) {
|
||||||
|
$mustSeconds = $mustSeconds + $workingHours[$dDay];
|
||||||
|
}
|
||||||
|
|
||||||
|
$timestamp = $timestamp + 86400;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
||||||
|
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
|
||||||
|
$timerecordings = TimerecordingModel::search($searchArray);
|
||||||
|
$responsecount = count($timerecordings);
|
||||||
|
foreach ($timerecordings as $timerecording):
|
||||||
|
$state = "";
|
||||||
|
$enddate = "";
|
||||||
|
$sum = "-";
|
||||||
|
$day = "";
|
||||||
|
$orderdate = $timerecording->start;
|
||||||
|
if ($timerecording->timerecordingCategory->hourday == 1) {
|
||||||
|
$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)];
|
||||||
|
$isSeconds=$isSeconds+$seconds;
|
||||||
|
} else if ($timerecording->timerecordingCategory->hourday == 2) {
|
||||||
|
$date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end);
|
||||||
|
$datadate = date("Y-m-d", $timerecording->start);
|
||||||
|
$enddate = date("Y-m-d", $timerecording->end);
|
||||||
|
$start = "-";
|
||||||
|
$end = "-";
|
||||||
|
$day = $daysgerm[date("w", $timerecording->start)];
|
||||||
|
// echo $enddate-$datadate."<br>";
|
||||||
|
} else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) {
|
||||||
|
$date = date("d.m.Y", $timerecording->start);
|
||||||
|
$datadate = date("Y-m-d", $timerecording->start);
|
||||||
|
$start = "-";
|
||||||
|
$end = "-";
|
||||||
|
$day = $daysgerm[date("w", $timerecording->start)];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||||
|
$state = '<i class="fa-regular fa-clock mr-1"></i>';
|
||||||
|
} else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) {
|
||||||
|
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
||||||
|
}
|
||||||
|
$edit = "";
|
||||||
|
if ($timerecording->completed == 0 && $timerecording->timerecordingCategory->only_admin == 0):
|
||||||
|
if ($timerecording->approved == 0) :
|
||||||
|
$edit = '<i class="far fa-edit edit-button" data-id="' . $timerecording->id . '"
|
||||||
|
data-date="' . $datadate . '"
|
||||||
|
data-category="' . $timerecording->timerecordingCategory->id . '"
|
||||||
|
data-start="' . $start . '"
|
||||||
|
data-end="' . $end . '"
|
||||||
|
data-enddate="' . $enddate . '"
|
||||||
|
data-commend="' . $timerecording->commend . '"
|
||||||
|
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;
|
||||||
|
|
||||||
|
$rows[] = array(
|
||||||
|
'date' => array('date' => $state . $day . " " . $date, 'order' => $orderdate),
|
||||||
|
'start' => array('start' => $start, 'order' => $start),
|
||||||
|
'end' => array('end' => $end, 'order' => $end),
|
||||||
|
'sum' => array('sum' => $sum, 'order' => $sum),
|
||||||
|
'category' => array('category' => $timerecording->timerecordingCategory->name, 'order' => $timerecording->timerecordingCategory->name),
|
||||||
|
'commend' => array('commend' => $timerecording->commend, 'order' => $timerecording->commend),
|
||||||
|
'edit' => array('edit' => $edit, 'order' => $edit),
|
||||||
|
);
|
||||||
|
endforeach;
|
||||||
|
$json['success'] = true;
|
||||||
|
$json['time']['is'] = sprintf('%02dh:%02dm',floor($isSeconds / 3600 ),floor($isSeconds / 60 % 60));
|
||||||
|
$json['time']['must'] = sprintf('%02dh:%02dm',floor($mustSeconds / 3600 ),floor($mustSeconds / 60 % 60));
|
||||||
|
$json['data'] = $rows;
|
||||||
|
$json['recordsFiltered'] = $responsecount;
|
||||||
|
$json['recordsTotal'] = $responsecount;
|
||||||
|
$json = json_encode($json);
|
||||||
|
echo trim($json);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
protected function deleteAction()
|
protected function deleteAction()
|
||||||
{
|
{
|
||||||
$id = $this->request->id;
|
$id = $this->request->id;
|
||||||
@@ -139,6 +370,9 @@ class TimerecordingController extends mfBaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$timerecordings->delete();
|
$timerecordings->delete();
|
||||||
|
if ($this->request->ajax == 1) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
$this->redirect("Timerecording");
|
$this->redirect("Timerecording");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class TimerecordingModel
|
|||||||
return $items;
|
return $items;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllPermits()
|
public static function getAllPermits()
|
||||||
{
|
{
|
||||||
$items = [];
|
$items = [];
|
||||||
@@ -140,7 +141,26 @@ class TimerecordingModel
|
|||||||
$where .= " AND user_id=$userid";
|
$where .= " AND user_id=$userid";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (array_key_exists("start", $filter) && array_key_exists("end", $filter)) {
|
||||||
|
$start = $filter['start'];
|
||||||
|
$end = $filter['end'];
|
||||||
|
if (is_numeric($start) && is_numeric($end)) {
|
||||||
|
$where .= " AND `start` > $start AND `start` < $end";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (array_key_exists("starttime", $filter) && array_key_exists("endtime", $filter)) {
|
||||||
|
$starttime = $filter['starttime'];
|
||||||
|
$endtime = $filter['endtime'];
|
||||||
|
$id = $filter['id'];
|
||||||
|
if (is_numeric($starttime) && is_numeric($endtime)) {
|
||||||
|
$where .= " AND ((`start` <= $starttime AND `end` >= $starttime ) || (`start` >= $endtime AND `end` <= $endtime) || (`start` >= $starttime AND `end` >= $starttime AND `start` <= $endtime AND `end` <= $endtime))";
|
||||||
|
if ($id && is_numeric($id)) {
|
||||||
|
$where .= " AND `id` != $id";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
// var_dump($filter, $where);exit;
|
// var_dump($filter, $where);exit;
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,10 +119,10 @@ class TimerecordingCategoryModel
|
|||||||
$where = "1=1 ";
|
$where = "1=1 ";
|
||||||
|
|
||||||
//var_dump($filter);exit;
|
//var_dump($filter);exit;
|
||||||
if (array_key_exists("network_id", $filter)) {
|
if (array_key_exists("id", $filter)) {
|
||||||
$networkid = $filter['network_id'];
|
$id = $filter['id'];
|
||||||
if (is_numeric($networkid)) {
|
if (is_numeric($id)) {
|
||||||
$where .= " AND network_id=$networkid";
|
$where .= " AND id=$id";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
60
application/TimerecordingEmployee/TimerecordingEmployee.php
Normal file
60
application/TimerecordingEmployee/TimerecordingEmployee.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class TimerecordingEmployee extends mfBaseModel
|
||||||
|
{
|
||||||
|
private $editor;
|
||||||
|
private $creator;
|
||||||
|
private $user;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class TimerecordingEmployeeController extends mfBaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function init()
|
||||||
|
{
|
||||||
|
$this->needlogin = true;
|
||||||
|
$me = new User();
|
||||||
|
$me->loadMe();
|
||||||
|
$this->me = $me;
|
||||||
|
$this->layout()->set("me", $me);
|
||||||
|
|
||||||
|
if (!$me->can(["Fibu"])) {
|
||||||
|
$this->redirect("Dashboard");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function indexAction()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->layout()->setTemplate("TimerecordingEmployee/Index");
|
||||||
|
$timerecordingemployees = TimerecordingEmployeeModel::getAllArray();
|
||||||
|
$timerecordingusers = UserModel::search(['employee' => 'true']);
|
||||||
|
$timerecordingworkinghours = TimerecordingEmployeeWorkingHourModel::getAllArray();
|
||||||
|
$this->layout()->set("timerecordingemployees", $timerecordingemployees);
|
||||||
|
$this->layout()->set("timerecordingworkinghours", $timerecordingworkinghours);
|
||||||
|
$this->layout()->set("timerecordingusers", $timerecordingusers);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addAction()
|
||||||
|
{
|
||||||
|
$id = $this->request->id;
|
||||||
|
$userid = $this->request->userid;
|
||||||
|
$days = TimerecordingEmployeeWorkingHourModel::$days_definition;
|
||||||
|
$timerecordingworkinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
|
||||||
|
$this->layout()->set("days", $days);
|
||||||
|
$this->layout()->set("timerecordingworkinghours", $timerecordingworkinghours);
|
||||||
|
$this->layout()->setTemplate("TimerecordingEmployee/Form");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function editAction()
|
||||||
|
{
|
||||||
|
$id = $this->request->id;
|
||||||
|
$userid = $this->request->userid;
|
||||||
|
if (!is_numeric($id) || !$id) {
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$timerecordingemployees = new TimerecordingEmployee($id);
|
||||||
|
if ($timerecordingemployees->id != $id) {
|
||||||
|
$this->layout()->setFlash("Personaladministration nicht gefunden", "error");
|
||||||
|
$this->redirect("TimerecordingEmployee");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->layout()->set("timerecordingemployees", $timerecordingemployees);
|
||||||
|
}
|
||||||
|
$timerecordinguser = UserModel::search(['worker_id' => $userid]);
|
||||||
|
$this->layout()->set("timerecordinguser", $timerecordinguser);
|
||||||
|
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";
|
||||||
|
$timerecordingemployees = new TimerecordingEmployee($id);
|
||||||
|
if (!$timerecordingemployees->id) {
|
||||||
|
$this->layout()->setFlash("Personaladministration nicht gefunden", "error");
|
||||||
|
$this->redirect("TimerecordingEmployee");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$mode = "add";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TimerecordingEmployeeWorkingHourModel::deleteUserHours($r->user_id);
|
||||||
|
if ($r->day) {
|
||||||
|
foreach ($r->day as $key => $day) {
|
||||||
|
unset($dataWorkHours);
|
||||||
|
$dataWorkHours = [];
|
||||||
|
$starttime = $r->timestart[$key];
|
||||||
|
$endtime = $r->timeend[$key];
|
||||||
|
|
||||||
|
if ($starttime && $endtime) {
|
||||||
|
$dataWorkHours['user_id'] = $r->user_id;
|
||||||
|
$dataWorkHours['day'] = $day;
|
||||||
|
$dataWorkHours['start'] = $starttime;
|
||||||
|
$dataWorkHours['end'] = $endtime;
|
||||||
|
$timerecordingemployeesworkinghours = TimerecordingEmployeeWorkingHourModel::create($dataWorkHours);
|
||||||
|
$timerecordingemployeesworkinghours->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$plushours = $r->plushours;
|
||||||
|
$plushours = str_replace(',', '.', $plushours);
|
||||||
|
if (is_numeric($plushours)) {
|
||||||
|
$plushours = $plushours * 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$data['user_id'] = trim($r->user_id);
|
||||||
|
$data['auto_workinghours'] = trim($r->auto_workinghours);
|
||||||
|
$data['holidays'] = trim($r->holidays);
|
||||||
|
$data['plushours'] = $plushours;
|
||||||
|
|
||||||
|
|
||||||
|
if (!$data['user_id']) {
|
||||||
|
$this->layout()->setFlash("Mitarbeiter darf nicht leer sein", "error");
|
||||||
|
$this->redirect("TimerecordingEmployee");
|
||||||
|
}
|
||||||
|
if (!$data['auto_workinghours']) {
|
||||||
|
$data['auto_workinghours'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($mode == "edit") {
|
||||||
|
$timerecordingemployees->update($data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$timerecordingemployees = TimerecordingEmployeeModel::create($data);
|
||||||
|
}
|
||||||
|
// var_dump($filestore);
|
||||||
|
// exit;
|
||||||
|
$id = $timerecordingemployees->save();
|
||||||
|
|
||||||
|
if (!$id) {
|
||||||
|
$this->layout()->setFlash("Personaladministration konnte nicht angelegt werden", "error");
|
||||||
|
$this->redirect("TimerecordingEmployee");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mode == "edit") {
|
||||||
|
$this->layout()->setFlash("Personaladministration erfolgreich geändert", "success");
|
||||||
|
} else if ($mode = "add") {
|
||||||
|
$this->layout()->setFlash("Personaladministration erfolgreich angelegt", "success");
|
||||||
|
}
|
||||||
|
$this->redirect("TimerecordingEmployee");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function deleteAction()
|
||||||
|
{
|
||||||
|
$id = $this->request->id;
|
||||||
|
$timerecordingemployees = new TimerecordingEmployee($id);
|
||||||
|
if (!$timerecordingemployees->id || $timerecordingemployees->id != $id) {
|
||||||
|
$this->layout()->setFlash("Personaladministration nicht gefunden.", "error");
|
||||||
|
$this->redirect("TimerecordingEmployee");
|
||||||
|
}
|
||||||
|
|
||||||
|
$timerecordingemployees->delete();
|
||||||
|
$this->redirect("TimerecordingEmployee");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
144
application/TimerecordingEmployee/TimerecordingEmployeeModel.php
Normal file
144
application/TimerecordingEmployee/TimerecordingEmployeeModel.php
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class TimerecordingEmployeeModel
|
||||||
|
{
|
||||||
|
private $user_id;
|
||||||
|
private $auto_workinghours;
|
||||||
|
private $holidays;
|
||||||
|
private $plushours;
|
||||||
|
|
||||||
|
|
||||||
|
public static function find($data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create(array $data)
|
||||||
|
{
|
||||||
|
$model = new TimerecordingEmployee();
|
||||||
|
|
||||||
|
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("TimerecordingEmployee", "*", "id=$id LIMIT 1");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new TimerecordingEmployee($data);
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAll()
|
||||||
|
{
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$res = $db->select("TimerecordingEmployee", "*", "1=1");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new TimerecordingEmployee($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAllArray()
|
||||||
|
{
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$res = $db->select("TimerecordingEmployee", "*", "1=1");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_array($res)) {
|
||||||
|
$items[$data['user_id']] = $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFirst()
|
||||||
|
{
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$res = $db->select("TimerecordingEmployee", "*", "$where ");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new TimerecordingEmployee($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("TimerecordingEmployee", "*", "$where");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new TimerecordingEmployee($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getSqlFilter($filter)
|
||||||
|
{
|
||||||
|
$where = "1=1 ";
|
||||||
|
|
||||||
|
//var_dump($filter);exit;
|
||||||
|
if (array_key_exists("network_id", $filter)) {
|
||||||
|
$networkid = $filter['network_id'];
|
||||||
|
if (is_numeric($networkid)) {
|
||||||
|
$where .= " AND network_id=$networkid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($filter, $where);exit;
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class TimerecordingEmployeeWorkingHour extends mfBaseModel
|
||||||
|
{
|
||||||
|
private $editor;
|
||||||
|
private $creator;
|
||||||
|
private $user;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class TimerecordingEmployeeWorkingHourModel
|
||||||
|
{
|
||||||
|
private $user_id;
|
||||||
|
private $day;
|
||||||
|
private $start;
|
||||||
|
private $end;
|
||||||
|
public static $days_definition = array(1 => "Montag", 2 => "Dienstag", 3 => "Mittwoch", 4 => "Donnerstag", 5 => "Freitag", 6 => "Samstag", 0 => "Sonntag");
|
||||||
|
public static $days_short = array(0 => "So", 1 => "Mo", 2 => "Di", 3 => "Mi", 4 => "Do", 5 => "Fr", 6 => "Sa");
|
||||||
|
|
||||||
|
public static function cleardays($days)
|
||||||
|
{
|
||||||
|
$days_short = TimerecordingEmployeeWorkingHourModel::$days_short;
|
||||||
|
foreach ($days_short as $day_short) {
|
||||||
|
$days = str_replace($day_short . " - " . $day_short, $day_short, $days);
|
||||||
|
}
|
||||||
|
return $days;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function find($data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function create(array $data)
|
||||||
|
{
|
||||||
|
$model = new TimerecordingEmployeeWorkingHour();
|
||||||
|
|
||||||
|
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("TimerecordingEmployeeWorkingHour", "*", "id=$id LIMIT 1");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new TimerecordingEmployeeWorkingHour($data);
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAll()
|
||||||
|
{
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$res = $db->select("TimerecordingEmployeeWorkingHour", "*", "1=1");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new TimerecordingEmployeeWorkingHour($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAllArray()
|
||||||
|
{
|
||||||
|
$items = [];
|
||||||
|
$daysshort = TimerecordingEmployeeWorkingHourModel::$days_short;
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$res = $db->select("TimerecordingEmployeeWorkingHour", "*", "1=1 ORDER by `user_id`,`day`");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
$olduser = 0;
|
||||||
|
$counter = 0;
|
||||||
|
$oldend = "";
|
||||||
|
$oldstart = "";
|
||||||
|
$oldday = "";
|
||||||
|
$datetimetext = "";
|
||||||
|
$secondcounter = 0;
|
||||||
|
|
||||||
|
while ($data = $db->fetch_array($res)) {
|
||||||
|
if ($olduser != $data['user_id']) {
|
||||||
|
if ($counter > 0) {
|
||||||
|
$secondcounter = 0;
|
||||||
|
$datetimetext .= " - " . $daysshort[$oldday] . " " . $oldstart . " - " . $oldend;
|
||||||
|
$datetimetext = TimerecordingEmployeeWorkingHourModel::cleardays($datetimetext);
|
||||||
|
$items[$olduser]['datetimetext'] = $datetimetext;
|
||||||
|
}
|
||||||
|
$datetimetext = "";
|
||||||
|
unset($oldstart);
|
||||||
|
unset($oldend);
|
||||||
|
unset($oldday);
|
||||||
|
$items[$data['user_id']] = $data;
|
||||||
|
}
|
||||||
|
$secondcounter = $secondcounter + strtotime(date("Y-m-d " . $data['end'] . ":00")) - strtotime(date("Y-m-d " . $data['start'] . ":00"));
|
||||||
|
|
||||||
|
if (!$datetimetext) {
|
||||||
|
$datetimetext = $daysshort[$data['day']];
|
||||||
|
}
|
||||||
|
echo $oldstart . $data['start'];
|
||||||
|
if (($oldstart != $data['start'] || $oldend != $data['end']) && $oldend) {
|
||||||
|
$datetimetext .= " - " . $daysshort[$oldday] . " " . $oldstart . " - " . $oldend;
|
||||||
|
$datetimetext .= "<br> " . $daysshort[$data['day']];
|
||||||
|
}
|
||||||
|
|
||||||
|
$items[$data['user_id']]['datetimetext'] = $datetimetext;
|
||||||
|
$items[$data['user_id']]['secondcounter'] = $secondcounter;
|
||||||
|
$olduser = $data['user_id'];
|
||||||
|
$oldstart = $data['start'];
|
||||||
|
$oldend = $data['end'];
|
||||||
|
$oldday = $data['day'];
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
$datetimetext .= " - " . $daysshort[$oldday] . " " . $oldstart . " - " . $oldend;
|
||||||
|
$datetimetext = TimerecordingEmployeeWorkingHourModel::cleardays($datetimetext);
|
||||||
|
$items[$olduser]['datetimetext'] = $datetimetext;
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function deleteUserHours($userid)
|
||||||
|
{
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
$sql = "DELETE FROM `TimerecordingEmployeeWorkingHour` WHERE `user_id`='" . $userid . "'";
|
||||||
|
$res = $db->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFirst()
|
||||||
|
{
|
||||||
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
|
$where = self::getSqlFilter($filter);
|
||||||
|
$res = $db->select("TimerecordingEmployeeWorkingHour", "*", "$where ");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
$data = $db->fetch_object($res);
|
||||||
|
$item = new TimerecordingEmployeeWorkingHour($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("TimerecordingEmployeeWorkingHour", "*", "$where ORDER by `day`,`start`");
|
||||||
|
if ($db->num_rows($res)) {
|
||||||
|
while ($data = $db->fetch_object($res)) {
|
||||||
|
$items[] = new TimerecordingEmployeeWorkingHour($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getSqlFilter($filter)
|
||||||
|
{
|
||||||
|
$where = "1=1 ";
|
||||||
|
|
||||||
|
if (array_key_exists("user_id", $filter)) {
|
||||||
|
$userid = $filter['user_id'];
|
||||||
|
if (is_numeric($userid)) {
|
||||||
|
$where .= " AND user_id=$userid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($filter, $where);exit;
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -66,9 +66,16 @@ class TimerecordingHolidayController extends mfBaseController
|
|||||||
} else {
|
} else {
|
||||||
$mode = "add";
|
$mode = "add";
|
||||||
}
|
}
|
||||||
|
if ($r->timestamp) {
|
||||||
|
$timestamp = strtotime($r->timestamp . " 00:00:00");
|
||||||
|
if ($timestamp< 1577833200)
|
||||||
|
{
|
||||||
|
$timestamp="";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$data['timestamp'] = trim($r->timestamp);
|
$data['timestamp'] = trim($timestamp);
|
||||||
$data['description'] = trim($r->description);
|
$data['description'] = trim($r->description);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ final class TimerecordingEmployee extends AbstractMigration
|
|||||||
$table = $this->table("TimerecordingEmployee", ["signed" => true]);
|
$table = $this->table("TimerecordingEmployee", ["signed" => true]);
|
||||||
$table->addColumn("user_id", "integer", ["null" => false]);
|
$table->addColumn("user_id", "integer", ["null" => false]);
|
||||||
$table->addColumn("auto_workinghours", "integer", ["null" => false, "default" => "0"]);
|
$table->addColumn("auto_workinghours", "integer", ["null" => false, "default" => "0"]);
|
||||||
|
$table->addColumn("holidays", "integer", ["null" => false, "default" => "0"]);
|
||||||
|
$table->addColumn("plushours", "integer", ["null" => false, "default" => "0"]);
|
||||||
$table->addColumn("create_by", "integer", ["null" => false]);
|
$table->addColumn("create_by", "integer", ["null" => false]);
|
||||||
$table->addColumn("edit_by", "integer", ["null" => false]);
|
$table->addColumn("edit_by", "integer", ["null" => false]);
|
||||||
$table->addColumn("create", "integer", ["null" => false]);
|
$table->addColumn("create", "integer", ["null" => false]);
|
||||||
|
|||||||
@@ -129,6 +129,22 @@ table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
|
|||||||
{
|
{
|
||||||
color: #f00;
|
color: #f00;
|
||||||
}
|
}
|
||||||
|
.edit-td {
|
||||||
|
text-align: left;
|
||||||
|
letter-spacing: 12px;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
.display-calendar
|
||||||
|
{
|
||||||
|
color:#0d6efd;
|
||||||
|
font-size: 30px;
|
||||||
|
margin-right:20px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.active-calendar
|
||||||
|
{
|
||||||
|
color:#25b343;
|
||||||
|
}
|
||||||
@media (max-width: 1200px) {
|
@media (max-width: 1200px) {
|
||||||
.fa-circle-xmark, .fa-ban, .fa-trash, .fa-edit, .fa-square-check, .fa-arrows-up-down-left-right {
|
.fa-circle-xmark, .fa-ban, .fa-trash, .fa-edit, .fa-square-check, .fa-arrows-up-down-left-right {
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
@@ -196,6 +212,18 @@ table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin: 12px 3px 7px 0px;
|
margin: 12px 3px 7px 0px;
|
||||||
}
|
}
|
||||||
|
.display-calendar
|
||||||
|
{
|
||||||
|
font-size:35px;
|
||||||
|
margin-top:5px;
|
||||||
|
margin-right:30px;
|
||||||
|
margin-bottom:20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.label-calendar
|
||||||
|
{
|
||||||
|
margin-top:7px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table.dataTable > tbody > tr.child span.dtr-data {
|
table.dataTable > tbody > tr.child span.dtr-data {
|
||||||
|
|||||||
323
public/js/pages/timerecording/index.js
Normal file
323
public/js/pages/timerecording/index.js
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
let table;
|
||||||
|
if (typeof hidesearch === "undefined") {
|
||||||
|
var hidesearch;
|
||||||
|
hidesearch = [100];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof cstmdom === "undefined") {
|
||||||
|
var cstmdom;
|
||||||
|
cstmdom = "flBrtip";
|
||||||
|
|
||||||
|
}
|
||||||
|
if (typeof columndefs === "undefined") {
|
||||||
|
var columndefs;
|
||||||
|
columndefs = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof columnfilter === "undefined") {
|
||||||
|
var columnfilter;
|
||||||
|
columnfilter = "";
|
||||||
|
}
|
||||||
|
if (typeof columnoptions === "undefined") {
|
||||||
|
var columnoptions;
|
||||||
|
columnoptions = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#filterrow th').each(function (i) {
|
||||||
|
let title = $('#datatable thead th').eq($(this).index()).text();
|
||||||
|
|
||||||
|
if (hidesearch.includes($(this).index())) {
|
||||||
|
|
||||||
|
} else if (columnfilter.includes($(this).index())) {
|
||||||
|
$(this).html('<select style="padding: 0;height: 28px;;text-align: center;" id="selectsearch" class="form-control form-control-select form-control-special" data-index="' + i + '">' + columnoptions + '</select>');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$(this).html('<input type="text" placeholder="' + title + '" class="form-control" data-index="' + i + '" value="" />');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
table = $('#datatable').DataTable({
|
||||||
|
responsive: true,
|
||||||
|
"order": [[0, "desc"]],
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
extend: 'excelHtml5',
|
||||||
|
text: 'XLSX Export',
|
||||||
|
className: 'btn-success margina d-none d-lg-block',
|
||||||
|
exportOptions: {
|
||||||
|
columns: ['th:not(:last-child)']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
], columnDefs: [
|
||||||
|
columndefs
|
||||||
|
],
|
||||||
|
"language": {
|
||||||
|
"url": "/datatables/json/german.json?v1"
|
||||||
|
},
|
||||||
|
orderCellsTop: true,
|
||||||
|
stateSave: true,
|
||||||
|
"initComplete": function () {
|
||||||
|
$('#datatable_filter').append('<i id="clear_cookie" class="fas fa-times clear-fa" title="Filter löschen" aria-hidden="true" ></i>');
|
||||||
|
$('#clear_cookie').click(function () {
|
||||||
|
$('#filterrow input').val('');
|
||||||
|
$('#filterrow select').val('');
|
||||||
|
table.search('').columns().search('').draw();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"dom": cstmdom,
|
||||||
|
"ajax": {
|
||||||
|
"url": requestUrl,
|
||||||
|
"type": "GET",
|
||||||
|
"data": function (d) {
|
||||||
|
$('.display-calendar').each(function (index) {
|
||||||
|
if ($(this).hasClass('active-calendar')) {
|
||||||
|
d.datatype = $(this).data('datatype');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
d.dataweek = $('#dataweek').val();
|
||||||
|
d.datamonth = $('#datamonth').val();
|
||||||
|
},
|
||||||
|
"dataSrc": function (json) {
|
||||||
|
$('#is-time').text(json.time.is);
|
||||||
|
$('#must-time').text(json.time.must);
|
||||||
|
return json.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
_: "date.date",
|
||||||
|
"sort": "date.order"
|
||||||
|
},
|
||||||
|
className: "text-nowrap"
|
||||||
|
}, {
|
||||||
|
"data": {
|
||||||
|
_: "start.start",
|
||||||
|
"sort": "start.order"
|
||||||
|
},
|
||||||
|
className: "text-center"
|
||||||
|
}, {
|
||||||
|
"data": {
|
||||||
|
_: "end.end",
|
||||||
|
"sort": "end.order"
|
||||||
|
},
|
||||||
|
className: "text-center"
|
||||||
|
}, {
|
||||||
|
"data": {
|
||||||
|
_: "sum.sum",
|
||||||
|
"sort": "sum.order"
|
||||||
|
},
|
||||||
|
className: "text-center"
|
||||||
|
}, {
|
||||||
|
"data": {
|
||||||
|
_: "category.category",
|
||||||
|
"sort": "category.order"
|
||||||
|
},
|
||||||
|
className: ""
|
||||||
|
}
|
||||||
|
, {
|
||||||
|
"data": {
|
||||||
|
_: "commend.commend",
|
||||||
|
"sort": "commend.order"
|
||||||
|
},
|
||||||
|
className: "text-center"
|
||||||
|
}, {
|
||||||
|
"data": {
|
||||||
|
_: "edit.edit",
|
||||||
|
"sort": "edit.order"
|
||||||
|
},
|
||||||
|
className: "edit-td"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#filterrow').on('keyup', 'input', function () {
|
||||||
|
|
||||||
|
table
|
||||||
|
.column($(this).data('index'))
|
||||||
|
.search(this.value)
|
||||||
|
.draw();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#selectsearch').change(function () {
|
||||||
|
table
|
||||||
|
.column($(this).data('index'))
|
||||||
|
.search(this.value)
|
||||||
|
.draw();
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
let state = table.state.loaded();
|
||||||
|
if (state) {
|
||||||
|
table.columns().eq(0).each(function (colIdx) {
|
||||||
|
var colSearch = state.columns[colIdx].search;
|
||||||
|
|
||||||
|
if (colSearch.search) {
|
||||||
|
$('#filterrow').find("[data-index='" + colIdx + "']").val(colSearch.search);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
table.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
$(".select2").select2();
|
||||||
|
|
||||||
|
$("body").on("change", "#timerecordingCategory_id", function () {
|
||||||
|
if (parseInt($(this).find(':selected').data('hourday')) === 2) {
|
||||||
|
$("#endtime-div").hide();
|
||||||
|
$("#endtime-div").find('input').each(function () {
|
||||||
|
$(this).prop("required", false);
|
||||||
|
});
|
||||||
|
$("#enddate-div").show();
|
||||||
|
$("#enddate-div").find('input').each(function () {
|
||||||
|
$(this).prop("required", true);
|
||||||
|
$(this).prop("min", $('#date').val());
|
||||||
|
$(this).val($('#date').val());
|
||||||
|
})
|
||||||
|
} else if (parseInt($(this).find(':selected').data('hourday')) === 1) {
|
||||||
|
$("#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('');
|
||||||
|
})
|
||||||
|
} else if (parseInt($(this).find(':selected').data('hourday')) === 3 || parseInt($(this).find(':selected').data('hourday')) === 4) {
|
||||||
|
$("#endtime-div").hide();
|
||||||
|
$("#endtime-div").find('input').each(function () {
|
||||||
|
$(this).prop("required", false);
|
||||||
|
$(this).prop("disabled", true);
|
||||||
|
|
||||||
|
});
|
||||||
|
$("#enddate-div").hide();
|
||||||
|
$("#enddate-div").find('input').each(function () {
|
||||||
|
$(this).prop("required", false);
|
||||||
|
$(this).prop("min", '');
|
||||||
|
$(this).val('');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (parseInt($(this).find(':selected').data('comment')) === 1) {
|
||||||
|
$('#commend').prop("required", true);
|
||||||
|
} else {
|
||||||
|
$('#commend').prop("required", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("body").on("change", "#date", function () {
|
||||||
|
if ($('#enddate-div').css('display') === "block") {
|
||||||
|
if ($('#date').val() > $('#enddate').val()) {
|
||||||
|
$('#enddate').prop("min", $('#date').val());
|
||||||
|
$('#enddate').val($('#date').val());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("body").on("change", "#start", function () {
|
||||||
|
|
||||||
|
if ($('#start').val() > $('#end').val()) {
|
||||||
|
$('#end').val($('#start').val());
|
||||||
|
}
|
||||||
|
$('#end').prop("min", $('#start').val());
|
||||||
|
});
|
||||||
|
|
||||||
|
$("body").on("click", ".edit-button", function () {
|
||||||
|
$('#submit-button').hide().removeClass('btn-primary').addClass('btn-danger').show();
|
||||||
|
$('#submit-button').text('Ändern');
|
||||||
|
$('#cancel-button').show();
|
||||||
|
$('#timerecordingCategory_id').val($(this).data('category')).change();
|
||||||
|
$('#id').val($(this).data('id'));
|
||||||
|
$('#date').val($(this).data('date'));
|
||||||
|
$('#start').val($(this).data('start'));
|
||||||
|
$('#end').val($(this).data('end'));
|
||||||
|
$('#enddate').val($(this).data('enddate'));
|
||||||
|
$('#commend').val($(this).data('commend'));
|
||||||
|
$('.alert-success').remove();
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
});
|
||||||
|
$("body").on("click", "#cancel-button", function () {
|
||||||
|
$('#submit-button').hide().removeClass('btn-danger').addClass('btn-primary').show();
|
||||||
|
$('#submit-button').text('Speichern');
|
||||||
|
$('#cancel-button').hide();
|
||||||
|
$('#id').val('');
|
||||||
|
});
|
||||||
|
|
||||||
|
$("body").on("change", "#dataweek,#datamonth", function () {
|
||||||
|
table.ajax.reload();
|
||||||
|
});
|
||||||
|
$("body").on("click", ".display-calendar", function () {
|
||||||
|
$('.display-calendar').each(function (index) {
|
||||||
|
$(this).removeClass('active-calendar');
|
||||||
|
});
|
||||||
|
$(this).addClass('active-calendar');
|
||||||
|
|
||||||
|
if ($(this).data('datatype') == "1") {
|
||||||
|
console.log($(this).data('datatype'));
|
||||||
|
$('#dataweek-col').show();
|
||||||
|
$('#datamonth-col').hide();
|
||||||
|
} else if ($(this).data('datatype') == "2") {
|
||||||
|
$('#datamonth-col').show();
|
||||||
|
$('#dataweek-col').hide();
|
||||||
|
}
|
||||||
|
$(".select2").select2();
|
||||||
|
table.ajax.reload();
|
||||||
|
});
|
||||||
|
$("body").on("click", ".delete-item", function () {
|
||||||
|
if (confirm('Buchung wirklich löschen?')) {
|
||||||
|
$.post(deleteUrl, {
|
||||||
|
id: $.trim($(this).data('id')),
|
||||||
|
ajax: 1
|
||||||
|
}).done(function (data) {
|
||||||
|
|
||||||
|
table.ajax.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
$('form').submit(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$('#alert-box').remove();
|
||||||
|
$.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()),
|
||||||
|
commend: $.trim($('#commend').val()),
|
||||||
|
ajax: 1
|
||||||
|
}).done(function (data) {
|
||||||
|
var result = $.parseJSON(data);
|
||||||
|
if (result.state === "success") {
|
||||||
|
$('.wrapper .container-fluid').prepend(`<div id="alert-box" class="row">
|
||||||
|
<div class="col-md-1"></div>
|
||||||
|
<div class="col-md-10 alert alert-success alert-dismissible">
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||||
|
<h5><i class="icon fas fa-check"></i> Erfolgreich</h5>
|
||||||
|
` + result.message + `</div>
|
||||||
|
</div>`);
|
||||||
|
}
|
||||||
|
if (result.state === "error") {
|
||||||
|
$('.wrapper .container-fluid').prepend(`<div id="alert-box" class="row">
|
||||||
|
<div class="col-md-1"></div>
|
||||||
|
<div class="col-md-10 alert alert-danger alert-dismissible">
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||||
|
<h5><i class="icon fas fa-ban"></i> Fehler</h5>
|
||||||
|
` + result.error + `</div>
|
||||||
|
</div>`);
|
||||||
|
}
|
||||||
|
$('#submit-button').hide().removeClass('btn-danger').addClass('btn-primary').show();
|
||||||
|
$('#submit-button').text('Speichern');
|
||||||
|
$('#cancel-button').hide();
|
||||||
|
$('#id').val('');
|
||||||
|
table.ajax.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
;
|
||||||
Reference in New Issue
Block a user