<?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.
*/
  $SQLQuery = "SELECT * FROM ".$prefix."gigs WHERE GigID = '".$GigID."' OR GigDate='".$timestamp."' AND (GigStatus = 'Gig'";
  if ( getSetup('SetupFrontendAllowOptionalGigs') ) $SQLQuery .= " OR GigStatus = 'Option'";
  $SQLQuery .= ")";
  if ( !getSetup('SetupFrontendAllowPrivateGigs') ) $SQLQuery .= " AND GigIsPrivate = 0";
  $SQLQuery .= " AND GigPublish = 1";
  $Result = mysqli_query($db, $SQLQuery);
  echo '<div id="CalendarShowGigDetails">';
  echo '<table summary="Table_ShowGigs">';
  $DateWasShown = FALSE;
  while ($row = mysqli_fetch_array($Result))
  {
    extract($row);
    // GigDate
      if (!$DateWasShown)
      {
        echo '<tr><th>'.$L_GigDate.': </th><th>';
        include ($Path.'calendar/includes/frontend/GigDate.php');
        echo '</th></tr>';
        $DateWasShown = TRUE;
      }
      else {
        // empty row after every gig
        echo '<tr><td>&nbsp;</td><td>&nbsp;</td></tr>';
      }
    // Spalten definieren
      $Attributes = getSetup ('SetupFrontendDetailAttributes');
      if ( $Attributes!="" ) $Attributes = explode (', ',$Attributes);
        else $Attributes = array();
      $FrontendType = 'details';
      $countAttributes = count($Attributes);
      for ($i=0; $i<$countAttributes; $i++)
      {
        // check on potential empty string for GigLocation
        if ($Attributes[$i]=='GigLocation') {
          if ($GigCountry=="" && $GigDistrict=="" && $GigPostalCode=="" && $GigCity=="")
            $GigLocation='';
          else
            $GigLocation='---'; }
        if ( $GigDateOfLastEdit==0 )
          $GigDateOfLastEdit='';
        if ( $SetupFrontendCalendarGigDetailsShowEmptyAttributes OR ${$Attributes[$i]}!='' )
        {
          echo '<tr><td style="white-space: nowrap;">'.${"L_$Attributes[$i]"}.': </td><td>';
          include ($Path.'calendar/includes/frontend/'.$Attributes[$i].'.php');
          echo '</td></tr>';
        }
      }
  }
  // Define Link for Back-Button
  if (!empty($_SERVER['HTTP_REFERER']))
    $BackURL = $_SERVER['HTTP_REFERER'];
  elseif ($GigDate>=getTimestampFromDate(date("d"), date("m"), date("y"))) { // today or future
    if (!empty($SetupFrontendCalendarURL))
      $BackURL = $SetupFrontendCalendarURL;
    else
      $BackURL = strtok($_SERVER["REQUEST_URI"], '?'); }
  else { // past
    //if (!empty($SetupFrontendCalendarURL))
      //$BackURL = $SetupFrontendCalendarPastURL;
    //else
      $BackURL = strtok($_SERVER["REQUEST_URI"], '?'); }
  echo '</table>
    <input type="button" value="'.$L_Button04.'" onclick="self.location.href=\''.$BackURL.'\'" class="button"/>
  </div>';
?>