Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/sys_.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 $lastsql;

$cutoff=0;
ignore_user_abort(false);

$onmap=get('onmap');
$showall=get('showall');

$search=trim($search);

$tstart=getmicrotime();

$show_result=0;
$noaccess_bags_cnt=0;

if($bag)
  $search=trim(trim($search).' '.'MyBag='.$bag);
else
  $search=trim($search);

//if(cfg_load_tree)
//  $show_result_array=search($search.$tree_filter);
//else
  $show_result_array=search($search);
  
if(count($show_result_array)==0)
  $nothing_found=1;

$main_history_array=$history_array;
$show_result_array_sizeof=count($show_result_array);

if($show_result)
  echo('<div id="found">Result: <strong>'.$result.'</strong></div>');


$group_array=array();
$group_name_array=array();
$group_name_cnt_array=array();

if($onmap)
  $max_access=1;
elseif(count($show_result_array)<1)
  $max_access=1;
else
  $max_access=2;
reset($show_result_array);
foreach($show_result_array as $line)
{
  $group_name=strtolower(read($line,'sysGroupBy'));

  /* off, to avoid checking rights on fields
  if($max_access<2)
  {
    $access=check_access(read($line,'MyBag'));
    if($access>$max_access)
      $max_access=$access;
  }
  */

  if(isset($group_name_cnt_array[$group_name]))
    $group_name_cnt_array[$group_name]++;
  else
    $group_name_cnt_array[$group_name]=1;

  $group_array[$group_name][]=$line;
  $group_name_array[$group_name]=$group_name;
}


$max_width=800; //max width for tmp_.txt list
  
if(cfg_load_tree) //showing tree on the left
{
  $max_width=700; //max width for tmp_.txt list

  echo '<table style="width:100%;"><tr><td class="tree">';

  include(cfg_data_path.'/script/inc_tree.txt');

  $group_array=array();
  $group_name_array=array();
  $group_name_cnt_array=array();

  $max_access=0;
  reset($show_result_array);
  foreach($show_result_array as $line)
  {
    $group_name=strtolower(read($line,'sysGroupBy'));

    if($max_access<2)
    {
      $access=check_access(read($line,'MyBag'));
      if($access>$max_access)
        $max_access=$access;
    }

    if(isset($group_name_cnt_array[$group_name]))
      $group_name_cnt_array[$group_name]++;
    else
      $group_name_cnt_array[$group_name]=1;

    $group_array[$group_name][]=$line;
    $group_name_array[$group_name]=$group_name;
  }

  echo '</td><td>';
}
  

