diff --git a/Layout/default/menu.php b/Layout/default/menu.php
index eaaf84f64..d9abd36ee 100644
--- a/Layout/default/menu.php
+++ b/Layout/default/menu.php
@@ -40,9 +40,11 @@
can('Fibu')): ?>
"> Freigaben
"> Auswertung/Korrektur
+
"> Verrechnung
"> Buchungsarten
"> Feiertage
"> Personaladministration
+
"> Fahrzeugverwaltung
@@ -96,6 +98,9 @@
is(["Admin","netowner","lineplanner","lineworker"]) && $me->can("Linework")): ?>
"> Leitungsbau
is(["Admin","netowner","netoperator","lineworker"]) && $me->can("Patching")): ?>
is(["Admin","netowner","pipeplanner","lineplanner","pipeworker","netoperator","lineworker"]) && $me->can("Filestore")): ?>
"> Dateiablage
+is(["Admin","netowner","pipeplanner","pipeplanner"]) && $me->is("employee")): ?>
+is(["Admin","netowner","lineplanner","lineworker"]) && $me->is("employee")): ?>
+is(["Admin","netowner","lineplanner","lineworker"]) && $me->is("employee")): ?>
diff --git a/application/Timerecording/Timerecording.php b/application/Timerecording/Timerecording.php
index 86c9aeade..e6cfdbb8e 100644
--- a/application/Timerecording/Timerecording.php
+++ b/application/Timerecording/Timerecording.php
@@ -6,7 +6,8 @@ class Timerecording extends mfBaseModel
private $creator;
private $user;
private $timerecordingCategory;
-
+ private $timerecordingCar;
+
public function getProperty($name)
diff --git a/application/Timerecording/TimerecordingController.php b/application/Timerecording/TimerecordingController.php
index 187a0c421..20b4889a0 100644
--- a/application/Timerecording/TimerecordingController.php
+++ b/application/Timerecording/TimerecordingController.php
@@ -22,7 +22,9 @@ class TimerecordingController extends mfBaseController
$this->updateHolidays($this->me->id);
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
+ $timerecordingCars = TimerecordingCarModel::search(['timerecording' => 1]);
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
+ $this->layout()->set("timerecordingCars", $timerecordingCars);
$this->layout()->setTemplate("Timerecording/Index");
}
@@ -206,13 +208,12 @@ class TimerecordingController extends mfBaseController
$employee = TimerecordingEmployeeModel::search(['user_id' => $userid]);
$plushours = $employee[0]->plushours_now * 1.25;
- $overtime = $employee[0]->overtime * 1.5;
+ $overtime = $employee[0]->overtime_now * 1.5;
$overtimesum = $plushours + $overtime;
if ($overtimesum < $isTime) {
if ($overtimesum < 0) {
$overtimesum = 0;
}
-
$result['state'] = "error";
$result['error'] = "Maximal verfügbarer ZA: " . sprintf('%02dh:%02dm', floor($overtimesum / 3600), floor($overtimesum / 60 % 60)) . ".";
echo json_encode($result);
@@ -221,7 +222,7 @@ class TimerecordingController extends mfBaseController
if ($plushours >= $isTime) {
$isTime = $isTime * 0.8;
$return['hours'] = $isTime;
- } elseif ($plushours <= 0) {
+ } elseif ($plushours == 0) {
$isTime = $isTime * 0.66666666666666666666666666666667;
$return ['hours_overtime'] = $isTime;
} else {
@@ -265,7 +266,7 @@ class TimerecordingController extends mfBaseController
$this->updateOpenTimerecording();
}
$data = [];
- if ($hourday == 1 || $hourday == 6) {
+ if ($hourday == 1 || $hourday == 6 || $hourday == 7) {
$starttime = strtotime($r->date . " " . $r->start . ":00");
$endtime = strtotime($r->date . " " . $r->end . ":00");
if ($hourday == 6) {
@@ -282,7 +283,7 @@ class TimerecordingController extends mfBaseController
$endtime = strtotime($r->date . " 23:59:00");
}
- if ($hourday != 5) {
+ if ($hourday != 5 && $hourday != 7) {
$result = $this->checkTimerecording($starttime, $endtime, $id);
}
if ($result['state'] == "error") {
@@ -321,6 +322,19 @@ class TimerecordingController extends mfBaseController
$data['businesstrip_info'] = $r->businesstrip_info;
$data['homeoffice'] = $r->homeoffice;
$data['days'] = $r->days;
+ $data['timerecordingCar_id'] = $r->timerecordingCar_id;
+ $data['mileage_start'] = $r->mileage_start;
+ $data['mileage_end'] = $r->mileage_end;
+
+ if (!$data['timerecordingCar_id']) {
+ $data['timerecordingCar_id'] = NULL;
+ }
+ if (!$data['mileage_start']) {
+ $data['mileage_start'] = NULL;
+ }
+ if (!$data['mileage_end']) {
+ $data['mileage_end'] = NULL;
+ }
if (!$data['businesstrip'] || $data['businesstrip'] == "false") {
$data['businesstrip'] = 0;
@@ -436,6 +450,7 @@ class TimerecordingController extends mfBaseController
$this->updateHolidays($data['user_id']);
}
$this->updatePlushours($data['user_id']);
+ TimerecordingCarModel::calcMileage();
}
if ($mode == "edit") {
@@ -828,6 +843,16 @@ class TimerecordingController extends mfBaseController
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
+ } else if ($timerecording->timerecordingCategory->hourday == 7) {
+ $date = date("d.m.Y", $timerecording->start);
+ $datadate = date("Y-m-d", $timerecording->start);
+ $start = date("H:i", $timerecording->start);
+ $end = date("H:i", $timerecording->end);
+ $seconds = $timerecording->end - $timerecording->start;
+ $minutes = floor(($seconds % 3600) / 60);
+ $hours = floor($seconds / 3600);
+ $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
+ $day = $daysgerm[date("w", $timerecording->start)];
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -836,8 +861,17 @@ class TimerecordingController extends mfBaseController
$state = '
';
}
$edit = "";
- if ($timerecording->businesstrip == 1) {
- $category = "
" . $timerecording->timerecordingCategory->name . " (Dienstreise: " . $timerecording->businesstrip_info . ")";
+ if ($timerecording->timerecordingCategory->hourday == 7) {
+ $distance = $timerecording->mileage_end - $timerecording->mileage_start;
+ $category = "
" . $timerecording->timerecordingCategory->name . "(" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM) (Zielort: " . $timerecording->businesstrip_info . ")";
+ } else if ($timerecording->businesstrip == 1) {
+ if ($timerecording->timerecordingCar) {
+ $distance = $timerecording->mileage_end - $timerecording->mileage_start;
+ $car = " (" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM)";
+ } else {
+ $car = "";
+ }
+ $category = "
" . $timerecording->timerecordingCategory->name . "$car (Dienstreise: " . $timerecording->businesstrip_info . ")";
} else if ($timerecording->homeoffice == 1) {
$category = "
" . $timerecording->timerecordingCategory->name . " (Homeoffice)";
} else {
@@ -860,13 +894,16 @@ class TimerecordingController extends mfBaseController
data-businesstrip="' . $timerecording->businesstrip . '"
data-businesstripinfo="' . $timerecording->businesstrip_info . '"
data-homeoffice="' . $timerecording->homeoffice . '"
+ data-car="' . $timerecording->timerecordingCar_id . '"
+ data-mileagestart="' . $timerecording->mileage_start . '"
+ data-mileageend="' . $timerecording->mileage_end . '"
title="Bearbeiten">';
else :
$edit .= '
';
endif;
$edit .= '
';
endif;
- if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
+ if ($datatype == 3 && ($timerecording->timerecordingCategory->hourday == 1 || $timerecording->timerecordingCategory->hourday == 7 || $timerecording->timerecordingCategory->hourday == 5)) {
} else {
$rows[] = array(
'date' => array('date' => $state . $day . " " . $date, 'order' => $orderdate),
diff --git a/application/Timerecording/TimerecordingModel.php b/application/Timerecording/TimerecordingModel.php
index a777b5c9f..e90456ed6 100644
--- a/application/Timerecording/TimerecordingModel.php
+++ b/application/Timerecording/TimerecordingModel.php
@@ -11,6 +11,10 @@ class TimerecordingModel
private $timerecordingCategory_id;
private $businesstrip;
private $businesstrip_info;
+ private $timerecordingCar_id;
+ private $mileage_start;
+ private $mileage_end;
+
private $homeoffice;
private $comment;
private $approved;
@@ -151,7 +155,7 @@ class TimerecordingModel
$start = $filter['start'];
$end = $filter['end'];
if (is_numeric($start) && is_numeric($end)) {
- $where .= " AND ((`start` >= $start AND `start` <= $end) OR (`end` >= $start AND `end` <= $end) OR `end` is NULL) ORDER by user_id ASC";
+ $where .= " AND ((`start` >= $start AND `start` <= $end) OR (`end` >= $start AND `end` <= $end) OR `end` is NULL) ORDER by user_id,start ASC";
}
}
if (array_key_exists("start", $filter) && array_key_exists("timerecordingCategory_id", $filter)) {
@@ -174,7 +178,20 @@ class TimerecordingModel
$where .= " AND `start` >= $start AND `days` !=0 ORDER by start ASC";
}
}
+ if (array_key_exists("timerecordingCar_id", $filter)) {
+ $timerecordingCar = $filter['timerecordingCar_id'];
+ if (is_numeric($timerecordingCar)) {
+ $where .= " AND `timerecordingCar_id` = $timerecordingCar ORDER by mileage_end DESC LIMIT 1";
+ }
+ }
+ if (array_key_exists("timerecordingCar_id_all", $filter)) {
+ $timerecordingCar = $filter['timerecordingCar_id_all'];
+
+ if (is_numeric($timerecordingCar)) {
+ $where .= " AND `timerecordingCar_id` = $timerecordingCar ORDER by mileage_start ASC";
+ }
+ }
if (array_key_exists("starttime", $filter) && array_key_exists("endtime", $filter)) {
$starttime = $filter['starttime'];
@@ -182,11 +199,11 @@ class TimerecordingModel
$id = $filter['id'];
if (is_numeric($starttime) && is_numeric($endtime)) {
if ($id && is_numeric($id)) {
- $where .= " AND `id` != $id";
+ $where .= " AND `id` != $id ";
}
- $where .= " AND (((`start` <= $starttime AND `end` > $starttime ) OR (`start` > $endtime AND `end` < $endtime) OR (`start` > $starttime AND `end` > $starttime AND `start` <= $endtime AND `end` <= $endtime) OR (`start` > $starttime AND `end` > $starttime AND `start` < $endtime AND `end` > $endtime) OR (`start` = $starttime AND `end` = $endtime )) OR ( `start` <= $starttime AND `end` IS NULL)) ORDER by user_id ASC";
+ $where .= " AND (((`start` <= $starttime AND `end` > $starttime ) OR (`start` > $endtime AND `end` < $endtime) OR (`start` > $starttime AND `end` > $starttime AND `start` <= $endtime AND `end` <= $endtime) OR (`start` > $starttime AND `end` > $starttime AND `start` < $endtime AND `end` > $endtime) OR (`start` = $starttime AND `end` = $endtime )) OR ( `start` <= $starttime AND `end` IS NULL)) AND `days` = 0 ORDER by user_id,start ASC";
-//var_dump($where);exit;
+//echo ($where);die();
}
}
if (array_key_exists("type", $filter)) {
diff --git a/application/TimerecordingBilling/TimerecordingBillingController.php b/application/TimerecordingBilling/TimerecordingBillingController.php
new file mode 100644
index 000000000..a3348342a
--- /dev/null
+++ b/application/TimerecordingBilling/TimerecordingBillingController.php
@@ -0,0 +1,184 @@
+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()
+ {
+ $startdate = 1709254800;
+ $today = time();
+ $months = [];
+ $month = $startdate;
+ while ($month < $today) {
+ $months[] = date("m.Y", $month);
+ $month = strtotime("+1 month", $month);
+ }
+ $this->layout()->set("months", $months);
+ $this->layout()->setTemplate("TimerecordingBilling/Index");
+ }
+
+ protected function detailAction()
+ {
+ $r = $this->request;
+ $month = $r->get("month");
+ if (!$month) {
+ $this->redirect("TimerecordingBilling");
+ }
+ $month = strtotime("01." . $month);
+ $timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
+ foreach ($timerecordingsEmolyees as $timerecordingsEmolyee) {
+ $user = new User($timerecordingsEmolyee->user_id);
+ $employee_number = (string)$user->getFlag('employee_number');
+ $timerecordingReport = new TimerecordingReportController();
+ $timerecordings[$timerecordingsEmolyee->user_id]['user_id'] = $timerecordingsEmolyee->user_id;
+ $timerecordings[$timerecordingsEmolyee->user_id]['user_name'] = $timerecordingsEmolyee->user->name;
+ $timerecordings[$timerecordingsEmolyee->user_id]['employee_number'] = $employee_number;
+ $timerecordings[$timerecordingsEmolyee->user_id]['data'] = $timerecordingReport->getTimerecordingsTimes('2', $month, $month, $month, $timerecordingsEmolyee->user_id, 0);
+ }
+ $this->layout()->set("timerecordings", $timerecordings);
+ $this->layout()->setTemplate("TimerecordingBilling/Detail");
+ $this->layout()->set("month", date("m.Y", $month));
+ }
+
+ protected function apiAction()
+ {
+ $do = $this->request->do;
+ $month = $this->request->month;
+
+ $data = [];
+
+ switch ($do) {
+ case "generatebmdexport":
+ $return = $this->generateBmdExport($month);
+ break;
+ case "generatebmdexportnlz":
+ $return = $this->generateBmdExport($month, 1);
+ 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 editAction()
+ {
+
+ }
+
+ protected function saveAction()
+ {
+
+ }
+
+
+ protected function deleteAction()
+ {
+
+ }
+
+ protected function generateBmdLine()
+ {
+
+ }
+
+ protected function generateBmdExport($month, $nlz = 0)
+ {
+ //create and download csv file
+ $filename = "BMDExport_" . $month . ".csv";
+ $file = fopen("php://output", 'w');
+ header('Content-Type: text/csv; charset=utf-8');
+ header('Content-Disposition: attachment; filename=' . $filename);
+ if ($nlz == 0) {
+ $headerarray = ["Monat", "Firma", "Mitarbeiter", "Lohnart", "Menge", "Satz", "Betrag", "Kostenstelle", "NLZ-Kennzeichen", "NLZ Von-Datum", "NLZ Bis-Datum"];
+ fputcsv($file, $headerarray, ";");
+ } else {
+ $headerarray = ["Firma", "Mitarbeiter", "DV-Nr", "Art", "Sonderzeit", "Verarbeitungs-KZ", "Von", "Bis", "Verwaltung", "Bezahlt"];
+ fputcsv($file, $headerarray, ";");
+ }
+ $month = strtotime("01." . $month);
+ $monthbmd = date("n", $month);
+ $companybmd = "1";
+ $timerecordingsEmolyees = TimerecordingEmployeeModel::getAll();
+ foreach ($timerecordingsEmolyees as $timerecordingsEmolyee) {
+ $user = new User($timerecordingsEmolyee->user_id);
+ $employee_number = (string)$user->getFlag('employee_number');
+ $employeetypesbmd = TimerecordingEmployeeModel::$employeetypesbmd;
+ $employee_type = $employeetypesbmd[$timerecordingsEmolyee->type];
+ $timerecordingReport = new TimerecordingReportController();
+ $timerecording = $timerecordingReport->getTimerecordingsTimes('2', $month, $month, $month, $timerecordingsEmolyee->user_id, 0);
+
+ foreach ($timerecording['time']['isclean'] as $key => $value) {
+ $hours = $value;
+ //calc ishours in hours
+ $hours = $hours / 3600;
+ $hours = round($hours, 2);
+ $hours = str_replace(".", ",", $hours);
+ if (strpos($key, ',') !== false && $nlz == 0) {
+ $bodyarray = [$monthbmd, $companybmd, $employee_number, $employee_type, $hours, "", "", "", "", "", ""];
+ fputcsv($file, $bodyarray, ";");
+ } else if (strpos($key, ',') === false && $nlz == 1) {
+
+ }
+
+ }
+
+ if ($timerecording['time']['diet'] > 0 && $nlz == 0) {
+ $dietsum = round($timerecording['time']['diet'], 2);
+ $dietsum = str_replace(".", ",", $dietsum);
+ $bodyarray = [$monthbmd, $companybmd, $employee_number, "2500", "", "", $dietsum, "", "", "", ""];
+ fputcsv($file, $bodyarray, ";");
+ }
+ if (!empty($timerecording['time']['nlztimes']) && $nlz == 1) {
+ foreach ($timerecording['time']['nlztimes'] as $nlztime) {
+ if ($nlztime['minutes']) {
+ $time = $nlztime['minutes'] / 60;
+ $time = round($time, 2);
+ $time = str_replace(".", ",", $time);
+ if ($nlztime['unpaid'] == "0") {
+ $pay = $time;
+ } else {
+ $pay = 0;
+ }
+
+ } else {
+ $time = "";
+ $pay = "";
+ }
+
+ $bodyarray = [$companybmd, $employee_number, 1, $nlztime['categoryshort'], "", "3", $nlztime['start'], $nlztime['end'], $time, $pay];
+ fputcsv($file, $bodyarray, ";");
+ }
+ }
+
+ }
+
+
+ die();
+
+ }
+}
diff --git a/application/TimerecordingBilling/TimerecordingBillingModel.php b/application/TimerecordingBilling/TimerecordingBillingModel.php
new file mode 100644
index 000000000..75e6eec9f
--- /dev/null
+++ b/application/TimerecordingBilling/TimerecordingBillingModel.php
@@ -0,0 +1,8 @@
+$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;
+}
+
+}
\ No newline at end of file
diff --git a/application/TimerecordingCar/TimerecordingCarController.php b/application/TimerecordingCar/TimerecordingCarController.php
new file mode 100644
index 000000000..548f92b2a
--- /dev/null
+++ b/application/TimerecordingCar/TimerecordingCarController.php
@@ -0,0 +1,173 @@
+needlogin = true;
+ $me = new User();
+ $me->loadMe();
+ $this->me = $me;
+ $this->layout()->set("me", $me);
+
+ if (!$me->is(["Admin"])) {
+ $this->redirect("Dashboard");
+ }
+ }
+
+ protected function indexAction()
+ {
+
+ $this->layout()->setTemplate("TimerecordingCar/Index");
+ $timerecordingcars = TimerecordingCarModel::getAll();
+ $this->layout()->set("timerecordingcars", $timerecordingcars);
+
+ }
+
+ protected function detailAction()
+ {
+ $timerecordingcarid = $this->request->id;
+ $this->layout()->setTemplate("TimerecordingCar/Detail");
+ $timerecordingcar = TimerecordingCarModel::getOne($timerecordingcarid);
+ $this->layout()->set("timerecordingcar", $timerecordingcar);
+ $timerecordings = TimerecordingModel::search(["timerecordingCar_id_all" => $timerecordingcarid]);
+ $this->layout()->set("timerecordings", $timerecordings);
+
+ }
+
+ protected function addAction()
+ {
+
+ $this->layout()->setTemplate("TimerecordingCar/Form");
+
+ }
+
+ protected function editAction()
+ {
+ $id = $this->request->id;
+
+ if (!is_numeric($id) || !$id) {
+ $this->layout()->setFlash("Auto nicht gefunden", "error");
+ $this->redirect("TimerecordingCar");
+ }
+
+ $timerecordingcars = new TimerecordingCar($id);
+ if ($timerecordingcars->id != $id) {
+ $this->layout()->setFlash("Auto nicht gefunden", "error");
+ $this->redirect("TimerecordingCar");
+ }
+
+ $this->layout()->set("timerecordingcars", $timerecordingcars);
+ return $this->addAction();
+ }
+
+ protected function saveAction()
+ {
+ $r = $this->request;
+ $id = $r->id;
+ //var_dump($r->get());exit;
+ if (is_numeric($id) && $id > 0) {
+ $mode = "edit";
+ $timerecordingcars = new TimerecordingCar($id);
+ if (!$timerecordingcars->id) {
+ $this->layout()->setFlash("Autos nicht gefunden", "error");
+ $this->redirect("TimerecordingCar");
+ }
+ } else {
+ $mode = "add";
+ }
+
+ $data = [];
+ $data['number_plate'] = trim($r->number_plate);
+ $data['brand'] = trim($r->brand);
+ $data['model'] = trim($r->model);
+ $data['mileage'] = trim($r->mileage);
+ $data['initial_approval'] = strtotime($r->initial_approval);
+ $data['timerecording'] = $r->timerecording;
+ $data['first_approval'] = trim($r->first_approval);
+
+
+ if (!$data['initial_approval']) {
+ $data['initial_approval'] = null;
+ }
+
+ if (!$data['timerecording']) {
+ $data['timerecording'] = 0;
+ }
+ if (!$data['mileage']) {
+ $data['mileage'] = null;
+ }
+
+ if (!$data['first_approval'] || trim($data['first_approval']) == "") {
+ $data['first_approval'] = null;
+ }
+
+ if (!$data['number_plate']) {
+ $this->layout()->setFlash("Kennzeichen darf nicht leer sein", "error");
+ $this->redirect("TimerecordingCar");
+ }
+ if (!$data['brand']) {
+ $this->layout()->setFlash("Marke darf nicht leer sein", "error");
+ $this->redirect("TimerecordingCar");
+ }
+ if (!$data['model']) {
+ $this->layout()->setFlash("Model/Typ darf nicht leer sein", "error");
+ $this->redirect("TimerecordingCar");
+ }
+
+
+// var_dump($_FILES);
+// var_dump($upload);
+// exit;
+
+
+ if ($mode == "edit") {
+ $timerecordingcars->update($data);
+
+ } else {
+ $timerecordingcars = TimerecordingCarModel::create($data);
+ }
+// var_dump($filestore);
+// exit;
+ $id = $timerecordingcars->save();
+
+ $returnUrl = "TimerecordingCar";
+ $returnAction = "Index";
+ $returnVariables = array();
+ $returnAnker = "";
+ if ($this->request->returnto == "detail") {
+ $returnUrl = "TimerecordingCar";
+ $returnAction = "detail";
+ $returnVariables = array("id" => $id);
+
+ }
+ TimerecordingCarModel::calcMileage();
+ if (!$id) {
+ $this->layout()->setFlash("Auto konnte nicht angelegt werden", "error");
+ $this->redirect("TimerecordingCar");
+ }
+
+ if ($mode == "edit") {
+ $this->layout()->setFlash("Auto erfolgreich geändert", "success");
+ } else if ($mode = "add") {
+ $this->layout()->setFlash("Auto erfolgreich angelegt", "success");
+ }
+ $this->redirect($returnUrl, $returnAction, $returnVariables, $returnAnker);
+ }
+
+
+ protected function deleteAction()
+ {
+ $id = $this->request->id;
+ $timerecordingcars = new TimerecordingCar($id);
+ if (!$timerecordingcars->id || $timerecordingcars->id != $id) {
+ $this->layout()->setFlash("Auto nicht gefunden.", "error");
+ $this->redirect("TimerecordingCar");
+ }
+
+ $timerecordingcars->delete();
+ $this->redirect("TimerecordingCar");
+ }
+
+}
diff --git a/application/TimerecordingCar/TimerecordingCarModel.php b/application/TimerecordingCar/TimerecordingCarModel.php
new file mode 100644
index 000000000..ad78e52d8
--- /dev/null
+++ b/application/TimerecordingCar/TimerecordingCarModel.php
@@ -0,0 +1,156 @@
+ $value) {
+ if (property_exists(get_called_class(), $field)) {
+ if (substr($field, 0, 5) == "vlan_" && !$value) {
+ $model->$field = null;
+ continue;
+ }
+ $model->$field = $value;
+ }
+ }
+
+ $me = mfValuecache::singleton()->get("me");
+ if (!$me) {
+ $me = new User();
+ $me->loadMe();
+ mfValuecache::singleton()->set("me", $me);
+ }
+
+ if ($model->create_by === null) {
+ $model->create_by = $me->id;
+ }
+ if ($model->edit_by === null) {
+ $model->edit_by = $me->id;
+ }
+
+ return $model;
+ }
+
+ public static function getOne($id)
+ {
+ if (!is_numeric($id) || !$id) {
+ throw new Exception("Invalid number", 400);
+ }
+ $item = [];
+ $db = FronkDB::singleton();
+
+ $res = $db->select("TimerecordingCar", "*", "id=$id LIMIT 1");
+ if ($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new TimerecordingCar($data);
+ }
+ return $item;
+ }
+
+ public static function calcMileage()
+ {
+ $TimerecordingCars = self::getAll();
+ foreach ($TimerecordingCars as $TimerecordingCar) {
+ $timerecording = TimerecordingModel::search(["timerecordingCar_id" => $TimerecordingCar->id]);
+ if (!$timerecording) {
+ if ($TimerecordingCar->mileage_now != $TimerecordingCar->mileage) {
+ $TimerecordingCar->mileage_now = $TimerecordingCar->mileage;
+ $TimerecordingCar->save();
+ }
+ } else {
+ if (!$TimerecordingCar->mileage_now || $TimerecordingCar->mileage_now < $timerecording[0]->mileage_end) {
+ $TimerecordingCar->mileage_now = $timerecording[0]->mileage_end;
+ $TimerecordingCar->save();
+ } else if ($timerecording[0]->mileage_end < $TimerecordingCar->mileage) {
+ $TimerecordingCar->mileage_now = $TimerecordingCar->mileage;
+ $TimerecordingCar->save();
+ }
+ }
+ }
+
+ }
+
+ public static function getAll()
+ {
+ $items = [];
+
+ $db = FronkDB::singleton();
+
+ $res = $db->select("TimerecordingCar", "*", "1=1");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[] = new TimerecordingCar($data);
+ }
+ }
+ return $items;
+
+ }
+
+ public static function getFirst()
+ {
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("TimerecordingCar", "*", "$where ");
+ if ($db->num_rows($res)) {
+ $data = $db->fetch_object($res);
+ $item = new TimerecordingCar($data);
+ if ($item->id) {
+ return $item;
+ } else {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static function search($filter)
+ {
+ $items = [];
+ $db = FronkDB::singleton();
+
+ $where = self::getSqlFilter($filter);
+ $res = $db->select("TimerecordingCar", "*", "$where");
+ if ($db->num_rows($res)) {
+ while ($data = $db->fetch_object($res)) {
+ $items[] = new TimerecordingCar($data);
+ }
+ }
+ return $items;
+ }
+
+ private static function getSqlFilter($filter)
+ {
+ $where = "1=1 ";
+
+ //var_dump($filter);exit;
+ if (array_key_exists("timerecording", $filter)) {
+ $timerecording = $filter['timerecording'];
+ if (is_numeric($timerecording)) {
+ $where .= " AND timerecording=$timerecording";
+ }
+ }
+
+ //var_dump($filter, $where);exit;
+ return $where;
+ }
+
+}
diff --git a/application/TimerecordingCategory/TimerecordingCategoryController.php b/application/TimerecordingCategory/TimerecordingCategoryController.php
index 561298780..1b4f115d1 100644
--- a/application/TimerecordingCategory/TimerecordingCategoryController.php
+++ b/application/TimerecordingCategory/TimerecordingCategoryController.php
@@ -87,6 +87,7 @@ class TimerecordingCategoryController extends mfBaseController
$data['require_comment'] = trim($r->require_comment);
$data['only_admin'] = trim($r->only_admin);
$data['businesstrip'] = trim($r->businesstrip);
+ $data['unpaid'] = trim($r->unpaid);
if (!$data['name']) {
@@ -107,6 +108,9 @@ class TimerecordingCategoryController extends mfBaseController
if (!$data['businesstrip']) {
$data['businesstrip'] = 0;
}
+ if (!$data['unpaid']) {
+ $data['unpaid'] = 0;
+ }
// var_dump($_FILES);
// var_dump($upload);
// exit;
diff --git a/application/TimerecordingCategory/TimerecordingCategoryModel.php b/application/TimerecordingCategory/TimerecordingCategoryModel.php
index 1d343e2d2..eaa7a89be 100644
--- a/application/TimerecordingCategory/TimerecordingCategoryModel.php
+++ b/application/TimerecordingCategory/TimerecordingCategoryModel.php
@@ -9,7 +9,8 @@ class TimerecordingCategoryModel
private $require_comment;
private $only_admin;
private $businesstrip;
- public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage", 6 => "ZA Uhrzeit (von/bis)");
+ private $unpaid;
+ public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum", 5 => "Anzahl Tage", 6 => "ZA Uhrzeit (von/bis)", 7 => "Fahrtenbuch (von/bis)");
public static $approval_definition = array(0 => "Nein", 1 => "Ja");
public static $require_comment_definition = array(0 => "Nein", 1 => "Ja");
public static $businesstrip_definition = array(0 => "Nein", 1 => "Ja");
diff --git a/application/TimerecordingEmployee/TimerecordingEmployeeModel.php b/application/TimerecordingEmployee/TimerecordingEmployeeModel.php
index a76f9a4a7..089e76cfb 100644
--- a/application/TimerecordingEmployee/TimerecordingEmployeeModel.php
+++ b/application/TimerecordingEmployee/TimerecordingEmployeeModel.php
@@ -17,6 +17,7 @@ class TimerecordingEmployeeModel
private $bpahours;
private $startdate;
private $birthday;
+ public static $employeetypesbmd = array('1' => '1000', '2' => '1200', '3' => '1400');
public static function find($data)
diff --git a/application/TimerecordingReport/TimerecordingReportController.php b/application/TimerecordingReport/TimerecordingReportController.php
index 8c4722f1f..6fe936c3b 100644
--- a/application/TimerecordingReport/TimerecordingReportController.php
+++ b/application/TimerecordingReport/TimerecordingReportController.php
@@ -25,6 +25,8 @@ class TimerecordingReportController extends mfBaseController
$this->layout()->set("timerecordingusers", $timerecordingusers);
$timerecordings = TimerecordingModel::getAll();
$this->layout()->set("timerecordings", $timerecordings);
+ $timerecordingCars = TimerecordingCarModel::search(['timerecording' => 1]);
+ $this->layout()->set("timerecordingCars", $timerecordingCars);
}
protected function apiAction()
@@ -57,7 +59,7 @@ class TimerecordingReportController extends mfBaseController
$this->returnJson($data);
}
- protected function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
+ public function getTimerecordingsApi($datatype, $dataweek, $datamonth, $datayear)
{
$mustSeconds = 0;
$isSeconds = 0;
@@ -290,6 +292,16 @@ class TimerecordingReportController extends mfBaseController
$sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
+ } else if ($timerecording->timerecordingCategory->hourday == 7) {
+ $date = date("d.m.Y", $timerecording->start);
+ $datadate = date("Y-m-d", $timerecording->start);
+ $start = date("H:i", $timerecording->start);
+ $end = date("H:i", $timerecording->end);
+ $seconds = $timerecording->end - $timerecording->start;
+ $minutes = floor(($seconds % 3600) / 60);
+ $hours = floor($seconds / 3600);
+ $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
+ $day = $daysgerm[date("w", $timerecording->start)];
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -298,8 +310,17 @@ class TimerecordingReportController extends mfBaseController
$state = '
';
}
$edit = "";
- if ($timerecording->businesstrip == 1) {
- $category = "
" . $timerecording->timerecordingCategory->name . " (Dienstreise: " . $timerecording->businesstrip_info . ")";
+ if ($timerecording->timerecordingCategory->hourday == 7) {
+ $distance = $timerecording->mileage_end - $timerecording->mileage_start;
+ $category = "
" . $timerecording->timerecordingCategory->name . "(" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM) (Zielort: " . $timerecording->businesstrip_info . ")";
+ } else if ($timerecording->businesstrip == 1) {
+ if ($timerecording->timerecordingCar) {
+ $distance = $timerecording->mileage_end - $timerecording->mileage_start;
+ $car = " (" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM)";
+ } else {
+ $car = "";
+ }
+ $category = "
" . $timerecording->timerecordingCategory->name . "$car (Dienstreise: " . $timerecording->businesstrip_info . ")";
} else if ($timerecording->homeoffice == 1) {
$category = "
" . $timerecording->timerecordingCategory->name . " (Homeoffice)";
} else {
@@ -322,15 +343,18 @@ class TimerecordingReportController extends mfBaseController
data-userid="' . $timerecording->user_id . '"
data-businesstrip="' . $timerecording->businesstrip . '"
data-businesstripinfo="' . $timerecording->businesstrip_info . '"
- data-homeoffice="' . $timerecording->homeoffice . '"
- data-days="' . $timerecording->days . '"
+ data-homeoffice="' . $timerecording->homeoffice . '"
+ data-days="' . $timerecording->days . '"
+ data-car="' . $timerecording->timerecordingCar_id . '"
+ data-mileagestart="' . $timerecording->mileage_start . '"
+ data-mileageend="' . $timerecording->mileage_end . '"
title="Bearbeiten">';
else :
$edit .= '
';
endif;
$edit .= '
';
endif;
- if ($datatype == 3 && $timerecording->timerecordingCategory->hourday == 1) {
+ if ($datatype == 3 && ($timerecording->timerecordingCategory->hourday == 1 || $timerecording->timerecordingCategory->hourday == 7 || $timerecording->timerecordingCategory->hourday == 5)) {
} else {
$rows[] = array(
'user' => array('user' => $timerecording->user->name, 'order' => $timerecording->user->name),
@@ -363,23 +387,32 @@ class TimerecordingReportController extends mfBaseController
}
- protected function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear)
+ public function getTimerecordingsTimes($datatype, $dataweek, $datamonth, $datayear, $user_id = NULL, $ajax = 1)
{
$r = $this->request;
$mustSeconds = 0;
$isSeconds = 0;
+ $isSecondscleanarray = array();
$holiDays = 0;
$plusHours = 0;
+ $nlzTimes = array();
+ $daysum = array();
+ if (!$user_id) {
+ $user_id = $r->user_id;
+ }
+
$rows = [];
- $employee = TimerecordingEmployeeModel::search(['user_id' => $r->user_id]);
+ $employee = TimerecordingEmployeeModel::search(['user_id' => $user_id]);
if ($employee) {
$holiDays = $employee[0]->holidays;
$plusHours = $employee[0]->plushours;
+ $plusHours_now = $employee[0]->plushours_now;
+ $overtime_now = $employee[0]->overtime_now;
$auto_workinghours = $employee[0]->auto_workinghours;
$startdate = $employee[0]->startdate;
}
- $workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $r->user_id]);
+ $workinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $user_id]);
$holidays = TimerecordingHolidayModel::getAll();
foreach ($workinghours as $workinghour) {
@@ -402,7 +435,7 @@ class TimerecordingReportController extends mfBaseController
$timestamp_sonntag = strtotime("{$year}-W{$kw}-7");
$firstdate = strtotime(date("Y-m-d", $timestamp_montag) . " 00:00:00");
$lastdate = strtotime(date("Y-m-d", $timestamp_sonntag) . ' 23:59:59');
- $searchArray = ['user_id' => $r->user_id, 'start' => $timestamp_montag, 'end' => $lastdate];
+ $searchArray = ['user_id' => $user_id, 'start' => $timestamp_montag, 'end' => $lastdate];
$daycounter = '0';
@@ -422,7 +455,11 @@ class TimerecordingReportController extends mfBaseController
$lastdate = strtotime(date("Y-m-t", $datamonth));
$daycount = date("t", $datamonth);
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
- $searchArray = ['user_id' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
+ //Lastdate staticmust deleted
+// $lastdate = strtotime("2024-03-22 23:59:59");
+// $daycount=22;
+
+ $searchArray = ['user_id' => $user_id, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -441,7 +478,7 @@ class TimerecordingReportController extends mfBaseController
$lastdate = strtotime(date("Y-12-31 23:59:59", $datayear));
$daycount = date("t", $datamonth);
$lastdate = strtotime(date("Y-m-d", $lastdate) . ' 23:59:59');
- $searchArray = ['user_id' => $r->user_id, 'start' => $firstdate, 'end' => $lastdate];
+ $searchArray = ['user_id' => $user_id, 'start' => $firstdate, 'end' => $lastdate];
$timestamp = $firstdate;
for ($i = 1; $i <= $daycount; $i++) {
@@ -462,14 +499,52 @@ class TimerecordingReportController extends mfBaseController
$timerecordingcategories = TimerecordingCategoryModel::getAll();
$timerecordings = TimerecordingModel::search($searchArray);
+
$responsecount = count($timerecordings);
+ $oldday = "";
+ $homeoffice = false;
+ $homeofficesum = 0;
+ $dietsum = 0;
+ $diet = 0;
+ $dietbase = TimerecordingBillingModel::$dieatBase;
+
foreach ($timerecordings as $timerecording):
$state = "";
$enddate = "";
$sum = "-";
$day = "";
$orderdate = $timerecording->start;
+ if ($oldday != date('Y-m-d', $timerecording->start)) {
+
+ if ($homeoffice == 1) {
+ $homeofficesum++;
+ $homeoffice = false;
+ }
+ if ($diet > 10800) {
+ if ($diet >= 43200) {
+ $diet = 43200;
+ }
+ $calcdiet = $dietbase / 12;
+ $calcdiet = ($diet / 3600) * $calcdiet;
+ $dietsum = $dietsum + $calcdiet;
+ }
+ $diet = 0;
+
+ }
+ if ($timerecording->homeoffice == 1 && (!$homeoffice || $homeoffice == 1)) {
+
+ $homeoffice = 1;
+ } else {
+ $homeoffice = 0;
+ }
+
+
+ if ($timerecording->businesstrip == 1 && $timerecording->timerecordingCategory->hourday == 1) {
+ $diet = $diet + $timerecording->end - $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);
@@ -480,6 +555,27 @@ class TimerecordingReportController extends mfBaseController
$sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
$day = $daysgerm[date("w", $timerecording->start)];
$isSeconds = $isSeconds + $seconds;
+ if ($isSecondscleanarray[$timerecording->timerecordingCategory->short]) {
+ $isSecondscleanarray[$timerecording->timerecordingCategory->short] = $isSecondscleanarray[$timerecording->timerecordingCategory->short] + $seconds;
+ } else {
+ $isSecondscleanarray[$timerecording->timerecordingCategory->short] = $seconds;
+ }
+
+
+ if ($timerecording->timerecordingCategory->short != "1000,1200,1400") {
+ if (!$daysum[$timerecording->timerecordingCategory->name]) {
+ $daysum[$timerecording->timerecordingCategory->name] = $seconds;
+ } else {
+ $daysum[$timerecording->timerecordingCategory->name] = $daysum[$timerecording->timerecordingCategory->name] + $seconds;
+ }
+
+ $nlzTimes[$timerecording->id]['start'] = date("d.m.Y", $timerecording->start);
+ $nlzTimes[$timerecording->id]['end'] = date("d.m.Y", $timerecording->end);
+ $nlzTimes[$timerecording->id]['minutes'] = $seconds / 60;
+ $nlzTimes[$timerecording->id]['unpaid'] = $timerecording->timerecordingCategory->unpaid;
+ $nlzTimes[$timerecording->id]['category'] = $timerecording->timerecordingCategory->name;
+ $nlzTimes[$timerecording->id]['categoryshort'] = $timerecording->timerecordingCategory->short;
+ }
} else if ($timerecording->timerecordingCategory->hourday == 2 || ($timerecording->timerecordingCategory->hourday == 3 && $timerecording->end)) {
$date = date("d.m.", $timerecording->start) . " - " . $daysgerm[date("w", $timerecording->end)] . " " . date("d.m.Y", $timerecording->end);
$datadate = date("Y-m-d", $timerecording->start);
@@ -500,10 +596,18 @@ class TimerecordingReportController extends mfBaseController
}
$summcounter = 0;
$savecounter = 0;
+ $sumdays = 0;
+
for ($i = $starttimecalc; $i <= $endtimecalc; $i = $i + 86400) {
$holidaycounter = $workingHours[date("w", $i)];
- $isSeconds = $isSeconds + $holidaycounter;
- $summcounter = $summcounter + $holidaycounter;
+ $daycheck = date("Y-m-d", $i);
+ if (!$holiDay[$daycheck]) {
+ if ($holidaycounter) {
+ $isSeconds = $isSeconds + $holidaycounter;
+ $summcounter = $summcounter + $holidaycounter;
+ $sumdays++;
+ }
+ }
if ($savecounter == 1000) {
echo $savecounter;
die();
@@ -513,7 +617,24 @@ class TimerecordingReportController extends mfBaseController
$seconds = $summcounter;
$minutes = floor(($seconds % 3600) / 60);
$hours = floor($seconds / 3600);
- $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
+// $sum = sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
+ if ($sumdays == 1 || $sumdays == 0) {
+ $sum = $sumdays . " Tag";
+ } else if ($sumdays > 1) {
+ $sum = $sumdays . " Tage";
+ }
+
+ if (!$daysum[$timerecording->timerecordingCategory->name]) {
+ $daysum[$timerecording->timerecordingCategory->name] = $sumdays;
+ } else {
+ $daysum[$timerecording->timerecordingCategory->name] = $daysum[$timerecording->timerecordingCategory->name] + $sumdays;
+ }
+ $nlzTimes[$timerecording->id]['start'] = date("d.m.Y", $timerecording->start);
+ $nlzTimes[$timerecording->id]['end'] = date("d.m.Y", $timerecording->end);
+ $nlzTimes[$timerecording->id]['days'] = $sumdays;
+ $nlzTimes[$timerecording->id]['unpaid'] = $timerecording->timerecordingCategory->unpaid;
+ $nlzTimes[$timerecording->id]['category'] = $timerecording->timerecordingCategory->name;
+ $nlzTimes[$timerecording->id]['categoryshort'] = $timerecording->timerecordingCategory->short;
} else if ($timerecording->timerecordingCategory->hourday == 3 && !$timerecording->end) {
$date = date("d.m.Y", $timerecording->start) . " - " . $daysgerm[date("w", time())] . " " . date("d.m.Y", time());;
@@ -554,6 +675,18 @@ class TimerecordingReportController extends mfBaseController
$end = "-";
$day = $daysgerm[date("w", $timerecording->start)];
$sum = $timerecording->days . " Tage";
+ } else if ($timerecording->timerecordingCategory->hourday == 6) {
+ $date = date("d.m.Y", $timerecording->start);
+ $datadate = date("Y-m-d", $timerecording->start);
+ $start = date("H:i", $timerecording->start);
+ $end = date("H:i", $timerecording->end);
+// $seconds = $timerecording->hours;
+ $seconds = $timerecording->end - $timerecording->start;
+ $minutes = floor(($seconds % 3600) / 60);
+ $hours = floor($seconds / 3600);
+ $sum = "-" . sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes);
+ $day = $daysgerm[date("w", $timerecording->start)];
+ $isSeconds = $isSeconds + $seconds;
}
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
@@ -593,18 +726,73 @@ class TimerecordingReportController extends mfBaseController
} else {
}
+ $oldday = date('Y-m-d', $timerecording->start);
endforeach;
+ if ($homeoffice == 1) {
+ $homeofficesum++;
+ $homeoffice = 0;
+ }
+ if ($diet > 10800) {
+ if ($diet >= 43200) {
+ $diet = 43200;
+ }
+ $calcdiet = $dietbase / 12;
+ $calcdiet = ($diet / 3600) * $calcdiet;
+ $dietsum = $dietsum + $calcdiet;
+ }
+
+ $summseconds = $isSeconds - $mustSeconds;
+ $isorder = $isSeconds;
+ 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));
+ }
+ $summsecondsorder = $summseconds;
+ if ($summseconds < 0) {
+ $summseconds = $summseconds * -1;
+ $summseconds = "-" . sprintf('%02dh:%02dm', floor($summseconds / 3600), floor($summseconds / 60 % 60));
+ } else {
+ $summseconds = sprintf('%02dh:%02dm', floor($summseconds / 3600), floor($summseconds / 60 % 60));
+ }
+ $plusHours_noworder = $plusHours_now;
+ if ($plusHours_now < 0) {
+ $plusHours_now = $plusHours_now * -1;
+ $plusHours_now = "-" . sprintf('%02dh:%02dm', floor($plusHours_now / 3600), floor($plusHours_now / 60 % 60));
+ } else {
+ $plusHours_now = sprintf('%02dh:%02dm', floor($plusHours_now / 3600), floor($plusHours_now / 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']['isorder'] = $isorder;
+ $json['time']['isclean'] = $isSecondscleanarray;
$json['time']['must'] = sprintf('%02dh:%02dm', floor($mustSeconds / 3600), floor($mustSeconds / 60 % 60));
+ $json['time']['mustorder'] = $mustSeconds;
$json['time']['holidays'] = $holiDays;
$json['time']['plushours'] = sprintf('%02dh:%02dm', floor($plusHours / 3600), floor($plusHours / 60 % 60));
+ $json['time']['plushours_now'] = $plusHours_now;
+ $json['time']['plushours_noworder'] = $plusHours_noworder;
+ $json['time']['overtime_now'] = sprintf('%02dh:%02dm', floor($overtime_now / 3600), floor($overtime_now / 60 % 60));
+ $json['time']['overtime_noworder'] = $overtime_now;
+ $json['time']['homeoffice'] = $homeofficesum;
+ $json['time']['summseconds'] = $summseconds;
+ $json['time']['summsecondsorder'] = $summsecondsorder;
+ $json['time']['nlztimes'] = $nlzTimes;
+ $json['time']['diet'] = $dietsum;
+ $json['time']['daysum'] = $daysum;
$json['recordsFiltered'] = $responsecount;
$json['recordsTotal'] = $responsecount;
- $json = json_encode($json);
- echo trim($json);
- die();
+
+ if ($ajax == 1) {
+ $json = json_encode($json);
+ echo trim($json);
+ die();
+ } else {
+ return $json;
+ }
}
protected function addAction()
diff --git a/db/migrations/20240317165103_timerecording_car.php b/db/migrations/20240317165103_timerecording_car.php
new file mode 100644
index 000000000..a96d000e1
--- /dev/null
+++ b/db/migrations/20240317165103_timerecording_car.php
@@ -0,0 +1,40 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("TimerecordingCar", ["signed" => true]);
+ $table->addColumn("number_plate", "string", ["null" => false]);
+ $table->addColumn("brand", "text", ["null" => true]);
+ $table->addColumn("model", "text", ["null" => true]);
+ $table->addColumn("mileage", "integer", ["null" => true]);
+ $table->addColumn("mileage_now", "integer", ["null" => true]);
+ $table->addColumn("mileage_timestamp", "integer", ["null" => true]);
+ $table->addColumn("initial_approval", "integer", ["null" => true]);
+ $table->addColumn("timerecording", "integer", ["default" => 1]);
+ $table->addColumn("create_by", "integer", ["null" => false]);
+ $table->addColumn("edit_by", "integer", ["null" => false]);
+ $table->addColumn("create", "integer", ["null" => false]);
+ $table->addColumn("edit", "integer", ["null" => false]);
+ $table->save();
+ }
+
+ if ($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if ($this->getEnvironment() == "thetool") {
+ $this->table("TimerecordingCar")->drop()->save();
+ }
+ if ($this->getEnvironment() == "addressdb") {
+ }
+ }
+}
+?>
\ No newline at end of file
diff --git a/db/migrations/20240317171644_timerecording_add_fields_car.php b/db/migrations/20240317171644_timerecording_add_fields_car.php
new file mode 100644
index 000000000..e05f488af
--- /dev/null
+++ b/db/migrations/20240317171644_timerecording_add_fields_car.php
@@ -0,0 +1,36 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("Timerecording", ["signed" => true]);
+ $table->addColumn("timerecordingCar_id", "integer", ["null" => true, "default" => NULL, "after" => "businesstrip_info"]);
+ $table->addColumn("mileage_start", "integer", ["null" => true, "default" => NULL, "after" => "timerecordingCar"]);
+ $table->addColumn("mileage_end", "integer", ["null" => true, "default" => NULL, "after" => "mileage_start"]);
+ $table->update();
+ }
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if ($this->getEnvironment() == "thetool") {
+ $this->table("Timerecording")->removeColumn("timerecordingCar")->save();
+ $this->table("Timerecording")->removeColumn("mileage_start")->save();
+ $this->table("Timerecording")->removeColumn("mileage_end")->save();
+ }
+
+
+ if($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+}
diff --git a/db/migrations/20240326191604_timerecording_category_add_field_unpaid.php b/db/migrations/20240326191604_timerecording_category_add_field_unpaid.php
new file mode 100644
index 000000000..47f64eaff
--- /dev/null
+++ b/db/migrations/20240326191604_timerecording_category_add_field_unpaid.php
@@ -0,0 +1,30 @@
+getEnvironment() == "thetool") {
+ $table = $this->table("TimerecordingCategory", ["signed" => true]);
+ $table->addColumn("unpaid", "integer", ["null" => false, "default" => '0', "after" => "businesstrip"]);
+ $table->update();
+ }
+
+ if ($this->getEnvironment() == "addressdb") {
+
+ }
+ }
+
+ public function down(): void
+ {
+ if ($this->getEnvironment() == "thetool") {
+ $this->table("TimerecordingCategory")->removeColumn("unpaid")->save();
+ }
+
+ if ($this->getEnvironment() == "addressdb") {
+ }
+ }
+}
diff --git a/public/js/pages/timerecording/index.js b/public/js/pages/timerecording/index.js
index ad7b846a1..c2bf0611b 100644
--- a/public/js/pages/timerecording/index.js
+++ b/public/js/pages/timerecording/index.js
@@ -223,7 +223,25 @@ $(document).ready(function () {
$(this).prop("min", '');
$(this).val('');
})
+ } else if (parseInt($(this).find(':selected').data('hourday')) === 7) {
+ $("#endtime-div").show();
+ $("#endtime-div").find('input').each(function () {
+ $(this).prop("required", true);
+ $(this).prop("disabled", false);
+ });
+ $("#enddate-div").hide();
+ $("#enddate-div").find('input').each(function () {
+ $(this).prop("required", false);
+ $(this).prop("min", '');
+ $(this).val('');
+ })
+ $('#businesstrip_info').val('');
+ $('#businesstrip_info').show();
+ $('.car-div-car').show();
+
}
+
+
if (parseInt($(this).find(':selected').data('comment')) === 1) {
$('#comment').prop("required", true);
} else {
@@ -235,11 +253,28 @@ $(document).ready(function () {
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
$('#businesstrip_info').hide();
+ $('.car-div').find('input').prop("required", false);
+ $('.car-div').find('input').val('');
+ $('#timerecordingCar_id').val('').change();
+ $('.car-div').hide();
+ } else if (parseInt($(this).find(':selected').data('hourday')) === 7) {
+ $('.businesstrip-div').show();
+ $('.businesstrip-check-div').hide();
+ $('#businesstrip').prop("checked", true);
+ $('#businesstrip_info').show();
+ $('#businesstrip_info').prop('required', true);
+ $('#homeoffice-div').hide();
} else {
$('.businesstrip-div').hide();
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
+ $('#timerecordingCar_id').val('').change();
+ $('.car-div').find('input').prop("required", false);
+ $('.car-div').find('input').val('');
+ $('.car-div').hide();
+
$('#businesstrip_info').hide();
+
}
if (parseInt($(this).find(':selected').data('homeoffice')) === 1) {
@@ -306,12 +341,26 @@ $(document).ready(function () {
$('#businesstrip_info').show();
$('#businesstrip_info').prop('required', true);
$('#homeoffice-div').hide();
+ $('#timerecordingCar_id').val('').change();
}
if ($(this).data('homeoffice') == 1) {
$('.businesstrip-div').hide();
$('#homeoffice').prop("checked", true);
$('#homeoffice-div').show();
}
+ if ($(this).data('car')) {
+
+ $('#timerecordingCar_id').val($(this).data('car')).change();
+ if ($(this).data('mileagestart')) {
+ $('.car-div').show();
+ $('.car-div').find('input').prop("required", true);
+ $('#mileage_start').val($(this).data('mileagestart'));
+ $('#mileage_end').val($(this).data('mileageend'));
+ $('#mileage_end').prop("min", $(this).data('mileagestart'));
+ } else {
+
+ }
+ }
$('.alert-success').remove();
window.scrollTo(0, 0);
});
@@ -324,8 +373,14 @@ $(document).ready(function () {
$('#businesstrip').prop("checked", false);
$('#businesstrip_info').val('');
$('#businesstrip_info').hide();
+ $('#businesstrip_info').prop("required", false);
$('#homeoffice').prop("checked", false);
+ $('.car-div').hide();
+ $('.car-div').find('input').val('');
+ $('.car-div').find('input').prop("required", false);
+ $('#timerecordingCar_id').val('').change();
$('#timerecordingCategory_id').change();
+
});
$("body").on("change", "#dataweek,#datamonth,#datayear", function () {
@@ -362,7 +417,7 @@ $(document).ready(function () {
$('#businesstrip_info').prop('required', true);
$('#homeoffice').prop('checked', false);
$('#homeoffice-div').hide();
-
+ $('.car-div-car').show();
} else {
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
@@ -376,6 +431,10 @@ $(document).ready(function () {
if ($(this).prop('checked') == true) {
$('#businesstrip').prop('checked', false);
$('.businesstrip-div').hide();
+ $('#timerecordingCar_id').val('');
+ $('.car-div').find('input').prop("required", false);
+ $('.car-div').find('input').val('');
+ $('.car-div').hide();
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
$('#businesstrip_info').prop('required', false);
@@ -414,6 +473,24 @@ $(document).ready(function () {
});
+ $("body").on("change", "#timerecordingCar_id", function () {
+ if ($('#timerecordingCar_id').val() == "") {
+ $('.car-div').find('input').prop("required", false);
+ $('.car-div').find('input').val('');
+ $('.car-div').hide();
+ $('.car-div-car').show();
+ } else {
+ $('.car-div').show();
+ $('.car-div').find('input').prop("required", true);
+ $('#mileage_start').val($(this).find(':selected').data('mileagenow'));
+ $('#mileage_end').prop("min", $('#mileage_start').val());
+ }
+ });
+
+ $("body").on("change", "#mileage_start", function () {
+ $('#mileage_end').prop("min", $('#mileage_start').val());
+ });
+
$("body").on("click", ".delete-item", function () {
if (confirm('Buchung wirklich löschen?')) {
$.post(deleteUrl, {
@@ -430,12 +507,16 @@ $(document).ready(function () {
$('#alert-box').remove();
var businesstrip = false;
var homeoffice = false;
+ var car = false;
if ($('#businesstrip').prop('checked') == true) {
businesstrip = 1;
}
if ($('#homeoffice').prop('checked') == true) {
homeoffice = 1;
}
+ if ($.trim($('#timerecordingCar_id').val())) {
+ car = 1;
+ }
$.post(insertUrl, {
id: $.trim($('#id').val()),
timerecordingCategory_id: $.trim($('#timerecordingCategory_id').val()),
@@ -446,6 +527,9 @@ $(document).ready(function () {
comment: $.trim($('#comment').val()),
businesstrip: businesstrip,
businesstrip_info: $.trim($('#businesstrip_info').val()),
+ timerecordingCar_id: $.trim($('#timerecordingCar_id').val()),
+ mileage_start: $.trim($('#mileage_start').val()),
+ mileage_end: $.trim($('#mileage_end').val()),
homeoffice: homeoffice,
hourday: $.trim($('#timerecordingCategory_id').find(':selected').data('hourday')),
ajax: 1
@@ -459,10 +543,13 @@ $(document).ready(function () {
Erfolgreich
` + result.message + `