Zeiterfassungs Update

* Neuer Buchungszeitraum bei den Buchungskategorien ZA Uhrzeit (von/bis)
 * Überprüfungen/Berechungen/Errorhandling ZAs
 * Anpassungen Freigaben nun mit Standartfilter Offen
This commit is contained in:
Spitzer Daniel
2024-03-12 13:30:52 +01:00
parent 6e02b849bd
commit d1a25a23c2
13 changed files with 341 additions and 62 deletions

View File

@@ -127,7 +127,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
data-comment="<?= $timerecordingCategories->require_comment ?>"
data-hourday="<?= $timerecordingCategories->hourday ?>"
data-businesstrip="<?= $timerecordingCategories->businesstrip ?>"
data-homeoffice="<?= ($timerecordingCategories->hourday==1) ? 1 : 0 ?>"><?= $timerecordingCategories->name ?></option>
data-homeoffice="<?= ($timerecordingCategories->hourday == 1) ? 1 : 0 ?>"><?= $timerecordingCategories->name ?></option>
</option>
<?php
endif;
@@ -178,10 +178,13 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
<label class="col-form-label" for="comment">Anmerkung</label>
<input type="text" id="comment" name="comment" class="form-control"/>
</div>
<div class="form-group col-lg-4" id="div-calc-overtime" style="display:none">
<label class="col-form-label mobile-hide" for="comment">&nbsp;</label>
<div class=" d-block" style="padding: 0.45rem 0.9rem;" id="calc-overtime"></div>
</div>
</div>
<div class="row" >
<div class="row">
<div class="col-lg-1 mb-2" id="homeoffice-div">
<div class="form-check text-center mt-1">
@@ -354,7 +357,8 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
let insertUrl = "<?= self::getUrl("Timerecording", "save") ?>";
let deleteUrl = "<?= self::getUrl("Timerecording", "delete") ?>";
let requestUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'getTimerecordings']) ?>";
let autoWorkinghoursUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'fillWorkinghours']) ?>";
let autoWorkinghoursUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'fillWorkinghours']) ?>";
let checkWorkinghoursUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'checkWorkinghours']) ?>";
</script>
<script type="text/javascript"

View File

@@ -33,7 +33,7 @@
</div>
</div>
</div>
<table id="datatable" class="table table-striped table-hover table-sm">
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<th class="text-center">Beizeichnung</th>

View File

@@ -42,7 +42,7 @@ $type[3] = "Lehrling";
</div>
</div>
<div class="col-lg-12">
<table id="datatable" class="table table-striped table-hover table-sm">
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<th class="text-center">Mitarbeiter</th>
@@ -87,6 +87,14 @@ $type[3] = "Lehrling";
$plusHours = $timerecordingemployees[$timerecordinguser->id]['plushours_now'];
$plusHours = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
}
if ($timerecordingemployees[$timerecordinguser->id]['overtime_now'] < 0) {
$overTime = $timerecordingemployees[$timerecordinguser->id]['overtime_now'] * -1;
$overTime = "-" . sprintf('%02dh:%02dm', floor($overTime / 3600), floor($overTime / 60 % 60));
} else {
$overTime = $timerecordingemployees[$timerecordinguser->id]['overtime_now'];
$overTime = sprintf('%02dh:%02dm', floor($overTime / 3600), floor($overTime / 60 % 60));
}
?>
<tr>
@@ -97,7 +105,7 @@ $type[3] = "Lehrling";
<td class="text-center"><?= $sum ?></td>
<td class="text-center"
data-order="<?= ($timerecordingemployees[$timerecordinguser->id]['plushours_now']) ? $timerecordingemployees[$timerecordinguser->id]['plushours_now'] : 0 ?>"><?= $plusHours ?></td>
<td class="text-center" data-order="<?= $timerecordingemployees[$timerecordinguser->id]['overtime'] ?>"><?= sprintf('%02d:%02d', floor($timerecordingemployees[$timerecordinguser->id]['overtime'] / 3600), floor($timerecordingemployees[$timerecordinguser->id]['overtime'] / 60 % 60)) ?></td>
<td class="text-center" data-order="<?= $timerecordingemployees[$timerecordinguser->id]['overtime_now'] ?>"><?= $overTime ?></td>
<td class="text-center" data-order="<?= ($timerecordingemployees[$timerecordinguser->id]['holidays_now']) ? $timerecordingemployees[$timerecordinguser->id]['holidays_now'] : '' ?>"><?= ($timerecordingemployees[$timerecordinguser->id]['holidays_now']) ? $timerecordingemployees[$timerecordinguser->id]['holidays_now'] . ' Tage' : '' ?> </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;">

