109 lines
3.4 KiB
PHP
109 lines
3.4 KiB
PHP
#!/usr/bin/php
|
|
<?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(1);
|
|
|
|
define("INTERNAL_USER_ID", $me->id);
|
|
define("INTERNAL_USER_USERNAME", $me->username);
|
|
|
|
$pipeworkController = new PipeworkController(false);
|
|
|
|
$networkIDs = [41, 90, 22, 2, 25, 24, 7, 15, 6, 12, 13];
|
|
|
|
$allNetworkData = [];
|
|
|
|
foreach ($networkIDs as $networkID) {
|
|
$network = new Network($networkID);
|
|
|
|
$from = date("U", strtotime("-1 week"));
|
|
$to = date("U");
|
|
|
|
$pipeworkHistory = BuildingModel::getHistory($from, $to, $networkID, '');
|
|
$allNetworkData[$network->name] = $pipeworkHistory;
|
|
}
|
|
|
|
$html = "<html><body>";
|
|
$html .= "<h1>Pipework History Report</h1>";
|
|
|
|
foreach ($allNetworkData as $networkName => $networkData) {
|
|
$html .= "<h2>Network: " . htmlspecialchars($networkName) . "</h2>";
|
|
if (empty($networkData)) {
|
|
$html .= '<h5 style="color: orange;">' . htmlspecialchars("Keine Änderungen im Tiefbau") . '</h5>';
|
|
continue;
|
|
}
|
|
|
|
$html .= "<table border='1'>";
|
|
$html .= "<tr><th>Straße</th><th>Ort</th><th>Feld</th><th>Wert</th><th>Editiert</th><th>Von</th></tr>";
|
|
foreach ($networkData as $item) {
|
|
$userName = UserModel::getOne($item->last_edited_by_user_id);
|
|
$html .= "<tr>";
|
|
$html .= "<td>" . htmlspecialchars($item->building_street) . "</td>";
|
|
$html .= "<td>" . htmlspecialchars($item->building_city) . "</td>";
|
|
$html .= "<td>" . htmlspecialchars($item->item_label) . "</td>";
|
|
$html .= "<td>";
|
|
switch ($item->item_type) {
|
|
case 'string':
|
|
$html .= htmlspecialchars($item->value_string);
|
|
break;
|
|
case 'int':
|
|
$html .= htmlspecialchars($item->value_int);
|
|
break;
|
|
case 'text':
|
|
$html .= nl2br(htmlspecialchars($item->value_text));
|
|
break;
|
|
default:
|
|
$html .= "N/A";
|
|
}
|
|
$html .= "</td>";
|
|
$html .= "<td>" . date("Y-m-d H:i:s", $item->last_edited_at) . "</td>";
|
|
$html .= "<td>" . htmlspecialchars($userName->username) . "</td>";
|
|
$html .= "</tr>";
|
|
}
|
|
|
|
$html .= "</table><br>";
|
|
}
|
|
|
|
$html .= "</body></html>";
|
|
|
|
// Instantiate PHPMailer
|
|
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
|
|
|
|
try {
|
|
// Server settings
|
|
$mail->isSMTP();
|
|
$mail->Host = TT_PIPEWORK_SMTP_HOST;
|
|
$mail->SMTPAuth = true;
|
|
$mail->Username = TT_PIPEWORK_SMTP_USER;
|
|
$mail->Password = TT_PIPEWORK_SMTP_PASS;
|
|
$mail->CharSet = "UTF-8";
|
|
$mail->Encoding = 'base64';
|
|
$mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
|
|
$mail->Port = 587;
|
|
|
|
// Recipients
|
|
$mail->setFrom('einkauf@xinon.at', 'XINON Einkauf');
|
|
$mail->addAddress('mark.zaff@xinon.eu', 'Mark Zaff');
|
|
$mail->addAddress('luca.haid@xinon.eu', 'Luca Haid');
|
|
|
|
// Content
|
|
$mail->isHTML(true);
|
|
$mail->Subject = 'Tiefbau Report';
|
|
$mail->Body = $html;
|
|
$mail->AltBody = strip_tags($html);
|
|
|
|
$mail->send();
|
|
echo 'Message has been sent';
|
|
} catch (Exception $e) {
|
|
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
|
}
|
|
|
|
?>
|