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

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/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="../inc/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 validation des formulaires -->
<script language="JavaScript" src="../inc/validator.js"></script>

<!-- Scripts Javascript pour affichages -->
<script language="JavaScript" src="../inc/aff.js"></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="return v.exec()">
	<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="tfvNormal" 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="tfvNormal" 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="tfvNormal" 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="tfvNormal" 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="tfvNormal" 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="tfvNormal" 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>

<script>
// form fields description structure
var a_fields = {
	'code':{'l':'Code','r':true,'t':'f_code'},
	'des':{'l':'Désignation','r':true,'t':'f_des'},
	'qte':{'l':'Quantité','r':true,'f':'real','t':'f_qte','mx':10},
	'pu':{'l':'PU TTC','r': true,'f':'real','t':'f_pu','mx':10},
	'ns':{'l':'N° de série','r':false,'t':'f_ns','mx':50}
	'texte':{'l':'Commentaire','r':false,'t':'f_texte'}
},

o_config = {
	'to_disable' : ['submit', 'RAZ'],
	'alert' : 1
}

// validator constructor call
var v = new validator('pdti_maj', a_fields, o_config);

</script>

</body>
</html>