View File

@@ -37,7 +37,7 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
</div>
</div>
</div>
<table id="datatable" class="table table-striped table-hover table-sm">
<table id="datatable" class="table table-hover table-sm">
<thead>
<tr>
<th style="width: 200px;" class="text-center">Datum</th>

View File

@@ -182,9 +182,9 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
<script type="text/javascript">
var hidesearch = [2, 3, 4, 8];
var columnfilter = [7];
var columnoptions = '<option value=""></option><option value="Offen">Offen</option><option value="Genehmigt">Genehmigt</option><option value="Abgelehnt">Abgelehnt</option>';
var columnoptions = '<option value=""></option><option selected="selected" value="Offen">Offen</option><option value="Genehmigt">Genehmigt</option><option value="Abgelehnt">Abgelehnt</option>';
$(document).ready(function () {
$('#selectsearch').change();
});
</script>

View File

@@ -92,6 +92,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
.fixed-state {
background-color: #d0fbd9;
}
.form-check-label {
margin-top: 2px;
}
@@ -200,56 +201,60 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
<div class="form-group col-lg-2">
<label class="col-form-label" for="comment">Anmerkung</label>
<input type="text" id="comment" name="comment" class="form-control"
<input type="text" id="comment" name="comment" class="form-control">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-1 mb-2" id="homeoffice-div">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="homeoffice"
id="homeoffice" value="1">
<label class="form-check-label" for="homeoffice">
Homeoffice
</label>
<div class="form-group col-lg-2" id="div-calc-overtime" style="display:none">
<label class="col-form-label mobile-hide" for="comment">&nbsp;</label>
<div class=" d-block" style="padding: 0.45rem 0.9rem;" id="calc-overtime"></div>
</div>
</div>
<div class="col-lg-2 mb-2 businesstrip-div">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="businesstrip"
id="businesstrip" value="1">
<label class="form-check-label" for="businesstrip">
Dienstreise > 12KM
</label>
<div class="row">
<div class="col-lg-1 mb-2" id="homeoffice-div">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="homeoffice"
id="homeoffice" value="1">
<label class="form-check-label" for="homeoffice">
Homeoffice
</label>
</div>
</div>
<div class="col-lg-2 mb-2 businesstrip-div">
<div class="form-check text-center mt-1">
<input class="form-check-input" type="checkbox" name="businesstrip"
id="businesstrip" value="1">
<label class="form-check-label" for="businesstrip">
Dienstreise > 12KM
</label>
</div>
</div>
<div class="col-lg-2 businesstrip-div">
<input style="display:none" type="text" id="businesstrip_info" name="businesstrip_info"
placeholder="Ort"
class="form-control"/>
</div>
</div>
<div class="col-lg-2 businesstrip-div">
<input style="display:none" type="text" id="businesstrip_info" name="businesstrip_info"
placeholder="Ort"
class="form-control"/>
<div class=" row mt-2">
<div class="col-lg-2 ">
<button id="submit-button" type="submit" class="btn btn-primary">Speichern</button>
<button id="cancel-button" type="button" class="btn btn-secondary" style="display:none">
Abbrechen
</button>
</div>
</div>
<div class=" row mt-2">
<div class="col-lg-4" id="message-box">
</div>
</div>
</div>
<div class=" row mt-2">
<div class="col-lg-2 ">
<button id="submit-button" type="submit" class="btn btn-primary">Speichern</button>
<button id="cancel-button" type="button" class="btn btn-secondary" style="display:none">Abbrechen
</button>
</div>
</div>
<div class=" row mt-2">
<div class="col-lg-4" id="message-box">
</div>
</div>
</div>
</form>
</div>
<div class="card">
<div class="card-body mb-3">
<div class="form-group module-row row mb-3">
@@ -375,7 +380,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
let deleteUrl = "<?= self::getUrl("Timerecording", "delete") ?>";
let requestUrl = "<?= self::getUrl("TimerecordingReport", "api", ['do' => 'getTimerecordings']) ?>";
let requestTimesUrl = "<?= self::getUrl("TimerecordingReport", "api", ['do' => 'getTimerecordingsTimes']) ?>";
let checkWorkinghoursUrl = "<?= self::getUrl("Timerecording", "api", ['do' => 'checkWorkinghours']) ?>";
</script>
<script type="text/javascript"

