1. Import
This commit is contained in:
318
html/tools/tool_vop.php
Normal file
318
html/tools/tool_vop.php
Normal file
@@ -0,0 +1,318 @@
|
||||
<?php
|
||||
/*=======================================================================
|
||||
*
|
||||
* tool_vop.php
|
||||
*
|
||||
* Autor: Marc Vollmann
|
||||
*
|
||||
=======================================================================*/
|
||||
|
||||
include_once ("../include/mcglobal.inc.php");
|
||||
|
||||
$autoMode = false;
|
||||
if (!isset($argv[1]) || $argv[1] == "") :
|
||||
include_once ("../include/auth.inc.php");
|
||||
getSecHttpVars("1", array("f_act", "objId", "objType"));
|
||||
$autoMode = false;
|
||||
$hqIdMail = $hq_id;
|
||||
// Check for authentication access and granted rights
|
||||
$usrAccessArray["hq"] = "1";
|
||||
$accessOK = authCheckForAccess($hq_id, $usr_id, $emp_id, "", $customerId, $cscIdRoot, $cscIdActual);
|
||||
else :
|
||||
if ($argv[1] == "acapella7890") :
|
||||
$autoMode = true;
|
||||
$hqIdMail = trim($argv[2]);
|
||||
else :
|
||||
die();
|
||||
endif;
|
||||
endif;
|
||||
|
||||
include_once ('../include/email/htmlMimeMail.php');
|
||||
|
||||
/*
|
||||
getLanguage(__FILE__);
|
||||
$deactivateMenuStatic = "1";
|
||||
$pageTitel = getLngt("Vorort-Prüfungen");
|
||||
include_once ("../admin/menu.php");
|
||||
include_once ("../include/html.inc.php");
|
||||
include_once ("../include/inc_filters.inc.php");
|
||||
include_once ("../include/inc_vehicle.inc.php");
|
||||
include_once ("../include/inc_group.inc.php");
|
||||
getCurrentScript(__FILE__);
|
||||
*/
|
||||
|
||||
// Check for authentication access and granted rights
|
||||
// $usrAccessArray["hq"] = "1";
|
||||
// authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
|
||||
// authCheckEmployeeRights($emp_id, "1", "1");
|
||||
|
||||
// $currentDate = getDateTime("1");
|
||||
// $currentDateTime = getDateTime("6");
|
||||
|
||||
|
||||
if ($hqIdMail != "" && (is_numeric($hqIdMail) || $hqIdMail == "HQ_ALL")) :
|
||||
|
||||
// Get user
|
||||
if (!$autoMode) :
|
||||
$usrName = getFieldValueFromId("user","usr_id",$usr_id,"usr_name");
|
||||
$usrFirstname = getFieldValueFromId("user","usr_id",$usr_id,"usr_firstname");
|
||||
endif;
|
||||
|
||||
// Init
|
||||
$sendPerMail = false;
|
||||
$f_secretFileName = "";
|
||||
|
||||
$triggerArray = array();
|
||||
|
||||
$whereClauseCrId = "";
|
||||
if ($objId != "" && is_numeric($objId)) :
|
||||
$whereClauseCrId = " cr.cr_id = '" . $objId . "' AND ";
|
||||
endif;
|
||||
|
||||
$constAmStarttimeInDays = 180; // 6 months
|
||||
$constAmStarttimeInDays2 = 120; // 4 months
|
||||
|
||||
$checkTime = getDateTime("datetime_plus_offset", array(0,0,0,0,-($constAmStarttimeInDays),0), "Y-m-d") . " 00:00:00";
|
||||
$checkTime2 = getDateTime("datetime_plus_offset", array(0,0,0,0,-($constAmStarttimeInDays2),0), "Y-m-d") . " 00:00:00";
|
||||
|
||||
$crvhRpAssocDoesExist = array();
|
||||
|
||||
$whereClauseHq1 = " cr.hq_id = '" . $hqIdMail . "' AND ";
|
||||
if ($hqIdMail == "HQ_ALL") :
|
||||
$whereClauseHq1 = "";
|
||||
$whereClauseHq2 = "";
|
||||
endif;
|
||||
|
||||
// "Vorort-Prüfung Kundenberichte", Kategorie = mtfc_id = 102
|
||||
$sqlquery = "SELECT rp.rp_id, rp.rp_createtime, rp.rp_objid, cr.cr_id, cr.cr_eid, crvh.crvh_id, crvh.crvh_sid, crvh.crvh_vh_sign, mtfv2.mtfv_value AS cs_eid, cr.cmp_id AS cr_cmp_id, usr.usr_name, usr.usr_firstname"
|
||||
. " FROM metafieldcategory AS mtfc, metafieldkey AS mtfk, metafieldcategorykey AS mtfck, metafieldvalue AS mtfv, "
|
||||
. " courier AS cr, couriervehicle AS crvh, company AS cr_cmp, user AS usr, headquarters AS hq,"
|
||||
. " phoenix_group.report_process AS rp LEFT JOIN metafieldvalue AS mtfv2 ON mtfv2.mtfv_id = rp.rp_id AND mtfv2.mtfck_id = '86' AND mtfv2.mtfv_value != ''"
|
||||
. " WHERE mtfc.mtfc_id = '102' AND"
|
||||
. " mtfk.mtfk_id = '426' AND"
|
||||
. " mtfck.mtfc_id = mtfc.mtfc_id AND"
|
||||
. " mtfck.mtfk_id = mtfk.mtfk_id AND"
|
||||
. " LEFT(mtfk.mtfk_type, 11) = 'select:crvh' AND"
|
||||
. " mtfv.mtfck_id = mtfck.mtfck_id AND"
|
||||
. " mtfv.mtfv_id = rp.rp_id AND"
|
||||
. " mtfv.mtfv_value != '' AND"
|
||||
. " crvh.crvh_sid COLLATE latin1_general_ci = mtfv.mtfv_value COLLATE latin1_general_ci AND"
|
||||
. " crvh.cr_id = cr.cr_id AND"
|
||||
. $whereClauseCrId
|
||||
. " cr.cmp_id = cr_cmp.cmp_id AND"
|
||||
. " cr_cmp.cmp_authenticated = '1' AND"
|
||||
. " cr_cmp.cmp_visible = '1' AND"
|
||||
. $whereClauseHq1
|
||||
. " cr.hq_id = hq.hq_id AND"
|
||||
. " cr.usr_id = usr.usr_id"
|
||||
. " ORDER BY crvh.crvh_sid, usr.usr_name, usr.usr_firstname, rp.rp_id, mtfk.mtfk_name";
|
||||
/*
|
||||
$sqlquery = "SELECT cr.cr_id, cr.cr_eid, crvh.crvh_id, crvh.crvh_sid, crvh.crvh_vh_sign, cr.cmp_id AS cr_cmp_id, usr.usr_name, usr.usr_firstname, rp.rp_id, rp.rp_createtime, rp.rp_objid, cs.cs_eid, cs.cmp_id AS cs_cmp_id"
|
||||
. " FROM courier AS cr, user AS usr, headquarters AS hq, couriervehicle AS crvh"
|
||||
. " LEFT JOIN metafieldvalue AS mtfv ON crvh.crvh_sid COLLATE latin1_general_ci = mtfv.mtfv_value COLLATE latin1_general_ci"
|
||||
. " INNER JOIN metafieldcategorykey AS mtfck ON mtfv.mtfck_id = mtfck.mtfck_id AND mtfck.mtfc_id = '102' AND mtfck.mtfk_id = '426'"
|
||||
. " INNER JOIN metafieldkey AS mtfk ON mtfck.mtfk_id = mtfk.mtfk_id AND LEFT(mtfk.mtfk_type, 11) = 'select:crvh'"
|
||||
. " LEFT JOIN phoenix_group.report_process AS rp ON mtfv.mtfv_id = rp.rp_id"
|
||||
. " LEFT JOIN customer AS cs ON rp.rp_objid = cs.cs_id"
|
||||
. " WHERE crvh.cr_id = cr.cr_id AND"
|
||||
. $whereClauseCrId
|
||||
. " cr.hq_id = '" . $hq_id . "' AND"
|
||||
. " cr.hq_id = hq.hq_id AND"
|
||||
. " cr.usr_id = usr.usr_id"
|
||||
. " ORDER BY rp.rp_id, mtfk.mtfk_name, 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 ($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 .= "<html>\n";
|
||||
$triggerOut .= "<body>\n";
|
||||
|
||||
$triggerOut .= "<table>\n";
|
||||
$triggerOut .= "<tr>\n";
|
||||
$triggerOut .= "<td class=\"f12bp1_blue\">" . getLngt("ÜBERSICHT VORORTPRÜFUNGEN") . "</td>";
|
||||
$triggerOut .= "</tr>\n";
|
||||
$triggerOut .= "</table>\n";
|
||||
$triggerOut .= "<br><br>";
|
||||
|
||||
$triggerOut .= "<table>\n";
|
||||
$triggerOut .= "<tr>\n";
|
||||
$triggerOut .= "<td style=\"background-color: #66CCFF;\"> KEIN EINTRAG </td>";
|
||||
$triggerOut .= "<td style=\"background-color: #00FF00;\"> <4 Monate </td>";
|
||||
$triggerOut .= "<td style=\"background-color: #FFFF33;\"> 4-6 Monate </td>";
|
||||
$triggerOut .= "<td style=\"background-color: #FF0033;\"> >6 Monate </td>";
|
||||
$triggerOut .= "</tr>\n";
|
||||
$triggerOut .= "</table>\n";
|
||||
$triggerOut .= "<br><br>";
|
||||
|
||||
$triggerOut .= "<table>\n";
|
||||
$triggerOut .= "<tr>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Fahrzeug") . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Kennzeichen") . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("EID") . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Name") . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Vorname") . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Bericht") . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Kunde") . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center;\">" . getLngt("Datum") . " </td>\n";
|
||||
$triggerOut .= "</tr>\n";
|
||||
for ($i = 0; $i < $triggerKeysArrayLen; $i++) :
|
||||
$tmpArray = $triggerArray[$triggerKeysArray[$i]];
|
||||
$tmpArrayLen = count($tmpArray);
|
||||
$rowColor = $tmpArray[0];
|
||||
$triggerOut .= "<tr>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/courier_vehicle.php?courierId=" . $tmpArray[7] . "&f_crvh_id=" . $tmpArray[11] . "\" target=\"_blank\">" . $tmpArray[3] . "</a> </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . $tmpArray[4] . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/courier_special.php?companyId=" . $tmpArray[12] . "\" target=\"_blank\">" . $tmpArray[8] . "</a> </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . $tmpArray[9] . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . $tmpArray[10] . " </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../groupware/report.php?rpObjType=cs&rpIdsFilter=" . $tmpArray[1] . "\" target=\"_blank\">" . $tmpArray[1] . "</a> </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\"><a href=\"../admin/customer_special.php?companyId=" . $tmpArray[6] . "\" target=\"_blank\">" . $tmpArray[5] . "</a> </td>\n";
|
||||
$triggerOut .= "<td style=\"text-align:center; background-color: #" . $rowColor . ";\">" . substr($tmpArray[2],8,2) . "." . substr($tmpArray[2],5,2) . "." . substr($tmpArray[2],0,4) . "</td>\n";
|
||||
|
||||
$triggerOut .= "</tr>\n";
|
||||
endfor;
|
||||
$triggerOut .= "</table>\n";
|
||||
|
||||
$triggerOut .= "</body>\n";
|
||||
$triggerOut .= "</html>\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<br><br>";
|
||||
$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;
|
||||
?>
|
||||
|
||||
<?php if (!$autoMode) : ?>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
|
||||
</head>
|
||||
|
||||
<body class="menu_bgcol" >
|
||||
|
||||
<center>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<b><?php echo $triggerOut ?></b>
|
||||
|
||||
</center>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user