<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.8 www.exoops.info 2006/03
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Pascal Le Boustouller
// Author Website : http://www.perso-search.com/e-xoopsien
// Licence Type   : GPL
// ------------------------------------------------------------------------- //
include("header.php");
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/cache/config.php");
include(XOOPS_ROOT_PATH."/modules/MyAnnonces/include/functions.php");
include(XOOPS_ROOT_PATH."/header.php");
include_once(XOOPS_ROOT_PATH.'/class/xoopspagenav.php');
echo "<script language=\"javascript\">\nfunction CLA(CLA) { var MainWindow = window.open (CLA, \"_blank\",\"width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no\");}\n</script>";
if ($debut=="") { $debut=0; }
if (!$class) { $class='date'; }
if (!$ord) { $ord='DESC'; }
if (!$class || $class == 'date' && $ord == 'ASC') $texte = ""._DATE." "._CLA_ORDON1."";
if (!$class || $class == 'date' && $ord == 'DESC') $texte = ""._DATE." "._CLA_ORDON2."";
if ($class == 'title' && $ord == 'DESC') $texte = ""._TITLE." "._CLA_ORDON3."";
if ($class == 'title' && $ord == 'ASC') $texte = ""._TITLE." "._CLA_ORDON4."";
if ($class == 'view' && $ord == 'DESC') $texte = ""._CLA_VIEW." "._CLA_ORDON5."";
if ($class == 'view' && $ord == 'ASC') $texte = ""._CLA_VIEW." "._CLA_ORDON6."";
if ($class == 'price' && $ord == 'DESC') $texte = ""._CLA_PRICE." "._CLA_ORDON7."";
if ($class == 'price' && $ord == 'ASC') $texte = ""._CLA_PRICE." "._CLA_ORDON8."";
if ($class == 'type' && $ord == 'DESC') $texte = ""._CLA_TYP." "._CLA_ORDON3."";
if ($class == 'type' && $ord == 'ASC') $texte = ""._CLA_TYP." "._CLA_ORDON4."";
$query = stripslashes($terme);
if ($type =="1") {
$types = "title LIKE '%$query%'";
}
if ($type =="2") {
$types = "description LIKE '%$query%'";
}
if ($type =="3") {
$types = "title LIKE '%$query%' OR description LIKE '%$query%'";
}
      OpenTable();
	   echo "<B><A HREF=\"index.php\">"._CLA_MAIN."</A> &raquo; "._CLA_SEARCHANN."</B><br />\n";
	   
  echo "<FORM ACTION=\"recherche.php\" METHOD=POST>
  <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"1\">";
  echo "<CENTER>"._CLA_TERME."<br /><INPUT TYPE=\"text\" class=\"text\" NAME=\"terme\" SIZE=20 value=\"$query\"> <INPUT TYPE=\"submit\" class=\"button\" VALUE=\"Go\"><br />"._CLA_LOOKFOR."<br />
<SELECT NAME=\"type\" class=\"select\">
	<OPTION VALUE=\"1\""; if ($type == "1") echo " selected";
	echo "> "._CLA_BY_TITLE."
	<OPTION VALUE=\"2\""; if ($type == "2") echo " selected";
	echo "> "._CLA_BY_DESC."
	<OPTION VALUE=\"3\""; if ($type == "3") echo " selected";
	echo "> "._CLA_BY_TITLEDESC."
