<?php

	$a = true;
	$b = true;

        $sql1="SELECT * FROM objekte WHERE ID = '" . $_GET['obj'] . "' ";
        $result1 = $db->query($sql1);
		$nt1 = $result1->fetch_assoc();
		$sql2="SELECT Firma AS Vorname, Telefon, EMail FROM Firma WHERE ID = 2 ";
		$result2 = $db->query($sql2);
		$nt2 = $result2->fetch_assoc();
		echo "<h2>" . $nt1['Kurz'] . "<br />Objekt-Nr: " . $nt1['ID'] . "</h2>\n";
		echo "<h2 style=\"float:left;\">" . $nt1['Art'] . "</h2>";
		echo "<span style=\"float: right;\">\n";
		echo "	<a style=\"height: 24px; line-height: 24px; display: block;\" href=\"index.php?section=wohn&topic=wkauf&obj=".$_GET['obj']."&pdf=create\" target=\"_blank\">PDF-Expose --><img style=\"float:right;margin-right:10px;\" src=\"img/small_pdf.png\" alt=\"Expose zum Objekt als PDF anzeigen\" title=\"Expose zum Objekt als PDF anzeigen\" /></a>\n";
		echo "</span><br style=\"clear:both;\" />\n";
		if (isset($_GET['f'])) {
			$pic = "img/objekte/".$_GET['obj']."_".$_GET['f'].".jpg";
		}
		else
			{
				$pic = '';
			}



			
?>
<table class="uebersicht">
    <colgroup>
	    <col width="130" />
		<col width="110" />
		<col width="120" />
		<col width="130" />
		<col width="130" />
		<col width="70" />
	</colgroup>
	<tr>
		<td colspan="6"><hr style="margin-top: 0px; margin-left: -5px; margin-right: -5px;"/></td>
	</tr>
	<tr>
		<th colspan="4">Übersicht</th>
		<th colspan="2">Kontakt</th>
	</tr>
	<tr>
		<td>Zimmer:</td><td><?php echo $nt1['Zimmer']; ?></td>
<?php
		if ('1' == $nt1['Balkon']) {
			echo "        <td><img src=\"img/balkon.png\" alt=\"Balkon\" /></td>\n";
		}
		else {
			echo "<td>&nbsp;</td>\n";
		}
		if ('1' == $nt1['Terrasse']) {
			echo "        <td><img src=\"img/terrasse.png\" alt=\"Terrasse\" /></td>\n";
		}
		else {
			echo "<td>&nbsp;</td>\n";
		}
?>
		<td colspan="2"><?php echo fnc_getUsernameById ( $nt1['TID'], 'welcome' ); ?></td><td rowspan="3">

	</tr>
	<tr>
	    <td>Wohnfl&auml;che:</td><td><?php echo $nt1['WohnF']; ?> m&sup2;</td>
<?php
		if ('1' == $nt1['Garten']) {
			echo "        <td><img src=\"img/garten.png\" alt=\"Garten\" /></td>\n";
		}
		else {
			echo "<td>&nbsp;</td>\n";
		}
		if ('1' == $nt1['Garage']) {
			echo "        <td><img src=\"img/garage.png\" alt=\"Garage\" /></td>\n";
		}
		else {
			echo "<td>&nbsp;</td>\n";
		}
?>
		<td colspan="2"><?php echo $nt2['Telefon']; ?></td>
	</tr>
	<tr>
	    <td>Kaufpreis:</td><td><?php echo number_format ( $nt1['Mkalt'], 0, ',', '.' ); ?> &euro;</td>
<?php
		if ('1' == $nt1['EinbauK']) {
			echo "        <td><img src=\"img/ebk.png\" alt=\"Einbauküche\" /></td>\n";
		}
		else {
			echo "<td>&nbsp;</td>\n";
		}
		if ('1' == $nt1['StellPl']) {
			echo "        <td><img src=\"img/stellpl.png\" alt=\"Stellplatz\" /></td>\n";
		}
		else {
			echo "<td>&nbsp;</td>\n";
		}
?>
		<td colspan="2"><?php echo $nt2['EMail']; ?></td>
	</tr>
	<tr>
		<td colspan="6"><hr style="margin-bottom: 0px; margin-left: -5px; margin-right: -5px;"/></td>
	</tr>