if($script and mobile)
{
  if(file_exists(cfg_data_path.'/config/script/tmp_'.$script.'_mobile.txt'))
  {
    include(cfg_data_path.'/config/script/tmp_'.$script.'_mobile.txt');
  }
  elseif(file_exists(cfg_data_path.'/script/tmp_'.$script.'_mobile.txt'))
  {
    include(cfg_data_path.'/script/tmp_'.$script.'_mobile.txt');
  }
  elseif(file_exists(cfg_data_path.'/config/script/script_'.$script.'_mobile.html'))
  {
    include(cfg_data_path.'/config/script/script_'.$script.'_mobile.html');
  }
  elseif(file_exists(cfg_data_path.'/script/script_'.$script.'_mobile.html'))
  {
    include(cfg_data_path.'/script/script_'.$script.'_mobile.html');
  }
  elseif(file_exists(cfg_data_path.'/config/script/tmp_'.$script.'.txt'))
  {
    include(cfg_data_path.'/config/script/tmp_'.$script.'.txt');
  }
  elseif(file_exists(cfg_data_path.'/script/tmp_'.$script.'.txt'))
  {
    include(cfg_data_path.'/script/tmp_'.$script.'.txt');
  }
  elseif(file_exists(cfg_data_path.'/config/script/script_'.$script.'.html'))
  {
    include(cfg_data_path.'/config/script/script_'.$script.'.html');
  }
  elseif(file_exists(cfg_data_path.'/script/script_'.$script.'.html'))
  {
    include(cfg_data_path.'/script/script_'.$script.'.html');
  }
  else
  {
    myecho('Unknown script %1',$script);
  }
}
elseif($script)
{
  if(file_exists(cfg_data_path.'/config/script/tmp_'.$script.'.txt'))
  {
    include(cfg_data_path.'/config/script/tmp_'.$script.'.txt');
  }
  elseif(file_exists(cfg_data_path.'/script/tmp_'.$script.'.txt'))
  {
    include(cfg_data_path.'/script/tmp_'.$script.'.txt');
  }
  elseif(file_exists(cfg_data_path.'/config/script/script_'.$script.'.html'))
  {
    include(cfg_data_path.'/config/script/script_'.$script.'.html');
  }
  elseif(file_exists(cfg_data_path.'/script/script_'.$script.'.html'))
  {
    include(cfg_data_path.'/script/script_'.$script.'.html');
  }
  else
  {
    myecho('Unknown script %1',$script);
  }
}
else
{
  echo('<script>var needToComment=true;</script><form action="index.php#actual" onsubmit="needToConfirm=false;" method="post">');
  //onsubmit="if(needToComment){var tmp=prompt(\''.myecho('Comment. Why do you change data?','RETURN').'\', this.odb_sys_comment.value); if(tmp==null){return false;}else{needToConfirm=false; this.odb_sys_comment.value=tmp;}}"
  echo('<div><input name="odb_run" type="hidden" value="qchange" />'.$context_inputs);
  echo('<input name="odb_search" type="hidden" value="'.$search.'" />');
  echo('<input name="odb_trans" type="hidden" value="'.rand(10000000,99999999).'" />');
  echo ODBSEARCH;
  
  if($message)
  {
    echo '<div class="message">';
    myecho($message);
    echo '</div>';
  }

  if($max_access>1)
  {
    echo('<div class="change_submit">');
    $sys_comment=$sys_comment;
    if(!$sys_comment)
      $sys_comment='Your comment here...';
    echo(' <input class="odb_sys_comment" title="Why do you change data?" name="odb_sys_comment" type="hidden" value="'.$sys_comment.'"></input>');

    if(!mobile)
    {

    //echo('<input class="button" name="odb_save" type="submit" value="'.myecho('Save','RETURN').'" />');
    echo('<p class="bbutton"><input name="odb_save" type="submit" value="'.myecho('Save','RETURN').'" /></p>');

      //echo('<input class="button" name="odb_compare" onclick="needToComment=false;" type="submit" value="'.myecho('Compare','RETURN').'" />');
      //echo('<input class="button" name="odb_copy" type="submit" value="'.myecho('Clone','RETURN').'" />');
      //echo('<input name="odb_recalculate" type="submit" value="'.myecho('Recalculate','RETURN').'" />');
      //echo('<input class="button" name="odb_delete" type="submit" value="'.myecho('Delete','RETURN').'" />');
      //echo('<input class="button" name="reset" type="reset" value="'.myecho('Cancel','RETURN').'" />');
  
      echo('<p class="bbutton"><input name="odb_copy" type="submit" value="'.myecho('Clone','RETURN').'" /></p>');
      echo('<p class="bbutton" id="odb_compare_p" style="display:none"><input name="odb_compare" onclick="needToComment=false;" type="submit" value="'.myecho('Compare','RETURN').'" /></p>');
      echo('<p class="bbutton" id="odb_delete_p" style="display:none"><input name="odb_delete" type="submit" value="'.myecho('Delete','RETURN').'" /></p>');
    }
    


      $action_array=array();
      //USEREXIT OnShowAction
      $userexit='onshowaction';
      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');
      }
  
      if(count($action_array))
      {
        echo '<br /><br /><div id="odb_action_p">';
        $action_count=0;
        reset($action_array);
        foreach($action_array as $action_name => $tmp_value)
        {
          //echo('<input class="button" name="odb_action'.$action_count.'" type="submit" value="'.$mm2.' - '.myecho($action_name,'RETURN').'" />');
          echo('<p class="bbutton"><input id="odb_action'.$action_count.'" name="odb_action'.$action_count.'" type="submit" value="'.myecho($action_name,'RETURN').'" /></p>');
          $action_count++;
        }
        echo '</div>';
      }


    echo('</div>');
  }




  if($show_result_array_sizeof>0)
  {    
    if(sizeof($group_array)>0)
    {
      ksort($group_array);

      $cnt_mark=0;
      $record_array=array();
      reset($group_array);
      while(list($group_name,$record_array)=each($group_array))
      {
        if(isset($group_name_cnt_array[$group_name]))
          $group_cnt_max=$group_name_cnt_array[$group_name];
        else
          $group_cnt_max=1;

        $cnt_mark++;
        echo '<a name="mark'.$cnt_mark.'"></a>';

        if(mobile)
        {
          if(sizeof($record_array)>1)
          {
            $id=get('id');
            include(cfg_data_path.'/script/tmp__mobile.txt');
          }
          else
          {
            $id=read($record_array[0],'sysId');
            include(cfg_data_path.'/script/tmp_detail_mobile.txt');
          }
        }
        else
        {
          if(sizeof($record_array)>1)
          {
            $id=get('id');
            if($compare and (strpos($session_array['compare'],$group_name)>0 or $compare=='all'))
            {
              include(cfg_data_path.'/script/tmp_compare.txt');
            }
            else
            { 
              include(cfg_data_path.'/script/tmp_.txt');
            }
          }
          else
          {
            $id=read($record_array[0],'sysId');
              if($mark)
                include(cfg_data_path.'/script/tmp_mark.txt');
              else
            include(cfg_data_path.'/script/tmp_detail.txt');
          }
        }
      }
    }
  }
  else
  {
    //nothing found
    $nothing_found=1;
    //~ if(strpos('_'.$search,'Imports'))
    //~ {
      //~ myecho('<h2>Import data not found...</h2>');
      //~ myecho('<p>Maybe your import is still waiting for processing. There is a <a href="index.php?odb_search=MyBag%3d%20Imports">list of all imports</a> here.</p>');
    //~ }
    //~ else
    //~ {
    if(mobile)
    {
      if($search!='---')
      {
        echo '<h2 style="color:#f00;">';
        myecho('Nothing found...');
        echo '</h2>';
        echo '<p style="color:#f00;">';
        myecho('Database do not contain anything like'); echo ': "'.$search.'".';
        echo '</p>';
      }
    }
    else
    {
      ?>
    <div style="margin:auto; margin-top:150px; width:500px; padding:8px 5px 10px 5px; border:#aaf 1px solid; background-color:#ccf;">
    <div><form id="form2" action="index.php" method="get"><div>
      
      <p class="bbutton"><input name="submit" type="submit" value="<?php myecho('Search'); ?>" /></p>
      <input class="fld_" style="width:400px; margin-top:3px;" name="odb_search" type="text" value="" />
      </div></form></div></div>
<?php
    }
      //~ echo '<ul>';
      //~ $tmp_array=explode(' ',$search);
      //~ while(list($tmp_value,$tmp_name)=each($tmp_array))
      //~ {
        //~ if(strlen($tmp_name)>0)
        //~ {
          //~ if(file_exists(cfg_data_path.'/config/structure/'.cfg_structure.'/grp_'.strtolower($tmp_name).'.php'))
          //~ {
            //~ echo('<li><a href="index.php?odb_run=new&amp;odb_group='.$tmp_name.''.$context_params.'">Add new '.$tmp_name.'</a></li>');
          //~ }
        //~ }
      //~ }

      //~ check_words($search);
    //~ }
    
  }

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

if(cfg_load_tree)
  echo '</td></tr></table>';

echo('<div class="clearer"></div>');
$cnt_mark++;
echo '<span><a name="mark'.$cnt_mark.'"></a></span>';
?>
Return current item: OpenBizMap