<?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.
*/
  include_once($Path."includes/error_reporting.php");
  include_once($Path."gigkalender.ini.php");
  include_once($Path."functions/standard.php");
  include_once($Path."includes/frontend_language_selector.php");
  
  //if ( !$XXX ) $SetupFrontendCalendarPeriodSelector = getSetup('SetupFrontendCalendarPeriodSelector');
  //  else $SetupFrontendCalendarPeriodSelector = 'past';
  $Monatsmerker = '';
  echo '<div id="Table">';
      if ( GigsPublished($SetupFrontendCalendarPeriodSelector) )
      {
        echo '<table summary="CalendarTable">';
        if (getSetup('SetupFrontendCalendarShowTableHeads'))
        {
          echo '<tr>';
          // Spalten definieren
            $Attributes = getSetup ('SetupFrontendAttributes');
            if ( $Attributes!="" ) $Attributes = explode (', ',$Attributes);
            else $Attributes = array();
            $amountAttributes = count($Attributes);
            for ($i=0; $i<$amountAttributes; $i++)
            {
              echo '<th>'.${"L_$Attributes[$i]"}.'</th>';
            }
            echo '<th>'.$L_GigDetails.'</th>';
            echo '</tr>';
         }
        $SQL = "SELECT * FROM ".DB_PREFIX."gigs WHERE GigPublish=1 AND (GigStatus='Gig' OR GigStatus='Option')";
        if ( $ArtistSelector!="" ) $SQL .= " AND GigArtist='".$ArtistSelector."' ";
        switch ($SetupFrontendCalendarPeriodSelector)
        {
          case 'all': $SQL .=  'order by GigDate'; break;
          case 'future': $SQL .=  'order by GigDate'; break;
          case 'past': $SQL .=  'order by GigDate DESC'; break;
        }
        $resultat = mysql_query($SQL);
        $x = 0;
        while ($row = mysql_fetch_array($resultat) AND $x<getSetup('SetupFrontendCalendarMaxAmountOfGigs') )
        {
          extract($row);
          if
          (
            $SetupFrontendCalendarPeriodSelector=='all'
            OR ($SetupFrontendCalendarPeriodSelector=='future' AND getDateIsInFuture($GigDate))
            OR ($SetupFrontendCalendarPeriodSelector=='past' AND !getDateIsInFuture($GigDate))
          )
          {
          if ( getEventIsPublished($GigID) )
	        {
            $Attributes = getSetup ('SetupFrontendAttributes');
            if ( $Attributes!="" ) $Attributes = explode (', ',$Attributes);
              else $Attributes = array();
            // Monats-Separator ausgeben
            $Monat = date('m', $GigDate);
            $MonatsName = getMonthNameFromMonthNumber($Monat);
            $Jahr = date('Y', $GigDate);
            $AmountCols = $amountAttributes+3;
            if ( getSetup('SetupFrontendCalendarShowMonthlySeparator') AND $Monatsmerker!=$Monat ) echo '<tr><td colspan="'.$AmountCols.'" class="NameOfMonth">'.$MonatsName.' '.$Jahr.'</td></tr>';
	          $Monatsmerker = $Monat;
            echo '<tr>';
            // Spalten definieren
              $FrontendType = 'table';
              for ($i=0; $i<$amountAttributes; $i++)
              {
                echo '<td class="'.$Attributes[$i].'" style="white-space: nowrap;">';
                include($Path."calendar/includes/frontend/".$Attributes[$i].".php");
                echo '</td>';
              }
            echo '<td class="GigDetailsLink">';
            include ($Path.'calendar/includes/frontend/GigDetailsLink.php');
            echo '</td>';
            print '</tr>';
            $x++;
	        }
        }
      }
      echo "</table>";
    }
    else { echo $L_013."<br />";  }
    echo '</div>';
?>