<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
  // Sessioin-Variable 'OverviewAmountCols' definieren
    if ( isset($_REQUEST['OverviewAmountCols']) ) { $_SESSION["OverviewAmountCols"] = $_REQUEST['OverviewAmountCols']; }
    if ( !isset($_SESSION["OverviewAmountCols"]) ) { $_SESSION["OverviewAmountCols"] = "6"; }
    $OverviewAmountCols = $_SESSION["OverviewAmountCols"];
  // Sessioin-Variable 'OverviewAmountRows' definieren
    if ( isset($_REQUEST['OverviewAmountRows']) ) { $_SESSION["OverviewAmountRows"] = $_REQUEST['OverviewAmountRows']; }
    if ( !isset($_SESSION["OverviewAmountRows"]) ) { $_SESSION["OverviewAmountRows"] = "3"; }
    $OverviewAmountRows = $_SESSION["OverviewAmountRows"];
  // Sessioin-Variable 'OverviewFirstMonth' definieren
    if ( isset($_REQUEST['OverviewFirstMonth']) ) { $_SESSION["OverviewFirstMonth"] = $_REQUEST['OverviewFirstMonth']; }
    if ( !isset($_SESSION["OverviewFirstMonth"]) ) {  $_SESSION["OverviewFirstMonth"] = "currentMonth"; }
    $OverviewFirstMonth = $_SESSION["OverviewFirstMonth"];
  // Sessioin-Variable 'OverviewPitch' definieren
    if ( isset($_REQUEST['OverviewPitch']) ) {  $_SESSION["OverviewPitch"] = $_REQUEST['OverviewPitch']; }
    if ( !isset($_SESSION["OverviewPitch"]) ) { $_SESSION["OverviewPitch"] = "0"; }
    $OverviewPitch = $_SESSION["OverviewPitch"];
  // Ansichts-Parameter
    echo '<form method="post" action="index.php?submenu=calendar&amp;page=backend_overview" accept-charset="UTF-8">
            <fieldset id="PageMenu">
              <select name="OverviewAmountCols" onchange="parent.location.href=\'index.php?submenu=calendar&amp;page=backend_overview&amp;OverviewAmountCols=\' +this.options[this.selectedIndex].value">';
              for ($i=3; $i<=20; $i++)
              {
                echo '<option value="'.$i.'"';
                if ($OverviewAmountCols==$i) echo ' selected="selected"';
                echo'>'.$i.'</option>';
              }
              echo '</select>
              <input type="hidden" name="thread[threadid]" value="$thread[threadid]" />
              <select name="OverviewAmountRows" onchange="parent.location.href=\'index.php?submenu=calendar&amp;page=backend_overview&amp;OverviewAmountRows=\' +this.options[this.selectedIndex].value">';
              for ($i=1; $i<=20; $i++)
              {
                echo '<option value="'.$i.'"';
                if ($OverviewAmountRows==$i) echo ' selected="selected"';
                echo '>'.$i.'</option>';
              }
              echo '</select>
              <input type="hidden" name="thread[threadid]" value="$thread[threadid]" />
              <select name="OverviewFirstMonth" onchange="parent.location.href=\'index.php?submenu=calendar&amp;page=backend_overview&amp;OverviewFirstMonth=\' +this.options[this.selectedIndex].value">
                <option value="January"'; if ($OverviewFirstMonth=='January') echo ' selected="selected"'; echo'>'.$L_January.'</option>
                <option value="currentMonth"'; if ($OverviewFirstMonth=='currentMonth') echo ' selected="selected"'; echo'>'.$L_160.'</option>
              </select>
              <input type="hidden" name="thread[threadid]" value="$thread[threadid]" />
              <select name="OverviewPitch" onchange="parent.location.href=\'index.php?submenu=calendar&amp;page=backend_overview&amp;OverviewPitch=\' +this.options[this.selectedIndex].value">
                <option value="0"'; if ($OverviewPitch==0) echo ' selected="selected"'; echo'>0</option>';
                  for ($i=1; $i<=12; $i++)
                  {
                    echo '<option value="'.$i.'"';
                    if ($OverviewPitch==$i) echo ' selected="selected"';
                    echo'>-'.$i.'</option>';
                  }
              echo '</select>';
          $OverviewAmountMonth = $OverviewAmountCols*$OverviewAmountRows;
          if (!isset($_GET['backwards']) AND !isset($_GET['forwards'])) {$backwards=-1;$forwards=1;}
          else
          {
            if (isset($_GET['backwards']) ) {$forwards=$backwards+1;$backwards--;}
            if (isset($_GET['forwards']) ) {$backwards=$forwards-1;$forwards++;}
          } 
          $Seite =$backwards+1;
          //echo $Seite;
          echo '<input type="button" value="&laquo;" onclick="self.location.href=\'index.php?submenu=calendar&amp;page=backend_overview&amp;backwards='.$backwards.'\'" />
                <input type="button" value="'.$L_Button38.'" onclick="self.location.href=\'index.php?submenu=calendar&amp;page=backend_overview\'" />
                <input type="button" value="&raquo;" onclick="self.location.href=\'index.php?submenu=calendar&amp;page=backend_overview&amp;forwards='.$forwards.'\'" />';
          // Button 'AddGig'
            include('calendar/includes/buttonAddGig.php');
          // Button 'Print'
            include('calendar/includes/buttonPrint.php');
          echo '</fieldset>
          </form>';


if ($OverviewFirstMonth=='January') $Pitch = $OverviewPitch+date('m')-1;
  else $Pitch = $OverviewPitch;
$Pitch = $Pitch-($Seite*$OverviewAmountMonth);
$AbzuziehendeJahre = floor($Pitch/12);
$Year = date('Y')-$AbzuziehendeJahre;
$Month = date('m')-$Pitch+($AbzuziehendeJahre*12);
if ($Month<=0)
{
  $Year--;
  $Month=$Month+12;
}
echo '<table summary="Jahresansicht">';
for ($i=1; $i<=$OverviewAmountRows; $i++)
{
  echo '<tr>';
  for ($j=1; $j<=$OverviewAmountCols; $j++)
  {
    if ($j<$OverviewAmountCols) echo '<td>';
      else echo '<td>';
    if ($Month>12) {$Month=1;$Year++;}
    $monat = $Month;
    include("calendar/backend_month-generate.php");
    echo '</td>';
    $Month++;
  }
  echo '</tr>';
}
echo '</table>';
?>
