This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
<?php
ini_set('display_errors',1);
include_once("../PHPReport.php");
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'data'=>array(
array('Some product',23.99,12),
array('Other product',5.25,2.25),
array('Third product',0.20,3.5)
)
)
);
echo $R->render();
exit();

View File

@@ -0,0 +1,57 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'header'=>array(
'product'=>'Product name','price'=>'Price','tax'=>'Tax'
),
'footer'=>array(
'product'=>'','price'=>28.54,'tax'=>17.89
),
'config'=>array(
'header'=>array(
'product'=>array('width'=>120,'align'=>'center'),
'price'=>array('width'=>80,'align'=>'center'),
'tax'=>array('width'=>80,'align'=>'center')
),
'data'=>array(
'product'=>array('align'=>'left'),
'price'=>array('align'=>'right'),
'tax'=>array('align'=>'right')
),
'footer'=>array(
'price'=>array('align'=>'right'),
'tax'=>array('align'=>'right')
)
),
'data'=>array(
array('product'=>'Some product','price'=>23.99,'tax'=>12),
array('product'=>'Other product','price'=>5.25,'tax'=>2.25),
array('product'=>'Third product','price'=>0.20,'tax'=>3.5)
),
'group'=>array(
'caption'=>array(
'cat1'=>'Category 1',
'cat2'=>'Another category'
),
'rows'=>array(
'cat1'=>array(0),
'cat2'=>array(1,2)
),
'summary'=>array(
'cat1'=>array('product'=>'','price'=>23.99,'tax'=>12),
'cat2'=>array('product'=>'','price'=>5.45,'tax'=>5.75)
)
),
'format'=>array(
'price'=>array('number'=>array('prefix'=>'$','decimals'=>2)),
'tax'=>array('number'=>array('sufix'=>' EUR','decimals'=>1))
)
)
);
echo $R->render('excel');
exit();

View File

@@ -0,0 +1,59 @@
<?php
include '../PHPReport.php';
//which template to use
if(isset($_GET['template']))
$template=$_GET['template'];
else
$template='invoice.xls';
//set absolute path to directory with template files
$templateDir='C:\Ampps\www\PHPReport\examples\template\\';
//we get some products, e.g. from database
$products=array(
array('description'=>'Example product','qty'=>2,'price'=>4.5,'total'=>9),
array('description'=>'Another product','qty'=>1,'price'=>13.9,'total'=>13.9),
array('description'=>'Super product!','qty'=>3,'price'=>1.5,'total'=>4.5),
array('description'=>'Yet another great product','qty'=>2,'price'=>10.8,'total'=>21.6),
array('description'=>'Awesome','qty'=>1,'price'=>19.9,'total'=>19.9)
);
//set config for report
$config=array(
'template'=>$template,
'templateDir'=>$templateDir
);
$R=new PHPReport($config);
$R->load(array(
array(
'id'=>'inv',
'data'=>array('date'=>date('Y-m-d'),'number'=>312,'customerid'=>12,'orderid'=>517,'company'=>'Example Inc.','address'=>'Some address','city'=>'Some City, 1122','phone'=>'+111222333'),
'format'=>array(
'date'=>array('datetime'=>'d/m/Y')
)
),
array(
'id'=>'prod',
'repeat'=>true,
'data'=>$products,
'minRows'=>2,
'format'=>array(
'price'=>array('number'=>array('prefix'=>'$','decimals'=>2)),
'total'=>array('number'=>array('prefix'=>'$','decimals'=>2))
)
),
array(
'id'=>'total',
'data'=>array('price'=>68.9),
'format'=>array(
'price'=>array('number'=>array('prefix'=>'$','decimals'=>2))
)
)
)
);
echo $R->render('html');
exit();

View File

@@ -0,0 +1,53 @@
<?php
include '../PHPReport.php';
//which template to use
if(isset($_GET['template']))
$template=$_GET['template'];
else
$template='stats.xls';
//set absolute path to directory with template files
$templateDir='C:\Ampps\www\PHPReport\examples\template\\';
//we get some data, e.g. from database
//function generates some random data
function getData($n=1,$cols=array('A'),$rows=1,$c=array('Some country'))
{
//data is an array with 34 elements for each row!
$data=array();
for($i=1;$i<=$n;$i++)
{
$d['country']=$c[$i-1];
foreach($cols as $col)
{
for($r=1;$r<=$rows;$r++)
{
$d[$col.$r]=rand(0,20);
}
}
$data[]=$d;
}
return $data;
}
$data=getData(3,array('A','B','C'),11,array('Italy','Germany','France'));
//set config for report
$config=array(
'template'=>$template,
'templateDir'=>$templateDir
);
$R=new PHPReport($config);
$R->load(array(
'id'=>'v',
'repeat'=>true,
'data'=>$data,
)
);
$R->setHeading('Report: Visitors in January');
echo $R->render('html');
exit();

View File

@@ -0,0 +1,27 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
array(
'id'=>'product',
'data'=>array(
array('Some product',23.99,12),
array('Other product',5.25,2.25),
array('Third product',0.20,3.5)
)
),
array(
'id'=>'product2',
'data'=>array(
array('value1','value2','value3','value4'),
array('value5','value6','value7','value8')
)
)
)
);
echo $R->render();
exit();

