Location: PHPKode > projects > OpenBizMap > openbizmap/mydata/script/tmp_rchart.txt
<?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.
*/

global $filter_array;

$title=get('title');
if(!$title)
  $title=$mm2;
if(!$title)
  $title='Report';

echo '<a name="top" ></a>';

echo '<h2>';
myecho($title);
echo '</h2>';

echo '<a class="noprint" style="margin-left:10px;" href="#" onclick="document.getElementById(\'reportdef\').style.display=\'block\'; this.style.display=\'none\';">';
  myecho('Show definition');
echo '</a>';

//echo '<a class="noprint" style="margin-left:10px;" href="#chart">';
//  myecho('Show chart');
//echo '</a>';

echo('<form action="index.php" method="get">');
echo('<div id="reportdef" style="display:none;"><input name="odb_script" type="hidden" value="chart"></input>');
echo('<input name="odb_search" type="hidden" value="'.$search.'"></input>');


$key2=get('k2');
$key3=get('k3');
$key4=get('k4');

echo '<div class="supergroup">';
  echo '<table class="noprint">';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<th>';
    echo '</th>';

    echo '<th>';
      myecho('Keys');
    echo '</th>';

    echo '<th>';
    echo '</th>';

    for($ii=1;$ii<REPORT_COLUMN_COUNT;$ii++)
    {
      echo '<th>';
        myecho('Column %1',$ii);
      echo '</th>';
    }

    echo '<th>';
    echo '</th>';

  echo '</tr>';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<th>';
      echo '1';
    echo '</th>';

    echo '<td>';
      $show_name='k2';
      $show_value=$key2;
      $variable_name='ALLWORDS';
      echo('<input class="fld_" name="'.$show_name.'" id="'.$show_name.'" type="text" title="'.$show_value.'" onkeydown1="new AutoSuggestControl(this, \''.$variable_name.'\', new RemoteStateSuggestions());" value="'.$show_value.'"/>');
    echo '</td>';


    echo '<th>';
      myecho('Name');
    echo '</th>';

    for($ii=1;$ii<REPORT_COLUMN_COUNT;$ii++)
    {
      $key1name=get('n'.$ii);
      echo '<td>';
        echo '<input class="fld_" name="n'.$ii.'" value="'.$key1name.'" />';
      echo '</td>';
    }

    echo '<th>';
    echo '</th>';

  echo '</tr>';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<th>';
      echo '2';
    echo '</th>';

    echo '<td>';
      $show_name='k3';
      $show_value=$key3;
      $variable_name='ALLWORDS';
      echo('<input class="fld_" name="'.$show_name.'" id="'.$show_name.'" type="text" title="'.$show_value.'" onkeydown1="new AutoSuggestControl(this, \''.$variable_name.'\', new RemoteStateSuggestions());" value="'.$show_value.'"/>');
    echo '</td>';

    echo '<th>';
      myecho('Filter');
    echo '</th>';

    for($ii=1;$ii<REPORT_COLUMN_COUNT;$ii++)
    {
      $key1filter=get('e'.$ii);
      echo '<td>';
        echo '<input class="fld_" name="e'.$ii.'" value="'.$key1filter.'" />';
      echo '</td>';
    }

    echo '<th>';
    echo '</th>';

  echo '</tr>';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<th>';
      echo '3';
    echo '</th>';

    echo '<td>';
      $show_name='k4';
      $show_value=$key4;
      $variable_name='ALLWORDS';
      echo('<input class="fld_" name="'.$show_name.'" id="'.$show_name.'" type="text" title="'.$show_value.'" onkeydown1="new AutoSuggestControl(this, \''.$variable_name.'\', new RemoteStateSuggestions());" value="'.$show_value.'"/>');
    echo '</td>';

    echo '<th>';
      myecho('Formula');
    echo '</th>';

    for($ii=1;$ii<REPORT_COLUMN_COUNT;$ii++)
    {
      $key1var=get('v'.$ii);
      echo '<td>';
        echo '<input class="fld_" name="v'.$ii.'" value="'.$key1var.'" />';
      echo '</td>';
    }

    echo '<td>';
      echo('<input type="submit" class="submit" value="'.myecho('Report','RETURN').'" />');
    echo '</td>';

  echo '</tr>';
  echo '</table>';
  echo '<a class="noprint" style="margin-left:10px;" href="index.php?odb_sys=structure" target="_blank">';
    myecho('Show all available fields');
  echo '</a>';
