<?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");

if (!isset($_SESSION["lng"])) $_SESSION["lng"]="fr";
include_once("../lng/".$_SESSION["lng"].".inc.php"); // Paramètres de language
include_once("../inc/config.inc.php");
include_once("../inc/fic_loc.inc.php");
include_once("../inc/fic_pen.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_log.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

// Variables Formulaire
$pbm_pdt=FALSE;
$titre = "CONSOMMABLES FACTURABLES";
$td = strip_tags(trim(@$_GET["td"]));
if (($td<>"ret") AND ($td<>"del"))
	$pbm_pdt=TRUE;
$tab_enr=array();
$didx1=intval(strip_tags(trim(@$_GET["di1"])));
$didx2=intval(strip_tags(trim(@$_GET["di2"])));
$ridx1=intval(strip_tags(trim(@$_GET["ri1"])));
$ridx2=intval(strip_tags(trim(@$_GET["ri2"])));
$qci1=intval(strip_tags(trim(@$_GET["qc1"])));
$qci2=intval(strip_tags(trim(@$_GET["qc2"])));

?>
<!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; ?> : P&eacute;nalit&eacute; Location</title>

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

<!-- Scripts Javascript pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

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

<!-- Scripts Javascript sur les champs -->
<script language="JavaScript" src="../jscript/verif_field.js"></script>

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

</head>
<body>

<p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
<br />
<div align="center">
<span class="annot_gras_it">Calculs en cours</span>
<br />
<br />
<img src="../img/wait30.gif" alt="wait" width="30" height="30">
</div>
<?PHP
$retourliste = TRUE;
if ($pbm_pdt==FALSE)
{
	$diff_idx1=0;
	$diff_idx2=0;
	if ((($didx1<>-1) && ($ridx1<>-1)) || (($didx2<>-1) && ($ridx2<>-1)))
	{
		if (($ridx1-$didx1)>$qci1)
			$diff_idx1=$ridx1-$didx1-$qci1;
		if (($ridx2-$didx2)>$qci2)
			$diff_idx2=$ridx2-$didx2-$qci2;
	}
	switch ($td)
	{
		// Ajout du montant consommables pour la location
		case "ret" :
			if ((isset($_SESSION["pdtlcl"])) AND (isset($_SESSION["pdtlbl"])))
			{
				// Calcul du montant pour les consommables
				$tot_consos=calcul_consloc($_SESSION["pdtlbl"][0]["idbarloc"],$_SESSION["pdtlbl"][0]["codetva"],$diff_idx1,$diff_idx2);
				$_SESSION["pdtlcl"][0]["valeur"]=$tot_consos;

				$msg = "Calculs effectu&eacute;s";
			}
			else
			{
				$retourliste=FALSE;
				$msg = "Probl&egrave;me dans les sessions";
			}
			break;
			
		// Suppression de la pénalité de location
		case "del" :
			$_SESSION["pdtlcl"]=array();
			$msg = "Consommables supprim&eacute;s";
			break;
			
		default :
			break;
	}
}
else
{
	$retourliste=FALSE;
	$msg = "Probl&egrave;me de param&egrave;tres";
}
?>
<p align="center">&nbsp;</p>
<p align="center">
<?PHP if ($retourliste==FALSE)
	echo '<span class="alerte1">';
else
	echo '<span class="annot_std_gras">';
?>
<?PHP echo $msg ?>
</span>
</p>

<?PHP 
cre_js_pdtlbl($td,$_SESSION["pdtlbl"],$_SESSION["pdtlpl"],$_SESSION["pdtlcl"],"window.opener.");
?>
<script type="text/javascript">
<!--
tbpbarloc();
self.close();
//-->
</script>
<p align="center">Fermeture automatique, sinon <a href="javascript:void(0)" onClick="javascript:; self.close('fscomp');"><?PHP echo $txt_lnk_clic_ici; ?></a> </p>

</body>
</html>
