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

Version 0.9.6
Copyright (C) 2006  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
****************************************************************************************/

include ("../inc/config.inc.php");
?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php require ("../inc/func_txt.inc.php") ?>
<?php require ("../inc/fic.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>
<?php
	$td = strip_tags(trim(@$_GET['td']));
	$codeint = strip_tags(trim(@$_GET['ci']));
	$codeart = strip_tags(trim(@$_GET['ca']));
		
	if ($codeint <> "")
	{
		// Récupération des données de la fiche article
		$row = lit_enr_pdt($codeart);
		extract ($row);
		
		if ($td == "add")
		{
			$pdti_codeint = $codeint;
			$pdti_codepdt = $pdt_code;
			$pdti_puttc = $pdt_puttc;
			$pdti_qte = 1;
			$pdti_ns = "";
			$pdti_texte = "";

			$titre = "SAISIE ARTICLE";
		}

		if ($td == "edit")
		{
			$row = lit_enr_pdt_in_int($codeart,$codeint);
			extract ($row);

			$titre = "EDITION ARTICLE";
		}

		if ($td == "del")
		{
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
			$rech = "SELECT * FROM `" .TBPDTI. "` WHERE `pdti_codepdt` = '$codeart' AND `pdti_codeint` = '$codeint'";
			$rs = mysql_query($rech)or die(mysql_error());
			if (mysql_num_rows($rs) == 0)
			{
				echo "Aucun résultat";
			}
			else
			{
				 while ($row = mysql_fetch_array($rs))
				{
					extract ($row);
				}
			}
			mysql_free_result($rs);
			mysql_close($conn);

			$titre = "SUPPRESSION ARTICLE";
		}
	}			
?>

<!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 : Article Intervention</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 -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour affichages -->
<script language="JavaScript" src="../inc/aff.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:qte ; format:reel_ns ; req:Y ; txt:Quantité ; lmx:10 ; stok:frmok ; stbad:frmbad",
	"nom:pu; format:reel_ns ; req:Y ; txt:PU TTC ; lmx:10 ; stok:frmok ; stbad:frmbad",
	"nom:ns; format:txt ; req:N ; txt:Numéro de série ; lmx:50 ; stok:frmok ; stbad:frmbad",
	"nom:texte; format:txt ; req:N ; txt:Commentaire ; stok:frmok ; stbad:frmbad");
</script>

</head>

<body>

<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<p align="center"><span class="titre_gras">Pour l'intervention : <?php echo $pdti_codeint; ?> </span></p>

<form name="pdti_maj" method="post" action="pdti_enr.php" onSubmit="javascript:; return (VForm(this,tab1_champ,''));">
	<input name="titre" type="hidden" id="titre" value="<?PHP echo $titre ?>">
    <input name="typdde" type="hidden" id="typdde" value="<?PHP echo $td ?>">
    <input name="codeint" type="hidden" id="codeint" value="<?PHP echo $pdti_codeint ?>">
  <table width="600"  border="0">
    <tr>
      <td width="20%" class="rubfrm" id="f_code">Code</td>
      <td width="84%">
		  <input name="code" type="text" id="code" value="<?PHP echo $pdti_codepdt ?>" size="50" maxlength="50" readonly="1">
	  </td> 
    </tr>
    <tr>
      <td width="20%" class="rubfrm" id="f_des">D&eacute;signation</td>
      <td>
	  	<input name="des" type="text" id="des" value="<?PHP echo htmlspecialchars($pdt_des); ?>" size="50" maxlength="50" readonly="1">
	  </td>
    </tr>
    <tr>
      <td width="30%" class="rubfrm" id="f_qte">Quantit&eacute;</td>
      <td>
	  	<input name="qte" type="text" id="qte" align="right" value="<?PHP echo $pdti_qte ?>" size="10" maxlength="10">
      	<img src="../img/oblig.gif" width="10" height="11">
	  </td>
    </tr>
    <tr>
      <td width="20%" class="rubfrm" id="f_pu">PU TTC </td>
      <td>
	  	<input name="pu" type="text" id="pu" align="right" value="<?PHP echo $pdti_puttc ?>" size="10" maxlength="10">
        <img src="../img/oblig.gif" width="10" height="11">
	  </td>
    </tr>
    <tr>
      <td width="20%" class="rubfrm" id="f_ns">N° Série</td>
      <td>
	  	<input name="ns" type="text" id="ns" value="<?PHP echo htmlspecialchars($pdti_ns); ?>" size="40" maxlength="100">
	  </td>
    </tr>
    <tr>
      <td width="20%" class="rubfrm" id="f_texte">Commentaire</td>
      <td>
	  	<textarea name="texte" id="texte" cols="50" rows="4"><?PHP echo htmlspecialchars($pdti_texte); ?></textarea>
	  </td>
    </tr>
  </table>
  <p align="center">
    <?PHP if ($td == "add") { ?>
    <input name="RAZ" type="reset" id="RAZ" value="R&eacute;initialiser">
    <input name="enr" type="submit" id="enr" value="Ajouter">
    <input name="annul" type="button" id="annul" value="Annuler" onclick="javascript:; self.close('fscomp');">
    <?PHP } ?>
    <?PHP if ($td == "edit") { ?>
    <input name="mod" type="submit" id="mod" value="Modifier">
    <input name="annul" type="button" id="annul" value="Annuler" onclick="javascript:; self.close('fscomp');">
    <?PHP } ?>
    <?PHP if ($td == "del") { ?>
    <input name="del" type="submit" id="del" value="Supprimer">
    <input name="annul" type="button" id="annul" value="Annuler" onclick="javascript:; self.close('fscomp');">
    <?PHP } ?>
  </p>
</form>

</body>
</html>