echo '</div>';

echo('</div></form>');

flush();





//-------------------------------------------------------------------------------------------------------------

function stat_add($column_name,$filter,$condition=1,$add=1,$avg=0,$nototal=0)
{
  global $agregation_array;
  global $val1_array;
  global $line;
  global $val2;
  global $val3;
  global $val4;
  global $avg_count_array;

  $val1=$column_name;
  if(($add!=0 or $avg) and $condition)
  {
    $filtered=1;
    $word_array=index_explode($filter);
    $lc_line=$line;
    reset($word_array);
    while(list($key,$tmp)=each($word_array))
    {
      $lt_pos=strpos($key,'<');
      $gt_pos=strpos($key,'>');
      $minus_pos=strpos('_'.$key,'-');

      if($grep_key and $key==$grep_key)
      {
        //already filtered
      }
      elseif($lt_pos)
      {
        if($minus_pos==1)
        {
          $val=substr($key,$lt_pos+1);
          $key=substr($key,1,$lt_pos-1);

          //echo $key.' '.$val;
          if(stristr($lc_line,''.$key) and read($lc_line,$key)<$val)
            $filtered=0;
        }
        else
        {
          $val=substr($key,$lt_pos+1);
          $key=substr($key,0,$lt_pos);

          if(!stristr($lc_line,''.$key))
            $filtered=0;
          elseif(read($lc_line,$key)>=$val)
            $filtered=0;
        }
      }
      elseif($gt_pos)
      {
        $val=substr($key,$gt_pos+1);
        $key=substr($key,0,$gt_pos);

        //if(strpos('_'.$lc_line,''.$key)==0)
        if(!stristr($lc_line,''.$key))
          $filtered=0;
        elseif(read($lc_line,''.$key)<=$val)
          $filtered=0;
      }
      elseif($minus_pos==1)
      {
        $key=substr($key,1);
        //if(strpos('_'.$lc_line,''.$key)>0)
        if(stristr('_'.$lc_line,''.$key))
          $filtered=0;
      }
      //elseif(strpos('_'.$lc_line,''.$key)==0)
      elseif(!stristr($lc_line,''.$key))
      {
        $filtered=0;
      }

      if(!$filtered)
        break;
    }

    if($filtered)//strlen($filter)==0 or strpos('_'.$line,$filter))
    {
      $val1_array[$val1]=$filter;
      $agregation_array[$val2][$val3][$val4][$val1]+=$add;
      //if(!$nototal)
      //  $agregation_array['TOTAL']['TOTAL']['TOTAL'][$val1]+=$add;

      if($avg)
      {
        $avg_count_array[$val2][$val3][$val4][$val1]+=1;
        //if(!$nototal)
        //  $avg_count_array['TOTAL']['TOTAL']['TOTAL'][$val1]+=1;
      }
    }
  }
}

$agregation_array=array();
$val1_array=array();
$val2_array=array();
$val3_array=array();
$val4_array=array();
$field_type_array=array();
$avg_count_array=array();
$compare_check='';

//$record_array=search($search.' '.$key2.' '.$key3.' '.$key4);
$record_array=$show_result_array;
$fld_name_array=search_dictionary('systemplate');

for($kk=1;$kk<REPORT_COLUMN_COUNT;$kk++)
{
  $key1name=get('n'.$kk);
  $key1filter=get('e'.$kk);
  $key1formula=get('v'.$kk);

  if(strpos('_'.$key1formula,'avg')>0)
    $field_type_array[substr('0'.$kk,-2).' '.$key1name]='money';
  elseif(strpos('_'.$key1formula,'sum')>0)
    $field_type_array[substr('0'.$kk,-2).' '.$key1name]='money';
  else
    $field_type_array[substr('0'.$kk,-2).' '.$key1name]='number';
      
  foreach($fld_name_array as $fld_name)
  {
    if(strpos('_'.$key1formula,$fld_name)>0)
      $field_type_array[substr('0'.$kk,-2).' '.$key1name]=$fld_name;
  }
}

