Zeiterfassung Update
* Script für Email Alarmierung §57a * Automatische auswahl beim Buchen von Dienstreisen auf das zugewiesene Fahrzeug
This commit is contained in:
66
scripts/check_timerecording_p57a.php
Normal file
66
scripts/check_timerecording_p57a.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG', false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR . "/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(154);
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
|
||||
|
||||
$timerecordingcars = TimerecordingCarModel::getAll();
|
||||
//var_dump($timerecordingemployees);
|
||||
|
||||
foreach ($timerecordingcars as $timerecordingcar) {
|
||||
unset ($approval);
|
||||
if ($timerecordingcar->initial_approval) {
|
||||
$initialApproval = date("Y-m-d H:i:s", $timerecordingcar->initial_approval);
|
||||
$initialApprovalMonth = date("m", $timerecordingcar->initial_approval);
|
||||
$firstApproval = strtotime('+' . $timerecordingcar->first_approval . 'years', strtotime($initialApproval));
|
||||
if ($firstApproval < time()) {
|
||||
$firstApproval = strtotime(date("Y-$initialApprovalMonth-01", time()));
|
||||
if ($firstApproval < time()) {
|
||||
$firstApproval = strtotime(date("Y-$initialApprovalMonth-01", strtotime('+1 year')));
|
||||
}
|
||||
}
|
||||
|
||||
$checkDate = date("m/Y", strtotime('+1 month'));
|
||||
$approval = date("m/Y", $firstApproval);
|
||||
if ($checkDate == $approval) {
|
||||
$model = trim($timerecordingcar->brand . " " . $timerecordingcar->model);
|
||||
$message = "§57a Überprüfung des Fahrzeuges " . $timerecordingcar->number_plate . " (" . $model . ") ist im Monat " . $approval . " fällig.";
|
||||
$message .= "\n\nFahrzeuginformationen:";
|
||||
$message .= "\nKennzeichen: " . $timerecordingcar->number_plate;
|
||||
$message .= "\nMarke/Model: " . $model;
|
||||
if ($timerecordingcar->mileage_now) {
|
||||
$message .= "\nKilometerstand: " . number_format($timerecordingcar->mileage_now, 0, ',', '.') . " KM";
|
||||
} else {
|
||||
$message .= "\nKilometerstand: -";
|
||||
}
|
||||
if ($timerecordingcar->user_id) {
|
||||
$message .= "\nFahrzeugverwalter: " . $timerecordingcar->user->name;
|
||||
} else {
|
||||
$message .= "\nFahrzeugverwalter: -";
|
||||
}
|
||||
$email = new Emailnotification();
|
||||
$email->setSubject('Fälligkeit §57a Überprüfung im Monat ' . $approval . ' (' . $timerecordingcar->number_plate . ')');
|
||||
$email->setBody($message);
|
||||
$email->setFrom('notify@xinon.at', 'Xinon Information');
|
||||
$email->setTo('backoffice@xinon.at');
|
||||
$email->send();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user