SVRZ#62191 Core-wens: mailen rapportage savepoint

KFSG#75378 Exporteren naar XLSX

svn path=/Website/trunk/; revision=60383
This commit is contained in:
Jos Groot Lipman
2023-05-11 11:28:16 +00:00
parent abc00551ca
commit c2d42dddcd
8 changed files with 147 additions and 45 deletions

View File

@@ -205,47 +205,55 @@ function notificationMail(rec, p_notificationXSL, params)
var strResult = http_request.responseText;
var contentType = /*global*/ lastContentType || "";
Log2File(1, "Got " + contentType);
var ext = "txt";
var isHTML = contentType.match(/text\/html/);
if (isHTML)
{
ext = "html"
var strResult = strResult.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "<!-- stripped script -->");
if (strResult.indexOf("shared/default-print.css") > -1) // injecteren voor eerste </head>
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var printcss = custabspath + "/../../appl/shared/default-print.css";
var fcss = fso.OpenTextFile(printcss);
var tekst = fcss.ReadAll();
fcss.Close();
strResult = strResult.replace(/<\/head>/i, "<style>/*embedding default-print.css*/\n" + tekst + "\n</style></head>");
}
if (strResult.indexOf("appl/api2/table.css") > -1) // injecteren voor eerste </head>
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var printcss = custabspath + "/../../appl/api2/table.css";
var fcss = fso.OpenTextFile(printcss);
var tekst = fcss.ReadAll();
fcss.Close();
strResult = strResult.replace(/<\/head>/i, "<style>/*embedding table.css*/\n\n" + tekst + "\n</style>\n</head>");
}
var strResult = strResult.replace(/<link rel=.*>/gi, "<!-- stripped css -->");
}
// TODO
// if <title> found use it for report title (subject line)?
var ext = "txt";
if (isHTML)
ext = "html"
else if (contentType.match(/text\/csv/))
{
ext = "csv";
}
else if (contentType.match(/application\/json/))
{
ext = "json";
var jresult = JSON.parse(strResult);
if ("tmpcsv" in jresult)
{
var tmpxlsx = jresult.tmpcsv.replace(/\.csv$/, ".xlsx");
var fso = fso = new ActiveXObject("Scripting.FileSystemObject")
var tmpbat = jresult.tmpcsv + ".bat";
var fs = fso.CreateTextFile(tmpbat, true);
var csvcmd = "..\\..\\..\\UTILS\\csv2xlsx\\csv2xlsx_386.exe" // Forward slashes werkt in een batchfile niet
+ " --infile " + jresult.tmpcsv
+ " --outfile " + tmpxlsx
+ " --columns " + jresult.colspec.join(",")
+ " --colsep \";\""
+ " --dateformat DD-MM-YYYY"
+ " --overwrite"
+ " --encoding \"WINDOWS1252\""
+ " --fontname Calibri --fontsize 11"
+ " --sheet Facilitor";
fs.Write(csvcmd);
fs.Close();
var WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run(tmpbat, 0, true);
mail_params.include_cust_file = tmpxlsx;
ext = "xlsx";
}
}
mail_params.attachFileName = "Facilitor_{0}.{1}".format(toDateTimeString(new Date()), ext);
sendMail( sender_email
, receiver_email
, rec("fac_notificatie_oms").Value
, isHTML?"":rec("fac_notificatie_oms").Value
, strResult
, rec("fac_notificatie_oms").Value // body
, isHTML?"":rec("fac_notificatie_oms").Value // body
, mail_params.include_cust_file?"":strResult // bodyhtml
, mail_params
);
// TODO: eventueel tmpcsv, tmpxlsx en tmpbat opruimen
}
else if (!rec("fac_srtnotificatie_xmlnode").value)
{