</SELECT>
</CENTER>";
  echo "</FORM><P>";
  
  if ($action == 1) {
  
list($nbe) = $db->fetchRow($db->query("SELECT COUNT(*) FROM ".$db->prefix("ann_annonces")." WHERE $types AND valid='Yes'"));
$result = $db->query("SELECT lid, title, type, price, date, town, country, valid, photo, view FROM ".$db->prefix("ann_annonces")." WHERE $types AND valid='Yes' ORDER BY $class $ord LIMIT $debut,$nb_affichage");
    $top=1;
    $nrows  = $db->getRowsNum($result);
if($nrows == 0) {
  echo "<P><CENTER>"._CLA_NORESPOND." <B>$terme</B></CENTER><P><br /><br />";
} else {
if ($top==1){
  
  $pagenav = new XoopsPageNav($nbe, $nb_affichage, $debut, "terme=$terme&action=1&class=$class&type=$type&ord=$ord&debut", "");
echo "<P><B>".$nbe."</B> "._CLA_DEFFOR."  <B>$terme</B><p>";
echo "<TABLE WIDTH=100% BORDER=0 class='bg2' CELLPADDING=2 CELLSPACING=1>
    <TR class='bg2'>";
	if ( $xoopsUser ) {
			if ( $xoopsUser->isAdmin() ) {
			echo "<TD WIDTH=5%>&nbsp;</TD>";
			}
			}
      echo "<TD WIDTH=15%>
	  <A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=type&debut=$debut&ord=ASC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON4."\"></A> "._CLA_TYP." 
<A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=type&debut=$debut&ord=DESC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON3."\"></A></TD>
<TD WIDTH=40%>
<A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=title&debut=$debut&ord=ASC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON4."\"></A> "._TITLE." 
<A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=title&debut=$debut&ord=DESC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON3."\"></A></TD>";
	  
	  if ($ynprice == 1) {
      echo "<TD align=center WIDTH=10%><A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=price&debut=$debut&ord=DESC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON7."\" ALIGN=\"absmiddle\"></A> "._CLA_PRICE." <A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=price&debut=$debut&ord=ASC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON8."\" ALIGN=\"absmiddle\"></A></TD>";
	  }
	  
      echo "<TD align=center WIDTH=10%><A HREF=\"recherche.php?terme=$terme&action=1&type=$type&debut=$debut&ord=DESC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON2."\" ALIGN=\"absmiddle\"></A> "._DATE." <A HREF=\"recherche.php?terme=$terme&action=1&type=$type&debut=$debut&ord=ASC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON1."\" ALIGN=\"absmiddle\"></A></TD>
      <TD WIDTH=15%>"._LOCATION."</TD>
	  <TD align=center WIDTH=5%>"._CLA_PHOTO."</TD>
	  <TD align=center WIDTH=5% nowrap><A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=view&debut=$debut&ord=DESC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."down.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON5."\" ALIGN=\"absmiddle\"></A> "._CLA_VIEW." <A HREF=\"recherche.php?terme=$terme&action=1&type=$type&class=view&debut=$debut&ord=ASC\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."up.gif\" BORDER=0 WIDTH=9 HEIGHT=7 ALT=\""._CLA_ORDON6."\" ALIGN=\"absmiddle\"></A></TD>
    </TR>";
		$rank = 1;
	while(list($lid, $title, $type, $price, $date, $town, $country, $valid, $photo, $vu)=$db->fetchRow($result)){
	$title = $myts->makeTboxData4Show($title);
	$type = $myts->makeTboxData4Show($type);
	$price = $myts->makeTboxData4Show($price);
	$town = $myts->makeTboxData4Show($town);
	$country = $myts->makeTboxData4Show($country);
	$date = formatTimestamp($date,"s");
	if(is_integer($rank/2)) $color="bg1";
	else $color="bg3";
		echo "<TR class='$color'>";
			if ( $xoopsUser ) {
			if ( $xoopsUser->isAdmin() ) {
			echo "<TD align=center><A HREF=\"admin/index.php?op=AnnoncesModAnnonce&lid=$lid\"><IMG SRC=\"".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."edit.gif\" BORDER=0 ALT=\""._CLA_MODADMIN."\"></A></TD>";
			}
			}
		echo "<TD><B>$type</B></TD><TD><a href=index.php?pa=viewannonces&lid=$lid>$title</a></TD>";
		
		if ($ynprice == 1) {
		echo "<TD align=right>";
		if ($price > 0) { echo "$price $monnaie"; }
		echo "</TD>";
		}
		
		echo "<TD align=center>$date</TD><TD>";
		if ($town) {  echo "$town";   }
		if ($country) {  echo " $country";   }
		echo "</TD>";
		echo "<TD align=center>";
		if ($photo) { echo "<A href=\"javascript:CLA('display-image.php?lid=$lid')\"><IMG SRC=\"images/photo.gif\" BORDER=0 WIDTH=15 HEIGHT=11 ALT=\""._CLA_IMGPISP."\"></A>"; } else { echo "&nbsp;"; }
		echo "</TD><TD align=center>$vu</TD>";
		
			$rank++;
	}	 
   echo "</TR></TABLE><BR />";
}
if(!isset($debut)) $debut=0;
// Show navigation bar
echo "<div align=\"center\">".$pagenav->renderNav(3, 3)."</div>";
	
    }
}
    CloseTable();
Copyright();
	include(XOOPS_ROOT_PATH."/footer.php");
?>