//showtime();
while(list($tmp,$line)=each($record_array))
{
  {
    $val2=read($line,$key2);
    $val3=read($line,$key3);
    $val4=read($line,$key4);

    $val2_array[$val2]++;
    $val3_array[$val3]++;
    $val4_array[$val4]++;

    for($kk=1;$kk<REPORT_COLUMN_COUNT;$kk++)
    {
      $key1name=get('n'.$kk);
      $key1filter=get('e'.$kk);
      $key1formula=get('v'.$kk);

      if($key1name=='')
        break;
        
      if($key1filter=='DUBLETS')
      {
        $key1filter='';
        $compare_check=substr('0'.$kk,-2).' '.$key1name;
      }

      if(strpos('_'.$key1formula,'avg')>0)
        $key1formulaval=0+str_replace(',','.',read($line,$key1name));
      elseif(strpos('_'.$key1formula,'sum')>0)
        $key1formulaval=0+str_replace(',','.',read($line,$key1name));
      else
        $key1formulaval=1;


      if(strpos($key1name,']'))
      {
        $key1filter=trim($key1filter);

        $value=$key1name;
        $pos=strpos('_'.$value,'[');
        $replacements=0;
        while($pos>0)
        {
          $variable=substr($value,$pos,strpos($value.']',']',$pos)-$pos);
          $vv=read($line,$variable);
          if(strlen($vv))
          {
            //echo 'VAR:'.$variable.'<br/>';
            $value=str_replace('['.$variable.']',$vv,$value);
            $key1filter=str_replace('['.$variable.']',$vv,$key1filter);
            $pos=strpos('_'.$value,'[');
            $replacements++;
            if(strpos($variable.'='.$vv,' ')>0)
              $key1filter.=' ['.$variable.'='.$vv.'$]';
            else
              $key1filter.=' '.$variable.'='.$vv.'$';
          }
          else
          {
            $value=str_replace('['.$variable.']','',$value);
            $value=trim(str_replace('  ',' ',$value));
            if($pos+1<strlen('_'.$value))
              $pos=strpos('_'.$value,'[',$pos+1);
            else
              $pos=0;
            if(strpos($variable,' ')>0)
              $key1filter.=' -['.$variable.'$]';
            else
              $key1filter.=' -'.$variable.'$';
          }
        }
        if($replacements==0)
          $value='';
        $key1name=$value;
      }

      if($key1name)
      {
        if(strpos('_'.$key1formula,'nototal')>0)
          $nototal=1;
        else
          $nototal=0;
          
        if(strpos('_'.$key1formula,'avg')>0)
          stat_add(substr('0'.$kk,-2).' '.$key1name,$key1filter,1,$key1formulaval,1,$nototal);
        else
          stat_add(substr('0'.$kk,-2).' '.$key1name,$key1filter,1,$key1formulaval,0,$nototal);
      }
    }
  }
}
//showtime('loop');



