$root = "../..";
$ueberschrift = "Tisch bearbeiten";
/*   
	date: 4.10.05
	author: christian osterrieder alpstein-austria						
*/
//header einfuegen:
include_once $root . "/backoffice/templates/header.inc.php";
include_once $root . "/backoffice/templates/bodyStart.inc.php";
include_once $root . "/backoffice/templates/components.inc.php";
include_once $root . "/include/bildFunctions.inc.php";
include_once $root . "/templates/constants.inc.php";
$index = $_POST["index"];
$bilder_id = $_POST["bilder_id"];
deleteBild($bilder_id);
$anzahl = getAnzahlBilderOfRaum($gastro_id);
if ($anzahl > 0) {
    ?>
  <table border="0" cellpadding="0" cellspacing="3">
	<tr> 
      <td><form action="./bilderLoeschen.php" method="post" name="weiter" target="_self" enctype="multipart/form-data">
			<input name="index" type="hidden" value="<?php 
    echo $index;
    ?>
"/>
			<?php 
    showSubmitButton(getUebersetzung("weitere Bilder l�schen"));
    ?>
		  </form>
      </td>
        $origWidth = $img->image_original_width;
        $origHeight = $img->image_original_height;
        if ($origWidth < $maxBreite) {
            $maxBreite = $origWidth;
        }
        if ($origHeight < $maxHoehe) {
            $maxHoehe = $origHeight;
        }
        //keep X to Y ratio
        //so there will be no geometrical distortions:
        $img->resize($maxBreite, $maxHoehe, "-");
        //save the resized image to file
        //commented to save server load
        $img->output_resized($_FILES['bild']['tmp_name']);
        //file-upload war erfolgreich:
        $pfad = $_FILES['bild']['tmp_name'];
        $bild_id = setBild($pfad, 'Picture for table card ' . $tableCardId, $img->image_resized_width, $img->image_resized_height, $fileExtension);
        setTableCardPic($bild_id, $tableCardId);
        if (!empty($old_id)) {
            //altes bild loeschen
            deleteBild($old_id);
        }
    }
    $nachricht = "Das Design der Tischkarte wurde erfolgreich gespeichert.";
    $nachricht = getUebersetzung($nachricht);
    $info = true;
    //back to the edit page:
    include_once './index.php';
    exit;
}
//end if tableCardId exists
foreach ($uebers_bes as $sprache_id => $beschreibung) {
    setUebersetzungVermieter($beschreibung, $defaultBeschreibung, $sprache_id);
}
$raum_id = $_POST["raum_id"];
$bild_id = getBildOfRaum($raum_id);
if (!empty($bild)) {
    //bild in groesse anpassen und speichern:
    $maxBreite = getGastroProperty(MAX_BILDBREITE_RAUM, $gastro_id);
    $maxHoehe = getGastroProperty(MAX_BILDHOEHE_RAUM, $gastro_id);
    //create the image from JPEG file
    $img = new hft_image($_FILES['bild']['tmp_name']);
    $origWidth = $img->image_original_width;
    $origHeight = $img->image_original_height;
    $pfad = $_FILES['bild']['tmp_name'];
    //altes bild loeschen
    deleteBild($bild_id);
    if ($origHeight == $maxHoehe && $origWidth == $maxBreite) {
        //nicht skalieren, bild ist korrekt
        //neues bild speichern:
        $bild_id = setBild($pfad, "Raumbild Raum" . $defaultBezeichnung, $origWidth, $origHeight, $fileExtension);
    } else {
        //skaliere bild
        if ($origWidth < $maxBreite) {
            $maxBreite = $origWidth;
        }
        if ($origHeight < $maxHoehe) {
            $maxHoehe = $origHeight;
        }
        //keep X to Y ratio
        //so there will be no geometrical distortions:
        $img->resize($maxBreite, $maxHoehe, "-");
?>
<style type="text/css">
<?php 
include_once $root . "/templates/stylesheetsIE9.php";
?>
</style>
<?php 
include_once "../templates/headerB.php";
include_once "../templates/bodyA.php";
?>

<?php 
//passwortprüfung:
if (checkPass($benutzername, $passwort, $unterkunft_id, $link)) {
    $pfad = getBildPfad($bilder_id, $link);
    deleteBild($bilder_id, $link);
    $fehler = true;
    $nachricht = "Das Bild konnte nicht gelöscht werden.";
    if (file_exists($pfad)) {
        unlink($pfad);
        $nachricht = "Das Bild wurde erfolgreich gelöscht.";
        $fehler = false;
    }
    $nachricht = getUebersetzung($nachricht, $sprache, $link);
    ?>
  <table border="0" cellpadding="0" cellspacing="3" class="table">
    <tr class="table"> 
      <td>
	  	<p class="standardSchriftBold"><?php 
    echo getUebersetzung("Bilder für Zimmer/Appartement/Wohnung/etc. löschen", $sprache, $link);
    ?>
    }
    /*
    $img = new hft_image($belegtFile);
    $origWidth = $img->image_original_width;
    $origHeight = $img->image_original_height;
    
    if ($origWidth < $breite){
    	$breite = $origWidth;
    }
    if ($origHeight < $hoehe){
    	$hoehe = $origHeight;
    }
    
    //keep X to Y ratio
    //so there will be no geometrical distortions:
    $img->resize($breite,$hoehe,"-"); 		
    //save the resized image to file
    //commented to save server load
    $img->output_resized($belegtFile);
    //file-upload war erfolgreich:
    */
    $pfad = $belegtFile;
    //altes bild loeschen
    deleteBild(getBildWithMarker(SYMBOL_TABLE_OCCUPIED));
    //neues bild speichern:
    $bild_id = setBild($pfad, "Symbol belegt", $breite, $hoehe, $fileExtension, SYMBOL_TABLE_OCCUPIED);
}
$nachricht = "Die Änderungen wurden erfolgreich durchgeführt";
$info = true;
include_once "./freiBelegtTisch.php";
exit;