* Berechnungen aller Ü50/Ü100/M25 sowie Steuerfrei und Pflichtig * Transfer Mehrstunden auf Ü50/Ü100/M25 * Anpassungen der Exports LZs MehrstundenGL ÜGL Ü50,Ü100,M25 * Autoberechnung der anteiligen Mehrstunden * automatische Ü100 Rausrechnung laut gesetzlichen Vorgaben Bugfixes: * Start und Enddatum eines Mitarbeiters werden nun überall berücksichtigt. * Textuelle Bereinigungen * Umfangreiche Testscenarien Verechnung/Exports
212 lines
7.1 KiB
PHP
212 lines
7.1 KiB
PHP
<?php
|
|
|
|
class TimerecordingEmployeeController 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()
|
|
{
|
|
|
|
$this->layout()->setTemplate("TimerecordingEmployee/Index");
|
|
$timerecordingemployees = TimerecordingEmployeeModel::getAllArray();
|
|
$timerecordingusers = UserModel::search(['employee' => 'true']);
|
|
$timerecordingworkinghours = TimerecordingEmployeeWorkingHourModel::getAllArray();
|
|
$this->layout()->set("timerecordingemployees", $timerecordingemployees);
|
|
$this->layout()->set("timerecordingworkinghours", $timerecordingworkinghours);
|
|
$this->layout()->set("timerecordingusers", $timerecordingusers);
|
|
|
|
}
|
|
|
|
protected function addAction()
|
|
{
|
|
$id = $this->request->id;
|
|
$userid = $this->request->userid;
|
|
$days = TimerecordingEmployeeWorkingHourModel::$days_definition;
|
|
$timerecordingworkinghours = TimerecordingEmployeeWorkingHourModel::search(['user_id' => $userid]);
|
|
$this->layout()->set("days", $days);
|
|
$this->layout()->set("timerecordingworkinghours", $timerecordingworkinghours);
|
|
$this->layout()->setTemplate("TimerecordingEmployee/Form");
|
|
}
|
|
|
|
protected function editAction()
|
|
{
|
|
$id = $this->request->id;
|
|
$userid = $this->request->userid;
|
|
if (!is_numeric($id) || !$id) {
|
|
|
|
|
|
} else {
|
|
$timerecordingemployees = new TimerecordingEmployee($id);
|
|
if ($timerecordingemployees->id != $id) {
|
|
$this->layout()->setFlash("Personaladministration nicht gefunden", "error");
|
|
$this->redirect("TimerecordingEmployee");
|
|
}
|
|
|
|
$this->layout()->set("timerecordingemployees", $timerecordingemployees);
|
|
}
|
|
$timerecordinguser = UserModel::search(['worker_id' => $userid]);
|
|
$this->layout()->set("timerecordinguser", $timerecordinguser);
|
|
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";
|
|
$timerecordingemployees = new TimerecordingEmployee($id);
|
|
if (!$timerecordingemployees->id) {
|
|
$this->layout()->setFlash("Personaladministration nicht gefunden", "error");
|
|
$this->redirect("TimerecordingEmployee");
|
|
}
|
|
} else {
|
|
$mode = "add";
|
|
}
|
|
|
|
|
|
TimerecordingEmployeeWorkingHourModel::deleteUserHours($r->user_id);
|
|
if ($r->day) {
|
|
foreach ($r->day as $key => $day) {
|
|
unset($dataWorkHours);
|
|
$dataWorkHours = [];
|
|
$starttime = $r->timestart[$key];
|
|
$endtime = $r->timeend[$key];
|
|
|
|
if ($starttime && $endtime) {
|
|
$dataWorkHours['user_id'] = $r->user_id;
|
|
$dataWorkHours['day'] = $day;
|
|
$dataWorkHours['start'] = $starttime;
|
|
$dataWorkHours['end'] = $endtime;
|
|
$timerecordingemployeesworkinghours = TimerecordingEmployeeWorkingHourModel::create($dataWorkHours);
|
|
$timerecordingemployeesworkinghours->save();
|
|
}
|
|
}
|
|
}
|
|
$plushours = $r->plushours;
|
|
if ($plushours) {
|
|
$plushours = str_replace(',', '.', $plushours);
|
|
if (is_numeric($plushours)) {
|
|
$plushours = $plushours * 3600;
|
|
} else {
|
|
$plushours = 0;
|
|
}
|
|
} else {
|
|
$plushours = 0;
|
|
}
|
|
$overtime = $r->overtime;
|
|
if ($overtime) {
|
|
$overtime = str_replace(',', '.', $overtime);
|
|
if (is_numeric($overtime)) {
|
|
$overtime = $overtime * 3600;
|
|
} else {
|
|
$overtime = 0;
|
|
}
|
|
} else {
|
|
$overtime = 0;
|
|
}
|
|
|
|
|
|
$data = [];
|
|
$data['user_id'] = trim($r->user_id);
|
|
$data['auto_workinghours'] = trim($r->auto_workinghours);
|
|
$data['holidays'] = trim($r->holidays);
|
|
$data['plushours'] = $plushours;
|
|
$data['startdate'] = strtotime($r->startdate);
|
|
$data['enddate'] = strtotime($r->enddate);
|
|
$data['type'] = trim($r->type);
|
|
$data['bmd_active'] = trim($r->bmd_active);
|
|
$data['overtime'] = $overtime;
|
|
|
|
if (!$data['holidays']) {
|
|
$data['holidays'] = 0;
|
|
}
|
|
if ($r->bpahours) {
|
|
$bpahours = $r->bpahours;
|
|
$bpahours = str_replace(',', '.', $bpahours);
|
|
if (is_numeric($bpahours)) {
|
|
$bpahours = $bpahours * 3600;
|
|
$data['bpahours'] = $bpahours;
|
|
}
|
|
}
|
|
if ($r->bpahours_value) {
|
|
$bpahours_value = $r->bpahours_value;
|
|
$bpahours_value = str_replace(',', '.', $bpahours_value);
|
|
if (is_numeric($bpahours_value)) {
|
|
$data['bpahours_value'] = $bpahours_value;
|
|
}
|
|
}
|
|
|
|
if (!$data['overtime']) {
|
|
$data['overtime'] = 0;
|
|
}
|
|
if (!$data['bmd_active']) {
|
|
$data['bmd_active'] = 0;
|
|
}
|
|
if (!$data['enddate']) {
|
|
$data['enddate'] = null;
|
|
}
|
|
|
|
if ($r->birthday) {
|
|
$data['birthday'] = strtotime($r->birthday);
|
|
} else {
|
|
$data['birthday'] = null;
|
|
}
|
|
if (!$data['user_id']) {
|
|
$this->layout()->setFlash("Mitarbeiter darf nicht leer sein", "error");
|
|
$this->redirect("TimerecordingEmployee");
|
|
}
|
|
if (!$data['auto_workinghours']) {
|
|
$data['auto_workinghours'] = 0;
|
|
}
|
|
|
|
if ($mode == "edit") {
|
|
$timerecordingemployees->update($data);
|
|
|
|
} else {
|
|
$timerecordingemployees = TimerecordingEmployeeModel::create($data);
|
|
}
|
|
$id = $timerecordingemployees->save();
|
|
|
|
if (!$id) {
|
|
$this->layout()->setFlash("Personaladministration konnte nicht angelegt werden", "error");
|
|
$this->redirect("TimerecordingEmployee");
|
|
}
|
|
|
|
if ($mode == "edit") {
|
|
$this->layout()->setFlash("Personaladministration erfolgreich geändert", "success");
|
|
} else if ($mode = "add") {
|
|
$this->layout()->setFlash("Personaladministration erfolgreich angelegt", "success");
|
|
}
|
|
$this->redirect("TimerecordingEmployee");
|
|
}
|
|
|
|
|
|
protected function deleteAction()
|
|
{
|
|
$id = $this->request->id;
|
|
$timerecordingemployees = new TimerecordingEmployee($id);
|
|
if (!$timerecordingemployees->id || $timerecordingemployees->id != $id) {
|
|
$this->layout()->setFlash("Personaladministration nicht gefunden.", "error");
|
|
$this->redirect("TimerecordingEmployee");
|
|
}
|
|
|
|
$timerecordingemployees->delete();
|
|
$this->redirect("TimerecordingEmployee");
|
|
}
|
|
|
|
}
|