Example #1
0
<?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.2, '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;
Example #2
-1
<?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.2, 3.5)), 'format' => array(1 => array('number' => array('prefix' => '$', 'decimals' => 2)), 2 => array('number' => array('sufix' => ' EUR', 'decimals' => 1)))));
echo $R->render();
exit;
Example #3
-1
<?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.90000000000001), 'format' => array('price' => array('number' => array('prefix' => '$', 'decimals' => 2))))));
echo $R->render('html');
exit;