View File

@@ -33,6 +33,7 @@ class TimerecordingController extends mfBaseController
$dataweek = $this->request->dataweek;
$datamonth = $this->request->datamonth;
$datayear = $this->request->datayear;
$ajax = $this->request->ajax;
$data = [];
@@ -43,10 +44,13 @@ class TimerecordingController extends mfBaseController
case "fillWorkinghours":
$return = $this->fillWorkinghours($dataweek);
break;
case "checkWorkinghours":
$return = $this->checkWorkingHours($ajax);
break;
default:
$return = false;
}
echo $do;
if (!is_array($return) || !count($return)) {
$data = ["status" => "error"];
$this->returnJson($data);
@@ -148,6 +152,108 @@ class TimerecordingController extends mfBaseController
}
}
protected function checkWorkingHours($ajax = 0)
{
$r = $this->request;
$starttime = strtotime($r->date . " " . $r->start . ":00");
$endtime = strtotime($r->date . " " . $r->end . ":00");
$date = $r->date;
if ($r->user_id) {
$userid = $r->user_id;
} else {
$userid = $this->me->id;
}
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
$realHolidays = TimerecordingHolidayModel::getAll();
foreach ($realHolidays as $realHoliday) {
$realholiDay[date('Y-m-d', $realHoliday->timestamp)] = $realHoliday->timestamp;
}
if ($realholiDay[$date]) {
$result['state'] = "error";
$result['error'] = "Kein Zeitausgleich an einem Feiertag möglich";
echo json_encode($result);
die();
}
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;
}
}
if (!$workingHours[date("w", $starttime)]) {
$result['state'] = "error";
$result['error'] = "Kein Zeitausgleich außerhalb der Arbeitszeiten möglich";
echo json_encode($result);
die();
}
$maxTime = $workingHours[date("w", $starttime)];
$isTime = $endtime - $starttime;
$cleanTime = $isTime;
if ($maxTime < $isTime) {
$result['state'] = "error";
$result['error'] = "Zeitausgleich kann maximal " . sprintf('%02dh:%02dm', floor($maxTime / 3600), floor($maxTime / 60 % 60)) . " an diesem Tag betragen.";
echo json_encode($result);
die();
}
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
$plushours = $employee[0]->plushours_now * 1.25;
$overtime = $employee[0]->overtime * 1.5;
$overtimesum = $plushours + $overtime;
if ($overtimesum < $isTime) {
if ($overtimesum < 0) {
$overtimesum = 0;
}
$result['state'] = "error";
$result['error'] = "Maximal verfügbarer ZA: " . sprintf('%02dh:%02dm', floor($overtimesum / 3600), floor($overtimesum / 60 % 60)) . ".";
echo json_encode($result);
die();
}
if ($plushours >= $isTime) {
$isTime = $isTime * 0.8;
$return['hours'] = $isTime;
} elseif ($plushours <= 0) {
$isTime = $isTime * 0.66666666666666666666666666666667;
$return ['hours_overtime'] = $isTime;
} else {
$isTime25 = $plushours;
$isTime50 = $isTime - $plushours;
$isTime25 = $isTime25 * 0.8;
$isTime50 = $isTime50 * 0.66666666666666666666666666666667;
$isTime = $isTime25 + $isTime50;
$return['hours'] = $isTime25;
$return['hours_overtime'] = $isTime50;
}
if ($ajax == 1) {
if ($r->ajax == 1) {
if ($isTime<0) {
$isTime = 0;
}
if ($cleanTime<0) {
$cleanTime = 0;
}
$result['state'] = "success";
$result['message'] = "<span class='text-bold'>Abzug:</span> " . sprintf('%02dh:%02dm', floor($isTime / 3600), floor($isTime / 60 % 60)) . " <span class='text-bold ml-1'>Zeitwert:</span> " . sprintf('%02dh:%02dm', floor($cleanTime / 3600), floor($cleanTime / 60 % 60));
echo json_encode($result);
die();
}
} else {
return $return;
}
}
protected function saveAction()
{
$r = $this->request;
@@ -159,10 +265,13 @@ class TimerecordingController extends mfBaseController
$this->updateOpenTimerecording();
}
if ($hourday == 1) {
$data = [];
if ($hourday == 1 || $hourday == 6) {
$starttime = strtotime($r->date . " " . $r->start . ":00");
$endtime = strtotime($r->date . " " . $r->end . ":00");
if ($hourday == 6) {
$data = $this->checkWorkingHours();
}
} elseif ($hourday == 2) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = strtotime($enddate . " 23:59:00");
@@ -198,7 +307,7 @@ class TimerecordingController extends mfBaseController
$mode = "add";
}
$data = [];
if ($r->user_id) {
$data['user_id'] = $r->user_id;
} else {
@@ -225,7 +334,7 @@ class TimerecordingController extends mfBaseController
}
if ($r->businesstrip == 1 && !$r->businesstrip_info) {
$result['state'] = "error";
$result['error'] = "Geschäftsreiseinformationen darf nicht leer sein";
$result['error'] = "Dienstreiseort darf nicht leer sein";
echo json_encode($result);
die();
}
@@ -307,6 +416,8 @@ class TimerecordingController extends mfBaseController
$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']);
} else if ($timerecordingCategoriess[0]->hourday == "6") {
$body .= 'von: ' . date("d.m.Y H:i", $data['start']) . ' bis: ' . date("H:i", $data['end']);
}
$email = new Emailnotification();
$email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' erstellt');
@@ -415,9 +526,18 @@ class TimerecordingController extends mfBaseController
$plushours = $employee->plushours;
$plushours_now = $employee->plushours_now;
$plushours_timestamp = $employee->plushours_timestamp;
$overtime = $employee->overtime;
$overtime_now = $employee->overtime_now;
$overtime_timestamp = $employee->overtime_timestamp;
if (!$plushours_timestamp) {
$plushours_timestamp = $employee->startdate;
$plushours_now = $plushours;
}
if (!$overtime_timestamp) {
$overtime_timestamp = $employee->startdate;
$overtime_now = $overtime;
}
$endtime = time() - 86400;
$endtime = date("Y-m-d", $endtime);
@@ -430,10 +550,27 @@ class TimerecordingController extends mfBaseController
} else {
$diffTime = 0;
}
if ($employee->plushours_now != $diffTime) {
$minushours = 0;
$minushoursovertime = 0;
$timerecordings = TimerecordingModel::search(['user_id' => $userid, 'start' => $plushours_timestamp, 'hours' => 1]);
foreach ($timerecordings as $timerecording) {
if ($timerecording->hours) {
$timediff = $timerecording->hours;
$minushours = $minushours + $timediff;
}
if ($timerecording->hours_overtime) {
$timediffovertime = $timerecording->hours_overtime;
$minushoursovertime = $minushoursovertime + $timediffovertime;
}
}
$plushours_now = $plushours_now - $minushours;
$diffTime = $diffTime - $minushours;
$overtime_now = $overtime_now - $minushoursovertime;
if ($employee->plushours_now != $plushours_now || $employee->overtime_now != $overtime_now) {
$employeeupdate = new TimerecordingEmployee($employee->id);
$data = [];
$data['plushours_now'] = $plushours_now;
$data['overtime_now'] = $overtime_now;
$employeeupdate->update($data);
$employeeupdate->save();
}
@@ -457,7 +594,7 @@ class TimerecordingController extends mfBaseController
$plusHours = $employee[0]->plushours_now;
$auto_workinghours = $employee[0]->auto_workinghours;
$startdate = $employee[0]->startdate;
$overtime = $employee[0]->overtime;
$overtime = $employee[0]->overtime_now;
}
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
$holidays = TimerecordingHolidayModel::getAll();
@@ -680,6 +817,18 @@ class TimerecordingController extends mfBaseController
$sum = $timerecording->days . " Tage";
}
}
} else if ($timerecording->timerecordingCategory->hourday == 6) {
$date = date("d.m.Y", $timerecording->start);
$datadate = date("Y-m-d", $timerecording->start);
$start = date("H:i", $timerecording->start);
$end = date("H:i", $timerecording->end);
// $seconds = $timerecording->hours;
$seconds = $timerecording->end - $timerecording->start;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -743,10 +892,17 @@ class TimerecordingController extends mfBaseController
} else {
$plusHours = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
}
if ($isSeconds < 0) {
$isSeconds = $isSeconds * -1;
$isSeconds = "-" . sprintf('%02dh:%02dm', floor($isSeconds / 3600), floor($isSeconds / 60 % 60));
} else {
$isSeconds = sprintf('%02dh:%02dm', floor($isSeconds / 3600), floor($isSeconds / 60 % 60));
}
$json['success'] = true;
$json['time']['auto_workinghours'] = $auto_workinghours;
$json['time']['is'] = sprintf('%02dh:%02dm', floor($isSeconds / 3600), floor($isSeconds / 60 % 60));
$json['time']['is'] = $isSeconds;
$json['time']['must'] = sprintf('%02dh:%02dm', floor($mustSeconds / 3600), floor($mustSeconds / 60 % 60));
$json['time']['holidays'] = $holiDays;
$json['time']['plushours'] = $plusHours;

