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

//init

  $onmap=get('onmap');
  $sort_variable_name='';
  $column_array=array();
  $tab_array=array();

  $variable_array=$record_array[0];

  //looking for column names
    //config
    $variable_array2=load_config($group_name);

  //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';
      $variable_array='$'.$variable_name.'='.get(purename($variable_name)).'$'.trim($variable_array);
    }
  
    $variable_name='Longitude';
    if(get(purename($variable_name)))
    {
      $variable_array2[$variable_name]['show_cond']=2;
      $variable_array2[$variable_name]['tab']='Geo';
      $variable_array='$'.$variable_name.'='.get(purename($variable_name)).'$'.trim($variable_array);
    }

    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)
      {
        $variable_array2[$variable_name]['tab']=trim($variable_array2[$variable_name]['tab']);

        if($variable_array2[$variable_name]['show_cond']==0 and substr($variable_name,0,3)!='sys')
          $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;
      }
    }


  if($onmap)
    echo '<div id="'.$group_name.'" class="detail supergroup onmap">';
  else
    echo '<div id="'.$group_name.'" class="detail supergroup">';

  $show_name='odb_'.$id;

  $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;

  $blockers='';
  $tmp_content='';
  $res=opendir(cfg_data_path.'/temp/lock');
  while($fl = readdir($res))
    if(substr($fl,0,5)=='lock_' and $fl!='lock_'.purename(USERNAME).'.txt')
    {
      $tmp_content=file_get_contents(cfg_data_path.'/temp/lock/'.$fl);
      if(strpos($tmp_content,$id))
        $blockers.=' '.substr($fl,5,-4);
    }
  closedir($res);

   echo '<h2 title="'.$info.'">';

    if(strpos('_'.read($variable_array,'sysId'),'new'.$group_name)>0)
      echo('');
    elseif(read($variable_array,'MyBag')=='deleted')
      echo('<image src="'.cfg_images_path.'/deleted.jpg" title="'.myecho('Deleted','RETURN').'" alt="'.myecho('Deleted','RETURN').'" /> ');
    elseif(check_access(read($variable_array,'MyBag'))>1)
      echo('<input onclick="on();" id="sw'.$cnt_mark.'" name="'.$show_name.'" type="checkbox" /> ');
    else
        echo('');

    myecho($variable_array2['sysDetailTitle']['value']);
    
    if(read($variable_array,'MyBag')=='deleted')
    {
      echo ' <span style="color:#f00;">';
      myecho('(Deleted)');
      echo '</span>';
    } 
  echo '</h2>';

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

  if(!$onmap)
  {
    echo '<div class="noprint" style="margin:5px; margin-left:10px;">';
    
      if(!get('history') or !count($main_history_array[read($variable_array,'sysId')]))
      {
        echo '<a href="index.php?odb_search=sysId%3D'.read($variable_array,'sysId').'&amp;odb_history=1">';
        myecho('Show history');
        echo '</a>';
        echo '&nbsp;|&nbsp;';
      }
  
      if(read($variable_array,'Longitude'))
      {
        echo '<a href="map.php?odb_search=sysId%3d'.read($variable_array,'sysId').'&odb_icon_field_name=Icon">';
          myecho('Show on map');
        echo '</a>';
        echo '&nbsp;|&nbsp;';
      }
  
      echo '<a href="map.php?odb_search=---&amp;odb_geocode='.read($variable_array,'sysId').'">';
          myecho('Geocode');
        echo '</a>';
        echo '&nbsp;|&nbsp;';
    
      echo '<a href="index.php?odb_script=search&amp;odb_group='.$group_name.'&amp;odb_search=---">';
      myecho('Search');
      echo '</a>';
  
    echo '</div>';

    if($blockers)
    {
      echo '<div class="noprint" style="width:27em; color:#f00; margin:5px; margin-left:10px;">';
      myecho('Someone else is changing the data');
      echo ' ('.trim($blockers).')';
      echo '</div>';
    }

  }
  //----------------------------------------------------------------------------------------------------

  if(read($variable_array,'Quality')=='Suspected')
  {
    echo('<div style="padding:5px; margin:10px; border:#000 1px solid; background-color:#ff0; width:290px;"><img src="images/radioactive1.jpg" />');
    echo('<div style="text-align:center;"><b>');
    myecho('WARNING: Quality suspected.');
    echo('<br />');
    echo(' <a href="index.php?odb_run=quality&amp;odb_id='.read($variable_array,'sysId').'&amp;odb_search='.$search.'">');
    myecho('Please confirm this quality here.');
    echo('</a></b>');
    echo('</div></div>');
  }

  //$standard_display_mode=$display_mode;
  $field_cnt=1;

  $tab_cnt=count($tab_array);
  if(isset($tab_array['...']))
    $tab_cnt--;

  $blink_me=1;
  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 and !$onmap)
        {
          echo '<tr>';

            if(cfg_clean_detail)
              echo '<th>';
            else
              echo '<th colspan="3">';
            myecho($fulllabel);

            if(substr(read($variable_array,$fulllabel.' Deadline'),0,2)=='OK')
            {
              echo '<br /><span style="color:#0a0;">';
              myecho('Deadline');
              echo ' '.read($variable_array,$fulllabel.' Deadline').'</span>';
            }
            elseif(substr(read($variable_array,$fulllabel.' Deadline'),0,8)>0 and $blink_me)
            {
              $blink_me=0;
              echo '<br /><blink style="color:#f00;">';
              myecho('Deadline');
              echo ' '.read($variable_array,$fulllabel.' Deadline').'</blink>';
              echo ' <input class="button" type="submit" name="odb_'.purename($fulllabel.' Deadline').'_'.$id.'"  value="'.htmlspecialchars('OK '.read($variable_array,$fulllabel.' Deadline')).'" />';
            }
            elseif(read($variable_array,$fulllabel.' Deadline')!='')
            {
              echo '<br /><span style="color:#555;">';
              myecho('Deadline');
              echo ' '.read($variable_array,$fulllabel.' Deadline').'</span>';
            }

            echo '</th>';

          echo '</tr>';
        }
          $show_mode_ext=CFG_DETAIL;

          reset($column_array);
          while(list($variable_name,$val)=each($column_array))
          {
            if((!$onmap and $variable_array2[$variable_name]['tab']==$tab_name) or ($onmap and $variable_array2[$variable_name]['hl']))
            {
              $template=trim($column_array[$variable_name]);//$variable_array[$variable_name]['template'];
              $formula=$variable_array2[$variable_name]['formula'];

              $show_name='odb_'.purename($variable_name).'_'.$id;
              $show_label='';//split_label($variable_name);
              $show_value=htmlspecialchars(read($variable_array,$variable_name));

              $show_dictionary=$variable_array2[$variable_name]['dict'];

              if(cfg_clean_detail)
              {
                echo '<tr onclick="lock(\''.$id.'\',\''.USERNAME.'\');">';

                if(read($variable_array,'MyBag')=='deleted')
                {
                  $show_mode=CFG_SHOW;
                  if($show_value)
                    echo '<td class="val_'.substr(purename($show_value),0,10).'">';
                  else
                    echo '<td>';
                }
                elseif($variable_name=='MyBag' and check_access(read($variable_array,'MyBag'))==2)
                {
                  $show_mode=CFG_SHOW;
                  if($show_value)
                    echo '<td class="val_'.substr(purename($show_value),0,10).'">';
                  else
                    echo '<td>';
                }
                elseif($onmap or check_access($variable_name,check_access(read($variable_array,'MyBag')))==1)
                {
                  $show_mode=CFG_SHOW;
                  if($show_value)
                    echo '<td class="val_'.substr(purename($show_value),0,10).'">';
                  else
                    echo '<td>';
                }
                elseif($variable_array2[$variable_name]['formula']=='' and $variable_array2[$variable_name]['show_cond']==2)
                {
                  $show_mode=CFG_EDIT;
                  if($show_value)
                    echo '<td class="val_'.substr(purename($show_value),0,10).'">';
                  else
                    echo '<td>';

                }
                else
                {
                  $show_mode=CFG_SHOW;
                  if($show_value)
                    echo '<td class="val_'.substr(purename($show_value),0,10).'">';
                  else
                    echo '<td>';

                }

                  if($template!='button')
                  {
                    echo '<div>';
  

                      echo $field_cnt.'. ';
                      $field_cnt++;

                      if($template=='link')
                        echo '<a href="'.$show_value.'">';

                      if($template=='search')
                        echo '<a href="index.php?odb_search='.$show_value.'">';

                      if(!$onmap and $variable_array2[$variable_name]['hl'])
                      {
                        echo '<b>';
                        myecho($variable_name);
                        echo '</b>';
                      }
                      else
                        myecho($variable_name);

                      if($template=='link' or $template=='search')
                        echo '</a>';

                    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' or $template=='button')
              {
                echo '<tr>';

                  echo '<th style="text-align:right; vertical-align:top; font-weight:normal; width:5px;">'.$field_cnt.'.</th>';
                  $field_cnt++;

                if($variable_name=='MyBag' and check_access(read($variable_array,'MyBag'))==2)
                {
                  $show_mode=CFG_SHOW;
                  echo '<td colspan="2">';
                }
                elseif($onmap or check_access($variable_name,check_access(read($variable_array,'MyBag')))==1)
                {
                  $show_mode=CFG_SHOW;
                  echo '<td colspan="2">';
                }
                elseif($variable_array2[$variable_name]['formula']=='' and $variable_array2[$variable_name]['show_cond']==2)
                {
                  $show_mode=CFG_EDIT;
                  echo '<td colspan="2">';
                }
                else
                {
                  $show_mode=CFG_SHOW;
                  echo '<td colspan="2">';
                }

                  if($template!='button')
                  {
                    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>';

                echo '<th style="text-align:right; vertical-align:top; font-weight:normal; width:5px;">'.$field_cnt.'.</th>';
                $field_cnt++;

                echo '<th>';

                  if($variable_array2[$variable_name]['hl'])
                  {
                    echo '<b>';
                    myecho($variable_name);
                    echo '</b>';
                  }
                  else
                    myecho($variable_name);
                echo '</th>';

              if($variable_name=='MyBag' and check_access(read($variable_array,'MyBag'))==2)
              {
                $show_mode=CFG_SHOW;
                echo '<td class="show">';
              }
              elseif($onmap or check_access($variable_name,check_access(read($variable_array,'MyBag')))==1)
              {
                $show_mode=CFG_SHOW;
                echo '<td class="show">';
              }
              elseif($variable_array2[$variable_name]['show_cond']==2)
              {
                $show_mode=CFG_EDIT;
                if(strlen($template) and strpos('_numbermoney',$template))
                  echo '<td style="text-align:right;">';
                elseif($show_value)
                  echo '<td class="val_'.substr(purename($show_value),0,10).'">';
                else
                  echo '<td>';
              }
              else
              {
                $show_mode=CFG_SHOW;
                if($show_value)
                  echo '<td class="val_'.substr(purename($show_value),0,10).'">';
                else
                  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>';
            }
          }
        }


        //USEREXIT OnTabShow
        $userexit='ontabshow';
        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');
        }

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

    if($onmap)
      break;
  }


  if(!$onmap)
  {

    global $main_history_array;
    if(get('history') and count($main_history_array[read($variable_array,'sysId')]))
    {
      echo '<div class="detGroup">';
      echo '<table>';
        echo '<tr>';
  
          echo '<th colspan="4">';
          myecho('History');
          echo '</th>';
  
        echo '</tr>';
        echo '<tr>';
        echo '<td colspan="4">';
          
          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 '</td>';
        echo '</tr>';
  
      $sorted_main_history_array=array();
      reset($main_history_array);
      while(list($tmp,$line)=each($main_history_array[read($variable_array,'sysId')]))
        $sorted_main_history_array[read($line,'sysModInfo').read($line,'sysValidFrom').rand(1000,9999)]=$line;
  
      //~ echo '<pre>';
      //~ print_r($main_history_array);
      //~ echo '</pre>';
  
      ksort($sorted_main_history_array);
  
      //~ echo '<pre>';
      //~ print_r($sorted_main_history_array);
      //~ echo '</pre>';
  
      $main_history_array[read($variable_array,'sysId')]=$sorted_main_history_array;
  
      //$ver0_array=line2array($main_history_array[0]);
      $ver0_array=array();
      reset($main_history_array);
      while(list($tmp,$line)=each($main_history_array[read($variable_array,'sysId')]))
      {
        $last_ver_array=line2array($line);
  
        $tmp=substr(read($line,'sysModInfo'),6,2).'.'.substr(read($line,'sysModInfo'),4,2).'.'.substr(read($line,'sysModInfo'),0,4).' '.substr(read($line,'sysModInfo'),8);
  
        if(strpos($line,'sysComment=PreSave Deleted')==0 and strpos($line,'sysComment=Deleted')==0)
        {
          echo '<tr><th>'.($tmp).'</th><th colspan="3"><b>'.$last_ver_array['sysComment'].'</b><br />'.substr(read($line,'sysModInfo'),6,2).'.'.substr(read($line,'sysModInfo'),4,2).'.'.substr(read($line,'sysModInfo'),0,4).' '.substr(read($line,'sysModInfo'),8).' Valid:'.$last_ver_array['sysValid'].' '.substr($last_ver_array['sysValidFrom'],6,2).'.'.substr($last_ver_array['sysValidFrom'],4,2).'.'.substr($last_ver_array['sysValidFrom'],0,4).'-'.substr($last_ver_array['sysValidTo'],6,2).'.'.substr($last_ver_array['sysValidTo'],4,2).'.'.substr($last_ver_array['sysValidTo'],0,4).'</th></tr>';
  
          if($tmp>0)
          {
            echo '<tr><th> </th><th>Changes</th><th>Before</th><th>After</th></tr>';
            reset($last_ver_array);
            while(list($key,$value)=each($last_ver_array))
              if(substr($key,0,3)!='sys' and $last_ver_array[$key]!=$ver0_array[$key])
                echo '<tr><th> </th><th>'.$key.'</th><td>'.$ver0_array[$key].'</td><td>'.$last_ver_array[$key].'</td></tr>';
            $ver0_array=$last_ver_array;
          }
        }
        //~ else
          //~ echo '<tr><td class="label">'.($tmp).'</td><td class="label" colspan="3">'.read($line,'sysComment').': '.substr(read($line,'sysModInfo'),6,2).'.'.substr(read($line,'sysModInfo'),4,2).'.'.substr(read($line,'sysModInfo'),0,4).' '.substr(read($line,'sysModInfo'),8).'</td></tr>';
      }
      echo '</table>';
      echo '</div>';
    }
    else
    {
      echo '<div class="rec_info" style="">';

        echo '<img src="odb_barcode.php?val='.read($variable_array,'sysId').'" alt="Barcode '.read($variable_array,'sysId').'" />';
        echo '<br />ID '.read($variable_array,'sysId');

      echo '</div>';
    }
  }
  else
  {
    echo '<div class="rec_info">';
      echo '<a href="index.php?odb_search=sysId%3D'.read($variable_array,'sysId').'">';
      myecho('More...');
      echo '</a>';
    echo('</div>');
  }

  echo('</div>');
  echo('<div class="clearer"></div>');

?>
Return current item: OpenBizMap