diff --git a/Layout/default/Timerecording/Index.php b/Layout/default/Timerecording/Index.php index 921c0cbd9..cc6c94328 100644 --- a/Layout/default/Timerecording/Index.php +++ b/Layout/default/Timerecording/Index.php @@ -13,7 +13,6 @@ $monthger[10] = "Oktober"; $monthger[11] = "November"; $monthger[12] = "Dezember"; $time = time(); - for ($i = 1; $i <= 25; $i++) { $kw = date('W', $time); $year = date('Y', $time); @@ -196,7 +195,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000); -
+
+ + +
diff --git a/Layout/default/TimerecordingBilling/Detail.php b/Layout/default/TimerecordingBilling/Detail.php new file mode 100644 index 000000000..75f4c5e8f --- /dev/null +++ b/Layout/default/TimerecordingBilling/Detail.php @@ -0,0 +1,131 @@ + + + +
+
+
+
+ +
+

Verrechnung/Abrechnung

+
+
+
+ + +
+
+
+
+
+

Liste aller Mitarbeiter

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + $value) { + if ($counter > 1) { + $offdays .= ""; + } + $offdays .= "
"; + if ($value < 100) { + $offdays .= $category . ": " . $value . " Tag(e) "; + } else { + + $offdays .= $category . ": " . sprintf('%02dh:%02dm', floor($value / 3600), floor($value / 60 % 60)); + } + $counter++; + } + $offdays .= "
"; + } else { + $offdays = "keine"; + } + ?> + + + + + + + + + + + + + + +
MitarbeiterPersonal Nr.SollstundenIststundenSollabweichungAkuelle GutstundenAkuelle ÜberstundenNichtleistungszeitenDiätenHomeoffice Tage
Tag(e)
+ +
+
+ +
+
+ + + + + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingBilling/Index.php b/Layout/default/TimerecordingBilling/Index.php new file mode 100644 index 000000000..81fb23d56 --- /dev/null +++ b/Layout/default/TimerecordingBilling/Index.php @@ -0,0 +1,77 @@ + + + +
+
+
+
+ +
+

Zeiterfassung Verrechnung/Abrechnung

+
+
+
+ + + +
+
+
+
+
+

Liste aller Abrechnungsmonate

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
MonatAbgeschlossenAbgeschlossen amAbgeschlossen von
$month]) ?>">
+ +
+
+ +
+ + + + + + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingCar/Detail.php b/Layout/default/TimerecordingCar/Detail.php new file mode 100644 index 000000000..023e4cf51 --- /dev/null +++ b/Layout/default/TimerecordingCar/Detail.php @@ -0,0 +1,199 @@ +initial_approval); +$initialApprovalMonth = date("m", $timerecordingcar->initial_approval); +$firstApproval = strtotime('+' . $timerecordingcar->first_approval . 'years', strtotime($initialApproval)); +if ($firstApproval < time()) { + $firstApproval = strtotime(date("Y-$initialApprovalMonth-01", time())); + if ($firstApproval < time()) { + $firstApproval = strtotime(date("Y-$initialApprovalMonth-01", strtotime('+1 year'))); + } +} +$approval = date("m/Y", $firstApproval); +?> + + + +
+
+
+
+ +
+

brand . "/" . $timerecordingcar->model . " (" . $timerecordingcar->number_plate . ")" ?> + Detail + + $timerecordingcar->id, 'returnto' => "detail"]) ?>"> + + + +

+
+
+
+ + +
+
+
+
+
+

Fahrzeug Informationen

+ +
+
+ + + + + + + + + + + + + + + + + + + + +
Markebrand ?>
Model/Typmodel ?>
Erste §57a nachfirst_approval) ? $timerecordingcar->first_approval . " Jahr(en)" : "-" ?>
Fahrtenbuchtimerecording) ? "Ja" : "Nein" ?>
+
+ + +
+
+
+

 

+ +
+
+ + + + + + + + + + + + + + + + + + +
Erstzulassunginitial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?>
Nächste $57ainitial_approval) ? $approval : "-" ?>
Kilometerstandmileage_now) ? $timerecordingcar->mileage_now . " KM" : "-" ?>
+
+ + +
+
+
+
+ + +
+
+
+
+
+

Fahrtenbuch

+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StartkilometerEndkilometerKilometerFahrerDatumZeitOrt
mileage_start ?> KMmileage_end ?> KMmileage_end - $timerecording->mileage_start ?>KM + user->name ?>start) ?>start) . " - " . date("H:i", $timerecording->end) ?>businesstrip_info ?> + + $timerecordingcar->id]) ?> + + + $timerecordingcar->id]) ?> + + +
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingCar/Form.php b/Layout/default/TimerecordingCar/Form.php new file mode 100644 index 000000000..070fdd9b9 --- /dev/null +++ b/Layout/default/TimerecordingCar/Form.php @@ -0,0 +1,151 @@ + $timerecordingcars->id]); +} else { + $cancelUrl = self::getUrl("TimerecordingCar"); +} +?> + + +
+
+
+
+ +
+

