#!/usr/bin/php
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 .= "Pipework History Report
";
foreach ($allNetworkData as $networkName => $networkData) {
$html .= "Network: " . htmlspecialchars($networkName) . "
";
if (empty($networkData)) {
$html .= '' . htmlspecialchars("Keine Änderungen im Tiefbau") . '
';
continue;
}
$html .= "";
$html .= "| Straße | Ort | Feld | Wert | Editiert | Von |
";
foreach ($networkData as $item) {
$userName = UserModel::getOne($item->last_edited_by_user_id);
$html .= "";
$html .= "| " . htmlspecialchars($item->building_street) . " | ";
$html .= "" . htmlspecialchars($item->building_city) . " | ";
$html .= "" . htmlspecialchars($item->item_label) . " | ";
$html .= "";
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 .= " | ";
$html .= "" . date("Y-m-d H:i:s", $item->last_edited_at) . " | ";
$html .= "" . htmlspecialchars($userName->username) . " | ";
$html .= "
";
}
$html .= "
";
}
$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}";
}
?>