<?php
include "../include/validsession.inc";
include "../include/opendb.inc";
include "../include/functions.php";



if (isset($_REQUEST["liensLocal"]))
$liensLocal =  $_REQUEST["liensLocal"];
else $liensLocal="";

if (isset($_REQUEST["sSQLLocal"]))
$sSQLLocal =  $_REQUEST["sSQLLocal"];
else $sSQLLocal="";

if (isset($_REQUEST["CodeE"]))
$CodeE =  $_REQUEST["CodeE"];
else $CodeE="";

if (isset($_REQUEST["Nom"]))
$Nom = $_REQUEST["Nom"];
else $Nom="";

if (isset($_REQUEST["Discription"]))
$Discription = $_REQUEST["Discription"];
else $Discription="";

if (isset($_REQUEST["TypeUtilisation"]))
$TypeUtilisation = $_REQUEST["TypeUtilisation"];
else $TypeUtilisation="";
   
if (isset($_REQUEST["StatutLocal"]))
$StatutLocal = $_REQUEST["StatutLocal"];
else $StatutLocal="";
   
if (isset($_REQUEST["Capacite"]))
$Capacite = $_REQUEST["Capacite"];
else $Capacite="";
   
if (isset($_REQUEST["CoutM"]))
$CoutM= $_REQUEST["CoutM"];
else $CoutM="";

if (isset($_REQUEST["Cout"]))
$Cout= $_REQUEST["Cout"];
else $Cout="";



/*************** Recherche *************************************************/
if ($CodeE <> ""){
$sSQLLocal = $sSQLLocal . "equipements.CodeE =  ".Stripslashes($CodeE)." and ";
$liensLocal  = $liensLocal."CodeE=".$CodeE."&";
}

if ($Nom <> "") {
$sSQLLocal= $sSQLLocal."equipements.Nom  Like  '".StripSlashes($Nom)."%' and ";
$liensLocal  = $liensLocal."Nom=".$Nom."&";
}

if ($Discription <> "") {
$sSQLLocal= $sSQLLocal."equipements.Description  Like  '".Stripslashes($Discription)."%' and ";
$liensLocal  = $liensLocal."Description=".$Discription."&";
}

if ($TypeUtilisation <> ""){
$sSQLLocal = $sSQLLocal."equipements.TypeUtilisation Like '".Stripslashes($TypeUtilisation)."%' and ";
$liensLocal  = $liensLocal."TypeUtilisation=".$TypeUtilisation."&";
}

if ($StatutLocal <> "" ) {
$sSQLLocal = $sSQLLocal."equipements.Statut  =  '".Stripslashes($StatutLocal)."' and ";
$liensLocal = $liensLocal."StatutLocal=".$StatutLocal."&" ;
}

if ($Capacite <> "" ) {
 $sSQLLocal = $sSQLLocal."equipements.Capacite  =  " .$Capacite. " and ";
 $liensLocal  = $liensLocal."Capacite=".$Capacite."&";
}

if ($Cout <> "" ) {
$sSQLLocal = $sSQLLocal ."equipements.Cout  =  ".$Cout. " and ";
$liensLocal = $liensLocal."Cout=".$Cout."&";
}

if ($CoutM <> "" ) {
$sSQLLocal = $sSQLLocal ."equipements.CoutM  =  ".$CoutM. " and ";
$liensLocal = $liensLocal."CoutM=".$CoutM."&";
}

if ($sSQLLocal == "")
header("Location: RechercheEquipementF.php");


if (isset( $_REQUEST["p"]) )
$p = $_REQUEST["p"];
else $p ="1 ";

$liensLocal  = $liensLocal."p=".$p."";
setcookie('cookie_lienslocal', $liensLocal, (time() + 3600));


$url = "RechercheEquipement.php?".substr($liensLocal, 0, strlen($liensLocal) - 4) ;

$sSQL = "SELECT * FROM equipements WHERE  ".substr($sSQLLocal, 0,strlen($sSQLLocal) - 4)." order by Nom";

$sql=substr($sSQL, 8);

$pagine = pagine($sql,10,"p",$url);

$rsQuery1 = mysql_query("SELECT * ".$sql);
 if (!$rsQuery1) {
  die('Could not query:' . mysql_error());
}
if(!isset($rien))
$rien=false;
if (mysql_num_rows($rsQuery1)==0)  $rien=true;

include "../include/top.inc";
/*********************************************Affichage*****************************/
?>

<table>
        <tr> 
          <td width="5">&nbsp;</td>
          <td valign="top" width="738"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
          <td width="23" rowspan="2"><img src="<? echo $pathimages;?>/images/innertopleft.gif" width="23" height="23"></td>
          <td bgcolor="#000066" width="1"><img src="<? echo $pathimages;?>/images/clearpix.gif" width="1" height="1"></td>
          <td width="23" rowspan="2"><img src="<? echo $pathimages;?>/images/innertopright.gif" width="23" height="23"></td>
        </tr>
        <tr>
          <td width="100%">&nbsp;</td>
        </tr>
        <tr>
          <td background="<? echo $pathimages;?>/images/leftbg.gif"><img src="<?echo $pathimages;?>/images/clearpix.gif" width="23" height="1"></td>
          <td width="100%" valign="top">

            <table width="680" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <tr>
                <td align="left" width="394">
                  
                    <table width="683" BORDER="0" CELLPADDING="0" CELLSPACING="1">
                      <tr>
                        <td width="648" valign="top" colspan="4" align="center" class="formtxt">
