diff.txt 100644 0 0 3102 7263020534 10603 0 ustar root root ? doc/sgml/05-fmt_table.sgml
? php/html/fmt_table.inc
? stuff/fmt_table.html
Index: CHANGES
===================================================================
RCS file: /repository/php-lib/CHANGES,v
retrieving revision 1.187
diff -u -r1.187 CHANGES
--- CHANGES 2001/01/05 09:30:21 1.187
+++ CHANGES 2001/04/05 07:39:58
@@ -1,5 +1,12 @@
$Id: CHANGES,v 1.187 2001/01/05 09:30:21 max Exp $
+04-Mar-2001
+ - Added class fmt_table.inc;
+ - added class documentation 05-fmt_table.sgml;
+ - changed documentation.sgml in order to include fmt_table.sgml;
+ - put fmt_table.html into stuff directory (sample html output of Fmt_Table)
+
05-Jan-2001 max
- Added user4.inc with User class that works with session4* session implementations.
Index: doc/sgml/documentation.sgml
===================================================================
RCS file: /repository/php-lib/doc/sgml/documentation.sgml,v
retrieving revision 1.11
diff -u -r1.11 documentation.sgml
--- doc/sgml/documentation.sgml 2000/02/24 23:33:02 1.11
+++ doc/sgml/documentation.sgml 2001/04/05 07:39:59
@@ -36,6 +36,7 @@
+
@@ -93,6 +94,7 @@
&f05widget;
&f05sqlquery;
&f05table;
+&f05fmttable;
&f05menu;
&f05menu2;
&f05form;
doc/sgml/05-fmt_table.sgml 100644 44 144 17431 7262646274 14463 0 ustar adabas users
The Fmt_Table class is an extension of Table that allows
you to pass content sensitive formating information to your
html output.
The Fmt_Table class can be used to
An empty pair of square brackets is a placeholder for the value
of the column in question ( resp. for the html presentation of this
value).
The
The
The default for the
The
The
Will add format conditions and format instructions to the table.
The array
Since the functionality of this class is best explained with approbiate
data, the data objects for this example are outlined.
The example makes use of the DB_Sql class of phplib.
A view object is used for the computation of our provisional and
final results.
Here also the help fields
$t->add_format(array('cols'=>'obtained' ,
'conds'=>"([expected] > [])",
'formats'=>"<font color='red'>[]</font>"));
// sql, that goes into the database first;
// your sql-loader might expect a semi-colon after each command
//
drop table sales
//
create table sales (
category varchar (32),
product varchar (32),
expected fixed (5,2),
obtained fixed (5,2)
)
//
insert into sales values ('sports','hoola hoops',103.56, 0)
//
insert into sales values ('sports','mountain bikes',155.88, 87.22)
//
insert into sales values ('sports','surf boards',106.56, 106.56)
//
insert into sales values ('entertainment','books',75.65, 109.44)
//
insert into sales values ('entertainment','videos',99.88, 82.34)
//
create view sales_view as
select 10 as order1,
10 as order2,
category,
product,
expected,
obtained,
obtained - expected as difference
from sales
union
select 10 as order1,
20 as order2,
category,
'' as product,
sum (expected) as expected,
sum (obtained) as obtained,
sum (obtained - expected) as difference
from sales
group by category
union
select 20 as order1,
10 as order2,
'' as category,
'' as product,
sum (expected) as expected,
sum (obtained) as obtained,
sum (obtained - expected) as difference
from sales
//
grant select on sales_view to wwwrun
//
commit
require("fmt_table.inc");
$db = new DB_Sql_1;
$q =
" select * from sales_view " .
" order by order1, category, order2, product";
$db->query($q);
$t = new Fmt_Table;
$t->heading = "on";
$t->suppress_empty = true;
$t->extrahtml = "border width = 100%";
$t->fields=array("category","product","expected","obtained","difference");
$t->add_format(array('cols'=>"obtained" ,
'conds'=>array("(([]==0)or([expected]==[]))",
"([expected] < [])",
"([expected] > [])"),
'formats'=>array("<font color='blue'>[]</font>",
"<font color='green'>[]</font>",
"<font color='red'>[]</font>")));
$t->add_format(array('cols'=>"category",
'conds'=>"[order1] == 20",
'formats'=>"<met colspan=2 align='right'>Overall sum:"));
$t->add_format(array('cols'=>"product",
'conds'=>"[order1] == 20",
'formats'=>"<met MET_SKIP>"));
$t->add_format(array('cols'=>"product",
'conds'=>"[order2] == 20",
'formats'=>"<met align='right'>Sum of [category]:"));
$t->add_format(array('cols'=>"difference",
'conds'=>"[obtained] == 0",
'formats'=>"<i>No Sales</i>"));
$t->add_format(array('cols'=>"ALL_COLUMNS",
'conds'=>"[order1] == 20",
'formats'=>"<met bgcolor='pink'><b>[]</b>"));
$t->add_format(array("cols"=>"ALL_COLUMNS",
"conds"=>"[order2] == 20",
"formats"=>"<met bgcolor='lightyellow'><b>[]</b>"));
$t->row_span = "category";
$t->show_result($db);
For an impression on how the html output does look like, see the file