View File

@@ -0,0 +1,21 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'data'=>array(
array('Some product',23.99,12),
array('Other product',5.25,2.25),
array('Third product',0.20,3.5)
),
'format'=>array(
1=>array('number'=>array('prefix'=>'$','decimals'=>2)),
2=>array('number'=>array('sufix'=>' EUR','decimals'=>1))
)
)
);
echo $R->render();
exit();

View File

@@ -0,0 +1,24 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'header'=>array(
'Product name','Price','Tax'
),
'data'=>array(
array('Some product',23.99,12),
array('Other product',5.25,2.25),
array('Third product',0.20,3.5)
),
'format'=>array(
1=>array('number'=>array('prefix'=>'$','decimals'=>2)),
2=>array('number'=>array('sufix'=>' EUR','decimals'=>1))
)
)
);
echo $R->render();
exit();

View File

@@ -0,0 +1,27 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'header'=>array(
'Product name','Price','Tax'
),
'footer'=>array(
'',28.54,17.89
),
'data'=>array(
array('Some product',23.99,12),
array('Other product',5.25,2.25),
array('Third product',0.20,3.5)
),
'format'=>array(
1=>array('number'=>array('prefix'=>'$','decimals'=>2)),
2=>array('number'=>array('sufix'=>' EUR','decimals'=>1))
)
)
);
echo $R->render();
exit();

View File

@@ -0,0 +1,32 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'header'=>array(
'Product name','Price','Tax'
),
'footer'=>array(
'',28.54,17.89
),
'config'=>array(
0=>array('width'=>120,'align'=>'left'),
1=>array('width'=>80,'align'=>'right'),
2=>array('width'=>80,'align'=>'right')
),
'data'=>array(
array('Some product',23.99,12),
array('Other product',5.25,2.25),
array('Third product',0.20,3.5)
),
'format'=>array(
1=>array('number'=>array('prefix'=>'$','decimals'=>2)),
2=>array('number'=>array('sufix'=>' EUR','decimals'=>1))
)
)
);
echo $R->render();
exit();

View File

@@ -0,0 +1,7 @@
<?php
$file="test.xls";
$test='<table border=1 width="200"><tr><td style="width:400px;">Cell 1</td><td>Cell 2</td></tr><tr><td style="width:400px;">Cell 1</td><td>Cell 2</td></tr></table>';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $test;
?>

View File

@@ -0,0 +1,43 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'header'=>array(
'product'=>'Product name','price'=>'Price','tax'=>'Tax'
),
'footer'=>array(
'product'=>'','price'=>28.54,'tax'=>17.89
),
'config'=>array(
'header'=>array(
'product'=>array('width'=>120,'align'=>'center'),
'price'=>array('width'=>80,'align'=>'center'),
'tax'=>array('width'=>80,'align'=>'center')
),
'data'=>array(
'product'=>array('align'=>'left'),
'price'=>array('align'=>'right'),
'tax'=>array('align'=>'right')
),
'footer'=>array(
'price'=>array('align'=>'right'),
'tax'=>array('align'=>'right')
)
),
'data'=>array(
array('product'=>'Some product','price'=>23.99,'tax'=>12),
array('product'=>'Other product','price'=>5.25,'tax'=>2.25),
array('product'=>'Third product','price'=>0.20,'tax'=>3.5)
),
'format'=>array(
'price'=>array('number'=>array('prefix'=>'$','decimals'=>2)),
'tax'=>array('number'=>array('sufix'=>' EUR','decimals'=>1))
)
)
);
echo $R->render();
exit();

View File

@@ -0,0 +1,56 @@
<?php
include '../PHPReport.php';
$R=new PHPReport();
$R->load(array(
'id'=>'product',
'header'=>array(
'product'=>'Product name','price'=>'Price','tax'=>'Tax'
),
'footer'=>array(
'product'=>'','price'=>28.54,'tax'=>17.89
),
'config'=>array(
'header'=>array(
'product'=>array('width'=>120,'align'=>'center'),
'price'=>array('width'=>80,'align'=>'center'),
'tax'=>array('width'=>80,'align'=>'center')
),
'data'=>array(
'product'=>array('align'=>'left'),
'price'=>array('align'=>'right'),
'tax'=>array('align'=>'right')
),
'footer'=>array(
'price'=>array('align'=>'right'),
'tax'=>array('align'=>'right')
)
),
'data'=>array(
array('product'=>'Some product','price'=>23.99,'tax'=>12),
array('product'=>'Other product','price'=>5.25,'tax'=>2.25),
array('product'=>'Third product','price'=>0.20,'tax'=>3.5)
),
'group'=>array(
'caption'=>array(
'Category 1', 'Another category'
),
'rows'=>array(
array(0),
array(1,2)
),
'summary'=>array(
array('product'=>'','price'=>23.99,'tax'=>12),
array('product'=>'','price'=>5.45,'tax'=>5.75)
)
),
'format'=>array(
'price'=>array('number'=>array('prefix'=>'$','decimals'=>2)),
'tax'=>array('number'=>array('sufix'=>' EUR','decimals'=>1))
)
)
);
echo $R->render();
exit();