View File

@@ -5,6 +5,8 @@ class TimerecordingModel
private $user_id;
private $start;
private $end;
private $hours;
private $hours_overtime;
private $days;
private $timerecordingCategory_id;
private $businesstrip;
@@ -159,6 +161,12 @@ class TimerecordingModel
$where .= " AND `start` >= $start AND `timerecordingCategory_id` = $timerecordingCategory_id ORDER by start ASC";
}
}
if (array_key_exists("start", $filter) && array_key_exists("hours", $filter)) {
$start = $filter['start'];
if (is_numeric($start)) {
$where .= " AND `start` >= $start AND (`hours`>0 or `hours_overtime`>0) ORDER by start ASC";
}
}
if (array_key_exists("start", $filter) && array_key_exists("days", $filter)) {
$days = $filter['days'];
$start = $filter['start'];

View File

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

View File

@@ -278,6 +278,18 @@ class TimerecordingReportController extends mfBaseController
}
}
} else if ($timerecording->timerecordingCategory->hourday == 6) {
$date = date("d.m.Y", $timerecording->start);
$datadate = date("Y-m-d", $timerecording->start);
$start = date("H:i", $timerecording->start);
$end = date("H:i", $timerecording->end);
// $seconds = $timerecording->hours;
$seconds = $timerecording->end - $timerecording->start;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {

View File

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

View File

@@ -190,8 +190,14 @@ $(document).ready(function () {
$(this).prop("required", true);
$(this).prop("min", $('#date').val());
$(this).val($('#date').val());
})
} else if (parseInt($(this).find(':selected').data('hourday')) === 1) {
});
$("#div-calc-overtime").hide();
} else if (parseInt($(this).find(':selected').data('hourday')) === 1 || parseInt($(this).find(':selected').data('hourday')) === 6) {
if (parseInt($(this).find(':selected').data('hourday')) === 6) {
$("#div-calc-overtime").show();
} else {
$("#div-calc-overtime").hide();
}
$("#endtime-div").show();
$("#endtime-div").find('input').each(function () {
$(this).prop("required", true);
@@ -210,6 +216,7 @@ $(document).ready(function () {
$(this).prop("disabled", true);
});
$("#div-calc-overtime").hide();
$("#enddate-div").hide();
$("#enddate-div").find('input').each(function () {
$(this).prop("required", false);
@@ -261,6 +268,25 @@ $(document).ready(function () {
$('#end').prop("min", $('#start').val());
});
$("body").on("change", "#start,#end,#date,#timerecordingCategory_id", function () {
if (parseInt($('#timerecordingCategory_id').find(':selected').data('hourday')) === 6) {
$.post(checkWorkinghoursUrl, {
date: $.trim($('#date').val()),
start: $.trim($('#start').val()),
end: $.trim($('#end').val()),
ajax: 1
}).done(function (data) {
var result = $.parseJSON(data);
if (result.state === "success") {
$('#calc-overtime').html(result.message);
}
if (result.state === "error") {
$('#calc-overtime').html('<div class="text-danger text-bold">' + result.error + '</div>');
}
});
}
});
$("body").on("click", ".edit-button", function () {
$('#submit-button').hide().removeClass('btn-primary').addClass('btn-danger').show();
$('#submit-button').text('Ändern');

View File

@@ -198,7 +198,13 @@ $(document).ready(function () {
});
$('#days-div').hide();
$('#days').prop("required", false);
} else if (parseInt($(this).find(':selected').data('hourday')) === 1) {
$("#div-calc-overtime").hide();
} else if (parseInt($(this).find(':selected').data('hourday')) === 1 || parseInt($(this).find(':selected').data('hourday')) === 6) {
if (parseInt($(this).find(':selected').data('hourday')) === 6) {
$("#div-calc-overtime").show();
} else {
$("#div-calc-overtime").hide();
}
$("#endtime-div").show();
$("#endtime-div").find('input').each(function () {
$(this).prop("required", true);
@@ -219,6 +225,7 @@ $(document).ready(function () {
$(this).prop("disabled", true);
});
$("#div-calc-overtime").hide();
$("#enddate-div").hide();
$("#enddate-div").find('input').each(function () {
$(this).prop("required", false);
@@ -287,6 +294,27 @@ $(document).ready(function () {
}
$('#end').prop("min", $('#start').val());
});
$("body").on("change", "#start,#end,#date,#timerecordingCategory_id,#user_id_select", function () {
if (parseInt($('#timerecordingCategory_id').find(':selected').data('hourday')) === 6) {
var userid;
userid = $('#user_id_select').val();
$.post(checkWorkinghoursUrl, {
user_id: userid,
date: $.trim($('#date').val()),
start: $.trim($('#start').val()),
end: $.trim($('#end').val()),
ajax: 1
}).done(function (data) {
var result = $.parseJSON(data);
if (result.state === "success") {
$('#calc-overtime').html(result.message);
}
if (result.state === "error") {
$('#calc-overtime').html('<div class="text-danger text-bold">' + result.error + '</div>');
}
});
}
});
$("body").on("click", ".edit-button", function () {
$('#submit-button').hide().removeClass('btn-primary').addClass('btn-danger').show();