<?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/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_loc.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);

if (isset($_GET['td']))
	$td = strip_tags(trim(@$_GET['td']));
else
{
	$td="";
	if ((strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_enr)) OR (strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_del)))
		$td = strip_tags(trim(@$_POST['td']));
}
	
if (isset($_GET['cp']))
	$codepdtloc = strip_tags(trim(@$_GET['cp']));
else
{
	$codepdtloc="";
	if ((strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_enr)) OR (strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_del)))
		$codepdtloc = strip_tags(trim(@$_POST['cp']));
}

if (isset($_GET['icpr']))
	$idpdtlocr = strip_tags(trim(@$_GET['icpr']));
else
{
	$idpdtlocr=0;
	if ((strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_enr)) OR (strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_del)))
		$idpdtlocr = strip_tags(trim(@$_POST['icpr']));
}

$pbm_pdtlocr=FALSE;
$totalpdtlocr=0;
$msg_err_age="Aucune agence choisie";

if ($codepdtloc <> "")
{
	$row = lit_enr_pdtloc($codepdtloc,TRUE);
	if (is_array($row))
	{
		extract ($row);
		
		$totalpdtlocr=nb_pdtlocr($codepdtloc);
		if ($totalpdtlocr==0)
			$td="add";
		$retourliste=FALSE;
		if ((strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_enr)) OR (strip_tags(trim(@$_POST["val"])) == html_entity_decode($but_del)))
		{
			$idpdtlocr = strip_tags(trim(@$_POST["icpr"]));
			$code = strip_tags(trim(@$_POST["cp"]));
			$codeage = str_majuscules(strip_tags(trim(@$_POST["codeage"])));
			$codetec = str_majuscules(strip_tags(trim(@$_POST["codetec"])));
			$date = datefrang(strip_tags(trim(@$_POST["datef"])));
			$durees = heure_sec(strip_tags(trim(@$_POST["duree"])).":00");
			$mtp = str_majuscules(strip_tags(trim(@$_POST["mtp"])));
			$fait = str_escape(trim(@$_POST["fait"]));
			$rech="";
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);

			switch ($td)
			{
				case "add" :
					$rech = "INSERT INTO " .TBPDTLOCR;
					$rech .= " (pdtlocr_codepdtloc,pdtlocr_codeage,pdtlocr_codetec,pdtlocr_date,pdtlocr_durees,pdtlocr_mtp,pdtlocr_fait) VALUES";
					$rech .= " ('$code','$codeage','$codetec','$date','$durees','$mtp','$fait')";
					break;
				case "edit" :
					$rech = "UPDATE `" .TBPDTLOCR. "` SET `pdtlocr_codepdtloc`='".$code."', `pdtlocr_codeage`='".$codeage."',";
					$rech.= " `pdtlocr_codetec`='".$codetec."', `pdtlocr_date`='".$date."', `pdtlocr_durees`='".$durees."',";
					$rech.= " `pdtlocr_mtp`='".$mtp."', `pdtlocr_fait`='".$fait."'";
					$rech.= "  WHERE `pdtlocr_id` = '".$idpdtlocr."'";
					break;
				case "del" :
					$rech = "DELETE FROM `" .TBPDTLOCR. "` WHERE `pdtlocr_id` = '$idpdtlocr'";
					break;
				default :
					break;
			}
			if ($rech<>"")
			{
				$rs = mysql_query($rech) or die(mysql_error());
				$retourliste=TRUE;
			}
			mysql_close($conn);
		}
		else
		{
			switch ($td)
			{
				case "add" :
					$titre = "SAISIE REPARATION";
					$pdtlocr_datef = $datef;
					$nbh="";
					break;
				case "edit" :
				case "del" :
					if ($td=="edit")
						$titre = "EDITION REPARATION";
					else
						$titre = "SUPPRESSION CONTACT";
					$row=lit_enr_pdtlocr_id_in_pdtloc($idpdtlocr,$codepdtloc);
					if (is_array($row))
					{
						extract ($row);
						$nbh = heure_to_hhmm(sec_heure($pdtlocr_durees));
						// Formatage des dates en français
						$pdtlocr_datef = formatedate($pdtlocr_date);
						// Contrôle qu'une agence n'essaye pas de "hacker" une réparation
						if (((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3)) AND ($pdtlocr_codeage <> @$_SESSION["code_age"]))
							$pbm_pdtlocr = TRUE;
					}
					else
						$pbm_pdtlocr=TRUE;
					break;
				case "lst" :
					$titre = "LISTE REPARATIONS";
					break;
				default :
					$pbm_pdtlocr=TRUE;
					break;
			}
		}
		// On recalcule le total réparations
		$totalpdtlocr=nb_pdtlocr($codepdtloc);
	}
	else
		$pbm_pdtlocr=TRUE;
}
else
	$pbm_pdtlocr=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 - <?PHP echo $title_esp_prive; ?> : R&eacute;paration article location</title>

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

