<?php
include "../include/configsession.php";
include "../include/validsession.inc";
include "../include/top.inc";
include "../include/fonction.inc";
include "../include/opendb.inc";
?>


<?php 
			$sSQL = "";
			$Code = $_REQUEST["codeO"];
			
			//***paramettre de recherche******************************
			if ( isset($_REQUEST["codeO"]) && !empty($_REQUEST["codeO"]) ) {
			 $sSQL = $sSQL."organisations.CodeO =  " .addslashes($_REQUEST["codeO"]). "  and ";
			 $liens  = $liens."codeO=".$_REQUEST["codeO"]."&";
			}
			if ( isset($_REQUEST["Nom"]) && !empty($_REQUEST["Nom"]) ) {
			 $sSQL = $sSQL."organisations.Nom Like  '%" .addslashes($_REQUEST["Nom"]). "%' and ";
			 $liens  = $liens."Nom=".$_REQUEST["Nom"]."&";
			}
			if ( isset($_REQUEST["Statut"]) && ($_REQUEST["Statut"] != "") ) {
			 $sSQL = $sSQL."organisations.Statut =  '".$_REQUEST["Statut"]."' and ";
			 $liens  = $liens."Statut=".$_REQUEST["Statut"]."&";
			}
			if ( isset($_REQUEST["adresse"]) && !empty($_REQUEST["adresse"]) ) {
			 $sSQL = $sSQL."organisations.adresse Like  '%" .addslashes($_REQUEST["adresse"]). "%' and ";
			 $liens  = $liens."adresse=".$_REQUEST["adresse"]."&";
			}
			if ( isset($_REQUEST["Tel"]) && !empty($_REQUEST["Tel"]) ) {
			 $sSQL = $sSQL."organisations.Tel Like  '%" .addslashes($_REQUEST["Tel"]). "%' and ";
			 $liens  = $liens."Tel=".$_REQUEST["Tel"]."&";
			}
			if ( isset($_REQUEST["Fax"]) && !empty($_REQUEST["Fax"]) ) {
			 $sSQL = $sSQL."organisations.Fax Like  '%" .addslashes($_REQUEST["Fax"]). "%' and ";
			 $liens  = $liens."Fax =".$_REQUEST["Fax"]."&";
			}
			if ( isset($_REQUEST["NomResponsable"]) && !empty($_REQUEST["NomResponsable"]) ) {
			 $sSQL = $sSQL."organisations.NomResponsable Like  '%" .addslashes($_REQUEST["NomResponsable"]). "%' and ";
			 $liens  = $liens."NomResponsable =".$_REQUEST["NomResponsable"]."&";
			}
			if ( isset($_REQUEST["PrenomResponsable"]) && !empty($_REQUEST["PrenomResponsable"]) ) {
			 $sSQL = $sSQL."organisations.PrenomResponsable Like  '%" .addslashes($_REQUEST["PrenomResponsable"]). "%' and ";
			 $liens  = $liens."PrenomResponsable =".$_REQUEST["PrenomResponsable"]."&";
			}
			if ( isset($_REQUEST["TelResponsable"]) && !empty($_REQUEST["TelResponsable"]) ) {
			 $sSQL = $sSQL."organisations.TelResponsable Like  '%" .addslashes($_REQUEST["TelResponsable"]). "%' and ";
			 $liens  = $liens."TelResponsable =".$_REQUEST["TelResponsable"]."&";
			}

			
			
		

if ($sSQL == "") {
Header("Location: RechercheOrganisme.php"); 
}



			
			
			
?>












<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="<?php echo $path; ?>/images/innertopleft.gif" width="23" height="23"></td>
          <td bgcolor="#000066" width="1"><img src="<?php echo $path; ?>/images/clearpix.gif" width="1" height="1"></td>
          <td width="23" rowspan="2"><img src="<?php echo $path; ?>/images/innertopright.gif" width="23" height="23"></td>
        </tr>
        <tr>
          <td width="100%">&nbsp;</td>
        </tr>
        <tr>
          <td background="<?php echo $path; ?>/images/leftbg.gif"><img src="<?php echo $path; ?>/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 Organisations</font></b>
