";
if ($currentClientIP != "") :
// echo "cr_id = " . $cr_id . "
";
// echo "day = " . $day . "
";
// echo "magic = " . $magic . "
";
if ($cr_id != "" && is_numeric($cr_id) && $day != "" && $magic == "adsg_3478") :
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 03");
$sqlquery = "SELECT bo_id, bo_type, bo_obj_data"
. " FROM phoenix_log.b2b_objects"
. " WHERE bo_type IN (215, 217) AND bo_ext_id0 = '" . $day . "' AND bo_ext_id1 = '" . $cr_id . "' AND bo_state = '0'"
. " ORDER BY bo_type, bo_ext_id2, bo_id";
// echo $sqlquery . "
";
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 04");
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 05");
$count = 0;
while ($row = $result->fetch_assoc()):
$boId[$count] = $row["bo_id"];
$boType[$count] = $row["bo_type"];
$boObjData[$count] = $row["bo_obj_data"];
$count++;
endwhile;
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 06");
$result->free();
$boIdLen = count($boId);
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 07");
// if (mysql_errno())
// writeToFile("mail_HLS.log", "DB-Error:" . " | " . $currentTime . " | " . date("Y-m-d H:i:s") . " | " . trim($_SERVER['REMOTE_ADDR']) . " | " . $filename . mysql_error());
// echo "
";
// echo "boIdLen = " . $boIdLen . "
";
if ($boIdLen > 0) :
$crvhSid = getFieldValueFromId("couriervehicle","cr_id",$cr_id,"crvh_sid");
$tourNo = substr($crvhSid, -1);
$cmpId = getFieldValueFromId("headquarters","hq_id",$hqId,"cmp_id");
$cmpLogo = getFieldValueFromId("company","cmp_id",$cmpId,"cmp_logo");
$cmpLogoWidth = getFieldValueFromId("company","cmp_id",$cmpId,"cmp_logo_width");
$cmpLogoHeight = getFieldValueFromId("company","cmp_id",$cmpId,"cmp_logo_height");
// Get barcode image
$barcode = getFieldValueFromClause("phoenix_log.b2b_objects", "bo_obj_data", "bo_type = '218' AND bo_ext_id0 = '" . $day . "' AND bo_ext_id1 = '" . $cr_id . "' AND bo_state = '0'");
$barcodeFilename = $absoluteSystemPath . "/temp/download/barcode_" . $cr_id . "_" . $day . "_" . getDateTime("6") . ".png";
// echo "barcodeFilename = " . $barcodeFilename . "
";
$tmpImgWidth = "300";
$tmpImgHeight = "50";
// $barcodeImg = barcode_BCGcode39_saveImage($barcodeFilename , "..", $barcode, $tmpScaleFactor, $tmpThickness, $tmpImgWidth, $tmpImgHeight);
$barcodeImg = barcode_BCGcode128_saveImage($barcodeFilename , "..", $barcode, $tmpScaleFactor, $tmpThickness, $tmpImgWidth, $tmpImgHeight);
// echo "BARCODE-IMG: " . $barcodeImg . "
";
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 08");
// print_r($boId); echo "
";
// print_r($boObjData); echo "
";
$mailtext = "
"
. ""
. "";
$mailtext .= "
";
$mailtext .= $barcodeImg . "
";
$mailtext .= "Datum: " . $currentDate . " ";
$mailtext .= "Übergabe aus der Tour " . $tourNo . "
";
$mailtext .= "
";
$headline_01 = "";
$headline_01 .= "";
$headline_01 .= "| " . getLngt("Pos.") . " | ";
$headline_01 .= " " . getLngt("Automatennr.") . " | ";
$headline_01 .= " " . getLngt("PN") . " | ";
$headline_01 .= " " . getLngt("Standort") . " | ";
$headline_01 .= " " . getLngt("Objektart") . " | ";
$headline_01 .= " " . getLngt("Objektnr.") . " | ";
$headline_01 .= " " . getLngt("Wert") . " | ";
$headline_01 .= " " . getLngt("Uhrzeit") . " | ";
$headline_01 .= " " . getLngt("Buchung") . " | ";
$headline_01 .= "
";
$headline_02 = "";
$headline_02 .= "";
$headline_02 .= "| " . getLngt("Pos.") . " | ";
$headline_02 .= " " . getLngt("Verkaufsstelle") . " | ";
$headline_02 .= " " . getLngt("Objektart") . " | ";
$headline_02 .= " " . getLngt("Objektnr.") . " | ";
$headline_02 .= " " . getLngt("Wert") . " | ";
$headline_02 .= " " . getLngt("Uhrzeit") . " | ";
$headline_02 .= " " . getLngt("Buchung") . " | ";
$headline_02 .= "
";
$atType2Arr = array();
$remBoType = "";
$lfd = 1;
for ($i = 0; $i < $boIdLen; $i++) :
if ($boType[$i] == "215") :
if ($remBoType != $boType[$i]) :
$lfd = 1;
if ($remBoType != "") :
$mailtext .= "";
$mailtext .= "
";
endif;
$mailtext .= "";
$mailtext .= $headline_01;
endif;
$remBoType = $boType[$i];
$tmpArr = explode(" ",$boObjData[$i]);
$atiSerialno = $tmpArr[0];
$atId = getFieldValueFromId("articleitem","ati_serialno",$atiSerialno,"at_id");
$atMatch = getFieldValueFromId("article","at_id",$atId,"at_match");
$stkId = getFieldValueFromId("articleitem","ati_serialno",$atiSerialno,"stk_id");
$stkName = getFieldValueFromId("stock","stk_id",$stkId,"stk_name");
$stkBarcode = getFieldValueFromId("stock","stk_id",$stkId,"stk_barcode");
$atiSerialno2 = $tmpArr[1];
$atId2 = getFieldValueFromId("articleitem","ati_serialno",$atiSerialno2,"at_id");
$atMatch2 = getFieldValueFromId("article","at_id",$atId2,"at_match");
if (!isset($atType2Arr[$atMatch2]) || $atType2Arr[$atMatch2] == "") :
$atType2Arr[$atMatch2] = 0;
endif;
$atType2Arr[$atMatch2]++;
$amount = substr($tmpArr[2],0,-2) . "." . substr($tmpArr[2],-2);
$clockTime = substr($tmpArr[4],0,2) . "." . substr($tmpArr[4],-2);
$mailtext .= "";
$mailtext .= "| " . ($i + 1) . " | ";
$mailtext .= "" . $atiSerialno . " | ";
$mailtext .= "" . "" . " | ";
$mailtext .= "" . $stkBarcode . " | ";
$mailtext .= "" . $atMatch2 . " | ";
$mailtext .= " " . $atiSerialno2 . " | ";
$mailtext .= "" . number_format(round($amount,2), 2, ",", ".") . " | ";
$mailtext .= "" . $clockTime . " | ";
$mailtext .= "" . "" . " | ";
$mailtext .= "
";
elseif ($boType[$i] == "217") :
if ($remBoType != $boType[$i]) :
$lfd = 1;
if ($remBoType != "") :
$mailtext .= "
";
$mailtext .= "
";
endif;
$mailtext .= "";
$mailtext .= $headline_02;
endif;
$remBoType = $boType[$i];
$tmpArr = explode("|",$boObjData[$i]);
$atihId = $tmpArr[0];
$atihSerialno = getFieldValueFromId("phoenix_log.articleitemhistory","atih_id",$atihId,"atih_serialno");
$atihData05 = getFieldValueFromId("phoenix_log.articleitemhistory","atih_id",$atihId,"atih_data_05");
$cscId = getFieldValueFromId("phoenix_log.articleitemhistory","atih_id",$atihId,"csc_id");
$atId = getFieldValueFromId("phoenix_log.articleitemhistory","atih_id",$atihId,"at_id");
$atMatch = getFieldValueFromId("phoenix.article","at_id",$atId,"at_match");
$cscName = getFieldValueFromId("phoenix.costcenter","csc_id",$cscId,"csc_name");
$stkId = getFieldValueFromId("phoenix_log.articleitemhistory","atih_id",$atihId,"stk_id");
$stkName = getFieldValueFromId("phoenix.stock","stk_id",$stkId,"stk_name");
$stkBarcode = getFieldValueFromId("phoenix.stock","stk_id",$stkId,"stk_barcode");
if (!isset($atType2Arr[$atMatch]) || $atType2Arr[$atMatch] == "") :
$atType2Arr[$atMatch] = 0;
endif;
$atType2Arr[$atMatch]++;
$clockTime = substr($tmpArr[2],0,2) . "." . substr($tmpArr[2],-2);
$mailtext .= "";
$mailtext .= "| " . ($i + 1) . " | ";
$mailtext .= "" . $cscName . " | ";
$mailtext .= "" . $atMatch . " | ";
$mailtext .= "" . $atihSerialno . " | ";
$mailtext .= "" . number_format(round($atihData05,2), 2, ",", ".") . " | ";
$mailtext .= "" . $clockTime . " | ";
$mailtext .= "" . "" . " | ";
$mailtext .= "
";
endif;
$lfd++;
endfor;
$atType2ArrKeys = array_keys($atType2Arr);
$atType2ArrKeysLen = count($atType2ArrKeys);
// print_r($atType2Arr); print_r($atType2ArrKeys);
$mailtext .= "
";
$mailtext .= "";
$mailtext .= "" . getLngt("Summen:") . "";
$mailtext .= "";
for ($i = 0; $i < $atType2ArrKeysLen; $i++) :
if ($atType2ArrKeys[$i] != "") :
$mailtext .= "";
$mailtext .= "| " . $atType2ArrKeys[$i] . " | ";
$mailtext .= "" . $atType2Arr[$atType2ArrKeys[$i]] . " | ";
$mailtext .= "
";
endif;
endfor;
$mailtext .= "
";
$mailtext .= "";
$mailtext .= "";
$mailtext .= "";
$mailtext .= "| _________________________ | | _________________________ | ";
$mailtext .= "
";
$mailtext .= "";
$mailtext .= "| " . getLngt("HOCHBAHN") . " | | " . getLngt("HLS") . " | ";
$mailtext .= "
";
$mailtext .= "
";
$mailtext .= "";
// echo $mailtext . "
";
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 09");
// Generate PDF document
$fileNameTarget = generatePDF($mailtext, $title, "0", "0", "", "", "");
// echo "fileNameTarget = " . $fileNameTarget . "
";
// Send mail with attached (generated) PDF document
if (true) :
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 10");
$mailSubject = $title;
$mailToAddresses = "ASSECUTOR-INFO@hochbahn.de";
// $mailToAddresses = "admin@assecutor.de";
$mailAttachedFileType = "";
$mailCcAddresses = "";
$mailBccAddresses = "proj.hha@assecutor.de";
$mailSenderAddress = "sys-op@assecutor.de";
$mailSent = sendPDFMail($hqId, $mailtext, $title, $mailToAddresses, $fileNameTarget, $mailSubject, $mailText, $mailAttachedFileType, $mailCcAddresses, $mailBccAddresses, $mailSenderAddress, $parKeyForLogFile, $objId, $cascadingObjType);
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 11");
if ($mailSent) :
$mailResultMsg = "OK";
for ($i = 0; $i < $boIdLen; $i++) :
updateStmt("phoenix_log.b2b_objects","bo_id",$boId[$i],array("bo_state","1"));
endfor;
else :
$mailResultMsg = "NOK";
endif;
// $cT = date("H:i:s"); writeToFile($logFile, $cT . " | 12");
endif;
endif;
else :
$opState = "ERR 102 : CR_ID or DAY missing or you do not have the force!";
endif;
else :
$opState = "ERR 101 : Unknown client IP!";
endif;
// Append to log file
writeToFile($logFile, "datetime=" . $currentTime . "|IP=" . $currentClientIP . "|cr_id=" . $cr_id . "|day=" . $day . "|bo_id=" . implode(",",$boId) . "|mail_result=" . $mailResultMsg . "|op_state=" . $opState);
echo "OK";
?>