- switchable report output type
This commit is contained in:
parent
1e6590f6bb
commit
8238fab8b7
@ -534,6 +534,7 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
|
|||||||
$gameid = trim($params["gameid"]);
|
$gameid = trim($params["gameid"]);
|
||||||
$filter = trim($params["filter"] ?? "");
|
$filter = trim($params["filter"] ?? "");
|
||||||
$groups = explode_list(trim($params["groups"])); // TODO: lehessen több csoportra is
|
$groups = explode_list(trim($params["groups"])); // TODO: lehessen több csoportra is
|
||||||
|
$outtype = trim($params["outtype"] ?? "pdf");
|
||||||
|
|
||||||
$game = $gameMgr->getGame($gameid);
|
$game = $gameMgr->getGame($gameid);
|
||||||
|
|
||||||
@ -552,24 +553,33 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
|
|||||||
|
|
||||||
// generate latex
|
// generate latex
|
||||||
$report_dir = "report";
|
$report_dir = "report";
|
||||||
$report->saveTeX($report_dir . DIRECTORY_SEPARATOR . "stats");
|
$content_dir = $report_dir . DIRECTORY_SEPARATOR . "stats";
|
||||||
|
$report->saveTeX($content_dir);
|
||||||
|
|
||||||
// run LuaLaTeX twice
|
$output = "";
|
||||||
chdir($report_dir);
|
$contentType = "";
|
||||||
$tex_cmd = "lualatex -interaction=nonstopmode report.tex";
|
if ($outtype === "pdf") {
|
||||||
exec($tex_cmd);
|
// run LuaLaTeX twice
|
||||||
exec($tex_cmd);
|
chdir($report_dir);
|
||||||
|
$tex_cmd = "lualatex -interaction=nonstopmode report.tex";
|
||||||
|
exec($tex_cmd);
|
||||||
|
exec($tex_cmd);
|
||||||
|
|
||||||
$output = "report.pdf";
|
$output = "report.pdf";
|
||||||
|
$contentType = "application/pdf";
|
||||||
|
} else {
|
||||||
|
$output = $content_dir . DIRECTORY_SEPARATOR . "content.tex";
|
||||||
|
$contentType = "text/plain";
|
||||||
|
}
|
||||||
|
|
||||||
header("Content-Type: application/pdf");
|
header("Content-Type: ${contentType}");
|
||||||
header("Content-Length: " . filesize($output));
|
header("Content-Length: " . filesize($output));
|
||||||
|
|
||||||
// deploy the generated PDF
|
// deploy the generated PDF
|
||||||
$pdf = fopen($output, "r");
|
$f = fopen($output, "r");
|
||||||
if ($pdf !== false) {
|
if ($f !== false) {
|
||||||
fpassthru($pdf);
|
fpassthru($f);
|
||||||
fclose($pdf);
|
fclose($f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "OK";
|
return "OK";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user