query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
while ($row = $result->fetch_assoc()):
if ($triggerArray[$row["crvh_id"]] == "") :
$triggerArray[$row["crvh_id"]] = array("66CCFF", $row["rp_id"], $row["rp_createtime"], $row["crvh_sid"], $row["crvh_vh_sign"], $row["cs_eid"], $row["cs_cmp_id"], $row["cr_id"], $row["cr_eid"], $row["usr_name"], $row["usr_firstname"], $row["crvh_id"], $row["cr_cmp_id"]);
$crvhRpAssocDoesExist[$row["crvh_sid"]] = "1";
endif;
$mtfvTime = $row["rp_createtime"];
if ($mtfvTime > $triggerArray[$row["crvh_id"]][2]) :
$triggerArray[$row["crvh_id"]] = array("66CCFF", $row["rp_id"], $row["rp_createtime"], $row["crvh_sid"], $row["crvh_vh_sign"], $row["cs_eid"], $row["cs_cmp_id"], $row["cr_id"], $row["cr_eid"], $row["usr_name"], $row["usr_firstname"], $row["crvh_id"], $row["cr_cmp_id"]);
endif;
if ($mtfvTime == "") :
$triggerArray[$row["crvh_id"]][0] = "66CCFF";
elseif ($mtfvTime <= $checkTime) :
$triggerArray[$row["crvh_id"]][0] = "FF0000";
elseif ($mtfvTime <= $checkTime2) :
$triggerArray[$row["crvh_id"]][0] = "FFFF33";
elseif ($mtfvTime > $checkTime) :
$triggerArray[$row["crvh_id"]][0] = "00FF00";
endif;
endwhile;
$result->free();
// GET ALL vehicle (of the selected courier)
$sqlquery = "SELECT '' AS rp_id, '' AS rp_createtime, '' AS rp_objid, cr.cr_id, cr.cr_eid, crvh.crvh_id, crvh.crvh_sid, crvh.crvh_vh_sign, '' AS cs_eid, '' AS cs_cmp_id, cr.cmp_id AS cr_cmp_id, usr.usr_name, usr.usr_firstname"
. " FROM courier AS cr, couriervehicle AS crvh, user AS usr, headquarters AS hq, company AS cr_cmp"
. " WHERE crvh.cr_id = cr.cr_id AND"
. " cr.hq_id = hq.hq_id AND"
. $whereClauseCrId
. $whereClauseHq1
. " cr.cmp_id = cr_cmp.cmp_id AND"
. " cr_cmp.cmp_authenticated = '1' AND"
. " cr_cmp.cmp_visible = '1' AND"
. " cr.hq_id = hq.hq_id AND"
. " cr.usr_id = usr.usr_id"
. " ORDER BY crvh.crvh_sid, usr.usr_name, usr.usr_firstname";
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
while ($row = $result->fetch_assoc()):
if ($crvhRpAssocDoesExist[$row["crvh_sid"]] == "") :
$triggerArray[$row["crvh_id"]] = array("66CCFF", $row["rp_id"], $row["rp_createtime"], $row["crvh_sid"], $row["crvh_vh_sign"], $row["cs_eid"], $row["cs_cmp_id"], $row["cr_id"], $row["cr_eid"], $row["usr_name"], $row["usr_firstname"], $row["crvh_id"], $row["cr_cmp_id"]);
endif;
endwhile;
$result->free();
$triggerKeysArray = array_keys($triggerArray);
$triggerKeysArrayLen = count($triggerKeysArray);
$triggerOut = "";
if ($triggerKeysArrayLen > 0) :
$sendPerMail = true; // At least one event to be mailed
$triggerOut .= "\n";
$triggerOut .= "
\n";
$triggerOut .= "\n";
$triggerOut .= "\n";
$triggerOut .= "| " . getLngt("ÜBERSICHT VORORTPRÜFUNGEN") . " | ";
$triggerOut .= "
\n";
$triggerOut .= "
\n";
$triggerOut .= "
";
$triggerOut .= "\n";
$triggerOut .= "\n";
$triggerOut .= "| KEIN EINTRAG | ";
$triggerOut .= " <4 Monate | ";
$triggerOut .= " 4-6 Monate | ";
$triggerOut .= " >6 Monate | ";
$triggerOut .= "
\n";
$triggerOut .= "
\n";
$triggerOut .= "
";
$triggerOut .= "\n";
$triggerOut .= "\n";
$triggerOut .= "| " . getLngt("Fahrzeug") . " | \n";
$triggerOut .= "" . getLngt("Kennzeichen") . " | \n";
$triggerOut .= "" . getLngt("EID") . " | \n";
$triggerOut .= "" . getLngt("Name") . " | \n";
$triggerOut .= "" . getLngt("Vorname") . " | \n";
$triggerOut .= "" . getLngt("Bericht") . " | \n";
$triggerOut .= "" . getLngt("Kunde") . " | \n";
$triggerOut .= "" . getLngt("Datum") . " | \n";
$triggerOut .= "
\n";
for ($i = 0; $i < $triggerKeysArrayLen; $i++) :
$tmpArray = $triggerArray[$triggerKeysArray[$i]];
$tmpArrayLen = count($tmpArray);
$rowColor = $tmpArray[0];
$triggerOut .= "\n";
$triggerOut .= "| " . $tmpArray[3] . " | \n";
$triggerOut .= "" . $tmpArray[4] . " | \n";
$triggerOut .= "" . $tmpArray[8] . " | \n";
$triggerOut .= "" . $tmpArray[9] . " | \n";
$triggerOut .= "" . $tmpArray[10] . " | \n";
$triggerOut .= "" . $tmpArray[1] . " | \n";
$triggerOut .= "" . $tmpArray[5] . " | \n";
$triggerOut .= "" . substr($tmpArray[2],8,2) . "." . substr($tmpArray[2],5,2) . "." . substr($tmpArray[2],0,4) . " | \n";
$triggerOut .= "
\n";
endfor;
$triggerOut .= "
\n";
$triggerOut .= "\n";
$triggerOut .= "\n";
endif;
// Send via email
if ($autoMode && $sendPerMail) :
$mailSenderAddress = "support@assecutor.de";
// Receiver of the mail
$mailReceiverAddressArray = array("support@assecutor.de");
if ($hqIdMail != "" && is_numeric($hqIdMail)) :
$mailReceiverAddress = getParameterValue("0", "MAIL_CRON_103_TO_ADDRESS", $hqIdMail);
endif;
if ($mailReceiverAddress == "") :
$mailReceiverAddress = getParameterValue("0", "MAIL_CRON_103_TO_ADDRESS", "0");
endif;
if ($mailReceiverAddress != "") :
$mailReceiverAddressArray = spliti(",",$mailReceiverAddress);
endif;
$mailSubject = "Vorort-Prüfung";
$mailCcAddress = "";
$mailBccAddress = "";
// $mailtext = "VORORT-PRÜFUNG
";
$mailtext = "";
if (!$autoMode) :
$mailtext .= "Ausgeführt von: " . $usrFirstname . " " . $usrName;
endif;
$mailtext .= $triggerOut;
$mailObj = new htmlMimeMail();
// Set From address
$mailObj->setFrom($mailSenderAddress);
// Set Cc address
if ($mailCcAddress != "") :
$mailObj->setCc($mailCcAddress);
endif;
// Set Bcc address
if ($mailBccAddress != "") :
$mailObj->setBcc($mailBccAddress);
endif;
// Subject of the mail
$mailObj->setSubject($mailSubject);
// Mail text
$mailObj->setHtml($mailtext, null, "./");
if ($f_secretFileName != "") :
if (file_exists("../temp/download/" . $f_secretFileName)) :
$attachment = $mailObj->getFile("../temp/download/" . $f_secretFileName);
$mailObj->addAttachment($attachment, $f_secretFileName, $f_mimetype . $f_charset);
endif;
endif;
$mailResult = $mailObj->send($mailReceiverAddressArray, 'smtp');
$out = "Der Sendevorgang wurde abgeschlossen! Bitte prüfen Sie Ihren Email-Eingangsordner!";
endif;
endif;
?>