<?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>';
          // GigDate
            echo '<th>'.$L_GigDate.'</th>';
          // GigBeginning
            echo '<th>'.$L_GigBeginning.'</th>';
          // Spalten definieren
            $Attributes = getSetup ('SetupFrontendAttributes');
            if ( $Attributes!="" ) $Attributes = explode (', ',$Attributes);
            else $Attributes = array();
            for ($i=0; $i<count($Attributes); $i++)
            {
              echo '<th>'.${"L_$Attributes[$i]"}.'</th>';
            }
            echo '</tr>';
         }
        $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);
    $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))
          )
          {
          $temp = DatumAusTimestamp ($GigDate);
          if ( CheckGigPublish($GigID) )
	        {
            $Attributes = getSetup ('SetupFrontendAttributes');
            if ( $Attributes!="" ) $Attributes = explode (', ',$Attributes);
              else $Attributes = array();
            // Monats-Separator ausgeben
              $Monat = date('m', $GigDate);
              $MonatsName = MonatsNameVonDatum($Monat);
              $Jahr = date('Y', $GigDate);
              $AmountCols = count($Attributes)+3;
              if ( getSetup('SetupFrontendCalendarShowMonthlySeparator') AND $Monatsmerker!=$Monat )
                echo '<tr><td colspan="'.$AmountCols.'" class="NameOfMonth">'.$MonatsName.' '.$Jahr.'</td></tr>';
 	            $Monatsmerker = $Monat;
            echo '<tr>';
            // GigDate
              echo '<td class="GigDate" style="white-space: nowrap;">';
              include ($Path.'calendar/includes/frontend/GigDate.php');
              echo '</td>';
            // GigBeginning
              echo '<td class="GigBeginning" style="white-space: nowrap;">';
              include ($Path.'calendar/includes/frontend/GigBeginning.php');
              echo '</td>';
            // Spalten definieren
              
              $FrontendType = 'table';
              for ($i=0; $i<count($Attributes); $i++)
              {
                echo '<td class="'.$Attributes[$i].'" style="white-space: nowrap;">';
                include($Path."calendar/includes/frontend/".$Attributes[$i].".php");
                echo '</td>';
              }
            print '</tr>';
            $x++;
	        }
        }
      }
      echo "</table>";
    }
    else { echo $L_013."<br />";  }
    echo '</div>';
?>