Zeiterfassung update
This commit is contained in:
@@ -42,6 +42,37 @@ class TimerecordingPermitController extends mfBaseController
|
||||
{
|
||||
}
|
||||
|
||||
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) . '
|
||||
|
||||
';
|
||||
}
|
||||
$body .= ucfirst($sendtext) . ' von: ' . $this->me->name . '
|
||||
';
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject('Antrag für ' . $timerecordingCategoriess[0]->name . ' ' . $sendtext);
|
||||
$email->setBody($body);
|
||||
$email->setFrom('zeiterfassung@xinon.at', 'Xinon Zeiterfassung');
|
||||
$email->setTo($user->email);
|
||||
$email->send();
|
||||
}
|
||||
|
||||
protected function approveAction()
|
||||
{
|
||||
@@ -55,7 +86,25 @@ class TimerecordingPermitController extends mfBaseController
|
||||
$data['approved'] = 1;
|
||||
$timerecordings->update($data);
|
||||
$timerecordings->save();
|
||||
$this->sendMail($timerecordings, "approve");
|
||||
$this->redirect("TimerecordingPermit");
|
||||
}
|
||||
|
||||
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("TimerecordingPermit");
|
||||
}
|
||||
$this->sendMail($timerecordings, "deny");
|
||||
$timerecordings->delete();
|
||||
|
||||
|
||||
if ($this->request->ajax == 1) {
|
||||
die();
|
||||
}
|
||||
$this->redirect("TimerecordingPermit");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user