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

Version 0.9.7

Copyright (C) 2006-2007  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/config.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_zc.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);
$titre = "EDITION FICHE VIERGE DE RELEVE";

$pbm_rel=FALSE;

$row = lit_enr_age(@$_SESSION["code_age"]);
if (is_array($row))
	extract ($row);
else
	$pbm_rel=TRUE;
?>
<!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 - ESPACE PRIVE : Relev&eacute;s - Etat Vierge</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 pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

<script language="javascript">
var tab1_champ=new Array(
	"nom:tfr ; format:liste ; req:Y ; txt:Etat à imprimer ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:client ; format:liste ; req:Y ; txt:Client ; vmn:1 ; stok:frmok ; stbad:frmbad");
</script>

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

</head>

<body onLoad="metFocus();">

<?php 
include_once("entete.inc.php"); 
if ($pbm_rel==FALSE)
{
	if (strip_tags(trim(@$_POST["submit"])) == "Valider") // On a validé
	{
		if ((@$_POST["tfr"] <> "") AND (@$_POST["client"] <> ""))
		{
			$urlimp = "rel_pdf_vierge.php?tfr=".@$_POST["tfr"]."&cc=".@$_POST["client"];
	?>
			<script type="text/javascript">
			lanceimp('<?PHP echo $urlimp; ?>');
			</script>
	<?PHP
		}
	}
?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<form name="rel_vierge" id="rel_vierge" method="post" action="rel_vierge.php" onSubmit="javascript:; return (VForm(this,tab1_champ,'',''));">
	<table width="360"  border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td class="rubfrm" id="f_tfr">
			<div align="center">Choisissez l'&eacute;tat &aacute; imprimer</div>
		</td>
	</tr>
	<tr>
		<td>
			<div align="center">
			<select name="tfr" id="tfr">
			  <option>-- Choisissez le type d'&eacute;tat --</option>
			  <option value="1">Relev&eacute; licence vierge</option>
			  <option value="2">Relev&eacute; Mat&eacute;riel vierge</option>
			</select>
			</div>
		</td>
	</tr>
	</table>
	<br>
	
	<?PHP
	// Création de la liste des clients de l'agence
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech ="SELECT * FROM ".TBCLI." WHERE `cli_prop` = '".@$_SESSION["code_age"]."' OR (`cli_prop` IS NULL AND `cli_codepays`='".$age_codepays."') ORDER BY cli_ste, cli_nom";
	$rs = mysql_query($rech) or die(mysql_error());
	
	if (mysql_num_rows($rs) <> 0)
	{
	?>
		<table width="360"  border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td class="rubfrm" id="f_client">
				<div align="center">Choisissez un client</div>
			</td>
		</tr>
		<tr>
			<td>
				<div align="center">
				<select name="client" id="client">
				<?PHP
					echo "<option>-- Choisissez un client --</option>";

					$tab_depzc=tab_zcc_age_open(@$_SESSION["code_age"],FALSE);
					while ($row = mysql_fetch_array($rs)) 
					{
						extract($row);
						if ($cli_ste <> "")
							$texte = $cli_ste." (".$cli_code.")";
						else
							$texte = $cli_nom." ".$cli_prenom." (".$cli_code.")";
						if ($cli_prop==@$_SESSION["code_age"])
							echo "<option value=\"".$cli_code."\">".$texte."</option>";
						else
						{						
							if (count(tab_depzc)>0)
							{
								if (in_array($cli_dep,$tab_depzc))
								{
									echo "<option value=\"".$cli_code."\">".$texte."</option>";
								}
							}
						}
					}
				?>
				</select>
				</div>
			</td>
		</tr>
		</table>
		<p align="center">
		  <input type="submit" class="bton_fmarr_std" name="submit" id="submit" value="Valider">
	<?PHP
	}
	else
	{
	?>
		<select name="client" id="client">
		<option>-- Pas de clients sur cette agence --</option>";
		</select>
	?>
		</p>
	<?PHP
	}
	
	mysql_free_result($rs);
	mysql_close($conn);
	?>
</p>
</form>
<?PHP
}
else
{
?>
	<script type="text/javascript">
	setTimeout("self.location.href=('index.php');",2000)
	</script>
	<p align="center" class="annot_std_it">Probl&ecirc;me sur les param&egrave;tres...</p>
<?PHP
}
include_once("pied.php");
?>