if(count($agregation_array))
{
  $color_array=array('#ff0000','#00ff00','#0000ff','#ff00ff','#00ffff','#cc0000','#00cc00','#dddddd','#ffff00','#0000cc');

  $sort_column=get('sort1');
  $sort_desc=get('sort2');

  @ksort($val2_array);
  @ksort($val3_array);
  @ksort($val4_array);

  $sort_index_array=array();
  $sort_dict_array=array();
  $sort_ii=0;

  reset($val2_array);
  while(list($val2,$tmp)=each($val2_array))
  {
    if(count($agregation_array[$val2]))
    {
      reset($agregation_array[$val2]);
      while(list($val3,$tmp)=each($agregation_array[$val2]))
      {
        reset($agregation_array[$val2][$val3]);
        while(list($val4,$tmp)=each($agregation_array[$val2][$val3]))
        {
          if($key2 and $sort_column==$key2)
            $sort_index_array[$sort_ii]=$val2;
          elseif($key3 and $sort_column==$key3)
            $sort_index_array[$sort_ii]=$val3;
          elseif($key4 and $sort_column==$key4)
            $sort_index_array[$sort_ii]=$val4;
          elseif($sort_column)
            $sort_index_array[$sort_ii]=$agregation_array[$val2][$val3][$val4][$sort_column];
          else
            $sort_index_array[$sort_ii]=$val2.$val3.$val4;

          $sort_dict_array[$sort_ii][2]=$val2;
          $sort_dict_array[$sort_ii][3]=$val3;
          $sort_dict_array[$sort_ii][4]=$val4;
          $sort_ii++;
        }
      }
    }
  }

  if($sort_column and !$sort_desc)
    arsort($sort_index_array);
  else
    asort($sort_index_array);

  $sort_index_array[$sort_ii]=1;
  $sort_dict_array[$sort_ii][2]='TOTAL';
  $sort_dict_array[$sort_ii][3]='TOTAL';
  $sort_dict_array[$sort_ii][4]='TOTAL';

  //-------------------------------------------------------------------------------------------------------------
  $content_data='';

  @ksort($val1_array);
  $rowsshown=0;
  $cnt=0;


    $content_data.='<row>';
    $content_data.='<null/>';
    //$content_data.='<string>'.myecho($key2,'RETURN').' '.myecho($key3,'RETURN').' '.myecho($key4,'RETURN').'</string>';

    reset($val1_array);
    while(list($val1,$tmp)=each($val1_array))
    {
      $content_data.='<string>'.myecho(substr($val1,3),'RETURN').'</string>';
    }
    $content_data.='</row>';

    reset($sort_index_array);
    while(list($sort_ii,$tmp)=each($sort_index_array))
    {
      $val2=$sort_dict_array[$sort_ii][2];
      $val3=$sort_dict_array[$sort_ii][3];
      $val4=$sort_dict_array[$sort_ii][4];

      if(isset($agregation_array[$val2][$val3][$val4]))
      {
        $content_data.='<row>';
        $content_data.='<string>'.myecho($val2,'RETURN').' '.myecho($val3,'RETURN').' '.myecho($val4,'RETURN').'</string>';

        reset($val1_array);
        while(list($val1,$tmp)=each($val1_array))
        {
          $show_value=$agregation_array[$val2][$val3][$val4][$val1];
          if(isset($avg_count_array[$val2][$val3][$val4][$val1]))
            $show_value=$agregation_array[$val2][$val3][$val4][$val1]/$avg_count_array[$val2][$val3][$val4][$val1];

          $content_data.='<number>'.$show_value.'</number>';
        }
        $content_data.='</row>';
      }
    }


  $chart_type='3d column';
  //$chart_type='polar';
  //$chart_type='3d pie';

  //--------------------------- Preparing chart xml ---------------------------------------------

  $content='';
  $content.='<chart>';

  $content.='<chart_data>';
  $content.=$content_data;
  $content.='</chart_data>';

  $content.='<chart_type>';
  $content.=$chart_type;
  $content.='</chart_type>';

  //Transition
  $content.='<chart_transition type="scale" delay="0" duration="1" order="all"/>';

  $content.='<chart_rect positive_color="ffffff" positive_alpha="20" negative_color="ff0000" negative_alpha="10" />';

  $content.='<series_color>';
  
  $content.='<color>ffa500</color>';
  $content.='<color>ff6347</color>';
  $content.='<color>f0e68c</color>';

  $content.='<color>da70d6</color>';
  $content.='<color>8a2be2</color>';

  $content.='<color>800080</color>';
  $content.='<color>6a5acd</color>';
  $content.='<color>9acd32</color>';
  $content.='<color>808000</color>';

  $content.='<color>4682b4</color>';
  $content.='<color>ff69b4</color>';
  $content.='<color>ffdead</color>';
  $content.='<color>d2691e</color>';

  $content.='<color>8b4513</color>';
  $content.='<color>a52a2a</color>';

  $content.='</series_color>';

  if($chart_type=='3d pie')
  {
    $content.='<chart_value hide_zero="true" color="000000" alpha="80" size="10" position="inside" prefix="" suffix="" decimals="0" separator="" as_percentage="true" />';
  }
  else
  {
    $content.='<chart_pref rotation_x="15" rotation_y="15" /><chart_grid_h thickness="1" type="solid" /><chart_grid_v thickness="1" type="solid" />';
    $content.='<chart_value hide_zero="true" color="000000" alpha="80" size="10" position="over" prefix="" suffix="" decimals="0" separator="" as_percentage="true" />';
  }

  //Label
  $content.='<legend_label layout="horizontal" bullet="circle" font="arial" bold="true" size="13" color="000000" alpha="85" />';
  $content.='<legend_rect fill_color="aaaaaa" fill_alpha="10" line_color="000000" line_alpha="0" line_thickness="0" />';

  //Title
  $content.='<draw>';
  $content.='<text  transition="slide_right" delay="0" duration="1" x="0" y="450" width="400" height="600" h_align="right" v_align="top" rotation="-90" font="arial" bold="true" size="55" color="000000" alpha="10">'.myecho($title,'RETURN').'</text>';
  $content.='</draw>';


  $content.='</chart>';


  $tmp_file_name=USERNAME.'-'.md5(time().rand(0,1000));
  addpath(cfg_data_path.'/temp/tempfile');
  $fp=fopen(cfg_data_path.'/temp/tempfile/'.$tmp_file_name,'w');
  fwrite($fp,$content);
  fclose($fp);
?>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" 
  WIDTH="800" 
  HEIGHT="450" 
  id="charts" 
  ALIGN="">
<PARAM NAME=movie VALUE="charts/charts.swf?library_path=charts/charts_library&xml_source=odb_tempfile.php?odb_file=<?php echo $tmp_file_name;?>">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#ffffff>
<PARAM NAME=wmode VALUE=transparent>

<EMBED src="charts/charts.swf?library_path=charts/charts_library&xml_source=odb_tempfile.php?odb_file=<?php echo $tmp_file_name;?>"
       quality=high 
       bgcolor=#ffffff
       wmode=transparent
       WIDTH="800" 
       HEIGHT="450" 
       NAME="charts" 
       ALIGN="" 
       swLiveConnect="true" 
       TYPE="application/x-shockwave-flash" 
       PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
<?php


//-------------------------------------------------------------------------------------------------
// Clasic report

@ksort($val1_array);
  $rowsshown=0;
  $cnt=0;

  echo '<div class="supergroup">';
    echo '<table>';
    echo '<tr>';
      echo '<th>';
      echo '</th>';

      if($key2)
      {
        echo '<th>';
        if($key2==$sort_column)
          if($sort_desc)
            echo '<a href="index.php?odb_sort1='.urlencode($sort_column).'&amp;'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted a-z" src="images/down.gif" />';
          else
            echo '<a href="index.php?'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted z-a" src="images/up.gif" />';
        else
          echo '<a href="index.php?odb_sort2=1&amp;odb_sort1='.urlencode($key2).'&amp;'.REPORTLINK.'">';

          myecho($key2);

          echo '</a>';
        echo '</th>';
      }
      if($key3)
      {
        echo '<th>';
        if($key3==$sort_column)
          if($sort_desc)
            echo '<a href="index.php?odb_sort1='.urlencode($sort_column).'&amp;'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted a-z" src="images/down.gif" />';
          else
            echo '<a href="index.php?'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted z-a" src="images/up.gif" />';
        else
          echo '<a href="index.php?odb_sort2=1&amp;odb_sort1='.urlencode($key3).'&amp;'.REPORTLINK.'">';

          myecho($key3);

          echo '</a>';
        echo '</th>';
      }
      if($key4)
      {
        echo '<th>';
        if($key4==$sort_column)
          if($sort_desc)
            echo '<a href="index.php?odb_sort1='.urlencode($sort_column).'&amp;'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted a-z" src="images/down.gif" />';
          else
            echo '<a href="index.php?'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted z-a" src="images/up.gif" />';
        else
          echo '<a href="index.php?odb_sort2=1&amp;odb_sort1='.urlencode($key4).'&amp;'.REPORTLINK.'">';

          myecho($key4);

          echo '</a>';
        echo '</th>';
      }
      reset($val1_array);
      while(list($val1,$tmp)=each($val1_array))
      {
        echo '<th>';
        if($val1==$sort_column)
          if(!$sort_desc)
            echo '<a href="index.php?odb_sort2=1&amp;odb_sort1='.urlencode($sort_column).'&amp;'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted a-z" src="images/down.gif" />';
          else
            echo '<a href="index.php?'.REPORTLINK.'"><img style="margin:3px;" alt="Sorted z-a" src="images/up.gif" />';
        else
          echo '<a href="index.php?odb_sort1='.urlencode($val1).'&amp;'.REPORTLINK.'">';

        myecho(substr($val1,3));
        echo '</a>';
        echo '</th>';
      }
    echo '</tr>';

    reset($sort_index_array);
    while(list($sort_ii,$tmp)=each($sort_index_array))
    {
      $val2=$sort_dict_array[$sort_ii][2];
      $val3=$sort_dict_array[$sort_ii][3];
      $val4=$sort_dict_array[$sort_ii][4];


      if(isset($agregation_array[$val2][$val3][$val4]))
      {
        $cnt++;

        if(strpos('_'.$val2.$val3.$val4,'TOTAL'))
          echo '<tr>';
        else
          echo '<tr class="record'.(($cnt-1)%2).'">';
        echo '<th>';
          echo $cnt.'.';
        echo '</th>';

        if($key2)
        {
          echo '<td><div class="fld_">';
            if(strlen($val2)==8 and $val2>19900101 and $val2<30000101)
              echo substr($val2,6,2).'.'.substr($val2,4,2).'.'.substr($val2,0,4);
            else
              echo str_replace(' ','&nbsp;',$val2);
          echo '</div></td>';
        }

        if($key3)
        {
          echo '<td><div class="fld_">';
            if(strlen($val3)==8 and $val3>19900101 and $val3<30000101)
              echo substr($val3,6,2).'.'.substr($val3,4,2).'.'.substr($val3,0,4);
            else
              echo str_replace(' ','&nbsp;',$val3);
          echo '</div></td>';
        }

        if($key4)
        {
          echo '<td><div class="fld_">';
            if(strlen($val4)==8 and $val4>19900101 and $val4<30000101)
              echo substr($val4,6,2).'.'.substr($val4,4,2).'.'.substr($val4,0,4);
            else
              echo str_replace(' ','&nbsp;',$val4);
          echo '</div></td>';
        }

        reset($val1_array);
        while(list($val1,$tmp)=each($val1_array))
        {

          echo '<td>';

            $drill_search=$search;
            if(strlen($key2))
              if($val2=='TOTAL')
                $drill_search.=' ['.$key2.']';
              elseif(strpos('_'.$key2,'['))
                $drill_search.=' '.$filter_array[$key2.'***'.$val2];
              elseif(strlen($val2))
                $drill_search.=' [$'.$key2.'='.$val2.'$]';
              elseif(strlen($key2))
                $drill_search.=' -[$'.$key2.'=]';

            if(strlen($key3))
              if($val3=='TOTAL')
                $drill_search.=' ['.$key3.']';
              elseif(strpos('_'.$key3,'['))
                  $drill_search.=' '.$filter_array[$key3.'***'.$val3];
              elseif(strlen($val3))
                $drill_search.=' [$'.$key3.'='.$val3.'$]';
              elseif(strlen($key3))
                $drill_search.=' -[$'.$key3.'=]';

            if(strlen($key4))
              if($val4=='TOTAL')
                $drill_search.=' ['.$key4.']';
              elseif(strpos('_'.$key4,'['))
                  $drill_search.=' '.$filter_array[$key4.'***'.$val4];
              elseif(strlen($val4))
                $drill_search.=' [$'.$key4.'='.$val4.'$]';
              elseif(strlen($key4))
                $drill_search.=' -[$'.$key4.'=]';

            if(strlen($val1_array[$val1])) $drill_search.=' '.$val1_array[$val1].'';
            $drill_search=trim($drill_search);
            $drill_search=urlencode($drill_search);

            if($val2!='TOTAL' and $val3!='TOTAL' and $val4!='TOTAL')
              if($val1==$compare_check)
                echo '<a href="index.php?odb_compare=all&amp;odb_search='.$drill_search.'">';
              else
                echo '<a href="index.php?odb_search='.$drill_search.'">';

            if(1)
            {
              $show_mode=CFG_SHOW;
              $show_value=$agregation_array[$val2][$val3][$val4][$val1];
              if(isset($avg_count_array[$val2][$val3][$val4][$val1]))
                $show_value=$agregation_array[$val2][$val3][$val4][$val1]/$avg_count_array[$val2][$val3][$val4][$val1];
              $template=$field_type_array[$val1];
              //$template='number';

              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 $field_type_array[$val1];
            }

            if($val2!='TOTAL' and $val3!='TOTAL' and $val4!='TOTAL')
              echo '</a>';

            //echo $val1.$val2.$val3.$val4;
          echo '</td>';
        }
      }

      echo '</tr>';
    }
    echo '</table>';
  echo '</div>';

//-------------------------------------------------------------------------------------------------

}
else
{
  echo '<br /><h2>';
  myecho('No data found');
  echo '</h2><br /><br /><br />';
}

?>
Return current item: OpenBizMap