<?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';
  $temp = '';
  echo '<div id="List">';
  if ( GigsPublished($SetupFrontendCalendarPeriodSelector) )
  {
    $SQL_Befehl = "SELECT * FROM ".$prefix."gigs WHERE GigPublish=1 AND (GigStatus='Gig' OR GigStatus='Option')";
    if ( $ArtistSelector!="" ) $SQL_Befehl .= " AND GigArtist='".$ArtistSelector."' ";
    switch ($SetupFrontendCalendarPeriodSelector)
    {
      case 'all': $SQL_Befehl .= ' order by GigDate'; break;
      case 'future': $SQL_Befehl .= ' order by GigDate'; break;
      case 'past': $SQL_Befehl .= ' order by GigDate DESC'; break;
    }
    $resultat = mysqli_query($db, $SQL_Befehl);
    echo '<table summary="CalendarList">';
    $x = 0;
    while ($row = mysqli_fetch_array($resultat) AND $x<getSetup('SetupFrontendCalendarMaxAmountOfGigs') )
    {
      extract($row);
      if
      ( 
        $SetupFrontendCalendarPeriodSelector=='all'
        OR ($SetupFrontendCalendarPeriodSelector=='future' AND DatumInZukunft($GigDate))
        OR ($SetupFrontendCalendarPeriodSelector=='past' AND !DatumInZukunft($GigDate))
      )
      {
        if ($GigNotes == "") {$GigNotes = "&nbsp;";}
        if ( CheckGigPublish($GigID) )
	      {
          $Monat = date('m', $GigDate);
          $MonatsName = MonatsNameVonDatum($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>';
	        // GigDate
            echo '<td class="GigDate">';
            include ($Path.'calendar/includes/frontend/GigDate.php');
            echo '</td>';
          // GigBeginning
            echo '<td class="GigBeginning">';
            include ($Path.'calendar/includes/frontend/GigBeginning.php');
            echo '</td>';
          // Spalten definieren
            $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>';
?>