"0") : $hqName = getFieldValueFromId("headquarters","hq_id",$hqIdMail,"hq_name"); endif; // Init $currentDateTime = getDateTime("0"); $sendPerMail = false; $path = "../temp/download/"; $f_secretFileName = "CRVH_LIST_" . getDateTime("6") . ".csv"; // List of all vehicles with special fields if (true) : $typeArr = defineOutputFormats(); $triggerArray = array(); $csvArray = array(); // Insert header $headerArray = array("SID", "EID", "Name", "Vorname", "Partnerprämie", "Partnerprovision", "Werbevergütung", "Transportversicherung", "Betriebshaftpflichtversicherung", "BHV-Datum", "Systemgebühr"); $fieldArray = array("crvh_sid", "cr_eid", "usr_name", "usr_firstname", "crvh_partner_premium", "crvh_partner_commission", "crvh_advertising_allowance", "crvh_transport_insurance_amount", "crvh_business_liability_insurance_amount", "crvh_business_liability_insurance_date", "crvh_system_fee_amount"); $triggerArray[] = $headerArray; $csvArray[] = implode(";", $headerArray); // Check for headquaters $whereClause = "cr.hq_id = '" . $hqIdMail . "'"; if ($hqIdMail == "HQ_ALL") : $whereClause = ""; endif; // Check for split regarding vehicle type if ($courierOrTruckOnly == "K" || $courierOrTruckOnly == "L") : if ($whereClause != "") : $whereClause .= " AND "; endif; if ($courierOrTruckOnly == "K") : $whereClause .= "crvh.vht_id < '7'"; else : $whereClause .= "crvh.vht_id >= '7' AND crvh.vht_id < '999'"; endif; endif; $orderByClause = "crvh.crvh_sid"; $sqlquery = getStmtCrCrvhList($whereClause, $orderByClause); // echo $sqlquery . "\n\n"; die(); $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $lineArr = array($row[$fieldArray[0]], $row[$fieldArray[1]], $row[$fieldArray[2]], $row[$fieldArray[3]], $row[$fieldArray[4]], $row[$fieldArray[5]], $row[$fieldArray[6]], $row[$fieldArray[7]], $row[$fieldArray[8]], $row[$fieldArray[9]], $row[$fieldArray[10]]); $triggerArray[] = $lineArr; $csvArray[] = implode(";", $lineArr); endwhile; $result->free(); $triggerArrayLen = count($triggerArray); $triggerOut = ""; // 66CCFF, FF0000, FF0044, FF6633, FFCC33, FFFF33 if ($triggerArrayLen > 0) : // $sendPerMail = true; // At least one event to be mailed // HTML output $triggerOut .= "\n"; $triggerOut .= "\n"; /* $triggerOut .= "
"; $triggerOut .= "\n"; $triggerOut .= "\n"; $triggerOut .= ""; $triggerOut .= ""; $triggerOut .= ""; $triggerOut .= ""; $triggerOut .= ""; $triggerOut .= "\n"; $triggerOut .= "
  KEIN EINTRAG     < 6 Monate      < 3 Monate      < 2 Monate      < 1 Monat    
\n"; */ $triggerOut .= "

"; $triggerOut .= "\n"; // Headline $triggerOut .= "\n"; $tmpArray = $triggerArray[0]; $tmpArrayLen = count($tmpArray); // $rowColor = $tmpArray[0]; $rowColor = "66CCFF"; // Here a static value for ($j = 0; $j < $tmpArrayLen; $j++) : $triggerOut .= "\n"; endfor; $triggerOut .= "\n"; // Body for ($i = 1; $i < $triggerArrayLen; $i++) : $tmpArray = $triggerArray[$i]; $tmpArrayLen = count($tmpArray); // $rowColor = $tmpArray[0]; $rowColor = "66CCFF"; // Here a static value $triggerOut .= "\n"; for ($j = 0; $j < $tmpArrayLen; $j++) : if ($typeArr[$fieldArray[$j]] == "float") : $formattedOutput = formatOutput($tmpArray[$j], $typeArr[$fieldArray[$j]], "2"); $textAlign = "right"; elseif ($typeArr[$fieldArray[$j]] == "datetime") : $formattedOutput = formatOutput($tmpArray[$j], $typeArr[$fieldArray[$j]], "4"); $textAlign = "center"; else : $formattedOutput = formatOutput($tmpArray[$j]); $textAlign = "left"; endif; $triggerOut .= "\n"; endfor; $triggerOut .= "\n"; endfor; $triggerOut .= "
 " . $tmpArray[$j] . "   
 " . $formattedOutput . ($rowColor == "FF0000" && $j == "6" ? " [überschritten]" : "") . "   
