<?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
if(get('group')) //problem new user mini crack
$group_name=get('group');
$variable_array2=load_config($group_name);
$variable_array=array();
reset($variable_array2);
while(list($variable_name,$tmp)=each($variable_array2))
{
$tmp_val=get(purename($variable_name));
if(!$tmp_val)
$tmp_val=get(str_replace(' ','_',$variable_name));
$variable_array[$variable_name]=$tmp_val;
}
//USEREXIT OnNew
$userexit='onnew';
if(file_exists(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt'))
{
include(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt');
}
else
{
include(cfg_data_path.'/script/userexit/exit_'.$userexit.'.txt');
}
$sort_variable_name='';
$column_array=array();
$tab_array=array();
$mybag_shown=0;
//looking for column names
$focus_field_name='';
//print_r($variable_array2);
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 and ($variable_array2[$variable_name]['show_cond']!=3 or $variable_array[$variable_name]))
{
$variable_array2[$variable_name]['tab']=trim($variable_array2[$variable_name]['tab']);
if($variable_array2[$variable_name]['show_cond']==0)
$variable_array2[$variable_name]['show_cond']=2;
if($variable_array2[$variable_name]['tab']=='')
$variable_array2[$variable_name]['tab']=$variable_array2['sysDetailTitle']['value'];
if($variable_array2[$variable_name]['show_cond']>1 and $variable_array2[$variable_name]['show_cond']!=5)
{
$column_array[$variable_name]=$variable_array2[$variable_name]['template'];//split_label($variable_name);
}
if(!isset($record_array[0][$variable_name]))
{
$record_array[0]='$'.$variable_name.'='.$record_array[0];
}
$tab_array[$variable_array2[$variable_name]['tab']]=1;
}
}
//adding geo info if needed
$variable_name='Latitude';
if(get(purename($variable_name)))
{
$variable_array2[$variable_name]['show_cond']=2;
$variable_array2[$variable_name]['tab']='Geo';
$column_array[$variable_name]='';
$tab_array[$variable_array2[$variable_name]['tab']]=1;
$variable_array[$variable_name]=get(purename($variable_name));
}
$variable_name='Longitude';
if(get(purename($variable_name)))
{
$variable_array2[$variable_name]['show_cond']=2;
$variable_array2[$variable_name]['tab']='Geo';
$column_array[$variable_name]='';
$tab_array[$variable_array2[$variable_name]['tab']]=1;
$variable_array[$variable_name]=get(purename($variable_name));
}
echo '<form action="index.php" method="post" onsubmit="needToConfirm = false;">
<div>
<input name="odb_run" type="hidden" value="new" />
<input name="odb_group" type="hidden" value="'.$group_name.'" />
<input name="odb_script" type="hidden" value="" />
<input name="odb_search" type="hidden" value="" />';
echo('<div class="change_submit">');
echo('<p class="bbutton"><input name="odb_save" type="submit" value="'.myecho('Save','RETURN').'" /></p>');
echo('</div>');
echo '<div id="'.$group_name.'" class="detail supergroup">';
$title=$mm2;
if(!$title)
$title=$variable_array2['sysDetailTitle']['value'];
echo '<h2>';
myecho($title);
echo '</h2>';
$standard_display_mode=$display_mode;
$field_cnt=1;
$tab_cnt=count($tab_array);
if(isset($tab_array['...']))
$tab_cnt--;
reset($tab_array);
while(list($tab_name,$val)=each($tab_array))
{
if($val and $tab_name!='...')
{
$fulllabel=split_label($tab_name);
if(strlen($fulllabel)>14)
$label=substr($fulllabel,0,12).'...';
else
$label=$fulllabel;
echo '<div class="detGroup">';
echo '<table>';
if($tab_cnt>1)
{
echo '<tr>';
if(cfg_clean_detail)
echo '<th>';
else
echo '<th colspan="3">';
myecho($fulllabel);
echo '</th>';
echo '</tr>';
}
//showing fields
$sizeof=sizeof($record_array);
for($ii=0;$ii<$sizeof;$ii++)
{
$display_mode=$standard_display_mode;
reset($column_array);
while(list($variable_name,$val)=each($column_array))
{
if($variable_array2[$variable_name]['tab']==$tab_name)
{
$template=$column_array[$variable_name];
//$formula=$variable_array2[$variable_name]['formula'];
$show_name='odb_'.purename($variable_name);
$show_label='';//split_label($variable_name);
$show_tooltip=$variable_array2[$variable_name]['description'];//.' '.$formula;
$show_value=$variable_array[$variable_name];
if(!$focus_field_name)
$focus_field_name=$show_name;
if($show_name=='odb_MyBag')
$mybag_shown=1;
$show_dictionary=$variable_array2[$variable_name]['dict'];
if(cfg_clear_view)
{
echo '<tr>';
if($variable_array2[$variable_name]['show_cond']==3)
{
$show_mode=CFG_SHOW;
if($show_value)
{
echo '<td class="val_'.substr(purename($show_value),0,10).'">';
echo('<input name="'.$show_name.'" id="'.$show_name.'" type="hidden" value="'.$show_value.'" />');
}
else
echo '<td>';
}
else
{
$show_mode=CFG_NEW; //CFG_EDIT;
if($show_value)
echo '<td class="val_'.substr(purename($show_value),0,10).'">';
else
echo '<td>';
}
echo '<div>';
echo $field_cnt.'. ';
$field_cnt++;
if($variable_array2[$variable_name]['hl'])
{
echo '<b style="font-size:1.2em;">';
myecho($variable_name);
if(strlen($show_value)==0 and $variable_array2[$variable_name]['show_cond']!=3 and $template!='check')
echo '<span style="color:#f00;">*</span>';
echo '</b>';
}
else
myecho($variable_name);
echo '</div>';
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 '</td>';
echo '</tr>';
}
elseif($template=='file' or $template=='description' or $template=='speedometer')
{
echo '<tr>';
echo '<th style="text-align:right; vertical-align:top; font-weight:normal; width:5px;">'.$field_cnt.'.</th>';
$field_cnt++;
if($variable_array2[$variable_name]['show_cond']==3)
{
$show_mode=CFG_SHOW;
echo '<td colspan="2">';
echo('<input name="'.$show_name.'" id="'.$show_name.'" type="hidden" value="'.$show_value.'" />');
}
else
{
$show_mode=CFG_NEW; //CFG_EDIT;
echo '<td colspan="2">';
}
echo '<div>';
if($variable_array2[$variable_name]['hl'])
{
echo '<b>';
myecho($variable_name);
echo '</b>';
}
else
myecho($variable_name);
echo '</div>';
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 '</td>';
echo '</tr>';
}
else
{
echo '<tr class="record">';
echo '<th style="text-align:right; font-weight:normal; width:10px;">'.$field_cnt.'.</th>';
$field_cnt++;
if($show_tooltip)
echo '<th title="'.$show_tooltip.'">';
else
echo '<th>';
if($variable_array2[$variable_name]['hl'])
{
echo '<b>';
myecho($variable_name);
if(strlen($show_value)==0 and $variable_array2[$variable_name]['show_cond']!=3 and $template!='check')
echo '<span style="color:#f00;">*</span>';
echo '</b>';
}
else
myecho($variable_name);
echo '</th>';
if($variable_array2[$variable_name]['show_cond']==3)
{
$show_mode=CFG_SHOW;
echo '<td>';
echo('<input name="'.$show_name.'" id="'.$show_name.'" type="hidden" value="'.$show_value.'" />');
}
else
{
$show_mode=CFG_NEW; //CFG_EDIT;
echo '<td>';
}
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 '</td>';
echo '</tr>';
}
}
}
}
echo '</table>';
echo '</div>';
}
}
if(!$mybag_shown)
echo '<input name="odb_MyBag" type="hidden" value="'.get('MyBag').'"/>';
echo('<div class="clearer"></div>');
echo('</div>');
echo'</div></form>';
if($focus_field_name)
echo CRLF.'<script language="JavaScript"> document.forms[1].'.$focus_field_name.'.focus(); </script>';
?>