<b><font color="#000080" size="3"><img border="0" src="../images/bartxt1.gif"> Liste des Equipements</font></b>
<br>

<br>
                        </td>
                      </tr>
                      <tr>
                        <td width="648" valign="top" colspan="4">
                        </td>
                      </tr>
                      
                      <tr>
                        <td width="224" valign="top" class="formtxt1" bgcolor="#000080"><b>Nom</b>
                          </td>
                        <td width="277" valign="top" class="formtxt1" bgcolor="#000080"><b>Description</b>
                        </td>
                        <td width="74" valign="top" class="formtxt1" bgcolor="#000080"> <b> Modifier</b>
                        </td>
                        <td width="73" valign="top" class="formtxt1" bgcolor="#000080"> <b> Supprimer</b>
                        </td>
                      </tr>
                      
                      
                        <?$colonne = 1; ?>
                      <? while (($row = mysql_fetch_assoc($rsQuery1))) {


                      ?>
					 
                       <? if ($colonne == 2) { ?>
                      <tr bgcolor="#DDDDDD">
                        <td width="224" valign="top" class="formtxt">
                        <? if ($_SESSION["EquipementM"] == True){
                        ?><a href="UpdateEquipement.php?CodeE=<? echo $row["CodeE"]; ?>">
                        <?}?>
                        <? echo $row["Nom"];?>
                        <?if ($_SESSION["EquipementM"] == True){ ?></a><?}?>
                          </td>
                        <td width="277" valign="top" class="formtxt"><? echo $row["Description"]; ?>
                        </td>
                        <td width="74" valign="top" class="formtxt"> 
                          <p align="center">&nbsp;
                          <?if ($_SESSION["EquipementM"] == True) {  ?><a href="UpdateEquipement.php?CodeE=<? echo $row["CodeE"]; ?>"><img border="0" src="<? echo $pathimages;?>/images/icon/tree_open.gif"></a><? }?></p>
                        </td>
                        <td width="73" valign="top" align="center"> 
                        
                        <?if ($_SESSION["EquipementS"] == True) { ?><img border="0" src="<? echo $pathimages;?>/images/icon/delete.gif" ><?}?>
                        </td>
                        
                        
                      </tr>
                      <? $colonne= 1;
                      }else {?>

                      <tr  bgcolor="#F5F5F5">
                        <td width="224" valign="top" class="formtxt">
                        <?if ($_SESSION["EquipementM"] == True) {  ?><a href="UpdateEquipement.php?CodeE=<? echo $row["CodeE"]; ?>"><? }?><? echo $row["Nom"];?>
                        <?if ($_SESSION["EquipementM"] == True) {  ?></a><? } ?>
                          </td>
                        <td width="277" valign="top" class="formtxt"><? echo $row["Description"]; ?>
                        </td>
                        <td width="74" valign="top" class="formtxt"> 
                          <p align="center">&nbsp;
                          <? if ($_SESSION["EquipementM"] == True) {  ?><a href="UpdateEquipement.php?CodeE=<? echo $row["CodeE"]; ?>"><img border="0" src="<?echo $pathimages;?>/images/icon/tree_open.gif"></a><? } ?></p>
                        </td>
                        <td width="73" valign="top" align="center"> 
                        
                         <?if ($_SESSION["EquipementS"] == True) { ?><img border="0" src="<? echo $pathimages;?>/images/icon/delete.gif" ><?}?>
                        </td>
                      </tr>
                      
                      <? $colonne= 2 ;
                      } ?>
                      

                    <?
                    
                    }  //end while           La boucle d'affichage des records

     ?>
	               <tr>
                   <td width="648" valign="top" colspan="8" class="formtxt">
                    <br>
                   <p align="center" class="formtxt">
                   <?php
                   echo $pagine;
                   if ($rien)
                       echo "Pas d'Equipement correspondant à votre recherche";

                       ?>
                   <br><br>

                   </td>
                   </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
            <td width"23" background="<? echo $pathimages;?>/images/rightbg1.gif"><img src="<?echo $pathimages;?>/images/clearpix.gif" width="23" height="1"></td>
          </tr>
          <tr>
            <td width="23" rowspan="2"><img src="<? echo $pathimages;?>/images/innerbottomleft.gif" width="23" height="23"></td>
            <td width="100%">
              <p align="center">&nbsp;</td>
            <td width="23" rowspan="2"><img src="<? echo $pathimages;?>/images/innerbottomright.gif" width="23" height="23"></td>
          </tr>
          <tr>
            <td width="1" bgcolor="#000066" height="1"><img src="<? echo $pathimages;?>/images/clearpix.gif" width="1" height="1"></td>
          </tr>
        </table>
        <font color="#0000FF"><img src="<? echo $pathimages;?>/images/clearpix.gif" width="1" height="22"></font>
          </td>
<?

include "../include/footer.inc";
?>