\n"; $triggerOut .= "\n"; $triggerOut .= "\n"; // CSV attachment $csvArrayLen = count($csvArray); for ($i = 0; $i < $csvArrayLen; $i++) : writeToFile($path . $f_secretFileName, $csvArray[$i]); endfor; endif; // Send via email if ($sendPerMail) : $mailSenderAddress = "support@assecutor.de"; // Receiver of the mail $mailReceiverAddressArray = array("support@assecutor.de"); if ($hqIdMail != "" && is_numeric($hqIdMail)) : $mailReceiverAddress = getParameterValue("0", "MAIL_CRON_201_TO_ADDRESS", $hqIdMail); // Check for split regarding vehicle type if ($courierOrTruckOnly == "K" || $courierOrTruckOnly == "L") : if ($courierOrTruckOnly == "K") : $mailReceiverAddress = getParameterValue("0", "MAIL_CRON_201_A_TO_ADDRESS", $hqIdMail); else : $mailReceiverAddress = getParameterValue("0", "MAIL_CRON_201_B_TO_ADDRESS", $hqIdMail); endif; endif; endif; if ($mailReceiverAddress == "") : $mailReceiverAddress = getParameterValue("0", "MAIL_CRON_201_TO_ADDRESS", "0"); endif; if ($mailReceiverAddress != "") : $mailReceiverAddressArray = spliti(",",$mailReceiverAddress); endif; // echo "mailReceiverAddress = " . $mailReceiverAddress . "\n\n"; // $mailReceiverAddressArray = array("mv@assecutor.de", "ingo.kublenz@stadtbote.de"); $mailSubject = "Fahrzeuggebühren [" . $hqName . "]"; if ($courierOrTruckOnly == "K" || $courierOrTruckOnly == "L") : if ($courierOrTruckOnly == "L") : $mailSubject .= " [" . "LKW" . "]"; else : $mailSubject .= " [" . "PKW" . "]"; endif; endif; $mailCcAddress = ""; $mailBccAddress = ""; $mailtext = "FAHRZEUGGEBÜHREN"; if ($courierOrTruckOnly == "K" || $courierOrTruckOnly == "L") : if ($courierOrTruckOnly == "L") : $mailtext .= " [" . "LKW" . "]"; else : $mailtext .= " [" . "PKW" . "]"; endif; endif; $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, "./"); // Attachment if ($f_secretFileName != "") : if (file_exists($path . $f_secretFileName)) : $attachment = $mailObj->getFile($path . $f_secretFileName); // $mailObj->addAttachment($attachment, $f_secretFileName, $f_mimetype . $f_charset); $mailObj->addAttachment($attachment, $f_secretFileName, 'text/csv'); endif; endif; $mailResult = $mailObj->send($mailReceiverAddressArray, 'smtp'); if ($mailResult) : // $mailsendStatus = getLngt("Die Nachricht wurde versandt!"); // Write logdata into log database // writeToLogDB("22",$currentHqId,$job_id,$currentSessionUsrId,"","","",$f_email . "|STATION"); else : // $mailsendStatus = getLngt("Die Nachricht konnte nicht gesendet werden!"); // Write logdata into log database // writeToLogDB("23",$currentHqId,$job_id,$currentSessionUsrId,"","","",$f_email . "|STATION"); endif; $mailObj = NULL; if (file_exists($path . $f_secretFileName)) : unlink($path . $f_secretFileName); endif; $out = "Der Sendevorgang wurde abgeschlossen! Bitte prüfen Sie Ihren Email-Eingangsordner!"; endif; endif; else : $out = "Leider haben Sie zur Ausführung keine Berechtigung!"; endif; endif; ?>