*
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class html_tables
{
function hash_table($rows,$head='',$obj, $frtn)
{
$start = $_POST['start'] ? $_POST['start'] : $_GET['start'];
$html = '';
$edittable = $head['_edittable'];
if(isset($edittable))
{
if($edittable)
{
// Generate the customization table...
return $this->edit_table($rows,$head,$obj,$frtn);
}
else
{
//$bo =& CreateObject('admin.bolog',True);
if(!isset($start))
{
$start = 0;
}
$num_rows = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
$stop = $start + $num_rows;
if($stop > count($rows))
{
$stop = count($rows);
}
$nextmatchs =& CreateObject('phpgwapi.nextmatchs');
$total_records = count($rows);//$bo->get_no_errors();
$left = $nextmatchs->left('/index.php',$start,$total_records,'menuaction=admin.uilog.list_log');
$right = $nextmatchs->right('/index.php',$start,$total_records,'menuaction=admin.uilog.list_log');
$hits = $nextmatchs->show_hits($total_records,$start);
$html .= '
';
}
}
if($head == '')
{
$frow = $rows[0];
$cnam = $this->arr_keys($frow);
while(list(,$fn)=each($cnam))
{
$head[$fn] = array();
}
}
if(@is_null($head['_cols']))
{
$cols = $this->arr_keys($rows[0]);
}
else
{
$cols = $head['_cols'];
}
// Build Header Row...
// First Get the layout arrays...
$layout = $head['#layout'];
if(!is_array($layout))
{
$layout = $this->arr_keys($cols);
}
// printlist, a list of all columns in a logical row,
// with Row/ColSpawn values, in print order...
$printlist = $this->make_printlist($layout,$cols);
// $table contains data for header row....
$table = $this->make_tblhead($printlist,$head);
// get GroupBy
$groupby = $head['_groupby'];
$supres = $head['_supres'];
$lastgroup = '';
// build actual Rows...
$rparms = array();
$mrow = $stop;
for($rno=0;$rno<$mrow;$rno++)
{
// Build GroupKey
if(isset($groupby))
{
$gkey = '';
reset($groupby);
while(list($gname,)=each($groupby))
{
$gkey .= $rows[$rno][$gname]['value'];
}
$rows[$rno]['#gkey'] = $gkey;
}
reset($printlist);
while(list($pc,$pcol)=each($printlist))
{
$cname = $pcol['#name'];
$cparms = $this->arr_merge($head[$cname],$pcol,array('bgcolor'=>'#FFFFFF'),$rows[$rno][$cname]);
$rows[$rno][$cname] = $cparms;
}
}
// Grouping Suppression
if(isset($groupby))
{
$grno = $start;
$gkey = $rows[$start]['#gkey'];
for($rno=$start+1;$rno<$stop;$rno++)
{
$rowspan = 1;
$rkey = $rows[$rno]['#gkey'];
while( $gkey == $rkey)
{
//echo "grno:$grno ($gkey) rno:$rno ($rkey) are equal
";
$rowspan = $rowspan + 1;
$row = $rows[$rno];
for($pc=0;$pcgrno:$grno ($gkey) rno:$rno ($rkey) are not equal";
$grno=$rno;
$gkey=$rkey;
}
}
/*
** Now Generate the Html For the Table Header
*/
//print_r($table);
$html .= $this->html_head($head,$table,$printlist);
/*
** Now (finally) Generate the Html For the Table
*/
//print_r($rows);
for($rno=$start;$rno<$stop;$rno++)
{
// let user have a hack at the row...
$row = $obj->$frtn($rno,$rows[$rno]);
// $row = $rows[$rno];
// $rp = $this->makeparms($row[$rno]['#row_parms']);
$rp = '';
$gkey = $row['#gkey'];
// $html .= "\t \n";
$html .= "\t \n";
reset($printlist);
while(list($pc,$pcol)=each($printlist))
{
$cname = $pcol['#name'];
$cp = $this->makeparms($row[$cname]);
if($row[$cname]['#supres'] != 'yes')
{
$html .= "\t\t".$row[$cname]['value']." | \n";
}
if($pcol['#eor']=='1')
{
$html .= "\t
\n"; // \t\n
}
}
}
$html .= "\n";
#$html .= "";
return $html;
}
function makeparms($parmlist)
{
$html = '';
$comma = ' ';
if(!is_array($parmlist))
{
return '';
}
reset($parmlist);
while(list($pname,$pvalue)=each($parmlist))
{
switch($pname)
{
case 'value':
break;
case 'colspan':
case 'rowspan':
if($pvalue != 1)
{
$html .= $comma . $pname . '="' . $pvalue . '"';
#$comma = ', ';
$comma = ' ';
};
break;
default:
if(substr($pname,0,1) != '#')
{
$html .= $comma . $pname . '="' . $pvalue . '"';
#$comma = ', ';
$comma = ' ';
}
}
}
return $html;
}
function edit_table($rows,$head='',$obj, $frtn)
{
$nocols = $_POST['nocols'];
$noflds = $_POST['noflds'];
$norows = $_POST['norows'];
$layout = $_POST['layout'];
$_cols = $_POST['_cols'];
$html = '';
$html .= '