<?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.
*/
  $VenueName = '';
  $VenueURL = '';
  $VenueCountry = '';
  $VenueDistrict = '';
  $VenuePostalCode = '';
  $VenueCity = '';
  $VenueIDToEdit = '';
  $OldVenueName = '';
  // POST-Variablen definieren
    if ( isset($_POST['senden']) )
    {
      foreach ($_POST as $key => $value) { $$key = $value; };
      // Formular überprüfen
        if ( $senden
             && $VenueName
             && (!isVenueInDatabase($VenueName)
                  OR $VenueName == $OldVenueName
                  OR ($job=='edit') AND !isVenueInDatabase($VenueName))
             && ( !$VenueURL OR checkURL( $VenueURL ) )
           )
        {
          $FormularKorrektAusgefuellt = true;
        }
        else 
        { 
          $FormularKorrektAusgefuellt = false; 
          $VenueIDToEdit = '';
        }
    }
    else
    {  
      if ( isset($_REQUEST['id'])  ) { $VenueID = $_REQUEST['id']; }
        else $VenueID ="";
      if ($_REQUEST['job']=='edit')
      { 
        $SQL = "SELECT * FROM ".DB_PREFIX."venues Where VenueID = '$VenueID'";
        $resultat = mysql_query($SQL);
        while ($row = mysql_fetch_array($resultat)) { extract($row); }
        $OldVenueName = $VenueName;
      }
      $FormularKorrektAusgefuellt = false;
      $senden = ''; 
    }
  if ( !IsUserAdmin() ) echo $L_015;
  else
  {
    if ($FormularKorrektAusgefuellt == true)
    { 
      $Venue = array( $VenueID, $VenueName, $VenueURL, $VenueCountry, $VenueDistrict, $VenuePostalCode, $VenueCity);
      // Venue hinzufügen
      if ($_REQUEST['job']=='add')
      {
        if (addVenue($Venue, "add")) echo $L_Venue_successfully_saved.'<br />';
          else echo $L_ERROR_Venue_NOT_saved.'<br />';
      }
      // Venue bearbeiten
      if ($_REQUEST['job']=='edit')
      {
        if (addVenue($Venue, "edit")) echo $L_Venue_successfully_edited.'<br />';
          else echo $L_ERROR_Venue_NOT_edited.'<br />';
      }
    echo '<br />
          <form method="post" action="index.php?submenu=calendar&amp;page=backend_showAllVenues" accept-charset="UTF-8">
            <fieldset>
              <input type="submit" value="'.$L_Button26.'" class="button" />
            </fieldset>
          </form>';
    }
    else
    {
      // Post-Variablen in Variablen speichern
        foreach ($_POST as $key => $value) $$key = stripslashes($value);
      echo '<form method="post" action="index.php?submenu=calendar&amp;page=backend_addVenue&amp;job='.$_REQUEST['job'].'" accept-charset="UTF-8">
        <table summary="AddVenue" style="float:left;">';
          include ('calendar/includes/addVenue/VenueName.php');
          include ('calendar/includes/addVenue/VenueURL.php');
          
          include ('calendar/includes/addVenue/VenueCountry.php');
          include ('calendar/includes/addVenue/VenueDistrict.php');
          include ('calendar/includes/addVenue/VenuePostalCode.php');
          include ('calendar/includes/addVenue/VenueCity.php');
          // Formular-Buttons
          echo '<tr>
            <td></td>
            <td>
              <input type="submit" name="senden" value="'.$L_Button01.'" class="button" />
              <input type="button" value="'.$L_Button03.'" onclick="self.location.href=\'index.php?submenu=calendar&amp;page=backend_showAllVenues\'" class="button"/>
              <input type="hidden" name="VenueID" value="'.$VenueID.'" />
              <input type="hidden" name="OldVenueName" value="'.$OldVenueName.'" />
            </td>
          </tr>
        </table>
        </form>          
      ';
    }
  }
?>