<h1>Objektübersicht</h1>

<table style="border: 1px solid gray;"><form name="o_search" action="index.php?section=suche" method="get">
	<colgroup>
		<col width="80">
		<col width="180">
		<col width="110">
		<col width="160">
		<col width="50">
		<col width="180">
	<colgroup>
	<tr>
		<td>Kategorie:</td>
		<td style="border-right: 1px solid gray;"><input type="hidden" name="section" value="suche" /><input onclick="document.o_search.submit();" type="radio" name="KAT" value="wohnen" <?php echo ( isset ( $_GET['KAT'] ) AND 'wohnen' == $_GET['KAT'] ) ? 'checked="checked" ' : ''; ?>/>Wohnimmobilien</td>
		<td style="padding-left:10px;">Vermartktung:</td>
		<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="V_TYP" value="Kauf" <?php echo ( isset ( $_GET['V_TYP'] ) AND 'Kauf' == $_GET['V_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Kauf</td>
		<td style="padding-left:10px;">Typ:</td>

<?php
	if ( isset ( $_GET['KAT'] ) AND 'wohnen' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="Wohnung" <?php echo ( isset ( $_GET['O_TYP'] ) AND 'Wohnung' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Wohnung</td>
<?php
		}
	elseif ( 'gewerbe' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="Büro" <?php echo ( isset ( $_GET['O_TYP'] ) AND 'Büro' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Büro</td>
<?php
		}
	else
		{
			echo '<td style="border-right: 1px solid gray;">&nbsp;</td>';
		}
?>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="KAT" value="gewerbe" <?php echo ( isset ( $_GET['KAT'] ) AND 'gewerbe' == $_GET['KAT'] ) ? 'checked="checked" ' : ''; ?>/>Gewerbeimmobilien</td>
		<td>&nbsp;</td>
		<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" <?php echo ( isset ( $_GET['KAT'] ) AND 'anlage' == $_GET['KAT'] ) ? 'disabled' : ''; ?> type="radio" name="V_TYP" value="Miete" <?php echo ( isset ( $_GET['V_TYP'] ) AND 'Miete' == $_GET['V_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Miete</td>
		<td>&nbsp;</td>
<?php
	if ( isset ( $_GET['KAT'] ) AND 'wohnen' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="Haus" <?php echo ( isset ( $_GET['O_TYP'] ) AND 'Haus' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Haus</td>
<?php
		}
	elseif ( 'gewerbe' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="Praxis" <?php echo ( isset ( $_GET['O_TYP'] ) AND 'Praxis' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Praxis</td>
<?php
		}
	else
		{
			echo '<td style="border-right: 1px solid gray;">&nbsp;</td>';
		}
?>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" <?php echo ( isset ( $_GET['V_TYP'] ) AND 'Miete' == $_GET['V_TYP'] ) ? 'disabled' : ''; ?> type="radio" name="KAT" value="anlage" <?php echo ( isset ( $_GET['KAT'] ) AND 'anlage' == $_GET['KAT'] ) ? 'checked="checked" ' : ''; ?>/>Anlageimmobilien</td>
		<td>&nbsp;</td>
		<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="V_TYP" value="alle" <?php echo ( !isset ( $_GET['V_TYP'] ) OR 'alle' == $_GET['V_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Alle Immobilien</td>
		<td>&nbsp;</td>
<?php
	if ( isset ( $_GET['KAT'] ) AND 'wohnen' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="alle" <?php echo ( !isset ( $_GET['O_TYP'] ) OR 'alle' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Alle Immobilien</td>
<?php
		}
	elseif ( 'gewerbe' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="Einzelhandel" <?php echo ( isset ( $_GET['O_TYP'] ) AND 'Einzelhandel' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Einzelhandel</td>
<?php
		}
	else
		{
			echo '<td style="border-right: 1px solid gray;">&nbsp;</td>';
		}
?>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="KAT" value="alle" <?php echo ( !isset ( $_GET['KAT'] ) OR 'alle' == $_GET['KAT'] ) ? 'checked="checked" ' : ''; ?>/>Alle Immobilien</td>
		<td>&nbsp;</td>
		<td style="border-right: 1px solid gray;">&nbsp;</td>
		<td>&nbsp;</td>
<?php
	if ( isset ( $_GET['KAT'] ) AND 'gewerbe' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="Produktionshalle" <?php echo ( isset ( $_GET['O_TYP'] ) AND 'Produktionshalle' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Produktionshalle</td>
<?php
		}
	else
		{
			echo '<td style="border-right: 1px solid gray;">&nbsp;</td>';
		}
?>
	</tr>
	<tr>
		<td colspan="2" style="border-right: 1px solid gray;">&nbsp;</td>
		<td colspan="2" style="border-right: 1px solid gray;">&nbsp;</td>
		<td>&nbsp;</td>
<?php
	if ( isset ( $_GET['KAT'] ) AND 'gewerbe' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="Gastronomie" <?php echo ( isset ( $_GET['O_TYP'] ) AND 'Gastronomie' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Gastronomie</td>
<?php
		}
	else
		{
			echo '<td style="border-right: 1px solid gray;">&nbsp;</td>';
		}
?>
	</tr>
	<tr>
		<td colspan="2" style="border-right: 1px solid gray;">&nbsp;</td>
		<td colspan="2" style="border-right: 1px solid gray;">&nbsp;</td>
		<td>&nbsp;</td>
<?php
	if ( isset ( $_GET['KAT'] ) AND 'gewerbe' == $_GET['KAT'] )
		{
?>
			<td style="border-right: 1px solid gray;"><input onclick="document.o_search.submit();" type="radio" name="O_TYP" value="alle" <?php echo ( !isset ( $_GET['O_TYP'] ) OR 'alle' == $_GET['O_TYP'] ) ? 'checked="checked" ' : ''; ?>/>Alle Immobilien</td>
<?php
		}
	else
		{
			echo '<td style="border-right: 1px solid gray;">&nbsp;</td>';
		}
?>
	</tr>
</form></table><br />&nbsp;<br />
<?php
$_GET['sortRow']	= ( !isset ( $_GET['sortRow'] ) OR empty ( $_GET['sortRow'] ) )		? 'Ort'		: $_GET['sortRow'];
$_GET['sortDir']	= ( !isset ( $_GET['sortDir'] ) OR empty ( $_GET['sortDir'] ) )		? 'ASC'		: $_GET['sortDir'];

$filter				= '';
if ( isset ( $_GET['KAT'] ) AND ! empty ( $_GET['KAT'] ) AND 'alle' != $_GET['KAT'] )
	{
		$filter		.= " AND KAT = '" . $_GET['KAT'] . "' ";
	}
if ( isset ( $_GET['O_TYP'] ) AND ! empty ( $_GET['O_TYP'] ) AND 'alle' != $_GET['O_TYP'] )
	{
		$filter		.= " AND O_TYP = '" . $_GET['O_TYP'] . "' ";
	}
if ( isset ( $_GET['V_TYP'] ) AND ! empty ( $_GET['V_TYP'] ) AND 'alle' != $_GET['V_TYP'] )
	{
		$filter		.= " AND V_TYP = '" . $_GET['V_TYP'] . "' ";
	}

$sql				= "SELECT *, DATE_FORMAT ( Datum, '%d.%m.%Y' ) AS Datum FROM objekte WHERE Aktiv = '1' AND Deaktiv = '0' " . $filter . " ORDER BY " . $_GET['sortRow'] . " " . $_GET['sortDir'] . ";";
$result				= $db->query ( $sql );

$tmp_imgOrt			= ( $_GET['sortRow'] == 'Ort' )		? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';
$tmp_imgDatum		= ( $_GET['sortRow'] == 'Datum' )	? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';
$tmp_imgID			= ( $_GET['sortRow'] == 'ID' )		? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';
$tmp_imgZimmer		= ( $_GET['sortRow'] == 'Zimmer' )	? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';
$tmp_imgWohnF		= ( $_GET['sortRow'] == 'WohnF' )	? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';
$tmp_imgWohnF		= ( $_GET['sortRow'] == 'WohnF' )	? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';
$tmp_imgMkalt		= ( $_GET['sortRow'] == 'Mkalt' )	? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';
$tmp_imgTID			= ( $_GET['sortRow'] == 'TID' )		? ( $_GET['sortDir'] == 'ASC' )		? 'sort_up.gif'	: 'sort_down.gif'	: 'sort_wo.gif';

$tmp_linkOrt		= ( $_GET['sortRow'] == 'Ort' )		? ( $_GET['sortDir'] == 'ASC' )		? 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Ort&sortDir=DESC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Ort&sortDir=ASC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Ort&sortDir=ASC';
$tmp_linkDatum		= ( $_GET['sortRow'] == 'Datum' )	? ( $_GET['sortDir'] == 'ASC' )		? 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Datum&sortDir=DESC'	: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Datum&sortDir=ASC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Datum&sortDir=ASC';
$tmp_linkID			= ( $_GET['sortRow'] == 'ID' )		? ( $_GET['sortDir'] == 'ASC' )		? 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=ID&sortDir=DESC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=ID&sortDir=ASC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=ID&sortDir=ASC';
$tmp_linkZimmer		= ( $_GET['sortRow'] == 'Zimmer' )	? ( $_GET['sortDir'] == 'ASC' )		? 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Zimmer&sortDir=DESC'	: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Zimmer&sortDir=ASC'	: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Zimmer&sortDir=ASC';
$tmp_linkWohnF		= ( $_GET['sortRow'] == 'WohnF' )	? ( $_GET['sortDir'] == 'ASC' )		? 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=WohnF&sortDir=DESC'	: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=WohnF&sortDir=ASC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=WohnF&sortDir=ASC';
$tmp_linkMkalt		= ( $_GET['sortRow'] == 'Mkalt' )	? ( $_GET['sortDir'] == 'ASC' )		? 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Mkalt&sortDir=DESC'	: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Mkalt&sortDir=ASC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=Mkalt&sortDir=ASC';
$tmp_linkTID		= ( $_GET['sortRow'] == 'TID' )		? ( $_GET['sortDir'] == 'ASC' )		? 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=TID&sortDir=DESC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=TID&sortDir=ASC'		: 'index.php?section=suche&KAT='. $_GET['KAT'] . '&V_TYP=' . $_GET['V_TYP'] . '&O_TYP=' . $_GET['O_TYP'] . '&sortRow=TID&sortDir=ASC';
?>

<table>
	<colgroup>
		<col width="180px" />
		<col width="100px" />
		<col width="50px" />
		<col width="155px" />
		<col width="45px" />
		<col width="60px" />
		<col width="170px" />
	</colgroup>
	<tr height="30">
		<th style="text-align:left;"><a style="text-decoration:none;color:black;border:none;" href="<?php echo $tmp_linkOrt; ?>"><img style="margin-bottom:-3px;border:0px;" height="16px" src="../img/<?php echo $tmp_imgOrt; ?>" /> Ort</a></th>
		<th style="text-align:left;"><a style="text-decoration:none;color:black;border:none;" href="<?php echo $tmp_linkDatum; ?>"><img style="margin-bottom:-3px;border:0px;" height="16px" src="../img/<?php echo $tmp_imgDatum; ?>" /> Datum</a></th>
		<th style="text-align:left;"><a style="text-decoration:none;color:black;border:none;" href="<?php echo $tmp_linkID; ?>"><img style="margin-bottom:-3px;border:0px;" height="16px" src="../img/<?php echo $tmp_imgID; ?>" /> Nr</a></th>
		<th style="text-align:left;"><a style="text-decoration:none;color:black;border:none;" href="<?php echo $tmp_linkZimmer; ?>"><img style="margin-bottom:-3px;border:0px;" height="16px" src="../img/<?php echo $tmp_imgZimmer; ?>" /> Zimmer</a></th>
		<th style="text-align:left;"><a style="text-decoration:none;color:black;border:none;" href="<?php echo $tmp_linkWohnF; ?>"><img style="margin-bottom:-3px;border:0px;" height="16px" src="../img/<?php echo $tmp_imgWohnF; ?>" /> m&sup2;</a></th>
		<th style="text-align:left;"><a style="text-decoration:none;color:black;border:none;" href="<?php echo $tmp_linkMkalt; ?>"><img style="margin-bottom:-3px;border:0px;" height="16px" src="../img/<?php echo $tmp_imgMkalt; ?>" /> Preis</a></th>
		<th style="text-align:left;"><a style="float:right;text-decoration:none;color:black;border:none;" href="<?php echo $tmp_linkTID; ?>"><img style="margin-bottom:-3px;border:0px;" height="16px" src="../img/<?php echo $tmp_imgTID; ?>" /> Makler</a></th>
	</tr>
<?php
while ( $nt = $result->fetch_assoc () )
	{
?>
		<tr><td onmouseover="setRowStyles ( this.parentNode , 'aktiv' );" onmouseout="setRowStyles ( this.parentNode , 'inaktiv' );"><?php echo $nt['Ort']; ?></td><td onmouseover="setRowStyles ( this.parentNode , 'aktiv' );" onmouseout="setRowStyles ( this.parentNode , 'inaktiv' );"><?php echo $nt['Datum']; ?></td><td onmouseover="setRowStyles ( this.parentNode , 'aktiv' );" onmouseout="setRowStyles ( this.parentNode , 'inaktiv' );"><?php echo $nt['ID']; ?></td><td onmouseover="setRowStyles ( this.parentNode , 'aktiv' );" onmouseout="setRowStyles ( this.parentNode , 'inaktiv' );" title="<?php echo ( str_replace ( ' ', '', $nt['Art'] ) != 'keineAngabe' ) ? $nt['Art'] : ''; ?>"><?php echo number_format ( $nt['Zimmer'], 1 ); ?> Zi <?php echo ( str_replace ( ' ', '', $nt['Art'] ) != 'keineAngabe' ) ? substr ( $nt['Art'], 0, 10 ) : ''; ?></td><td onmouseover="setRowStyles ( this.parentNode , 'aktiv' );" onmouseout="setRowStyles ( this.parentNode , 'inaktiv' );" style="text-align:right;padding-right:5px;"><?php echo $nt['WohnF']; ?></td><td onmouseover="setRowStyles ( this.parentNode , 'aktiv' );" onmouseout="setRowStyles ( this.parentNode , 'inaktiv' );" style="text-align:right;"><?php echo number_format ( $nt['Mkalt'], 0, ',', '.' ) ; ?></td><td onmouseover="setRowStyles ( this.parentNode , 'aktiv' );" onmouseout="setRowStyles ( this.parentNode , 'inaktiv' );" style="text-align:right;"><?php echo fnc_getUsernameById ( $nt['TID'], 'logfiles' ); ?></td></tr>
<?php
	}
?>