<!-- 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 tab_champ=new Array(
	"nom:datef ; format:date ; masque:<?PHP echo $datemsql; ?> ; req:Y ; txt:Date ; stok:frmok ; stbad:frmbad",
<?PHP
	if (($td=="add") OR ($td=="edit"))
	{
		if ((@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["niv_log"] <> 3))
		{
?>
	"nom:codeage; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
		}
		else
		{
?>
	"nom:codeage; format:liste ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
		}
	}
	else
	{
?>
	"nom:codeage; format:txt ; req:Y ; txt:<?PHP echo html_entity_decode($txt_chp_age); ?> ; stok:frmok ; stbad:frmbad",
<?PHP
	}
	if (($td=="add") OR ($td=="edit"))
	{
?>
	"nom:codetec; format:liste ; req:Y ; txt:Technicien; ?> ; vmn:1 ; stok:frmok ; stbad:frmbad",
<?PHP
	}
	else
	{
?>
	"nom:codetec; format:txt ; req:Y ; txt:Technicien; ?> ; stok:frmok ; stbad:frmbad",
<?PHP
	}
?>	
	"nom:duree ; format:liste ; req:Y ; txt:Durée ; vmn:1 ; stok:frmok ; stbad:frmbad",
	"nom:mtp; format:reel_ns ; req:N ; txt:Montant pièces ; stok:frmok ; stbad:frmbad",
	"nom:fait; format:txt ; req:Y ; txt:Travail effectué; stok:frmok ; stbad:frmbad");
//-->
</script>

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

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

<!-- Scripts Javascript pour vérifications des champs -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

<!-- Scripts Ajax -->
<script type="text/javascript" src="../ajax/util.js"></script>
<script type="text/javascript" src="../ajax/SelectUpdater.js"></script>

<?PHP if (($pbm_pdtlocr==FALSE) AND ($td == "add") AND (@$_SESSION["niv_log"] <> 4) AND (@$_SESSION["niv_log"] <> 3)) { ?>
<script type="text/javascript">
<!--        
function updateTec()
{
	tecUpdater = new SelectUpdater("codetec", "<?PHP echo $rep_appli.'/ajax/'; ?>recuptec2.php?ca=", "attn", "msg", "<?PHP echo $msg_err_age; ?>");
	ancienage = "";
	document.getElementById("codeage").onchange = function() {
		var listeage = document.getElementById("codeage");
		var age = listeage.options[listeage.selectedIndex].value;
		if (age.length > 0)
		{
			if (age != ancienage)
			{
				// Faire l'appel Ajax
				tecUpdater.run(age);
				ancienage = age;
			}
		}
		else
		{
			// Remettre la liste a vide et annuler l'appel eventuel
			tecUpdater.reset();
			ancienage = "";
		}
	}
}
//-->
</script>
<?PHP } ?>

</head>
<?PHP 
switch ($td)
{
	case "del" :
		echo '<body onLoad="warndel();metReadonly();">';
		break;
	case "add" :
	case "edit" :
		echo '<body onLoad="updateTec();metFocus();">';
		break;
	case "lst" :
		echo '<body>';
		break;
}

