+
+
+
+ | Mitarbeiter |
Datum |
- Mitarbeiter |
- Von |
- Bis |
+ Von |
+ Bis |
Summe |
Buchungsart |
Anmerkung |
- Verbucht |
-
+ |
|
@@ -85,79 +314,9 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
|
|
|
-
- 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 = '';
- } else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) {
- $state = '';
- }
- $completed = 'Nein';
- if ($timerecording->completed == 1) $completed = 'Ja';
-
- ?>
-
- | = $state ?>= $day . " " . $date ?> |
- = $timerecording->user->name ?> |
- = $start ?> |
- = $end ?> |
- = $sum ?> |
- = $timerecording->timerecordingCategory->name ?> |
- = $timerecording->commend ?> |
- = $completed ?> |
-
-completed == 0):
-// if ($timerecording->approved == 0) : ?>
-id ?>
-
-timerecordingCategory->id ?>
-
-
-
-
-
-
-
- $timerecording->id]) ?>
-
-
-
-
-
-
@@ -169,96 +328,15 @@ $daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
+ src="= self::getResourcePath() ?>js/pages/timerecordingReport/index.js?= $git_merge_ts ?>">
\ No newline at end of file
diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php
index 28e77f3b2..c69b06823 100644
--- a/application/Timerecording/TimerecordingController.php
+++ b/application/Timerecording/TimerecordingController.php
@@ -29,12 +29,13 @@ class TimerecordingController extends mfBaseController
$datatype = $this->request->datatype;
$dataweek = $this->request->dataweek;
$datamonth = $this->request->datamonth;
+ $datayear = $this->request->datayear;
$data = [];
switch ($do) {
case "getTimerecordings":
- $return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth);
+ $return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear);
break;
default:
$return = false;
@@ -79,7 +80,14 @@ class TimerecordingController extends mfBaseController
protected function checkTimerecording($starttime, $endtime, $id = NULL)
{
- $searchArray = ['user_id' => $this->me->id, 'starttime' => $starttime, 'endtime' => $endtime];
+ $r = $this->request;
+ if ($r->user_id) {
+ $userid = $r->user_id;
+ } else {
+ $userid = $this->me->id;
+ }
+
+ $searchArray = ['user_id' => $userid, 'starttime' => $starttime, 'endtime' => $endtime];
if ($id) {
$searchArray['id'] = $id;
}
@@ -87,6 +95,7 @@ class TimerecordingController extends mfBaseController
if ($timerecordings) {
$result['state'] = "error";
$result['error'] = "Zeitüberschneidung mit anderer Buchung";
+
} else {
$result['state'] = "success";
}
@@ -132,11 +141,15 @@ class TimerecordingController extends mfBaseController
}
$data = [];
- $data['user_id'] = $this->me->id;
+ if ($r->user_id) {
+ $data['user_id'] = $r->user_id;
+ } else {
+ $data['user_id'] = $this->me->id;
+ }
$data['start'] = $starttime;
$data['end'] = $endtime;
$data['timerecordingCategory_id'] = trim($r->timerecordingCategory_id);
- $data['commend'] = trim($r->commend);
+ $data['comment'] = trim($r->comment);
if (!$data['user_id']) {
$this->layout()->setFlash("Benutzer darf nicht leer sein", "error");
@@ -153,8 +166,8 @@ class TimerecordingController extends mfBaseController
if (!$data['timerecordingCategory_id']) {
$data['timerecordingCategory_id'] = NULL;
}
- if (!$data['commend']) {
- $data['commend'] = NULL;
+ if (!$data['comment']) {
+ $data['comment'] = NULL;
}
if ($mode == "edit") {
@@ -193,7 +206,7 @@ class TimerecordingController extends mfBaseController
$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->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' erstellt');
$email->setBody($body);
$email->setFrom('zeiterfassung@xinon.at', 'Xinon Zeiterfassung');
$email->setTo('daniel.spitzer@inode.at');
@@ -217,13 +230,22 @@ class TimerecordingController extends mfBaseController
}
- protected function getTimerecordingsApi($datatype, $dataweek, $datamonth)
+ protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
{
$mustSeconds = 0;
- $isSeconds=0;
+ $isSeconds = 0;
+ $holiDays = 0;
+ $plusHours = 0;
+
$rows = [];
+ $employee = TimerecordingEmployeeModel::search(['user_id' => $this->me->id]);
+ if ($employee) {
+ $holiDays = $employee[0]->holidays;
+ $plusHours = $employee[0]->plushours;
+
+ }
$workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $this->me->id]);
- $holidays= TimerecordingHolidayModel::getAll();
+ $holidays = TimerecordingHolidayModel::getAll();
foreach ($workinghours as $workinghour) {
$whstart = strtotime(date('Y-m-d', time()) . " " . $workinghour->start . ":00");
@@ -243,8 +265,8 @@ class TimerecordingController extends mfBaseController
$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];
+ $lastdate = strtotime(date("Y-m-d", $timestamp_sonntag) . ' 23:59:59');
+ $searchArray = ['user_id' => $this->me->id, 'start' => $timestamp_montag, 'end' => $lastdate];
$daycounter = '0';
@@ -261,7 +283,26 @@ class TimerecordingController extends mfBaseController
} else if ($datatype == 2) {
$firstdate = strtotime(date("Y-m-01", $datamonth));
$lastdate = strtotime(date("Y-m-t", $datamonth));
- $daycount=date("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;
+ }
+
+
+ } else if ($datatype == 3) {
+ $firstdate = strtotime(date("Y-01-01", $datayear));
+ $lastdate = strtotime(date("Y-12-31 23:59:59", $datayear));
+ $daycount = date("t", $datamonth);
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
$searchArray = ['user_id' => $this->me->id, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
@@ -281,7 +322,8 @@ class TimerecordingController extends mfBaseController
$daysgerm = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
- $timerecordingCategoriess = TimerecordingCategoryModel::getAll();
+ $timerecordingcategories = TimerecordingCategoryModel::getAll();
+
$timerecordings = TimerecordingModel::search($searchArray);
$responsecount = count($timerecordings);
foreach ($timerecordings as $timerecording):
@@ -300,7 +342,7 @@ class TimerecordingController extends mfBaseController
$hours = floor($seconds / 3600);
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
- $isSeconds=$isSeconds+$seconds;
+ $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);
@@ -308,7 +350,23 @@ class TimerecordingController extends mfBaseController
$start = "-";
$end = "-";
$day = $daysgerm[date("w", $timerecording->start)];
-// echo $enddate-$datadate."
";
+
+ if ($lastdate < $timerecording->end) {
+ $endtimecalc = $lastdate;
+ } else {
+ $endtimecalc = $timerecording->end;
+ }
+ $summcounter = 0;
+ for ($i = $timerecording->start; $i <= $endtimecalc; $i = $i + 86400) {
+ $holidaycounter = $workingHours[date("w", $i)];
+ $isSeconds = $isSeconds + $holidaycounter;
+ $summcounter = $summcounter + $holidaycounter;
+ }
+ $seconds = $summcounter;
+ $minutes = floor(($seconds % 3600) / 60);
+ $hours = floor($seconds / 3600);
+ $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
+
} else if ($timerecording->timerecordingCategory->hourday == 3 || $timerecording->timerecordingCategory->hourday == 4) {
$date = date("d.m.Y", $timerecording->start);
$datadate = date("Y-m-d", $timerecording->start);
@@ -331,27 +389,31 @@ class TimerecordingController extends mfBaseController
data-start="' . $start . '"
data-end="' . $end . '"
data-enddate="' . $enddate . '"
- data-commend="' . $timerecording->commend . '"
+ data-comment="' . $timerecording->comment . '"
title="Bearbeiten">';
else :
$edit .= '
';
endif;
$edit .= '
';
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),
- );
+ if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
+ } else {
+ $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),
+ 'comment' => array('comment' => $timerecording->comment, 'order' => $timerecording->comment),
+ '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['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['time']['holidays'] = $holiDays;
+ $json['time']['plushours'] = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
$json['data'] = $rows;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;
diff --git a/application/Timerecording/TimerecordingModel.php b/application/Timerecording/TimerecordingModel.php
index 89911a000..5a0a16111 100644
--- a/application/Timerecording/TimerecordingModel.php
+++ b/application/Timerecording/TimerecordingModel.php
@@ -6,7 +6,7 @@ class TimerecordingModel
private $start;
private $end;
private $timerecordingCategory_id;
- private $commend;
+ private $comment;
private $approved;
private $completed;
diff --git a/application/TimerecordingEmployee/TimerecordingEmployeeController.php b/application/TimerecordingEmployee/TimerecordingEmployeeController.php
index 621bc9605..5c1228ec0 100644
--- a/application/TimerecordingEmployee/TimerecordingEmployeeController.php
+++ b/application/TimerecordingEmployee/TimerecordingEmployeeController.php
@@ -107,6 +107,7 @@ class TimerecordingEmployeeController extends mfBaseController
$data['auto_workinghours'] = trim($r->auto_workinghours);
$data['holidays'] = trim($r->holidays);
$data['plushours'] = $plushours;
+ $data['startdate'] = strtotime($r->startdate);
if (!$data['user_id']) {
diff --git a/application/TimerecordingEmployee/TimerecordingEmployeeModel.php b/application/TimerecordingEmployee/TimerecordingEmployeeModel.php
index 826d7281a..14363409e 100644
--- a/application/TimerecordingEmployee/TimerecordingEmployeeModel.php
+++ b/application/TimerecordingEmployee/TimerecordingEmployeeModel.php
@@ -6,6 +6,7 @@ class TimerecordingEmployeeModel
private $auto_workinghours;
private $holidays;
private $plushours;
+ private $startdate;
public static function find($data)
@@ -130,10 +131,10 @@ class TimerecordingEmployeeModel
$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";
+ if (array_key_exists("user_id", $filter)) {
+ $userid = $filter['user_id'];
+ if (is_numeric($userid)) {
+ $where .= " AND user_id=$userid";
}
}
diff --git a/application/TimerecordingPermit/TimerecordingPermitController.php b/application/TimerecordingPermit/TimerecordingPermitController.php
index 6b9025d78..b332c36d7 100644
--- a/application/TimerecordingPermit/TimerecordingPermitController.php
+++ b/application/TimerecordingPermit/TimerecordingPermitController.php
@@ -42,6 +42,37 @@ class TimerecordingPermitController extends mfBaseController
{
}
+ protected function sendMail($timerecordings, $type)
+ {
+ if ($type == "deny") {
+ $sendtext = "abgelehnt";
+ } else if ($type == "approve") {
+ $sendtext = "genehmigt";
+ }
+ $user = UserModel::getOne($timerecordings->user_id);
+ $timerecordingCategoriess = TimerecordingCategoryModel::search(['id' => $timerecordings->timerecordingCategory_id]);
+ $body = 'Beantrag von: ' . $user->name . '
+';
+ $body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . '
+';
+ if ($timerecordingCategoriess[0]->hourday == "1") {
+ $body .= 'von: ' . date("d.m.Y H:i", $timerecordings->start) . ' bis: ' . date("H:i", $timerecordings->end). '
+
+';
+ } else if ($timerecordingCategoriess[0]->hourday == "2") {
+ $body .= 'von: ' . date("d.m.Y", $timerecordings->start) . ' bis: ' . date("d.m.Y", $timerecordings->end) . '
+
+';
+ }
+ $body .= ucfirst($sendtext) . ' von: ' . $this->me->name . '
+ ';
+ $email = new Emailnotification();
+ $email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' ' . $sendtext);
+ $email->setBody($body);
+ $email->setFrom('zeiterfassung@xinon.at', 'Xinon Zeiterfassung');
+ $email->setTo($user->email);
+ $email->send();
+ }
protected function approveAction()
{
@@ -55,7 +86,25 @@ class TimerecordingPermitController extends mfBaseController
$data['approved'] = 1;
$timerecordings->update($data);
$timerecordings->save();
+ $this->sendMail($timerecordings, "approve");
+ $this->redirect("TimerecordingPermit");
+ }
+ protected function denyAction()
+ {
+ $id = $this->request->id;
+ $timerecordings = new Timerecording($id);
+ if (!$timerecordings->id || $timerecordings->id != $id) {
+ $this->layout()->setFlash("Buchung nicht gefunden.", "error");
+ $this->redirect("TimerecordingPermit");
+ }
+ $this->sendMail($timerecordings, "deny");
+ $timerecordings->delete();
+
+
+ if ($this->request->ajax == 1) {
+ die();
+ }
$this->redirect("TimerecordingPermit");
}
diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php
index 6d5396b79..f8004f454 100644
--- a/application/TimerecordingReport/TimerecordingReportController.php
+++ b/application/TimerecordingReport/TimerecordingReportController.php
@@ -18,13 +18,231 @@ class TimerecordingReportController extends mfBaseController
protected function indexAction()
{
-
$this->layout()->setTemplate("TimerecordingReport/Index");
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
+ $timerecordingusers = UserModel::search(['employee' => 'true']);
+ $this->layout()->set("timerecordingusers", $timerecordingusers);
$timerecordings = TimerecordingModel::getAll();
$this->layout()->set("timerecordings", $timerecordings);
+ }
+ protected function apiAction()
+ {
+ $do = $this->request->do;
+ $datatype = $this->request->datatype;
+ $dataweek = $this->request->dataweek;
+ $datamonth = $this->request->datamonth;
+ $datayear = $this->request->datayear;
+
+ $data = [];
+
+ switch ($do) {
+ case "getTimerecordings":
+ $return = $this->getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear);
+ 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 getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
+ {
+ $mustSeconds = 0;
+ $isSeconds = 0;
+ $holiDays = 0;
+ $plusHours = 0;
+
+ $rows = [];
+ $employee = TimerecordingEmployeeModel::getAll();
+ if ($employee) {
+ $holiDays = $employee[0]->holidays;
+ $plusHours = $employee[0]->plushours;
+
+ }
+ $workinghours = TimerecordingEmployeeWorkingHourModel::getAll();
+ $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");
+ $lastdate = strtotime(date("Y-m-d", $timestamp_sonntag) . ' 23:59:59');
+ $searchArray = ['start' => $timestamp_montag, 'end' => $lastdate];
+
+ $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 = ['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;
+ }
+ } else if ($datatype == 3) {
+ $firstdate = strtotime(date("Y-01-01", $datayear));
+ $lastdate = strtotime(date("Y-12-31 23:59:59", $datayear));
+ $daycount = date("t", $datamonth);
+ $lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
+ $searchArray = ['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");
+ $timerecordingcategories = 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)];
+
+ if ($lastdate < $timerecording->end) {
+ $endtimecalc = $lastdate;
+ } else {
+ $endtimecalc = $timerecording->end;
+ }
+ $summcounter = 0;
+ for ($i = $timerecording->start; $i <= $endtimecalc; $i = $i + 86400) {
+ $holidaycounter = $workingHours[date("w", $i)];
+ $isSeconds = $isSeconds + $holidaycounter;
+ $summcounter = $summcounter + $holidaycounter;
+ }
+ $seconds = $summcounter;
+ $minutes = floor(($seconds % 3600) / 60);
+ $hours = floor($seconds / 3600);
+ $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
+
+ } 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 = '
';
+ } else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) {
+ $state = '
';
+ }
+ $edit = "";
+ if ($timerecording->completed == 0 && $timerecording->timerecordingCategory->only_admin == 0):
+ if ($timerecording->approved == 0) :
+ $edit = '
';
+ else :
+ $edit .= '
';
+ endif;
+ $edit .= '
';
+ endif;
+ if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
+ } else {
+ $rows[] = array(
+ 'user' => array('user' => $timerecording->user->name, 'order' => $timerecording->user->name),
+ '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),
+ 'comment' => array('comment' => $timerecording->comment, 'order' => $timerecording->comment),
+ '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['time']['holidays'] = $holiDays;
+ $json['time']['plushours'] = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
+ $json['data'] = $rows;
+ $json['recordsFiltered'] = $responsecount;
+ $json['recordsTotal'] = $responsecount;
+ $json = json_encode($json);
+ echo trim($json);
+ die();
}
protected function addAction()
diff --git a/db/migrations/20240130163932_timerecording_employee_add_fields.php b/db/migrations/20240130163932_timerecording_employee_add_fields.php
new file mode 100644
index 000000000..c7050caa9
--- /dev/null
+++ b/db/migrations/20240130163932_timerecording_employee_add_fields.php
@@ -0,0 +1,35 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("TimerecordingEmployee", ["signed" => true]);
+ $table->addColumn("holidays_now", "integer", ["null" => false, "after" => "holidays"]);
+ $table->addColumn("startdate", "integer", ["null" => false, "after" => "plushours"]);
+ $table->addColumn("plushours_now", "integer", ["null" => false, "after" => "plushours"]);
+ $table->update();
+ }
+
+ if ($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if ($this->getEnvironment() == "thetool") {
+ $this->table("WorkerPermission")->removeColumn("startdate")->save();
+ $this->table("WorkerPermission")->removeColumn("plushours_now")->save();
+ $this->table("WorkerPermission")->removeColumn("holidays_now")->save();
+ }
+
+ if ($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/db/migrations/20240203192437_timerecording_rename_field.php b/db/migrations/20240203192437_timerecording_rename_field.php
new file mode 100644
index 000000000..83da36ce4
--- /dev/null
+++ b/db/migrations/20240203192437_timerecording_rename_field.php
@@ -0,0 +1,33 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("Timerecording");
+ $table->renameColumn('commend', 'comment')
+ ->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if($this->getEnvironment() == "thetool") {
+ $table = $this->table("Timerecording");
+ $table->renameColumn('comment', 'commend')
+ ->save();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/public/assets/css/datatables-std.css b/public/assets/css/datatables-std.css
index 67f34371b..622aeed0b 100644
--- a/public/assets/css/datatables-std.css
+++ b/public/assets/css/datatables-std.css
@@ -138,7 +138,7 @@ table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
{
color:#0d6efd;
font-size: 30px;
- margin-right:20px;
+ margin-right:10px;
cursor: pointer;
}
.active-calendar
@@ -216,7 +216,7 @@ table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
{
font-size:35px;
margin-top:5px;
- margin-right:30px;
+ margin-right:10px;
margin-bottom:20px;
}
diff --git a/public/assets/js/datatables-std.js b/public/assets/js/datatables-std.js
index 940e96466..6237d0ef2 100644
--- a/public/assets/js/datatables-std.js
+++ b/public/assets/js/datatables-std.js
@@ -38,7 +38,14 @@ $('#filterrow th').each(function (i) {
});
table = $('#datatable').DataTable({
- responsive: true,
+ responsive: {
+ breakpoints: [
+ {name: 'desktop', width: Infinity},
+ {name: 'tablet', width: 1024},
+ {name: 'fablet', width: 768},
+ {name: 'phone', width: 480}
+ ]
+ },
buttons: [
{
extend: 'excelHtml5',
diff --git a/public/js/pages/timerecording/index.js b/public/js/pages/timerecording/index.js
index b32a175ca..3b4d15239 100644
--- a/public/js/pages/timerecording/index.js
+++ b/public/js/pages/timerecording/index.js
@@ -78,10 +78,13 @@ table = $('#datatable').DataTable({
d.dataweek = $('#dataweek').val();
d.datamonth = $('#datamonth').val();
+ d.datayear = $('#datayear').val();
},
"dataSrc": function (json) {
$('#is-time').text(json.time.is);
$('#must-time').text(json.time.must);
+ $('#holidays').text(json.time.holidays);
+ $('#plushours').text(json.time.plushours);
return json.data;
}
@@ -120,8 +123,8 @@ table = $('#datatable').DataTable({
}
, {
"data": {
- _: "commend.commend",
- "sort": "commend.order"
+ _: "comment.comment",
+ "sort": "comment.order"
},
className: "text-center"
}, {
@@ -206,9 +209,9 @@ $(document).ready(function () {
})
}
if (parseInt($(this).find(':selected').data('comment')) === 1) {
- $('#commend').prop("required", true);
+ $('#comment').prop("required", true);
} else {
- $('#commend').prop("required", false);
+ $('#comment').prop("required", false);
}
});
$("body").on("change", "#date", function () {
@@ -216,6 +219,8 @@ $(document).ready(function () {
if ($('#date').val() > $('#enddate').val()) {
$('#enddate').prop("min", $('#date').val());
$('#enddate').val($('#date').val());
+ } else {
+ $('#enddate').prop("min", $('#date').val());
}
}
});
@@ -237,7 +242,7 @@ $(document).ready(function () {
$('#start').val($(this).data('start'));
$('#end').val($(this).data('end'));
$('#enddate').val($(this).data('enddate'));
- $('#commend').val($(this).data('commend'));
+ $('#comment').val($(this).data('comment'));
$('.alert-success').remove();
window.scrollTo(0, 0);
});
@@ -248,7 +253,7 @@ $(document).ready(function () {
$('#id').val('');
});
- $("body").on("change", "#dataweek,#datamonth", function () {
+ $("body").on("change", "#dataweek,#datamonth,#datayear", function () {
table.ajax.reload();
});
$("body").on("click", ".display-calendar", function () {
@@ -258,11 +263,19 @@ $(document).ready(function () {
$(this).addClass('active-calendar');
if ($(this).data('datatype') == "1") {
- console.log($(this).data('datatype'));
$('#dataweek-col').show();
+ $('#dynamictime-div').show();
$('#datamonth-col').hide();
+ $('#datayear-col').hide();
} else if ($(this).data('datatype') == "2") {
$('#datamonth-col').show();
+ $('#dynamictime-div').show();
+ $('#dataweek-col').hide();
+ $('#datayear-col').hide();
+ } else if ($(this).data('datatype') == "3") {
+ $('#datayear-col').show();
+ $('#dynamictime-div').hide();
+ $('#datamonth-col').hide();
$('#dataweek-col').hide();
}
$(".select2").select2();
@@ -290,7 +303,7 @@ $(document).ready(function () {
enddate: $.trim($('#enddate').val()),
start: $.trim($('#start').val()),
end: $.trim($('#end').val()),
- commend: $.trim($('#commend').val()),
+ comment: $.trim($('#comment').val()),
ajax: 1
}).done(function (data) {
var result = $.parseJSON(data);
diff --git a/public/js/pages/timerecordingReport/index.js b/public/js/pages/timerecordingReport/index.js
new file mode 100644
index 000000000..ba924874e
--- /dev/null
+++ b/public/js/pages/timerecordingReport/index.js
@@ -0,0 +1,360 @@
+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('
');
+
+ } else {
+ $(this).html('
');
+ }
+});
+
+table = $('#datatable').DataTable({
+ responsive: true,
+ "order": [[1, "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('
');
+ $('#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();
+ d.datayear = $('#datayear').val();
+ },
+ "dataSrc": function (json) {
+ $('#is-time').text(json.time.is);
+ $('#must-time').text(json.time.must);
+ $('#holidays').text(json.time.holidays);
+ $('#plushours').text(json.time.plushours);
+ return json.data;
+ }
+
+ },
+ "columns": [
+ {
+ "data": {
+ _: "user.user",
+ "sort": "user.order"
+ },
+ className: "text-nowrap"
+ },
+ {
+ "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": {
+ _: "comment.comment",
+ "sort": "comment.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) {
+ $('#comment').prop("required", true);
+ } else {
+ $('#comment').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());
+ } else {
+ $('#enddate').prop("min", $('#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();
+ $('#user_id_select').prop('disabled', true);
+ $('#user_id_input').prop('disabled', false);
+
+ $('#user_id_select').val($(this).data('userid')).change();
+ $('#user_id_input').val($(this).data('userid'));
+
+ $('#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'));
+ $('#comment').val($(this).data('comment'));
+ $('.alert-success').remove();
+ window.scrollTo(0, 0);
+ });
+ $("body").on("click", "#cancel-button", function () {
+ $('#submit-button').text('Speichern');
+ $('#cancel-button').hide();
+ $('#user_id_select').prop('disabled', false);
+ $('#user_id_input').prop('disabled', true);
+ $('#user_id_select').change();
+ $('#timerecordingCategory_id').val($(this).data('category')).change();
+ $('#id').val('');
+ });
+
+ $("body").on("change", "#dataweek,#datamonth,#datayear", function () {
+ table.ajax.reload(null, false);
+ });
+ $("body").on("click", ".display-calendar", function () {
+ $('.display-calendar').each(function (index) {
+ $(this).removeClass('active-calendar');
+ });
+ $(this).addClass('active-calendar');
+
+ if ($(this).data('datatype') == "1") {
+ $('#dataweek-col').show();
+ $('#dynamictime-div').show();
+ $('#datamonth-col').hide();
+ $('#datayear-col').hide();
+ } else if ($(this).data('datatype') == "2") {
+ $('#datamonth-col').show();
+ $('#dynamictime-div').show();
+ $('#dataweek-col').hide();
+ $('#datayear-col').hide();
+ } else if ($(this).data('datatype') == "3") {
+ $('#datayear-col').show();
+ $('#dynamictime-div').hide();
+ $('#datamonth-col').hide();
+ $('#dataweek-col').hide();
+ }
+ $(".select2").select2();
+ table.ajax.reload(null, false);
+ });
+ $("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(null, false);
+ });
+ }
+ })
+
+ $('form').submit(function (e) {
+ e.preventDefault();
+ $('#alert-box').remove();
+ var userid;
+ if ($.trim($('#id').val())) {
+ userid = $('#user_id_input').val();
+ }
+
+ $.post(insertUrl, {
+ id: $.trim($('#id').val()),
+ user_id: userid,
+ timerecordingCategory_id: $.trim($('#timerecordingCategory_id').val()),
+ date: $.trim($('#date').val()),
+ enddate: $.trim($('#enddate').val()),
+ start: $.trim($('#start').val()),
+ end: $.trim($('#end').val()),
+ comment: $.trim($('#comment').val()),
+ ajax: 1
+ }).done(function (data) {
+ var result = $.parseJSON(data);
+ if (result.state === "success") {
+ $('.wrapper .container-fluid').prepend(`
+
+
+
+
Erfolgreich
+ ` + result.message + `
+
`);
+ }
+ if (result.state === "error") {
+ $('.wrapper .container-fluid').prepend(`
+
+
+
+
Fehler
+ ` + result.error + `
+
`);
+ }
+ $('#submit-button').hide().removeClass('btn-danger').addClass('btn-primary').show();
+ $('#submit-button').text('Speichern');
+ $('#cancel-button').hide();
+ $('#user_id_select').prop('disabled', false);
+ $('#user_id_input').prop('disabled', true);
+ $('#user_id_select').change();
+ $('#id').val('');
+ table.ajax.reload(null, false);
+ });
+ });
+})
+;
\ No newline at end of file