<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>
                      
             <?php   
			$SQL = "FROM organisations where ".substr($sSQL, 0, strlen($sSQL) - 4)." ";
			//Cockies de recherche
			$liens  = $liens."p=".$_REQUEST["p"]."";
			setcookie("lienRechercheO",$liens,time()+31536000);
					
			$url = "ResultatOrganisme.php?".substr($liens, 0, strlen($liens) - 1) ;		
			$pagine = pagine($SQL,15,"p",$url);
			$res = mysql_query("SELECT * ".$SQL);
			while($val=mysql_fetch_array($res)) { $i++;
			?>
			
					  <?php if ($colonne == 2)  { ?>
					  
                                        
                      <tr bgcolor="#DDDDDD">
                        <td width="224" valign="top" class="formtxt"><a href="UpdateOrganisme.php?code=<? echo $val["CodeO"]; ?>"><? echo $val["Nom"]; ?></a>
                          </td>
                        <td width="277" valign="top" class="formtxt"><? echo $val["Description"]; ?>
                        </td>
                        <td width="74" valign="top" class="formtxt"> 
                          <p align="center">&nbsp;<a href="UpdateOrganisme.php?code=<? echo $val["CodeO"]; ?>"><img border="0" src="<?php echo $path; ?>/images/icon/tree_open.gif"></a></p>
                        </td>
                        <td width="73" valign="top" align="center"> 
                        
						 <?php 
                        echo "<SCRIPT Language='JavaScript'>";
                        echo "function queryDelete".$val["CodeO"]."() {";
                        echo "if (confirm('Êtes-vous certain de vouloir supprimer ?')) {";
                        echo "var   URL = ('DeleteOrganisme.php?Code=".$val["CodeO"]."');";
						echo "window.location.href = URL }";
						echo "}";
 						echo "</SCRIPT>";
                                      
                        if ($_SESSION["OrganisationS"] = true) {
                        echo "<img border='0' src='".$path."/images/icon/delete.gif' onclick='javascript:queryDelete".$val["CodeO"]."();'>";
                        }
                        ?>  
						
                                              
                        </td>
                        
                        
                      </tr>
                     <?php 
                      $colonne = 1 ;}
                      else {
                      ?>
                      
                      
                      <tr  bgcolor="#F5F5F5">
                        <td width="224" valign="top" class="formtxt"><a href="UpdateOrganisme.php?code=<? echo $val["CodeO"]; ?>"><? echo $val["Nom"]; ?></a>
                          </td>
                        <td width="277" valign="top" class="formtxt"><? echo $val["Description"]; ?>
                        </td>
                        <td width="74" valign="top" class="formtxt"> 
                          <p align="center">&nbsp;<a href="UpdateOrganisme.php?code=<? echo $val["CodeO"]; ?>"><img border="0" src="<?php echo $path; ?>/images/icon/tree_open.gif"></a></p>
                        </td>
                        <td width="73" valign="top" align="center"> 
                        
                         <?php 
                        echo "<SCRIPT Language='JavaScript'>";
                        echo "function queryDelete".$val["CodeO"]."() {";
                        echo "if (confirm('Êtes-vous certain de vouloir supprimer ?')) {";
                        echo "var   URL = ('DeleteOrganisme.php?Code=".$val["CodeO"]."');";
						echo "window.location.href = URL }";
						echo "}";
 						echo "</SCRIPT>";
                                      
                        if ($_SESSION["OrganisationS"] = true) {
                        echo "<img border='0' src='".$path."/images/icon/delete.gif' onclick='javascript:queryDelete".$val["CodeO"]."();'>";
                        }
                        ?>  
                        </td>
                      </tr>
                      
                     <?php $colonne = 2 ;} }?>
                      
                                          
                   
                      
                   </td>
                 </tr>

<tr>
<td width="648" valign="top" colspan="4" class="formtxt">

					
<p align="center" class="formtxt"> <?php echo $pagine;?>
<br><br>


</td>
</tr>

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