forked from science-ation/science-ation
- Implemnt scalable columns in the report generator.
- New report option to fit the width of the report to the page - Columns in each reports_*.inc.php can be specified with 'scalable' => true to indicate that they may be scaled if the report is too wide for the page - Obviously, do no scaling if the option is off (off by default)
This commit is contained in:
parent
fddce24de3
commit
4af449a2c4
@ -54,7 +54,9 @@
|
||||
$report_options['allow_multiline'] = array('desc' => 'Allow table rows to span multiple lines',
|
||||
'values' => array('no'=>'No', 'yes'=>'Yes')
|
||||
);
|
||||
|
||||
$report_options['fit_columns'] = array('desc' => 'Scale column widths to fit on the page width',
|
||||
'values' => array('no'=>'No', 'yes'=>'Yes')
|
||||
);
|
||||
$report_options['label_box'] = array('desc' => 'Draw a box around each label',
|
||||
'values' => array('no'=>'No', 'yes'=>'Yes')
|
||||
);
|
||||
@ -564,11 +566,33 @@ foreach($report_stock as $n=>$v) {
|
||||
$components = array();
|
||||
$order = array();
|
||||
|
||||
$total_width = 0;
|
||||
$scale_width = 0;
|
||||
/* Add up the column widths, and figure out which
|
||||
* ones are scalable, just in case */
|
||||
foreach($report['col'] as $o=>$d) {
|
||||
$f = $d['field'];
|
||||
$total_width += $fields[$f]['width'];
|
||||
if($fields[$f]['scalable'] == true)
|
||||
$scale_width += $fields[$f]['width'];
|
||||
}
|
||||
|
||||
/* Determine the scale factor (use the label width so
|
||||
* we can enforce margins) */
|
||||
if($report['option']['fit_columns'] == 'yes' && $total_width > $label_stock['label_width']) {
|
||||
$static_width = $total_width - $scale_width;
|
||||
$scale_factor = ($label_stock['label_width'] - $static_width) / $scale_width;
|
||||
//echo "$scale_factor;
|
||||
} else {
|
||||
$scale_factor = 1.0;
|
||||
}
|
||||
|
||||
/* Select columns to display */
|
||||
foreach($report['col'] as $o=>$d) {
|
||||
$f = $d['field'];
|
||||
$table['header'][] = i18n($fields[$f]['header']);
|
||||
$table['widths'][] = $fields[$f]['width'];
|
||||
$sf = ($fields[$f]['scalable'] == true) ? $scale_factor : 1.0;
|
||||
$table['widths'][] = $fields[$f]['width'] * $sf;
|
||||
$table['dataalign'][] = 'left';
|
||||
$sel[] = "{$fields[$f]['table']} AS C$x";
|
||||
$fieldname[$f] = "C$x";
|
||||
|
@ -96,6 +96,7 @@ $report_students_fields = array(
|
||||
'name' => 'Student -- Full Name (last, first)',
|
||||
'header' => 'Name',
|
||||
'width' => 1.75,
|
||||
'scalable' => true,
|
||||
'table' => "CONCAT(students.lastname, ', ', students.firstname)",
|
||||
'table_sort'=> 'students.lastname' ),
|
||||
|
||||
@ -103,6 +104,7 @@ $report_students_fields = array(
|
||||
'name' => 'Student -- Full Name (first last)',
|
||||
'header' => 'Name',
|
||||
'width' => 1.75,
|
||||
'scalable' => true,
|
||||
'table' => "CONCAT(students.firstname, ' ', students.lastname)",
|
||||
'table_sort'=> 'students.lastname' ),
|
||||
|
||||
@ -110,6 +112,7 @@ $report_students_fields = array(
|
||||
'name' => 'Student -- Partner Name (last, first)',
|
||||
'header' => 'Partner',
|
||||
'width' => 1.5,
|
||||
'scalable' => true,
|
||||
'table' => "CONCAT(students2.lastname, ', ', students2.firstname)",
|
||||
'components' => array('partner') ),
|
||||
|
||||
@ -117,6 +120,7 @@ $report_students_fields = array(
|
||||
'name' => 'Student -- Partner Name (first last)',
|
||||
'header' => 'Partner',
|
||||
'width' => 1.5,
|
||||
'scalable' => true,
|
||||
'table' => "CONCAT(students2.firstname, ' ', students2.lastname)",
|
||||
'components' => array('partner') ),
|
||||
|
||||
@ -124,6 +128,7 @@ $report_students_fields = array(
|
||||
'name' => "Student -- Both Student Names",
|
||||
'header' => 'Student(s)',
|
||||
'width' => 3.0,
|
||||
'scalable' => true,
|
||||
'table' => "CONCAT(students.firstname, ' ', students.lastname, IF(students2.lastname IS NULL,'', CONCAT(', ', students2.firstname, ' ', students2.lastname)))",
|
||||
'table_sort' => 'students.lastname',
|
||||
'components' => array('partner') ),
|
||||
@ -132,6 +137,7 @@ $report_students_fields = array(
|
||||
'name' => "Student -- All Student Names (REQUIRES MYSQL 5.0) ",
|
||||
'header' => 'Student(s)',
|
||||
'width' => 3.0,
|
||||
'scalable' => true,
|
||||
'table' => "GROUP_CONCAT(students.firstname, ' ', students.lastname ORDER BY students.lastname SEPARATOR ', ')",
|
||||
'group_by' => array('students.registrations_id')),
|
||||
|
||||
@ -139,6 +145,7 @@ $report_students_fields = array(
|
||||
'name' => 'Student -- Email',
|
||||
'header' => 'Email',
|
||||
'width' => 1.75,
|
||||
'scalable' => true,
|
||||
'table' => 'students.email'),
|
||||
|
||||
'phone' => array(
|
||||
@ -192,6 +199,7 @@ $report_students_fields = array(
|
||||
'name' => 'Project -- Title',
|
||||
'header' => 'Project Title',
|
||||
'width' => 2.75,
|
||||
'scalable' => true,
|
||||
'table' => 'projects.title' ),
|
||||
|
||||
'shorttitle' => array(
|
||||
@ -264,6 +272,7 @@ $report_students_fields = array(
|
||||
'name' => 'Student Address -- Street Address',
|
||||
'header' => 'Address',
|
||||
'width' => 2.0,
|
||||
'scalable' => true,
|
||||
'table' => 'students.address'),
|
||||
|
||||
'city' => array(
|
||||
@ -284,16 +293,25 @@ $report_students_fields = array(
|
||||
'width' => 0.75,
|
||||
'table' => 'students.postalcode' ),
|
||||
|
||||
'address_full' => array(
|
||||
'name' => 'Student Address -- Full Address',
|
||||
'header' => 'Address',
|
||||
'width' => 3.0,
|
||||
'scalable' => true,
|
||||
'table' => "CONCAT(students.address, ', ', students.city, ', ', students.province, ', ', students.postalcode)" ),
|
||||
|
||||
'school' => array(
|
||||
'name' => 'School -- Name',
|
||||
'header' => 'School Name',
|
||||
'width' => 2.25,
|
||||
'scalable' => true,
|
||||
'table' => 'schools.school' ),
|
||||
|
||||
'schooladdr' => array(
|
||||
'name' => 'School -- Full Address',
|
||||
'header' => 'School Address',
|
||||
'width' => 3.0,
|
||||
'scalable' => true,
|
||||
'table' => "CONCAT(schools.address, ', ', schools.city, ', ', schools.province_code, ', ', schools.postalcode)" ),
|
||||
|
||||
'teacher' => array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user