Merge branch 'spidev' into 'master'
Zeiterfassung Update See merge request fronk/thetool!1858
This commit is contained in:
@@ -474,6 +474,34 @@ class TimerecordingController extends mfBaseController
|
||||
$email->setTo(TT_TIMERECORDING_EMAIL);
|
||||
$email->send();
|
||||
}
|
||||
else if ($timerecordingCategoriess[0]->approval_fibu == "1" && !$r->user_id)
|
||||
{
|
||||
$body = 'Beantrag von: ' . $this->me->name . '
|
||||
';
|
||||
$body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . '
|
||||
';
|
||||
if ($timerecordingCategoriess[0]->hourday == "1") {
|
||||
$body .= 'von: ' . date("d.m.Y H:i", $data['start']) . ' bis: ' . date("H:i", $data['end']);
|
||||
} else if ($timerecordingCategoriess[0]->hourday == "2") {
|
||||
$body .= 'von: ' . date("d.m.Y", $data['start']) . ' bis: ' . date("d.m.Y", $data['end']);
|
||||
} else if ($timerecordingCategoriess[0]->hourday == "6") {
|
||||
$body .= 'von: ' . date("d.m.Y H:i", $data['start']) . ' bis: ' . date("H:i", $data['end']);
|
||||
}
|
||||
/*
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' erstellt');
|
||||
$email->setBody($body);
|
||||
$email->setFrom(TT_TIMERECORDING_EMAIL, TT_TIMERECORDING_EMAIL_NAME);
|
||||
$email->setTo($this->me->email);
|
||||
$email->send();
|
||||
*/
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' erstellt (' . $this->me->name . ')');
|
||||
$email->setBody($body);
|
||||
$email->setFrom(TT_TIMERECORDING_EMAIL_FIBU, TT_TIMERECORDING_EMAIL_FIBU_NAME);
|
||||
$email->setTo(TT_TIMERECORDING_EMAIL_FIBU);
|
||||
$email->send();
|
||||
}
|
||||
if ($data['timerecordingCategory_id'] == "3" || $timerecordingCategoriess[0]->hourday == "5") {
|
||||
$this->updateHolidays($data['user_id']);
|
||||
}
|
||||
@@ -1091,9 +1119,9 @@ class TimerecordingController extends mfBaseController
|
||||
}
|
||||
}
|
||||
|
||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||
if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0)) {
|
||||
$state = '<i class="fa-regular fa-clock mr-1"></i>';
|
||||
} else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) {
|
||||
} else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1 )) {
|
||||
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
||||
}
|
||||
$edit = "";
|
||||
|
||||
@@ -125,6 +125,25 @@ class TimerecordingModel
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
public static function getAllPermitsFibu()
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$sql = "SELECT Timerecording.* FROM `Timerecording`
|
||||
INNER JOIN `TimerecordingCategory` ON (`Timerecording`.`timerecordingCategory_id` = `TimerecordingCategory`.`id`)
|
||||
WHERE `TimerecordingCategory`.`approval_fibu`='1'";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new Timerecording($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst()
|
||||
|
||||
@@ -84,6 +84,7 @@ class TimerecordingCategoryController extends mfBaseController
|
||||
$data['short'] = trim($r->short);
|
||||
$data['hourday'] = trim($r->hourday);
|
||||
$data['approval'] = trim($r->approval);
|
||||
$data['approval_fibu'] = trim($r->approval_fibu);
|
||||
$data['require_comment'] = trim($r->require_comment);
|
||||
$data['only_admin'] = trim($r->only_admin);
|
||||
$data['businesstrip'] = trim($r->businesstrip);
|
||||
|
||||
@@ -6,6 +6,7 @@ class TimerecordingCategoryModel
|
||||
private $short;
|
||||
private $hourday;
|
||||
private $approval;
|
||||
private $approval_fibu;
|
||||
private $require_comment;
|
||||
private $only_admin;
|
||||
private $businesstrip;
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingPermitFibuController 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("TimerecordingPermitFibu/Index");
|
||||
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
|
||||
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
|
||||
$timerecordings = TimerecordingModel::getAllPermitsFibu();
|
||||
$this->layout()->set("timerecordings", $timerecordings);
|
||||
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
}
|
||||
|
||||
protected function sendMail($timerecordings, $type)
|
||||
{
|
||||
if ($type == "deny") {
|
||||
$sendtext = "abgelehnt";
|
||||
} else if ($type == "approve") {
|
||||
$sendtext = "genehmigt";
|
||||
}
|
||||
$user = UserModel::getOne($timerecordings->user_id);
|
||||
$timerecordingCategoriess = TimerecordingCategoryModel::search(['id' => $timerecordings->timerecordingCategory_id]);
|
||||
$body = 'Beantrag von: ' . $user->name . '
|
||||
';
|
||||
$body .= 'Buchungsart: ' . $timerecordingCategoriess[0]->name . '
|
||||
';
|
||||
if ($timerecordingCategoriess[0]->hourday == "1") {
|
||||
$body .= 'von: ' . date("d.m.Y H:i", $timerecordings->start) . ' bis: ' . date("H:i", $timerecordings->end) . '
|
||||
|
||||
';
|
||||
} else if ($timerecordingCategoriess[0]->hourday == "2") {
|
||||
$body .= 'von: ' . date("d.m.Y", $timerecordings->start) . ' bis: ' . date("d.m.Y", $timerecordings->end) . '
|
||||
|
||||
';
|
||||
}
|
||||
else if ($timerecordingCategoriess[0]->hourday == "6") {
|
||||
$body .= 'von: ' . date("d.m.Y H:i", $timerecordings->start) . ' bis: ' . date("H:i", $timerecordings->end) . '
|
||||
|
||||
';
|
||||
}
|
||||
$body .= ucfirst($sendtext) . ' von: ' . $this->me->name . '
|
||||
';
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' ' . $sendtext);
|
||||
$email->setBody($body);
|
||||
$email->setFrom(TT_TIMERECORDING_EMAIL, TT_TIMERECORDING_EMAIL_NAME);
|
||||
$email->setTo($user->email);
|
||||
$email->send();
|
||||
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' ' . $sendtext . ' (' . $user->name . ')');
|
||||
$email->setBody($body);
|
||||
$email->setFrom(TT_TIMERECORDING_EMAIL, TT_TIMERECORDING_EMAIL_NAME);
|
||||
$email->setTo(TT_TIMERECORDING_EMAIL);
|
||||
$email->send();
|
||||
}
|
||||
|
||||
protected function approveAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$timerecordings = new Timerecording($id);
|
||||
if (!$timerecordings->id || $timerecordings->id != $id) {
|
||||
$this->layout()->setFlash("Buchung nicht gefunden.", "error");
|
||||
$this->redirect("TimerecordingPermitFibu");
|
||||
}
|
||||
$data = [];
|
||||
$data['approved'] = 1;
|
||||
$timerecordings->update($data);
|
||||
$timerecordings->save();
|
||||
//$this->sendMail($timerecordings, "approve");
|
||||
$this->redirect("TimerecordingPermitFibu");
|
||||
}
|
||||
|
||||
protected function denyAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$timerecordings = new Timerecording($id);
|
||||
if (!$timerecordings->id || $timerecordings->id != $id) {
|
||||
$this->layout()->setFlash("Buchung nicht gefunden.", "error");
|
||||
$this->redirect("TimerecordingPermitFibu");
|
||||
}
|
||||
//$this->sendMail($timerecordings, "deny");
|
||||
$timerecordings->delete();
|
||||
|
||||
|
||||
if ($this->request->ajax == 1) {
|
||||
die();
|
||||
}
|
||||
$this->redirect("TimerecordingPermitFibu");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -433,9 +433,9 @@ class TimerecordingReportController extends mfBaseController
|
||||
$day = $daysgerm[date("w", $timerecording->start)];
|
||||
}
|
||||
|
||||
if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0) {
|
||||
if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 0 )|| ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 0)) {
|
||||
$state = '<i class="fa-regular fa-clock mr-1"></i>';
|
||||
} else if ($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) {
|
||||
} else if (($timerecording->timerecordingCategory->approval == 1 && $timerecording->approved == 1) || ($timerecording->timerecordingCategory->approval_fibu == 1 && $timerecording->approved == 1 )) {
|
||||
$state = '<i class="fa-regular fa-circle-check mr-1"></i>';
|
||||
}
|
||||
$edit = "";
|
||||
|
||||
Reference in New Issue
Block a user