Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/tmp_xcal.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('<form action="index.php" method="get">');
echo('<div><input name="odb_script" type="hidden" value="xcal"></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.'" />');
echo('</div>');
flush();

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

$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();
$full_day_array=array();
$day_array=array();

if(get('quickdate'))
{
  $quickdate=get('quickdate');
  $quickdate=substr($quickdate,6,4).substr($quickdate,3,2).substr($quickdate,0,2);
  $date=round((-$today + mktime(0,0,0,substr($quickdate,4,2),substr($quickdate,6,2),substr($quickdate,0,4)))/3600/24,0)+7;
}
elseif(get('date'))
{
  $date=get('date');
  $quickdate=date('Ymd',mktime(0,0,0,date("m"),date("d")+$date-1,date("Y")));
}
else
{
  $date=7;
  $quickdate=date('Ymd');
}

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

$key_link='';
?>

<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; ?>"><?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; ?>"><?php myecho('Show next %1 days',$days_to_show); ?></a>

<input name="odb_quickdate" id="odb_quickdate" class="fld_" style="width:66px;" type="text" value="<?php echo substr($quickdate,6,2).'.'.substr($quickdate,4,2).'.'.substr($quickdate,0,4); ?>" onclick="var cal=new CalendarPopup(); cal.showYearNavigation(); cal.showYearNavigationInput(); cal.setWeekStartDay(1); cal.select(this,'odb_quickdate','dd.MM.yyyy'); return(false);" />
<input name="odb_show" type="submit" value="Show" />

</span>

<br />
<br />

<table class="cal_">
<?php
//header

echo '<tr>';
for($ii=1;$ii<8;$ii++)
  echo '<td class="cal_weekday cal_weekday'.($ii%7).'" style="font-size:18px; padding:5px;">'.myecho($weekday_array[($ii%7)],'RETURN').'</td>';
echo '</tr>';

for($dd=$date_shift;$dd<$date_shift+$days_to_show;$dd+=7)
{
  echo '<tr>';
  for($ee=$dd-6;$ee<$dd+1;$ee++)
  {
    if($ee==0)
      echo '<td class="cal_day1" style="background-color:#dfd;">';
    elseif(date('m',mktime(0,0,0,date("m"),date("d")+$ee,date("Y")))%2==0)
      echo '<td class="cal_day0">';
    else
      echo '<td class="cal_day1">';

      echo '<div style="color:#888;">';
      myecho(date('F',mktime(0,0,0,date("m"),date("d")+$ee,date("Y")))).'<br />';
      echo '<div class="cal_dayheader" style="text-align:left;">'.date('d',mktime(0,0,0,date("m"),date("d")+$ee,date("Y"))).'</div>';
      echo '</div>';
        echo '<ol style="margin:3px; padding-left:3px; list-style-position: inside;">';

        //------------------------------------------------------------
        $current_date=date('Ymd',mktime(0,0,0,date("m"),date("d")+$ee,date("Y")));
        if(sizeof($group_array))
        {
          reset($group_array);
          while(list($tmp_group,$record_array)=each($group_array))
          {
            //searching for the first important field
            $first_important_variable_name='';
            $second_important_variable_name='';
            $third_important_variable_name='';
            $variable_array2=load_config($tmp_group);
            reset($variable_array2);
            while(list($variable_name,$variable_description)=each($variable_array2))
            {
              if($variable_description['hl']==1 and $first_important_variable_name=='')
              {
                $first_important_variable_name=$variable_name;
              }
              elseif($variable_description['hl']==1 and $second_important_variable_name=='')
              {
                $second_important_variable_name=$variable_name;
              }
              elseif($variable_description['hl']==1)
              {
                $third_important_variable_name=$variable_name;
                break;
              }
            }

            //searching for dates
            foreach($record_array as $line )
            {
              $pos_tmp=strpos($line,$current_date);
              while($pos_tmp)
              {
                //getting field name
                $dpos=$pos_tmp;
                $spos=strrpos(substr($line,0,$dpos),'$');
                $kpos=strrpos(substr($line,0,$dpos),'=');
                $key=substr($line,$spos+1,$kpos-$spos-1);

                if(read($line,$key.' OK'))
                  $color='#888;';
                //elseif(strpos($line,'OK'))
                //  $color='#888;';
                else
                  $color='#080;';

                $tooltip=myecho($tmp_group,'RETURN');

                if($key!='sysComment' and $key!='sysModInfo' and $key!='sysModDate' and $key!='sysValidFrom')
                {
                  //showing on calendar
                  echo '<li class="cal_'.purename(read($line,$first_important_variable_name)).' cal_'.purename($key).'"><a title="'.$tooltip.'" href="index.php?odb_search=sysId%3d'.read($line,'sysId').'">';
                    echo '<b>';
                    echo read($line,$first_important_variable_name);

                    if(read($line,$first_important_variable_name)=='Verspätung' and read($line,'Verspatung')==1)
                      echo ': '.read($line,'Verspatung').' Tag';
                    if(read($line,$first_important_variable_name)=='Verspätung' and read($line,'Verspatung')>1)
                      echo ': '.read($line,'Verspatung').' Tage';

                    echo '</b>';

                    if(read($line,$second_important_variable_name))
                    {
                      echo ', <br />';
                      echo read($line,$second_important_variable_name);
                    }
                    if(read($line,$third_important_variable_name))
                    {
                      echo ', <br />';
                      echo read($line,$third_important_variable_name);
                    }
                    echo ', <br />';

                    $tmp_key=$key;
                    //$tmp_key=str_replace('Lieferdatum','WE',$tmp_key);
                    //$tmp_key=str_replace('Druckunterlagen','DU',$tmp_key);
                    //$tmp_key=str_replace('DU Versand bis','DU Versand',$tmp_key);

                    myecho($tmp_key);
                    //echo ' '.trim(str_replace($current_date,'',read($line,$key)));

                  echo '</a></li>';
                }

                $pos_tmp=strpos($line,$current_date,$pos_tmp+8);
              }
            }
          }
        }
        //------------------------------------------------------------

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