<?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;
$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);
reset($variable_array2);
while(list($variable_name,$val)=each($variable_array2))
{
if($val['tab']!='...' and substr($variable_name,0,3)!='sys' and check_access($variable_name,1)!=0)
{
$column_array[$variable_name]=$variable_array2[$variable_name];
if(strlen($variable_array2[$variable_name]['tab']))
$tab_array[$variable_array2[$variable_name]['tab']]++;
}
}
$new_record_array=array();
for($ii=0;$ii<count($record_array);$ii++)
{
if($compare=='all' or strpos('_'.$session_array['compare'],read($record_array[$ii],'sysId'))>0)
$new_record_array[]=$record_array[$ii];
}
$record_array=$new_record_array;
//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;
}
//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;
//show all records
$first_record_ii=0;
$last_record_ii=count($record_array);
echo '<div id="'.$group_name.'" class="main supergroup">';
echo '<h2>';
if($max_access>1)
{
echo('<input id="sw'.$cnt_mark.'" title="Select / unselect all" type="checkbox" onclick="check(this.checked,document.forms,\'sw'.$cnt_mark.'\',\'sw'.($cnt_mark+1).'\');" /> ');
}
myecho($variable_array2['sysListTitle']['value']);
echo ' - ';
myecho('Compare');
echo '</h2>';
echo '<table>';
$row_count=0;
echo '<tr>';
echo('<th class="noprint">');
echo colSymbol($row_count++).'.';
echo('</th>');
echo '<th class="column_numbers">';
echo '</th>';
echo '<th class="column_numbers">';
echo '</th>';
for($ii=$first_record_ii;$ii<$last_record_ii;$ii++)
{
if($max_access>1)
{
$variable_array=$record_array[$record_array_index[$ii]];
$id=read($variable_array,'sysId');
$show_name='odb_'.$id;
$tmp_access=check_access(read($variable_array,'MyBag'));
echo('<th class="noprint">');
if($tmp_access>1)
echo('<input name="'.$show_name.'" type="checkbox"></input> ');
else
echo('');
//echo read($variable_array,'sysModDate');
myecho($variable_array2['sysDetailTitle']['value']);
echo('</th>');
}
}
echo '</tr>';
echo '<tr>';
echo('<th class="noprint">');
echo colSymbol($row_count++).'.';
echo('</th>');
echo '<th class="column_numbers">';
echo '</th>';
echo '<th class="column_numbers">';
echo '</th>';
for($ii=$first_record_ii;$ii<$last_record_ii;$ii++)
{
echo '<th class="column_numbers">';
echo ''.($ii+1).'.';
echo '</th>';
}
echo '</tr>';
reset($column_array);
while(list($variable_name,$val)=each($column_array))
{
echo '<tr class="record'.($ii%2).'">';
echo('<th class="noprint">');
echo colSymbol($row_count++).'.';
echo('</th>');
echo '<th>';
myecho($val['tab']);
echo '</th>';
echo '<th>';
if($variable_name==$sort_column)
if($sort_desc)
echo '<a href="index.php?odb_sort1='.urlencode($sort_column).'&odb_compare='.$compare.'&odb_tab='.$current_tab.'&odb_search='.$grp_search.'"><img alt="Sorted a-z" src="images/down.gif" />';
else
echo '<a href="index.php?odb_compare='.$compare.'&odb_tab='.$current_tab.'&odb_search='.$grp_search.'"><img alt="Sorted z-a" src="images/up.gif" />';
else
echo '<a href="index.php?odb_sort2=1&odb_sort1='.urlencode($variable_name).'&odb_compare='.$compare.'&odb_tab='.$current_tab.'&odb_search='.$grp_search.'">';
myecho($variable_name);
echo '</a>';
$col_count++;
echo '</th>';
for($ii=$first_record_ii;$ii<$last_record_ii;$ii++)
{
$variable_array=$record_array[$record_array_index[$ii]];
$id=read($variable_array,'sysId');
$tmp_access=check_access(read($variable_array,'MyBag'));
$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;
if($variable_name=='MyBag' and $access==2)
{
$show_mode=CFG_SHOW;
echo '<td>';
}
elseif($access==1)
{
$show_mode=CFG_SHOW;
//~ if($column_array[$variable_name]['hl'])
//~ echo '<td class="show highlight">';
//~ else
echo '<td class="show">';
}
elseif($column_array[$variable_name]['formula']=='' and ($column_array[$variable_name]['show_cond']==2 or ($column_array[$variable_name]['show_cond']=='' and $access>1)))
{
$show_mode=CFG_EDIT;
if(strlen($template) and strpos('_numbermoney',$template))
echo '<td style="text-align:right;">';
else
echo '<td>';
}
else
{
$show_mode=CFG_SHOW;
//~ if($column_array[$variable_name]['hl'])
//~ echo '<td class="show highlight">';
//~ else
echo '<td class="show">';
}
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');
}
}
else
{
if($show_mode==CFG_NEW) //show value as input for new value
echo('<input class="fld_'.$show_size.'" name="'.$show_name.'" id="'.$show_name.'" type="text" title="'.$show_value.'" onkeydown="new AutoSuggestControl(this, \''.$variable_name.'\', new RemoteStateSuggestions());" value="'.$show_value.'"/>');
elseif($show_mode==CFG_SHOW) //show value in html
echo($show_value);
elseif($show_mode==CFG_EDIT) //show value as input
echo('<input class="fld_'.$show_size.'" name="'.$show_name.'" id="'.$show_name.'" type="text" title="'.$show_value.'" onkeydown="new AutoSuggestControl(this, \''.$variable_name.'\', new RemoteStateSuggestions());" value="'.$show_value.'"/>');
}
echo '</td>';
/*
echo '<td class="noprint">';
echo(' <a href="index.php?odb_search='.$group_name.'%20sysId%3D'.$id.''.$context_params.'">');
myecho('More...');
echo '</a>';
echo '</td>';
*/
}
echo '</tr>';
}
echo '<tr>';
echo '<th class="column_numbers">';
echo '</th>';
echo '<th class="column_numbers">';
echo '</th>';
echo '<th class="column_numbers">';
echo '</th>';
for($ii=$first_record_ii;$ii<$last_record_ii;$ii++)
{
if($max_access>1)
{
$variable_array=$record_array[$record_array_index[$ii]];
$id=read($variable_array,'sysId');
$show_name='odb_'.$id;
$tmp_access=check_access(read($variable_array,'MyBag'));
echo('<td class="noprint">');
echo '<div class="rec_info">';
$validfrom=read($variable_array,'sysValidFrom');
$validfrom=substr($validfrom,6,2).'.'.substr($validfrom,4,2).'.'.substr($validfrom,0,4);
$validto=read($variable_array,'sysValidTo');
$validto=substr($validto,6,2).'.'.substr($validto,4,2).'.'.substr($validto,0,4);
$modby=read($variable_array,'sysModBy');
//$modby=substr($modby,6,2).'.'.substr($modby,4,2).'.'.substr($modby,0,4).substr($modby,8);
//$modby=substr($modby,14);
$comment=read($variable_array,'sysComment');
$info='Valid:'.$validfrom.'-'.$validto.' by '.$modby;
if($validto=='31.12.9999')
myecho('Data valid from %1',$validfrom);
else
myecho('Data valid: %1 - %2',$validfrom,$validto);
if(read($variable_array,'MyBag'))
{
echo '<br />';
myecho('MyBag:'); echo ' '.read($variable_array,'MyBag');
}
echo '<br />';
myecho('Changed by:'); echo(' '.$modby);
echo '<br />';
myecho('Comment: \'%1\'.',$comment);
echo '<br />';
echo(' <a href="index.php?odb_search='.$group_name.'%20sysId%3D'.$id.''.$context_params.'">');
myecho('More...');
echo '</a>';
echo '</div>';
echo('</td>');
}
}
echo '</tr>';
echo '</table>';
echo '</div>';
echo '</div>';
?>