Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/tmp_rcal.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.
*/

// Calendar config ---------------------------------------------

$title=get('title');
if(!$title)
  $title=$mm2;
if(!$title)
  $title=$mm1;
if(!$title)
  $title='Calendar';

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('<form action="index.php" method="get">');
echo('<div id="reportdef" style="display:none;"><input name="odb_script" type="hidden" value="rcal"></input>');
echo('<input name="odb_search" type="hidden" value="'.$search.'" />');
echo('<input name="odb_date" type="hidden" value="'.get('date').'" />');
echo('<input name="odb_title" type="hidden" value="'.$title.'" />');


$key1=get('n1');
$key2=get('n2');
$key3=get('n3');
$key4=get('n4');
$key5=get('n5');
$key6=get('n6');
$key7=get('n7');
$key8=get('n8');
$key9=get('n9');
$key10=get('n10');

echo '<div class="supergroup">';
  echo '<table>';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<td class="label">';
    echo '</td>';

    echo '<td class="label">';
      myecho('Resource');
    echo '</td>';

    echo '<td class="label">';
      myecho('Date Field');
    echo '</td>';

    echo '<td class="label">';
      myecho('Subject');
    echo '</td>';

    echo '<td class="label">';
      myecho('Red Filter');
    echo '</td>';

    echo '<td class="label">';
      myecho('Gray Filter');
    echo '</td>';

    echo '<td class="label">';
      myecho('Green Filter');
    echo '</td>';

    echo '<td class="label">';
    echo '</td>';

  echo '</tr>';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<td class="label">';
      echo '1';
    echo '</td>';

    echo '<td class="input">';
      $show_name='n1';
      $show_value=$key1;
      $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 '<td class="input">';
      $show_name='n2';
      $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 '<td class="input">';
      $show_name='n3';
      $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 '<td class="input">';
      $show_name='n5';
      $show_value=$key5;
      $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 '<td class="input">';
      $show_name='n6';
      $show_value=$key6;
      $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 '<td class="input">';
      $show_name='n7';
      $show_value=$key7;
      $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 '<td>';
    echo '</td>';

  echo '</tr>';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<td class="label">';
      echo '2';
    echo '</td>';

    echo '<td class="input">';
      $show_name='n4';
      $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 '<td class="label">';
      myecho('Resource Title');
    echo '</td>';

    echo '<td class="label">';
      myecho('Resource Description');
    echo '</td>';

    echo '<td class="label">';

    echo '</td>';

    echo '<td class="label">';

    echo '</td>';

    echo '<td class="label">';
    echo '</td>';

    echo '<td class="label">';
    echo '</td>';

  echo '</tr>';
  echo '<tr>';
    //-----------------------------------------------------
    echo '<td class="label">';
      echo '3';
    echo '</td>';

    echo '<td class="input">';
      $show_name='n8';
      $show_value=$key8;
      $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 '<td class="input">';
      $show_name='n9';
      $show_value=$key9;
      $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 '<td class="input">';
      $show_name='n10';
      $show_value=$key10;
      $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 '<td class="label">';
    echo '</td>';

    echo '<td class="label">';
    echo '</td>';

    echo '<td class="label">';
    echo '</td>';

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

  echo '</tr>';
  echo '</table>';
  echo '<a 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();



$minute_width=0.2;
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$days_to_show=10;

$date_shift=0+get('date');
$starting_date=date('Ymd',mktime(0,0,0,date("m"),date("d")+$date_shift,date("Y")));
$ending_date=date('Ymd',mktime(0,0,0,date("m"),date("d")+$date_shift+$days_to_show,date("Y")));

$weekday_array[0]='Sunday';
$weekday_array[1]='Monday';
$weekday_array[2]='Tuesday';
$weekday_array[3]='Wednesday';
$weekday_array[4]='Thursday';
$weekday_array[5]='Friday';
$weekday_array[6]='Saturday';

$calendar_array=array();
$resource_array=array();