id) ? "Fahrzeug bearbeiten" : "Neues Fahrzeug" ?>

+
+
+
+ +
+
+ +
+
+

id) ? "Fahrzeug bearbeiten" : "Neues Fahrzeug" ?>

+ +
$_GET["returnto"]]) ?>"> +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ "/> +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ timerecording) ? 'checked="checked"' : '' ?> + type="checkbox" name="timerecording" value="1"/> +
+
+
+
+
+
+ +
+ + + + +
+
+ + +
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingCar/Index.php b/Layout/default/TimerecordingCar/Index.php new file mode 100644 index 000000000..746bf1f7f --- /dev/null +++ b/Layout/default/TimerecordingCar/Index.php @@ -0,0 +1,120 @@ + + + + +
+
+
+
+ +
+

Fahrzeuge

+
+
+
+ + + +
+
+
+
+
+

Liste aller Fahrzeuge

+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + initial_approval); + $initialApprovalMonth = date("m", $timerecordingcar->initial_approval); + $firstApproval = strtotime('+' . $timerecordingcar->first_approval . 'years', strtotime($initialApproval)); + if ($firstApproval < time()) { + $firstApproval = strtotime(date("Y-$initialApprovalMonth-01", time())); + if ($firstApproval < time()) { + $firstApproval = strtotime(date("Y-$initialApprovalMonth-01", strtotime('+1 year'))); + } + } + $approval = date("m/Y", $firstApproval); + + ?> + + + + + + + + + + + + +
KennzeichenMarkeModel/TypErstzulassssung$57aFahrtenbuchKilometerstand
+ $timerecordingcar->id]) ?>"> number_plate ?> + brand ?>model ?>initial_approval) ? date("m/Y", $timerecordingcar->initial_approval) : "-" ?>initial_approval) ? $approval : "-" ?>timerecording) ? "Ja" : "Nein" ?>mileage_now) ? number_format($timerecordingcar->mileage_now, 0, ',', '.')." KM" : "-" ?> + + $timerecordingcar->id]) ?>"> + $timerecordingcar->id]) ?>" + onclick="if(!confirm('Fahrzeug wirklich löschen?')) return false;" class="text-danger" + title="Löschen"> +
+ +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/Layout/default/TimerecordingCategories/Form.php b/Layout/default/TimerecordingCategories/Form.php index 6e21f051f..96072b0fe 100644 --- a/Layout/default/TimerecordingCategories/Form.php +++ b/Layout/default/TimerecordingCategories/Form.php @@ -93,6 +93,17 @@ +
+ +
+
+ unpaid) echo 'checked="checked"'; ?> + type="checkbox" name="unpaid" value="1"> +
+
+
diff --git a/Layout/default/TimerecordingReport/Index.php b/Layout/default/TimerecordingReport/Index.php index 1e782aa51..8d5b70464 100644 --- a/Layout/default/TimerecordingReport/Index.php +++ b/Layout/default/TimerecordingReport/Index.php @@ -121,7 +121,7 @@ $years[time() - 31536000] = date('Y', time() - 31536000);
- +
+ + +
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")): ?>
  • "> Patchungen
  • 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 + `
    `); - $('#businesstrip').prop('checked', false); - $('#businesstrip_info').hide(); - $('#businesstrip_info').val(''); - $('#businesstrip_info').prop('required', false); + if ($.trim($('#mileage_start').val())) { + $('#timerecordingCar_id').find(':selected').data('mileagenow', $.trim($('#mileage_end').val())); + } + if (car == 1) { + $('#timerecordingCar_id').val('').change(); + } + } if (result.state === "error") { $('.wrapper .container-fluid').prepend(`
    diff --git a/public/js/pages/timerecordingReport/index.js b/public/js/pages/timerecordingReport/index.js index 92396fffd..44307a3e7 100644 --- a/public/js/pages/timerecordingReport/index.js +++ b/public/js/pages/timerecordingReport/index.js @@ -250,6 +250,22 @@ $(document).ready(function () { $('#days-div').show(); $('#days').prop("required", true); + } 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); @@ -262,10 +278,25 @@ $(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(); } @@ -342,12 +373,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); }); @@ -365,6 +410,10 @@ $(document).ready(function () { $('#businesstrip_info').val(''); $('#businesstrip_info').hide(); $('#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(); }); @@ -431,7 +480,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(''); @@ -445,6 +494,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); @@ -456,6 +509,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, { @@ -474,12 +545,16 @@ $(document).ready(function () { userid = $('#user_id_select').val(); 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()), user_id: userid, @@ -492,6 +567,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 @@ -505,6 +583,12 @@ $(document).ready(function () {
    Erfolgreich
    ` + result.message + `
    `); + if ($.trim($('#mileage_start').val())) { + $('#timerecordingCar_id').find(':selected').data('mileagenow', $.trim($('#mileage_end').val())); + } + if (car == 1) { + $('#timerecordingCar_id').val('').change(); + } $('#businesstrip').prop('checked', false); $('#businesstrip_info').hide(); $('#businesstrip_info').val('');