From e24bbb0bbc1cd6bdd8348ee255592303db269ca8 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 30 Dec 2007 22:16:34 +0000 Subject: [PATCH] - Add a filter to the last commit, to not show the none tshirts. - Add a 'total' option to the report generator, to signal that this column should be added up. - If total is != zero, it shows the total at the bottom of each table, else, it shows the number of rows (changed the text to Total: for a total, and Rows: to show rows, if the total is 0) --- admin/reports.inc.php | 5 +++++ admin/reports_students.inc.php | 1 + db/db.update.95.sql | 3 ++- lpdf.php | 8 ++++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/admin/reports.inc.php b/admin/reports.inc.php index e3a83c05..70e64898 100644 --- a/admin/reports.inc.php +++ b/admin/reports.inc.php @@ -478,6 +478,7 @@ foreach($report_stock as $n=>$v) { $table['widths']=array(); $table['dataalign']=array(); $table['option']=array(); + $table['total']=0; /* Validate the stock */ if($report['option']['stock'] != '') { @@ -665,6 +666,7 @@ foreach($report_stock as $n=>$v) { $rep->addTable($table); $rep->nextLine(); $table['data'] = array(); + $table['total'] = 0; /* Start a new page AFTER a table is * dumped, so the first page doesn't * end up blank */ @@ -719,6 +721,9 @@ foreach($report_stock as $n=>$v) { $d['h'], $lh, $v, $opt); } + + if($fields[$f]['total'] == true) + $table['total'] += $v; } if(count($data)) $table['data'][] = $data; } diff --git a/admin/reports_students.inc.php b/admin/reports_students.inc.php index 34ca5c2d..3de9cf13 100644 --- a/admin/reports_students.inc.php +++ b/admin/reports_students.inc.php @@ -518,6 +518,7 @@ $report_students_fields = array( 'header' => 'Count', 'width' => 0.5, 'table' => 'COUNT(*)', + 'total' => true, 'group_by' => array('students.tshirt')), diff --git a/db/db.update.95.sql b/db/db.update.95.sql index 540ebdeb..0d0e490e 100644 --- a/db/db.update.95.sql +++ b/db/db.update.95.sql @@ -11,4 +11,5 @@ INSERT INTO `reports_items` (`id`, `reports_id`, `type`, `ord`, `field`, `value` ('', LAST_INSERT_ID(), 'option', 6, 'stock', 'fullpage', 0, 0, 0, 0, 0, '', ''), ('', LAST_INSERT_ID(), 'col', 0, 'tshirt', '', 0, 0, 0, 0, 1, '', ' '), ('', LAST_INSERT_ID(), 'col', 1, 'special_tshirt_count', '', 0, 0, 0, 0, 1, '', ' '), - ('', LAST_INSERT_ID(), 'sort', 0, 'tshirt', '', 0, 0, 0, 0, 1, '', ' '); + ('', LAST_INSERT_ID(), 'sort', 0, 'tshirt', '', 0, 0, 0, 0, 1, '', ' '), + ('', LAST_INSERT_ID(), 'filter', 0, 'tshirt', 'none', 5, 0, 0, 0, 1, '', ' '); diff --git a/lpdf.php b/lpdf.php index bc4596dd..0c78aacb 100644 --- a/lpdf.php +++ b/lpdf.php @@ -770,8 +770,12 @@ class lpdf pdf_stroke($this->pdf); // print the total in th etable at the bottom of the table - $t = count($table['data']); - $this->addText("(Total: $t)", 'right'); + if($table['total'] != 0) { + $this->addText("(Total: {$table['total']})", 'right'); + } else { + $t = count($table['data']); + $this->addText("(Rows: $t)", 'right'); + } }