if(count($group_array))
{
  reset($group_array);
  while(list($tmp_group,$record_array)=each($group_array))
  {
    if($tmp_group!='user' and $tmp_group!='logs' and $tmp_group!='accesslog')
    foreach($record_array as $line )
    {
      $day=read($line,$key2);

      //if($day)
      if(($day>=$starting_date and $day<=$ending_date) or $tmp_group=='accessabilitycard')
      {
        $resource=read($line,$key8);
        if($resource)
        {
          if(read($line,$key9))
            $resource_array[read($line,$key8)]['Link']='index.php?odb_search=sysId%3d'.read($line,'sysId');
          if(read($line,$key9))
            $resource_array[$resource]['Resource Title']=read($line,$key9);
          if(read($line,$key10))
            $resource_array[$resource]['Resource Description']=read($line,$key10);


          $resource_array[$resource]['color']='#555';
          $resource_array[$resource]['bgcolor']='#fff';

          if(read($line,'Green Lock')) $resource_array[$resource]['color']='#fff';
          if(read($line,'Green Lock')) $resource_array[$resource]['bgcolor']='#050';

          if(read($line,'Gray Lock')) $resource_array[$resource]['color']='#888';
          if(read($line,'Gray Lock')) $resource_array[$resource]['bgcolor']='#fff';

          if(read($line,'Red Lock')) $resource_array[$resource]['color']='#fff';
          if(read($line,'Red Lock')) $resource_array[$resource]['bgcolor']='#f00';
        }


        $resource=read($line,$key1);
        if($resource)
        {
          $next_ii=count($calendar_array[$resource][$day]);

          if($key5 and strpos($line,$key5)) $calendar_array[$resource][$day][$next_ii]['color']='#f00';
          if($key6 and strpos($line,$key6)) $calendar_array[$resource][$day][$next_ii]['color']='#888';
          if($key7 and strpos($line,$key7)) $calendar_array[$resource][$day][$next_ii]['color']='#050';

          $calendar_array[$resource][$day][$next_ii]['Subject']=str_replace($resource,'<b>'.$resource.'</b>',read($line,$key3));
          $calendar_array[$resource][$day][$next_ii]['Link']='index.php?odb_search='.read($line,'sysId');
          if(!isset($resource_array[$resource]))
          {
            $resource_array[$resource]['Resource Title']=$resource;
            $resource_array[$resource]['Link']='index.php?odb_script=new&amp;odb_search=---&amp;odb_group=accessabilitycard&amp;odb_'.purename($key8).'='.$resource; //problem fixed type accessa...
          }
        }

        $resource=read($line,$key4);
        if($resource)
        {
          $next_ii=count($calendar_array[$resource][$day]);

          if($key5 and strpos($line,$key5)) $calendar_array[$resource][$day][$next_ii]['color']='#f00';
          if($key6 and strpos($line,$key6)) $calendar_array[$resource][$day][$next_ii]['color']='#888';
          if($key7 and strpos($line,$key7)) $calendar_array[$resource][$day][$next_ii]['color']='#050';

          $calendar_array[$resource][$day][$next_ii]['Subject']=str_replace($resource,'<b>'.$resource.'</b>',read($line,$key3));
          $calendar_array[$resource][$day][$next_ii]['Link']='index.php?odb_search='.read($line,'sysId');
          if(!isset($resource_array[$resource]))
          {
            $resource_array[$resource]['Resource Title']=$resource;
            $resource_array[$resource]['Link']='index.php?odb_script=new&amp;odb_search=---&amp;odb_group=accessabilitycard&amp;odb_'.purename($key8).'='.$resource; //problem fixed type accessa...
          }
        }
      }
    }
  }
}
//~ echo '<pre>';
//~ print_r($calendar_array);
//~ echo '</pre>';
$key_link='n1='.$key1.'&amp;n2='.$key2.'&amp;n3='.$key3.'&amp;n4='.$key4.'&amp;n5='.$key5.'&amp;n6='.$key6.'&amp;n7='.$key7.'&amp;'.'&amp;n8='.$key8.'&amp;'.'&amp;n9='.$key9.'&amp;'.'&amp;n10='.$key10.'&amp;';
?>

<span  class="noprint" style="margin-left:10px;">
<a href="index.php?odb_script=<?php echo $script; ?>&amp;odb_search=<?php echo $search; ?>&amp;<?php echo $key_link; ?>odb_date=<?php echo ($date_shift-$days_to_show); ?>&amp;popup=<?php echo $popup; ?>"><?php myecho('Show previous %1 days',$days_to_show); ?></a> |
<a href="index.php?odb_script=<?php echo $script; ?>&amp;odb_search=<?php echo $search; ?>&amp;<?php echo $key_link; ?>odb_date=<?php echo ($date_shift+$days_to_show); ?>&amp;popup=<?php echo $popup; ?>"><?php myecho('Show next %1 days',$days_to_show); ?></a>
</span>
<br />
<br />

<table class="cal_">
<?php
  //header
  echo '<tr>';
  echo '<td>&nbsp;</td>';
    for($dd=$date_shift;$dd<$date_shift+$days_to_show;$dd++)
      echo '<td class="cal_weekday cal_weekday'.date('w',mktime(0,0,0,date("m"),date("d")+$dd,date("Y"))).'">'.myecho($weekday_array[date('w',mktime(0,0,0,date("m"),date("d")+$dd,date("Y")))],'RETURN').'</td>';
  echo '</tr>';

  echo '<tr>';
  echo '<td>&nbsp;</td>';
    for($dd=$date_shift;$dd<$date_shift+$days_to_show;$dd++)
      echo '<td class="cal_dayheader">'.date('d',mktime(0,0,0,date("m"),date("d")+$dd,date("Y"))).'</td>';
  echo '</tr>';

  echo '<tr>';
  echo '<td>&nbsp;</td>';
    for($dd=$date_shift;$dd<$date_shift+$days_to_show;$dd++)
      echo '<td class="cal_fulldate">'.date('d.m.Y',mktime(0,0,0,date("m"),date("d")+$dd,date("Y"))).'</td>';
  echo '</tr>';

  $color=0;
  //for each resource
  foreach($resource_array as $cc => $tmp_val)
  {
    $color=1-$color;

    echo '<tr>';

    echo '<td class="cal_resourceheader" style="background-color:'.$resource_array[$cc]['bgcolor'].';"><a style="color:'.$resource_array[$cc]['color'].';" href="'.$resource_array[$cc]['Link'].'">'.$cc;
    echo '<h3>';
    echo $resource_array[$cc]['Resource Title'].'</h3>'.$resource_array[$cc]['Resource Description'];
    echo '</a></td>';


      //for each day
      for($dd=$date_shift;$dd<$date_shift+$days_to_show;$dd++)
      {
        echo '<td class="cal_day cal_day'.$color.'">';

        $ticket_array=$calendar_array[$cc][date('Ymd',mktime(0,0,0,date("m"),date("d")+$dd,date("Y")))];

        echo '<ol style="margin:3px; padding-left:3px; list-style-position: inside;">';
        for($tt=0;$tt<sizeof($ticket_array);$tt++)
        {
          echo '<li>';
          echo '<a style="color:'.$ticket_array[$tt]['color'].';" title="'.$ticket_array[$tt]['Description'].'" href="'.$ticket_array[$tt]['Link'].'">'.$ticket_array[$tt]['Subject'].'</a><br>';
          echo '</li>';
        }
        echo '</ol>';
        echo '</td>';
      }

    echo '</tr>';
  }
?>
</table>
Return current item: OpenBizMap