Merge branch 'spidev' into 'master'
Zeiterfassungs Update See merge request fronk/thetool!303
This commit is contained in:
@@ -6,7 +6,8 @@ class Timerecording extends mfBaseModel
|
||||
private $creator;
|
||||
private $user;
|
||||
private $timerecordingCategory;
|
||||
|
||||
private $timerecordingCar;
|
||||
|
||||
|
||||
|
||||
public function getProperty($name)
|
||||
|
||||
@@ -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 = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
||||
}
|
||||
$edit = "";
|
||||
if ($timerecording->businesstrip == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
if ($timerecording->timerecordingCategory->hourday == 7) {
|
||||
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>(" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM) (Zielort: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} 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 = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>$car (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} else if ($timerecording->homeoffice == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Homeoffice)</span>";
|
||||
} 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"></i>';
|
||||
else :
|
||||
$edit .= '<div class="edit-placeholder"></div>';
|
||||
endif;
|
||||
$edit .= '<i data-id="' . $timerecording->id . '" class="fas fa-trash text-danger delete-item" ></i>';
|
||||
endif;
|
||||
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),
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingBillingController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->can(["Fibu"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
$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();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingBillingModel
|
||||
{
|
||||
public static $dieatBase = 26.4;
|
||||
public static $excludeEmployees = [1000, 1001, 9999, 4, 5, 6, 7, 8, 9, 10];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingCar extends mfBaseModel
|
||||
{
|
||||
private $editor;
|
||||
private $creator;
|
||||
|
||||
|
||||
|
||||
public function getProperty($name)
|
||||
{
|
||||
if ($this->$name == null) {
|
||||
|
||||
if (!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
|
||||
if ($this->creator === null) {
|
||||
$this->creator = new User($this->create_by);
|
||||
if ($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
|
||||
}
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if ($name == "editor") {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
|
||||
if ($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if ($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name . "_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
|
||||
if (!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if ($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingCarController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
|
||||
$this->layout()->setTemplate("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");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingCarModel
|
||||
{
|
||||
private $number_plate;
|
||||
private $brand;
|
||||
private $model;
|
||||
private $mileage;
|
||||
private $mileage_now;
|
||||
private $mileage_timestamp;
|
||||
private $initial_approval;
|
||||
private $first_approval;
|
||||
private $timerecording;
|
||||
|
||||
|
||||
public static function find($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new TimerecordingCar();
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (property_exists(get_called_class(), $field)) {
|
||||
if (substr($field, 0, 5) == "vlan_" && !$value) {
|
||||
$model->$field = null;
|
||||
continue;
|
||||
}
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if (!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
}
|
||||
|
||||
if ($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if ($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getOne($id)
|
||||
{
|
||||
if (!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
||||
}
|
||||
$edit = "";
|
||||
if ($timerecording->businesstrip == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
if ($timerecording->timerecordingCategory->hourday == 7) {
|
||||
$distance = $timerecording->mileage_end - $timerecording->mileage_start;
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>(" . $timerecording->timerecordingCar->number_plate . " " . $distance . "KM) (Zielort: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} 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 = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'>$car (Dienstreise: " . $timerecording->businesstrip_info . ")</span>";
|
||||
} else if ($timerecording->homeoffice == 1) {
|
||||
$category = "<span>" . $timerecording->timerecordingCategory->name . "</span><span class='text-bold ml-1'> (Homeoffice)</span>";
|
||||
} 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"></i>';
|
||||
else :
|
||||
$edit .= '<div class="edit-placeholder"></div>';
|
||||
endif;
|
||||
$edit .= '<i data-id="' . $timerecording->id . '" class="fas fa-trash text-danger delete-item" ></i>';
|
||||
endif;
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user