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

$pbm_intf = FALSE;

$tx = strip_tags(trim($_GET['tx'])); // Récupération origine ('m' : menu  / 'i' : intervention)
$ci = strip_tags(trim($_GET['ci'])); // Récupération code Intervention

if (($tx<>"m") AND ($tx<>"i"))
	$pbm_intf=TRUE;
	
if ($pbm_intf==FALSE)
{
	if ($ci <> "")
	{
		// Récupération des informations intervention
		$row = lit_enr_int($ci);
		if (is_array($row))
		{
			extract ($row);
	
			switch ($_SESSION["niv_log"])
			{
				// Contrôle qu'une agence n'essaye pas de "hacker" une intervention
				case 4 :
					if ($int_codeage == @$_SESSION["code_age"])
					{
						$row = lit_enr_age($int_codeage,TRUE);
						if (is_array($row))
						{
							extract ($row);
							
							if (intval($age_fact)==0)
								$pbm_intf=TRUE;
						}
						else
							$pbm_intf=TRUE;
					}
					else
						$pbm_intf=TRUE;
					break;
			}
		}
		else
			$pbm_intf = TRUE;
	}
	else
		$pbm_intf = 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; ?> : Liste des factures</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 divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

</head>

<body onLoad="metFocus();">

<?php 
if ($tx=="m")
	include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage">Liste des factures</span></p>
<p align="center"><span class="annot_gras_it">Pour l'intervention <?PHP echo $ci; ?></span></p>
<?PHP
if ($pbm_intf == FALSE)
{
	if ($tx=="m")
		echo '<strong><em><a href="int_lst.php?page=1&ord=DES&tri=Code">'.$txt_lnk_ret_liste.'</a></em></strong>';
	else
    	echo '<input name="quit" type="button" class="bton_std" id="quit" value="'.$but_quit.'" style="text-decoration: none; font-size: 11px; color:White ;font-weight:bold;background-color: #666666;" onClick="javascript:; self.close(\'fscomp\');">';
	echo "<br />";
	
	$url_add = "intf_maj.php?tx=".$tx."&td=add&ci=".$ci;
	
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	
	$rech = cree_strrechlstintf();
	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE ";
	else
		$rech .= " AND ";
	$rech .= " intf_codeint ='$ci'";
	$rech .= crestr_triord($intf_titre_col,"intf_numf",FALSE,$limit);
	
	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	
	if($numrows == 0)
		retpp();
	else
	{
		include_once("../inc/formr.inc.php"); 
	
		$rech = cree_strrechlstintf();
		if(!stristr($rech,"WHERE "))
			$rech .= " WHERE ";
		else
			$rech .= " AND ";
		$rech .= " intf_codeint ='$ci'";
		$rech .= crestr_triord($intf_titre_col,"intf_numf",TRUE,$limit);
	
		$rs = mysql_query($rech) or die(mysql_error());
	
		// *** Pagination de pied
		pagine_lst($numrows,$limit);
		
		// *** Affichage de la table
		echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
		
		// Création entête
		titlst($intf_titre_col);	
		echo "<th>".ucfirst($txt_ent_lst_clic)."</th>\n";
		
		$i = 0;
			
		while ($row = mysql_fetch_assoc($rs)) 
		{         
			// Création de l'entête de ligne (TR)
			creetrlst($i);
	
			echo "<td>".$row["intf_numf"];
			echo "</td>\n";
			echo "<td>".$row["intf_datefac"];
			echo "</td>\n";
			
			// CREATION lien dynamique sur icône (édition, suppression, etc...)
			echo "<td>";
			echo "<div align=\"center\">";
			$lst_maj = TRUE;
			echo "<a href=\"intf_maj.php?tx=".$tx."&td=edit&ci=".$row["intf_codeint"]."&cf=".$row["intf_numf"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\" title=\"".$alt_edit."\"></a>";
			echo "</div>";
			echo "</td>\n";
		
			echo "</tr>\n";
			
			$i++;
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
		mysql_close();  
		
		// *** Pagination de pied
		pagine_lst($numrows,$limit);
		
		$taille_piedla="";
		include_once("../inc/piedla.inc.php"); 
	}
}
else
{
	switch ($tx)
	{
		case "i" :
?>
	<script type="text/javascript">
	<!--
	self.close();
	//-->
	</script>
<?PHP
			break;
		default :
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('index.php');",2000)
	//-->
	</script>
	<p align="center" class="annot_std_it">Probl&egrave;me de param&egrave;tres</p>
<?PHP
		break;
	}
}

if ($tx=="m")
	include_once("pied.php")
?>
