<?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");
  $temp = '';
  echo '<div id="List">';
  if ( GigsPublished($SetupFrontendCalendarPeriodSelector) )
  { 
    $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);
    echo '<table summary="CalendarList">';
    $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 ($GigNotes == "") {$GigNotes = "&nbsp;";}
        if ( getEventIsPublished($GigID) )
	      {
          $Monat = date('m', $GigDate);
          $MonatsName = getMonthNameFromMonthNumber($Monat);
          $Jahr = date('Y', $GigDate);
          if ( getSetup('SetupFrontendCalendarShowMonthlySeparator') AND $temp!=$Monat ) echo '<tr><td colspan="4" class="NameOfMonth">'.$MonatsName.' '.$Jahr.'</td></tr>';
	        $temp = $Monat;
	        echo '<tr>';
          $Attributes = getSetup ('SetupFrontendAttributes');
          if ( $Attributes!="" ) $Attributes = explode (', ',$Attributes);
          else $Attributes = array();
          echo '<td>';
          $FrontendType = 'list';
          $AmountOfAttributes = count($Attributes);
          for ($i=0; $i<$AmountOfAttributes; $i++)
          {
            include ($Path.'calendar/includes/frontend/'.$Attributes[$i].'.php');
          }
          echo '</td>';
          echo '</tr>';
          $x++;
        }
      }
    }
    echo '</table>';
  }
  else
  {
    if ( $SetupFrontendCalendarPeriodSelector=="future" ) echo $L_013."<br />";
    if ( $SetupFrontendCalendarPeriodSelector=="past" ) echo $L_014."<br />";
    if ( $SetupFrontendCalendarPeriodSelector=="all" ) echo $L_206."<br />";
  }
  echo '</div>';
?>