</table><br />

<table class="foto">
    <colgroup>
		<col width="480px" />
		<col span="2" width="110px" />
	</colgroup>
	<tr>
<?php
	$count = 0;
	for ( $i = 1; $i < 11; $i++ )
		{
			$file = "img/objekte/".$_GET['obj']."_".$i.".jpg";
			if ( ( "1" == $i ) AND ( isset ( $_GET['f'] ) ) )
				{
					echo "<td rowspan=\"5\"><img id=\"showImg\" src=\"" . $pic . "?ts=" . date ( 'YmdHis' ) . "\" title=\""  .$nt1['Foto' . $i ] . "\" alt=\"" . $nt1[ 'Foto' . $i ] . "\" /></td>\n";
				}
			if ( file_exists ( $file ) )
				{
					if ( "" == $pic )
						{
							$pic = $file;
							echo "<td rowspan=\"5\"><img id=\"showImg\" src=\"" . $file . "?ts=" . date ( 'YmdHis' ) . "\" title=\"" . $nt1['Foto' . $i ] . "\" alt=\"" . $nt1['Foto' . $i ] . "\" /></td>\n";
						}
					echo "<td style=\"text-align:right;\"><img style=\"cursor:pointer;\" onclick=\"document.getElementById('showImg').setAttribute('src' , this.getAttribute('src'));document.getElementById('showImg').setAttribute('title' , this.getAttribute('title'));\" src=\"" . $file . "?ts=" . date ( 'YmdHis' ) . "\" title=\"" . $nt1['Foto' . $i ] . "\" alt=\"" . $nt1['Foto' . $i ] . "\" width=\"100px\" height=\"75px\" /></td>\n";
					if ( !$a )
						{
							echo "</tr>\n<tr>\n";
						}
					$a = ( $a xor $b );
					$count++;
				}
		}
	for ( $count; $count < 11; $count++ )
		{
			echo "<td>&nbsp</td>\n";
			if ( !$a )
				{
					echo "</tr>\n<tr>\n";
				}
			$a = ( $a xor $b );
		}
?>
</tr>
</table><br />

<table class="expose">
    <colgroup>
	    <col width="200" />
		<col width="150" />
		<col width="200" />
		<col width="150" />
	</colgroup>
	<tr>
		<th colspan="4">Beschreibung</th>
	</tr>
	<tr>
		<td colspan="4"><?php echo nl2br($nt1['OBeschreibung']); ?><br />&nbsp;<br /></td>
	</tr>
   <tr>
<?php
	if ( 'keineAngabe' == $nt1['Zustand'] )
		{
			echo "<td colspan=\"2\"></td>";
		}
	else
		{
			echo "<td>Zustand:</td><td>" . $nt1['Zustand'] . "</td>";
		}
	if ( 'keineAngabe' == $nt1['Quali'] )
		{
			echo "<td colspan=\"2\"></td>";
		}
	else
		{
			echo "<td>Qualität der Ausstattung:</td><td>" . $nt1['Quali'] . "</td>";
		}
?>
	</tr>
    <tr>
        <td>Baujahr:</td><td><?php echo $nt1['Baujahr']; ?></td><td>Modernisiert:</td><td><?php echo $nt1['Modern']; ?></td>
	</tr>
	<tr>
		<td colspan="4"><hr /></td>
	</tr>
	<tr>
		<th colspan="4">Kosten</th>
	</tr>
<?php
	if ( '1' == $nt['ProvisionsPflichtig'] )
		{
?>
    <tr>
	    <td>Provision:</td>
		<td colspan="3"><?php echo $nt1['Provision']; ?></td>
	</tr>
	<tr>
		<td>Provisionshinweis:</td>
		<td colspan="3"><?php echo $nt1['ProvisionsHinweis']; ?></td>
	</tr>
<?php
		}
