Subversion Repositories personal-webbase

Rev

Rev 14 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. if (!defined('WBLEGAL')) die('Kann nicht ohne Personal WebBase ausgef&uuml;hrt werden.');
  4.  
  5.   echo $header;
  6.  
  7. if ($modulueberschrift == '') $modulueberschrift = $modul;
  8. echo '<h1>'.my_htmlentities($modulueberschrift).'</h1>';
  9.  
  10.   echo '<center><b>Wochenauflistung</b> - <a href="'.$_SERVER['PHP_SELF'].'?modul='.urlencode($modul).'&amp;seite=auflistung"><b>Terminauflistung</b></a> - <a href="'.$_SERVER['PHP_SELF'].'?modul='.urlencode($modul).'&amp;seite=edit&amp;aktion=new&amp;herkunft='.urlencode($seite).'"><b>Neuer Eintrag</b></a><br><br></center>';
  11.  
  12. // http://news.php.net/php.notes/102689
  13.  
  14. function get_week_boundaries($int_time)
  15. {
  16.   // first: find monday 0:00
  17.   $weekdayid=date("w",$int_time);
  18.  
  19.   // christliche zeitrechnung (woche beginnt mit sonntag) umgehen
  20.   if ($weekdayid == 0) $weekdayid = 7;
  21.  
  22.   $dayid=date("j",$int_time);
  23.   $monthid=date("n", $int_time);
  24.   $yearid=date("Y", $int_time);
  25.   $beginofday=mktime(0,0,0,$monthid,$dayid,$yearid);
  26.   $beginofweek=$beginofday - (($weekdayid-1) * 86400); //86400 == seconds of one day (24 hours)
  27.   //now add the value of one week and call it the end of the week
  28.   //NOTE: End of week is Sunday, 23:59:59. I think you could also use Monday 00:00:00 but I though that'd suck
  29.   $endofweek=($beginofweek + 7 * 86400)-1;
  30.   $week["begin"]=$beginofweek;
  31.   $week["end"]=$endofweek;
  32.   $week["pov"]=$int_time;
  33.   return $week;
  34. }
  35.  
  36. function zweinull($e)
  37. {
  38.   if (strlen($e) == 1)
  39.     return '0'.$e;
  40.   else
  41.     return $e;
  42. }
  43.  
  44. function wochenstat($woche)
  45. {
  46.   global $mysql_zugangsdaten, $benutzer, $modul, $seite;
  47.  
  48.   wb_draw_table_begin();
  49.  
  50.   wb_draw_table_content('100', '<b>Tag</b>', '', '<b>Name</b>', '190', '<b>Startzeitpunkt</b>', '130', '<b>Verbleibende Zeit</b>', '100', '<b>Aktionen</b>', '100', '');
  51.  
  52.   $current_week = get_week_boundaries(time()+$woche*60*60*24*7);
  53.  
  54.   $eintr = false;
  55.   for ($i=0; $i<7; $i++)
  56.   {
  57.     $wbeg = $current_week["begin"]+$i*60*60*24;
  58.     $wd = date("d", $wbeg);
  59.     $wm = date("m", $wbeg);
  60.     $wy = date("Y", $wbeg);
  61.  
  62.     if ((date("d") == $wd) && (date("m") == $wm) && (date("Y") == $wy))
  63.     {
  64.       $a1 = '<font color="#FF0000"><b>';
  65.       $a2 = '</b></font>';
  66.     }
  67.     else
  68.     {
  69.       $a1 = '';
  70.       $a2 = '';
  71.     }
  72.     $res = db_query("SELECT `id`, `name`, `start_time` FROM `".$mysql_zugangsdaten['praefix']."kalender` WHERE `user` = '".$benutzer['id']."' AND SUBSTRING(`start_date`, 1, 4) = '$wy' AND SUBSTRING(`start_date`, 6, 2) = '$wm' AND SUBSTRING(`start_date`, 9, 2) = '$wd' ORDER BY `start_date`, `start_time`, `id`");
  73.     while ($row = db_fetch($res))
  74.     {
  75.       $eintr = true;
  76.       $z = ceil((mktime(0, 0, 0, $wm, $wd, $wy)-mktime(0, 0, 0, date('m'), date('d'), date('Y')))/60/60/24);
  77.       if ($z < 0)
  78.       {
  79.         $a1 = '<font color="#666666">';
  80.         $a2 = '</font>';
  81.       }
  82.  
  83.       $wochentag = '';
  84.       if ($i == 0) $wochentag = 'Montag';
  85.       if ($i == 1) $wochentag = 'Dienstag';
  86.       if ($i == 2) $wochentag = 'Mittwoch';
  87.       if ($i == 3) $wochentag = 'Donnerstag';
  88.       if ($i == 4) $wochentag = 'Freitag';
  89.       if ($i == 5) $wochentag = 'Samstag';
  90.       if ($i == 6) $wochentag = 'Sonntag';
  91.  
  92.       $verbleibend = '';
  93.       if ($z < 0) $verbleibend = 'Abgelaufen';
  94.       if ($z == 0) $verbleibend = 'Heute';
  95.       if ($z == 1) $verbleibend = 'Morgen';
  96.       if ($z == 2) $verbleibend = '&Uuml;bermorgen';
  97.       if ($z > 2) $verbleibend = $z.' Tage';
  98.  
  99.       wb_draw_table_content('', $a1.$wochentag.$a2, '', $a1.$row['name'].$a2, '', $a1.de_convertmysqldatetime($wy.'-'.$wm.'-'.$wd.' '.$row['start_time']).$a2, '', $a1.$verbleibend.$a2, '', '<a href="'.$_SERVER['PHP_SELF'].'?seite=edit&amp;modul='.urlencode($modul).'&amp;aktion=edit&amp;danach=A&amp;id='.urlencode($row['id']).'&amp;herkunft='.urlencode($seite).'" class="menu">Bearbeiten</a>', '', '<a href="javascript:abfrage(\''.$_SERVER['PHP_SELF'].'?seite=kraftsetzung&amp;modul='.urlencode($modul).'&amp;aktion=delete&amp;zurueck='.urlencode($seite).'&amp;id='.urlencode($row['id']).'\');" class="menu">L&ouml;schen</a>');
  100.     }
  101.   }
  102.   if (!$eintr)
  103.   {
  104.     gfx_tablespancontent(0, 6, 'Keine Termine vorhanden!');
  105.   }
  106.  
  107.   wb_draw_table_end();
  108. }
  109.  
  110. $d = date('j');
  111. $m = date('n');
  112. $y = date('Y');
  113.  
  114. $anzahl_wochen = 5; // Konfigurierbar
  115.  
  116. for ($ii=0; $ii<=$anzahl_wochen; $ii++)
  117. {
  118.   if ($ii == 0)
  119.     $ueb = 'diese Woche';
  120.   else if ($ii == 1)
  121.     $ueb = 'n&auml;chste Woche';
  122.   else if ($ii == 2)
  123.     $ueb = '&uuml;bern&auml;chste Woche';
  124.   else if ($ii > 2)
  125.     $ueb = 'in '.$ii.' Wochen';
  126.  
  127.   $uri = get_week_boundaries(mktime(0,0,0,$m,$d+7*$ii,$y));
  128.   echo '<b>Termine '.$ueb.'</b> (Kalenderwoche '.date('W/Y', mktime(0,0,0,$m,$d+7*$ii,$y)).' von '.date("d.m.Y", $uri['begin']).' - '.date("d.m.Y", $uri['end']).')<br><br>';
  129.   wochenstat($ii);
  130. }
  131.  
  132.   echo $footer;
  133.  
  134. ?>
  135.