if ($pbm_pdtlocr==FALSE)
{
?>
<p align="center"> <span class="titrepage"><?PHP echo $titre ?></span></p>
<p align="center"><span class="titre_gras">Pour l'article : <?php echo $pdtloc_des; ?> </span>
<br /><span class="annot_petit_gras">NS : <?php echo $pdtloc_ns; ?> </span></p>
<table width="890"  border="0">
<tr>
	<td width="33%">&nbsp;</td>
	<td width="33%">
	<?PHP if (($td=="add") OR ($td=="edit")) { ?>
	<div align="center"><span class="annot_std_it">(<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> : <?PHP echo $txt_div_saisoblg; ?>) </span></td>
	<?PHP } else { ?>
	&nbsp;
	<?PHP } ?>
	<td width="33%" align="right">
    <input name="quit" type="button" class="bton_std" id="quit" value="<?PHP echo $but_quit; ?>" style="text-decoration: none; font-size: 11px; color:White ;font-weight:bold;background-color: #666666;" onClick="javascript:; self.close('fscomp');">
	<?PHP if (($totalpdtlocr>0) AND ($td<>"lst")) { ?>
     <input name="lst" type="button" class="bton_std" id="lst" value="Revenir &agrave; la liste" style="text-decoration: none; font-size: 11px; color:White ;font-weight:bold;background-color: #666666;" onClick="javascript:; window.location=('pdtlocr_maj.php?cp=<?PHP echo $codepdtloc; ?>&td=lst');">
    <?PHP } ?>
	</div>
	</td>
</tr>
</table>
<?PHP
if ($retourliste==FALSE)
{
	switch ($td)
	{
		case "add" :
		case "edit" :
		case "del" :
			if ($td=="del")
			{
?>
<form name="pdtlocr_maj" method="post" action="pdtlocr_maj.php">
<?PHP 		} else { ?>
<form name="pdtlocr_maj" method="post" action="pdtlocr_maj.php" onSubmit="javascript:; return (VForm(this,tab_champ,'','<?PHP echo $_SESSION["lng"]; ?>'));">
<?PHP 		} ?>
<input name="icpr" type="hidden" id="icc" value="<?PHP echo $pdtlocr_id ?>">
<input name="cp" type="hidden" id="cp" value="<?PHP echo $codepdtloc ?>">
<input name="td" type="hidden" id="td" value="<?PHP echo $td ?>">
<table width="890"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_datef" align="right">Date r&eacute;paration</td>
	<td>
		<input name="datef" type="text" id="datef" value="<?PHP echo $pdtlocr_datef ?>" size="10" maxlength="10" readonly="1">
		<?PHP if ($td == "add") { ?>
		<img src="../img/calendar.png" align="absmiddle" id="f_img_datef" title="<?PHP echo $alt_chxdate; ?>">
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
		<?PHP } ?>
	</td>
</tr>
</table>

<!-- Code de l'agence (choisi uniquement si création, affiché uniquement si édition ou suppression) -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_agence" align="right">Agence</td>
	<td>
		<?PHP
		if (($td =="add") OR ($td =="edit"))
		{ 
			if ((@$_SESSION["niv_log"] == 5) OR (@$_SESSION["niv_log"] == 9))
			{
				// Création de la liste des agences ouvertes
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				// Filtre sur agences ouvertes
				$rech = "SELECT * FROM ".TBAGE." WHERE `age_ouvert` = '1' ORDER BY age_nom";
				$rs = mysql_query($rech) or die(mysql_error());
	
				if (mysql_num_rows($rs) <> 0)
				{
				?>
					<select name="codeage" id="codeage">
					<?PHP
						echo "<option value=\"\">".$sel_lst_age."</option>";

						while ($resultat = mysql_fetch_array($rs)) 
						{
							extract($resultat);
			
							$age_nomcode = $age_nom." (".$age_code.")";
							if ($pdtlocr_codeage == $age_code)
								echo '<option value="'.$age_code.'" selected>'.$age_nomcode.'</option>';
							else
								echo '<option value="'.$age_code.'">'.$age_nomcode.'</option>';
						}
					?>
					</select>
					<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
			<?PHP
				}
				else
				{
			?>
					<select name="codeage" id="codeage">
					<option>-- Pas d'agence active --</option>
					</select>
			<?PHP
				}
				mysql_free_result($rs);
				mysql_close($conn);
			}
			else
			{
				$row = lit_enr_age($_SESSION["code_age"],TRUE);
				extract ($row);
				$age_nomcode = $age_nom." (".$age_code.")";
			?>
				<input name="codeage" type="hidden" id="codeage" value="<?PHP echo $_SESSION["code_age"]; ?>">
				<input name="nagence" type="text" id="nagence" value="<?PHP echo $age_nomcode; ?>" size="50" maxlength="50" readonly="1">
			<?PHP
			}	
		} 
		else
		{
			$row = lit_enr_age($pdtlocr_codeage,TRUE);
			extract($row);
			$age_nomcode = $age_nom." (".$age_code.")";
		?>
		<input name="nomage" type="text" id="nomage" value="<?PHP echo $age_nomcode ?>" size="50" maxlength="50" readonly="1">
		<?PHP 
		} 
		?>
	</td>
</tr>
</table>

<!-- Technicien -->
<table width="100%"  border="0">
  <tr>
    <td width="160" class="rubfrm" id="f_codetec" align="right">Technicien</td>
    <td>
		<?PHP
		if (($td == "edit") OR ($td == "add"))
		{ 
		?>
			<select name="codetec" id="codetec">
		<?PHP
			echo '<option value="">'.$sel_lst_tec.'</option>';
			if ($pdtlocr_codeage<>"")
			{
				// Création de la liste des Techniciens de l'agence
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rech = "SELECT * FROM ".TBTEC." WHERE `tec_codeage` = '$pdtlocr_codeage' AND `tec_out` = '0' ORDER BY tec_nom";
				$rs = mysql_query($rech) or die(mysql_error());
			
				if (mysql_num_rows($rs) <> 0)
				{
					while ($resultat = mysql_fetch_array($rs)) 
					{
						extract($resultat);
						echo "<option value=\"".$tec_code."\"";
						if ($pdtlocr_codetec == $tec_code)
							echo " selected";
						echo ">".$tec_nom." ".$tec_prenom."</option>";
					}
				}
				mysql_free_result($rs);
				mysql_close($conn);
			}
		?>
		</select>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>"> 
		<span id="attn"></span><span id="msg" style="background-color:#FF0000; color:#FFFF00; font-weight:bold"><?PHP if (trim($pdtlocr_codeage)=="") echo htmlspecialchars($msg_err_age)?></span>
		<?PHP
		}
		else
		{
			$row = lit_enr_tec($pdtlocr_codetec,TRUE);
			if (is_array($row))
			{
				extract($row);
				$txt_tec = $tec_nom." ".$tec_prenom;
			}
			else
				$txt_tec="Pas de technicien affecté";
		?>
	        <input name="codetec" type="hidden" id="codetec" value="<?PHP echo $pdtlocr_codetec ?>" size="50" maxlength="50" readonly="1">
	        <input name="tec" type="text" id="tec" value="<?PHP echo $txt_tec; ?>" size="50" maxlength="50" readonly="1">
		<?PHP } ?>
	</td>
  </tr>
</table>

<!-- Durée -->
<table width="100%"  border="0">
<tr>
    <td width="160" class="rubfrm" id="f_duree" align="right">Dur&eacute;es</td>
    <td>
		<?PHP
		if (($td == "add") OR ($td == "edit"))
		{
		?>
			<select name="duree" id="duree">
			<?PHP
			// Création de la liste des heures
			for ($i=0; $i<360000 ;$i+=300)
			{
				$heure=heure_to_hhmm(sec_heure($i));

				if ($nbh == $heure)
					echo '<option value="'.$heure.'" selected>'.$heure.'</option>';
				else
					echo '<option value="'.$heure.'">'.$heure.'</option>';
			}
			?>
			</select>
		<?PHP
		}
		else
		{
		?>
	        <input name="nbh" type="text" id="nbh" value="<?PHP echo $nbh ?>" size="5" maxlength="5" readonly="1">
		<?PHP
		}
		?>
	</td>
</tr>
</table>

<!-- Montant des pièces changées -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_mtp" align="right">Montant HT pi&egrave;ces</td>
	<td>
	<?PHP if (($td == "add") OR ($td == "edit"))
	{ 
	?>
		<input name="mtp" type="text" id="mtp" style="text-align:right" value="<?PHP echo format_num($pdtlocr_mtp,2); ?>" size="10" onChange="formatedeci(this.id,2);">
		<?PHP echo $lang['symbole_monnaie']; ?>
		<div class="annot_petit_it">(La d&eacute;cimale doit &ecirc;tre '.' et pas la virgule)</div>
	<?PHP
	}
	else
	{
	?>
		<input name="mtp" type="text" id="mtp" style="text-align:right" value="<?PHP echo format_num($pdtlocr_mtp,2); ?>" size="10" maxlength="10" readonly="1"> 
		<?PHP echo $lang['symbole_monnaie']; ?>
	<?PHP
	}
	?>
	</td>
</tr>
</table>

<!-- Travail effectué -->
<table width="100%"  border="0">
<tr>
	<td width="160" class="rubfrm" id="f_fait" align="right">Travail effectu&eacute;</td>
	<td>
		<textarea name="fait" rows="5" id="fait"><?PHP echo htmlspecialchars($pdtlocr_fait) ?></textarea>
	</td>
</tr>
</table>
<p align="center">
<?PHP if ($td == "add") { ?>
<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
<input name="val" type="submit" class="bton_std" id="val" value="<?PHP echo $but_enr; ?>">
<?PHP }

if ($td == "edit") { ?>
<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
<input name="val" type="submit" class="bton_std" id="val" value="<?PHP echo $but_enr; ?>">
<br>
<br>
<input name="add" type="button" class="bton_std" id="add" value="Saisir une autre r&eacute;paration" onClick="javascript:; window.location=('pdtlocr_maj.php?cp=<?PHP echo $codepdtloc; ?>&td=add');">
<?PHP }

if ($td == "del") { ?>
<input name="val" type="submit" class="bton_std" id="val" value="<?PHP echo $but_del; ?>">
<?PHP } ?>
</p>
</form>
<?PHP
		break;
	case "lst" :
		// Création de la liste des réparations de ce produit
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
		mysql_select_db(DBNAME);
		$rech = "SELECT * FROM `" .TBPDTLOCR. "` WHERE `pdtlocr_codepdtloc` = '".$codepdtloc."' ORDER BY 'pdtlocr_date'";
		if ((@$_SESSION["niv_log"] == 4) OR (@$_SESSION["niv_log"] == 3))
			$rech.=" AND `pdtlocr_codeage` = '".$_SESSION["code_age"]."'";
	
		$rs = mysql_query($rech) or die(mysql_error());
		
		if (mysql_num_rows($rs) <> 0)
		{
			echo "<table class=\"MtableD\" border=\"0\" width=\"890\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
			 
			// Création de l'entête de la table contacts clients
			echo "<th>";
			echo "Date";
			echo "</th>\n";
			echo "<th>";
			echo "Agence";
			echo "</th>\n";
			echo "<th>";
			echo "Technicien";
			echo "</th>\n";
			echo "<th>";
			echo "Choisir";
			echo "</th>\n";
			
			$j = 0;
			
			while ($row = mysql_fetch_assoc($rs)) 
			{         
				// Création de l'entête de ligne (TR)
				creetrlstdet($j);
				
				echo "<td>\n";
				echo formatedate($row["pdtlocr_date"]);
				echo "</td>\n";
				echo "<td>\n";
				echo $row["pdtlocr_codeage"];
				echo "</td>\n";
				echo "<td>\n";
				echo $row["pdtlocr_codetec"];
				echo "</td>\n";

				echo "<td align=\"center\">\n";
				$lst_maj=TRUE;
				echo "<a href=\"pdtlocr_maj.php?td=edit&cp=".$row["pdtlocr_codepdtloc"]."&icpr=".$row["pdtlocr_id"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\"></a>";
				$lst_del=TRUE;
				echo " <a href=\"pdtlocr_maj.php?td=del&cp=".$row["pdtlocr_codepdtloc"]."&icpr=".$row["pdtlocr_id"]."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\"></a>";
				echo "</td>\n";
				echo "</tr>\n";
			
				$j++;
			}
			
			echo "</table>\n";
			// Fin affichage table liste réparations
			$taille_piedla="";
			include_once("piedla.inc.php");
		?>
		<p align="center">
    	<input name="add" type="button" class="bton_std" id="add" value="Saisir une r&eacute;paration" onClick="javascript:; window.location=('pdtlocr_maj.php?cp=<?PHP echo $codepdtloc; ?>&td=add');">
		</p>
		<?PHP
		}
		break;
		
	default :
		break;
	}
}
else
{
?>
	<script type="text/javascript">
	<!--
	var objet=window.opener.document.getElementById('mtrep');
	objet.value='<?PHP echo format_num(px_revient_pdtlocr($codepdtloc),2); ?>';
	somme('valnet','mtrep','totvalnet',2,1);
	window.location=('pdtlocr_maj.php?cp=<?PHP echo $codepdtloc; ?>&td=lst');
	//self.close('fscomp');
	//-->
	</script>
<?PHP
}
}
else
{
?>
	<script type="text/javascript">
	<!--
	//self.close('fscomp');
	//-->
	</script>
<?PHP
}
?>
</body>
</html>