?>
    <tr>
	    <td>Kaufpreis:</td>
		<td><?php echo number_format ( $nt1['Mkalt'], 0, ',', '.' ); ?> &euro;</td>
		<td>Wohngeld:</td>
		<td><?php echo number_format ( $nt1['Mwarm'], 0, ',', '.' ); ?> &euro;</td>
	</tr>
	<tr>
		<td>zzgl. Stellplatz:</td>
		<td><?php echo number_format ( $nt1['StellK'], 0, ',', '.' ); ?> &euro;</td>
		<td>Mieteinnahmen / Monat:</td>
		<td><?php echo number_format ( $nt1['SonK'], 0, ',', '.' ); ?> &euro;</td>
	</tr>
	<tr>
		<td colspan="4"><hr /></td>
	</tr>
	<tr>
		<th colspan="4">Ausstattung innen</th>
	</tr>
	<tr>
		<td>Schlafzimmer:</td><td><?php echo $nt1['AnzSchlaf']; ?></td>
		<td>Badezimmer:</td><td><?php echo $nt1['AnzBad']; ?></td>
	</tr>
    <tr>
	
	<?php
		$a = true;
		if ('1' == $nt1['Betreut']) {
			echo "<td>Betreutes Wohnen:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['Barrierefrei']) {
			echo "<td>Barrierefrei:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['EinbauK']) {
			echo "<td>Einbauküche:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['Speise']) {
			echo "<td>Speisekammer:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['BadeW']) {
			echo "<td>Badewanne:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['DuschK']) {
			echo "<td>Duschkabine:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['WCsep']) {
			echo "<td>WC separat:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['WCbad']) {
			echo "<td>WC im Bad:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['Abstell']) {
			echo "<td>Abstellraum:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['DachB']) {
			echo "<td>Dachboden:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['Keller']) {
			echo "<td>Keller:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
		}
	?>
	</tr>
	<tr>
		<td>Heizart:</td><td colspan="3"><?php echo $nt1['Heizart']; ?></td>
	</tr>
<?php 
	if ( 'keineAngabe' != $nt1['EnerTyp'] )
		{
?>
	<tr>
		<td>Energieausweistyp:</td><td colspan="3"><?php echo $nt1['EnerTyp']; ?></td>
	</tr>
	<tr>
		<td>Verbrauchskennwert:</td><td colspan="3"><?php echo $nt1['EnerVKW']; ?></td>
	</tr>
	<tr>
		<td>Warmwasser enthalten:</td><td colspan="3"><?php echo ( '1' == $nt1['EnerWWEnt'] ) ? "<img src=\"img/1.png\" alt=\"ja\" />" : "<img src=\"img/0.png\" alt=\"nein\" />"; ?></td>
	</tr>
<?php
	}
?>
	<tr>
		<td>Waschmaschine im:</td><td colspan="3"><?php echo $nt1['WaschOrt']; ?></td>
	</tr>
	<tr>
		<td>TV-Anschluss:</td><td colspan="3"><?php echo $nt1['TV']; ?><br />&nbsp;<br /></td>
	</tr>
	<tr>
		<th colspan="4">Ausstattung au&szlig;en</th>
	</tr>
    <tr>
	<?php
		$a = true;
		if ('1' == $nt1['Garage']) {
			echo "<td>Garage:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['StellPl']) {
			echo "<td>Stellplatz:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['Terrasse']) {
			echo "<td>Terrasse:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['Balkon']) {
			echo "<td>Balkon:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
			if ($a) {
				echo "</tr>\n<tr>\n";
			}
		}
		if ('1' == $nt1['Garten']) {
			echo "<td>Garten:</td><td><img src=\"img/1.png\" alt=\"ja\" /></td> \n";
			$a = ($a xor $b);
		}
	?>
	</tr>
	<tr>
		<th colspan="4">&nbsp;</th>
	</tr>
	<tr>
		<th colspan="4">Ausstattung</th>
	</tr>
	<tr>
		<td colspan="4"><?php echo nl2br($nt1['Ausstatt']); ?></td>
	</tr>
	<tr>
		<td colspan="4"><hr /></td>
	</tr>
	<tr>
		<th colspan="4">Lage</th>
	</tr>
	<tr>
		<td colspan="4"><?php echo nl2br($nt1['Lage']); ?></td>
	</tr>
	<tr>
		<td colspan="4"><hr /></td>
	</tr>
	<tr>
		<th colspan="4">Sonstiges</th>
	</tr>
	<tr>
		<td colspan="4"><?php echo nl2br($nt1['Sonstiges']); ?></td>
	</tr>
</table><br />
