<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 0.9.9

Copyright (C) 2006-2009  Sylvain FATOME
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smitst.homelinux.com
****************************************************************************************/

// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/fic_ret.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);

$td="";
if (isset($_GET['td']))
	$td = strip_tags(trim($_GET['td'])); // Récupération type demande (td=r -> uniquement si renvois en attente)
$pbm_mque=FALSE;

switch ($td)
{
	case "r" :
		$titre="FABRIQUANTS/EDITEURS/DISTRIBUTEURS AVEC ATTENTE DE RETOUR";
		if (@$_SESSION["niv_log"] == 3)
			$pbm_mque=TRUE;
		break;
	default :
		$titre="LISTE FABRIQUANTS/EDITEURS/DISTRIBUTEURS";
		break;
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<title>SMI - <?PHP echo $title_esp_prive; ?> : Relev&eacute;s - Liste Fabriquants/Editeurs</title>

<!-- Feuille de style pour les affichages courants -->
<link href="../css/smi.css" rel="stylesheet" type="text/css">

<!-- Feuille de style & Script pour le menu -->
<script language="JavaScript" src="../jscript/coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour fenêtres -->
<script language="JavaScript" src="../jscript/fen.js"></script>

<!-- Scripts Javascript divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

</head>

<body onLoad="metFocus();">

<?php 
include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage"><?PHP echo $titre; ?></span></p>
<?PHP
if ($pbm_mque==FALSE)
{
	if ($td=="")
		$url_add = "mque_maj.php?td=add&code=";
	
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	if ($td=="")
		$rech = cree_strrechlstrrlpma();
	else
		$rech = cree_strrechlstrrlpmar();
	$rech .= crestr_triord($mque_titre_col,"mque_code",FALSE,$limit);
	 
	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	
	// *** Pagination de pied
	pagine_lst($numrows,$limit);
		
	if ($numrows == 0)
	{
		if ($td=="")
			retpp();
		else
			echo "<br><span class=\"annot_std_gras\">Aucun num&eacute;ro de retour en attente de renvoi.</span><br>";
	}
	 else
	{
		include_once("../inc/formr.inc.php"); 
	
		if ($td=="")
			$rech = cree_strrechlstrrlpma();
		else
			$rech = cree_strrechlstrrlpmar();
		$rech .= crestr_triord($mque_titre_col,"mque_code",TRUE,$limit);
		
		$rs = mysql_query($rech) or die(mysql_error());
		$numrows = mysql_num_rows($rs);
		
		if ($td=="")
		{
			if ($numrows > 0)
				echo "<a href=\"mque_lst.php?td=r\">Effectuer les renvois de produits</a>";
		}
		else
		{
			echo "<a href=\"mque_lst.php\">Liste globale</a>";
		}
	
		// *** Affichage de la table
		echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
		
		// Création entête
		titlst($mque_titre_col);	
		echo "<th>".ucfirst($txt_ent_lst_clic)."</th>\n";
		
		$i = 0;
			
		while ($row = mysql_fetch_assoc($rs)) 
		{         
			if ($row["mque_code"]<>"*") //on affiche pas le code "Tous les éditeurs"
			{
				// Création de l'entête de ligne (TR)
				creetrlst($i);
				
				echo "<td>".$row["mque_code"]."</td>\n";
				echo "<td>".htmlspecialchars($row["mque_ste"]);
				if (nb_envoi_nonclos($row["mque_code"],FALSE)>0)
				{
					$lst_reteex = TRUE;
					echo " ";
					echo "<a href=\"rete_lst.php?search=".$row["mque_ste"]."\"><img src=\"../img/retns.png\" title =\"Renvois non sold&eacute;s\" border=\"0\" align=\"absmiddle\"></a>";
				}
				echo "</td>\n";
				echo "<td>".htmlspecialchars(str_majuscules($mques_types[$row["mque_type"]]))."</td>\n";
		
				// CREATION lien dynamique sur icône (édition, suppression, etc...)
				echo "<td>";
				echo "<div align=\"center\">";
				if ($td=="")
				{
					$lst_maj = TRUE;
					echo "<a href=\"mque_maj.php?td=edit&code=".$row["mque_code"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_edit."\"></a>";
					echo " ";
					$lst_retp = TRUE;
					echo "<a href=\"retp_maj.php?td=add&cm=".$row["mque_code"]."\"><img src=\"../img/retp.png\" border=\"0\" align=\"absmiddle\" title=\"Saisir produit &agrave; retourner\"></a>";
					echo " ";
					$lst_del = TRUE;
					echo "<a href=\"mque_maj.php?td=del&code=".$row["mque_code"]."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_del."\"></a>";
				}
				else
				{
					$lst_rete = TRUE;
					echo "<a href=\"rete_maj.php?td=add&cm=".$row["mque_code"]."\"><img src=\"../img/rete.png\" border=\"0\" align=\"absmiddle\" title=\"Cr&eacute;er bon de renvoi\"></a>";
				}
				echo "</div>";
				echo "</td>\n";
		
				echo "</tr>\n";
				
				$i++;
			}
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
		
		// *** Pagination de pied
		pagine_lst($numrows,$limit);

		mysql_close($conn);  
		
		$taille_piedla="";
		include_once("../inc/piedla.inc.php"); 
	}
}
else
	aff_ret_pbm_auto("mque_lst.php",2000);
include_once("pied.php");
?>
