Creating a Printable Report
Posted: Thu Apr 05, 2012 8:52 am
I've been working my way through this Wiki article (http://xataface.com/wiki/Creating_Printable_Reports) and it's incredibly well written. One question. If I want this to be a universal printing option (not table-specific) for all tables, how do I need to alter the code?
Here is the full code if it helps:
Here is the full code if it helps:
- Code: Select all
<?php
class actions_printable_report {
function handle(&$params){
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$query['-skip'] = 0;
$query['-limit'] = 10000;
if ( $query['-table'] != 'products' ){
return PEAR::raiseError('This action can only be called on the Products table.');
}
$products = df_get_records_array('products', $query);
echo '<html><head>'
.'<title>Printable Report</title>'
.'<style type="text/css">'
.' th { vertical-align: top}'
.'</style>'
.'</head>'
.'<body>';
foreach ($products as $p){
echo '<table>'
.'<tr><th>Product ID</th><td>'.$p->htmlValue('product_id').'</td></tr>'
.'<tr><th>Product Name</th><td>'.$p->htmlValue('product_name').'</td></tr>'
.'<tr><th>Description</th><td>'.$p->htmlValue('product_description').'</td></tr>'
.'<tr><th>Photo</th><td>'.$p->htmlValue('product_image').'</td></tr>'
.'</table>';
}
echo '</body></html>';
}
}