Zeiterfassung Update
* Neues Genehmigungsverfahren für Buchhaltung eingeführt * Buchungsarten für Mitarbeiter erweitert Arztbesuch/Behörde/Weiterbildung * Neues Flag in Personaladministration für von Buchhaltung zu genehmigen
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user