<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//init
$sort_variable_name='';
$column_array=array();
$tab_array=array();
$max_pages=5;
$page_size=10;
if($group_cnt_max>10 and $group_cnt_max<18)
$page_size=$group_cnt_max;
$current_page=get('page');
$show_all_records=0;
if($current_page=='all')
$show_all_records=1;
if(!$current_page)
$current_page=1;
$sort_column=get('sort1');
$sort_desc=get('sort2');
$marknew=get('marknew');
$grp_search=$search;
if(!strpos('_'.$search,'sysGroupBy='.$group_name))
$grp_search=$search.'%20sysGroupBy='.$group_name;
flush();
//looking for column names
//config
$variable_array2=load_config($group_name);
if(get('tab'))
$current_tab=get('tab');
elseif(get('mark')==$cnt_mark or $marknew==$cnt_mark)
$current_tab=get('tab');
elseif(sizeof($variable_array2)==3)
$current_tab='...';
else
$current_tab=$variable_array2['sysDetailTitle']['value'];
reset($variable_array2);
while(list($variable_name,$val)=each($variable_array2))
{
if(substr($variable_name,0,3)!='sys' and check_access($variable_name,1)!=0)
{
if($variable_array2[$variable_name]['show_cond']==0 and substr($variable_name,0,3)!='sys')
$variable_array2[$variable_name]['show_cond']=2;
if(($current_tab==$variable_array2[$variable_name]['tab'] or $variable_array2[$variable_name]['tab']=='' or $current_tab=='sysall' or $variable_array2[$variable_name]['hl']) and $variable_array2[$variable_name]['show_cond']>1 and $variable_array2[$variable_name]['show_cond']<5)
{
$column_array[$variable_name]=$variable_array2[$variable_name];
$new_variable_array[$variable_name]=$variable_array2[$variable_name];
}
if(strlen($variable_array2[$variable_name]['tab']))
$tab_array[$variable_array2[$variable_name]['tab']]++;
}
}
//records
$max_access=0;
for($ii=0;$ii<count($record_array);$ii++)
{
$tmp_access=check_access(read($record_array[$ii],'MyBag'));
if($tmp_access>$max_access)
$max_access=$tmp_access;
}
//edit off
if($max_access>1)
$max_access=1;
echo '<div id="'.$group_name.'" class="main supergroup">';
echo '<a name="'.$group_name.'0"></a>';
/*
echo '<h2>';
myecho($variable_array2['sysListTitle']['value']);
echo '</h2>';
if($show_all_records or $page_size>=$group_cnt_max)
myecho('Records: %1/%1',$group_cnt_max);
else
myecho('Records: %1/%2',$page_size,$group_cnt_max);
echo ' | ';
echo '<a href="#mark'.($cnt_mark+1).'">';
//myecho('Skip %1',myecho($variable_array2['sysListTitle']['value'],'RETURN'));
myecho('Skip');
echo '</a> | ';
echo '<a href="#top">';
myecho('Page Top');
echo '</a>';
*/
//echo '<br />';
//cutting to important columns only
$size_array['S']=-50;
$size_array['XL']=+50;
$size_array['XXL']=+100;
$size_array['date']=-20;
$size_array['vin']=+20;
$important_column_array=array();
$tmp_width=220;
reset($column_array);
while(list($variable_name,$tmp)=each($column_array))
if($tmp_width<800 and $variable_array2[$variable_name]['hl'])
{
$important_column_array[$variable_name]=$column_array[$variable_name];
$tmp_width=100+$tmp_width+$size_array[$column_array[$variable_name]['size'].$column_array[$variable_name]['template']];
}
reset($column_array);
while(list($variable_name,$tmp)=each($column_array))
if($tmp_width<800 and !$variable_array2[$variable_name]['hl'])
{
$important_column_array[$variable_name]=$column_array[$variable_name];
$tmp_width=100+$tmp_width+$size_array[$column_array[$variable_name]['size'].$column_array[$variable_name]['template']];
}
//cutting to important columns only
//sorting
$record_array_index=array();
reset($record_array_index);
foreach($record_array as $tmp_ii => $tmp_line)
if($sort_column)
$record_array_index[$tmp_ii]=read($tmp_line,$sort_column);
else
$record_array_index[$tmp_ii]=$tmp_ii;
if($sort_column)
{
if($sort_desc)
arsort($record_array_index);
else
asort($record_array_index);
$tmp_record_array_index=array();
reset($record_array_index);
foreach($record_array_index as $tmp_ii => $tmp_value)
$tmp_record_array_index[]=$tmp_ii;
$record_array_index=$tmp_record_array_index;
$tmp_record_array_index=array();
}
//showing fields
if(count($record_array)>$page_size)
$there_are_hidden_objects=1;
$first_record_ii=$page_size*($current_page-1);
$last_record_ii=$page_size*$current_page;
if($first_record_ii<0)
$first_record_ii=0;
if($last_record_ii>=count($record_array))
$last_record_ii=count($record_array)-1;
if($show_all_records)
{
$first_record_ii=0;
$last_record_ii=count($record_array)-1;
}
echo '<b>';
myecho($variable_array2['sysListTitle']['value']);
echo '</b><br />0. ';
reset($important_column_array);
while(list($variable_name,$val)=each($important_column_array))
{
myecho($variable_name);
echo ' | ';
//echo ': ';
}
echo '<br />';
for($ii=$first_record_ii;$ii<=$last_record_ii;$ii++)
{
$variable_array=$record_array[$record_array_index[$ii]];
$id=read($variable_array,'sysId');
//$display_mode=$standard_display_mode;
if(read($variable_array,'Quality')=='Suspected')
echo('<img title="Quality is suspected" src="images/radioactive1.jpg" />');
echo '<a name="'.$group_name.($ii).'"></a>';
/*
echo '<a href="#'.$group_name.($ii+1).'">';
myecho('Next');
echo '</a> | ';
if($ii>0)
{
echo '<a href="#'.$group_name.($ii-1).'">';
myecho('Previous');
echo '</a> | ';
}
echo '<a href="#'.$group_name.'0">';
myecho('Top');
echo '</a> | ';
echo(' <a href="index.php?odb_search='.$group_name.'%20sysId%3D'.$id.''.$context_params.'">');
myecho('More...');
echo '</a>';
*/
echo(' <a href="index.php?odb_search='.$group_name.'%20sysId%3D'.$id.''.$context_params.'">');
echo ($ii+1).'.';
echo '</a> ';
reset($important_column_array);
while(list($variable_name,$val)=each($important_column_array))
{
$tmp_access=check_access(read($variable_array,'MyBag'));
if($tmp_access>$max_access)
$tmp_access=$max_access;
$template=trim($column_array[$variable_name]['template']);
$show_name='odb_'.purename($variable_name).'_'.$id;
$show_label=$variable_name;
$show_value=htmlspecialchars(read($variable_array,$variable_name));
$show_dictionary=$column_array[$variable_name]['dict'];
$show_size=$column_array[$variable_name]['size'];
if(strlen($show_size))
$show_size=' size'.$show_size;
$access=$tmp_access;
$show_mode=CFG_LOAD;
//echo '';
//echo '<b>';
//myecho($variable_name);
//echo '</b>';
//echo ': ';
if($template!='')
{
if(file_exists(cfg_data_path.'/config/script/fld_'.$template.'.txt'))
{
include(cfg_data_path.'/config/script/fld_'.$template.'.txt');
}
else
{
if(!file_exists(cfg_data_path.'/script/fld_'.$template.'.txt'))
$template='';
include(cfg_data_path.'/script/fld_'.$template.'.txt');
}
}
echo($show_value);
echo ' | ';
//echo '<br />';
}
echo '<br />';
//echo '<hr />';
}
echo '<div class="more">';
myecho('Records: %1',$group_cnt_max);
$pages=ceil($group_cnt_max/$page_size);
if($pages>1)
{
//~ echo ' | ';
//~ myecho('Page');
//~ echo ' ';
$first_page=$current_page-$max_pages;
if($first_page<1)
$first_page=1;
$last_page=$current_page+$max_pages;
if($last_page>$pages)
$last_page=$pages;
//~ if($first_page<$current_page)
//~ {
//~ echo '<a href="index.php?odb_page='.($current_page-1).'&odb_search='.$grp_search.'&odb_tab='.$current_tab.'">';
//~ myecho('Previous');
//~ echo '</a>';
//~ echo ' ';
//~ }
//~ for($ii=$first_page;$ii<=$last_page;$ii++)
//~ if($ii==$current_page)
//~ echo $current_page.' ';
//~ else
//~ echo '<a href="index.php?odb_page='.$ii.'&odb_tab='.$current_tab.'&odb_search='.$grp_search.'">'.$ii.'</a> ';
if($last_page>$current_page)
{
echo ' | ';
echo '<a href="index.php?odb_page='.($current_page+1).'&odb_tab='.$current_tab.'&odb_search='.$grp_search.'">';
myecho('Next page');
echo '</a>';
}
if($pages>1)
{
echo ' | ';
echo '<a href="index.php?odb_page=all&odb_tab='.$current_tab.'&odb_search='.$grp_search.'">';
myecho('Show all');
echo '</a>';
}
}
echo '</div>';
echo '<a name="'.$group_name.($ii).'"></a>';
echo '</div>';
?>