-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReport.class.php
68 lines (45 loc) · 1.98 KB
/
Report.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
if (!class_exists("Report"))
{
/**
* Class Report
*
**/
class Report
{
public function execute($parameters,$file)
{
$param = "";
if (is_array($parameters))
{
foreach ($parameters as $pn => $pv)
{
$param .= '&' . $pn . "<-" . $pv;
}
}
$filein = "PATH_FILE_IN".$file.".jasper";
$filetype = 'PDF';
$uniqid = uniqid(md5(uniqid("")));
$fileout= $uniqid . "." . strtolower($filetype);
$pathout = "PATH_OUT ".$fileout;
$param = "report<-$filein".$param."&fileout<-".$pathout."&filetype<-".$filetype;
$pathMJasper = "";
$pathJava = "/usr/lib/jvm/java-7-openjdk";
$classPath = "$pathMJasper/lib/jasperreports-4.7.0.jar:$pathMJasper/lib/jasperreports-fonts-4.7.0.jar:$pathMJasper/lib/jasperreports-javaflow-4.7.0.jar:$pathMJasper/lib/commons-beanutils-1.7.jar:$pathMJasper/lib/commons-collections-2.1.jar:$pathMJasper/lib/commons-digester-1.7.jar:$pathMJasper/lib/commons-javaflow-20060411.jar:$pathMJasper/lib/commons-logging-api-1.0.2.jar:$pathMJasper/lib/itext-1.3.1.jar:$pathMJasper/lib/ojdbc14.jar:$pathMJasper/lib/iReport.jar:$pathMJasper/lib/jxl-2.6.3.jar:$pathMJasper/lib/mysql-connector-java-5.0.6-bin.jar:$pathMJasper/";
$jdbcDriver = "com.mysql.jdbc.Driver";
$jdbcDb = "jdbc:mysql://localhost/db";
$dbUser = "root";
$dbPass = "123";
$cmd = $pathJava . "/bin/java -Djava.awt.headless=true -classpath $classPath MJasper \"{$pathMJasper}\" \"{$param}\" \"{$dbUser}\" \"{$dbPass}\" \"{$jdbcDriver}\" \"{$jdbcDb}\"";
$cmd .= " 2> ../reports/log/log.txt";
exec($cmd,$output);
$fp = fopen("../reports/log/log1.txt", "a");
$write_file = fwrite($fp, "\n\n".$cmd."\n".$output);
fclose($fp);
if (trim($output[0])=="end") {
header("location: ../reports/temp/$fileout");
}
}
}
}
?>