<?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
****************************************************************************************/

session_start(); 
?>
<?php if ((@$HTTP_SESSION_VARS["etat_log"] <> "connecte") or ((@$HTTP_SESSION_VARS["niv_log"] <> 4) AND (@$HTTP_SESSION_VARS["niv_log"] <> 3))) header("Location: ../index.php") ?>
<?php include ("../inc/config.inc.php") ?>
<?php require ("../inc/func.inc.php") ?>
<?php require ("../inc/func_date.inc.php") ?>
<?php require ("../inc/func_log.inc.php") ?>
<?php require ("../inc/func_txt.inc.php") ?>
<?php require ("../inc/lst.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>

<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<title>SMI - ESPACE PRIVE : Index Agences</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>

<!-- Affichage nouvelle fenêtre pour impression -->
<script type="text/javascript">
	function lanceimp(page)
	{
	  window.open(page,'impression','width='+screen.width+' height='+screen.height);
	}
</script>

</head>

<body>

<?php
	include_once ("../inc/entete.php"); 
?>

<p align="center"><span class="titrepage">ESPACE AGENCES</span></p>
<p align="center" class="annot_gras_it">Tableau de bord</p>
<br>
<p align="center"><span class="rubNormal">INTERVENTIONS EN COURS</span><br>
<span class="annot_std_it">(G&eacute;r&eacute;es par votre agence)</span></p>
<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);

	$rech = cree_strrechlstint($niv_urgence);
	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE ".TBINT.".int_codeage='".@$HTTP_SESSION_VARS["code_age"]."' AND ".TBINT.".int_codestatut <> 'CLOT'";
	else
		$rech .= " AND ".TBINT.".int_codeage='".@$HTTP_SESSION_VARS["code_age"]."' AND ".TBINT.".int_codestatut <> 'CLOT'";
		
	$rech .= crestr_triord($int_titre_col,"int_code",FALSE,$limit);
	// *** Fin de Chaîne de Recherche
		 
	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	
	if($numrows > 0)
	{
		echo "<span class=\"annot_std_it\">";
		echo "(Statut : laisser la souris sur l'icône pour le statut)<br>";
		echo "</span>";
	
		// *** Affichage de la table
		 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
	
		// Création entête
		titlst(TRUE,$int_titre_col);
		echo "<th>".ucfirst("Cliquer")."</th>\n";
		
		$i = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
		 // Affichage résumé intervention
	
			// Création de l'entête de ligne (TR)
			creetrlst($i);
	
			 echo "<td>".$row["int_code"]."</td>\n";
			 echo "<td>".formatedate($row["int_datedde"])."</td>\n";
			 echo "<td>";
	
			 // Affichage détail urgence
	
				 echo "<div align=\"center\">";
				 echo $niv_urgence[$row["int_urg"]];
				 echo "</div>";
		
			 // Fin affichage détail urgence
	
			 echo "</td>\n";
	
			 echo "<td>".$row["int_codecli"];
	
			 // Affichage détail client
	
				 $detailcli = "->";
				 if ($row["cli_ste"] <> "")
					$detailcli .= $row["cli_ste"].", ";
				 $detailcli .= $row["cli_civilite"]." ".$row["cli_nom"];
				 echo "<br>";
				 echo "<span class=\"annot_std_it\">";
				 echo $detailcli;
				 echo "</span>";
		
			 // Fin affichage détail client
	
			 echo "</td>\n";
			 if ($row["int_codetec"] <> "")
				echo "<td>".$row["int_codetec"]."</td>\n";
			 else
				echo "<td>&nbsp;</td>\n";
			 
			 // Affichage Icône Statut
			 
			 echo "<td>";
			 echo "<div align=\"center\">";
			 
			 $statut = $row["int_codestatut"];
			 $rechico = "SELECT * FROM ".TBSTA." WHERE statut_code = '$statut'";
			 
			 $rsico = mysql_query($rechico) or die(mysql_error());
			 
				if (mysql_num_rows($rsico) <> 0)
				{
					 while ($rowico = mysql_fetch_array($rsico)) 
					{
						extract ($rowico);
						if ($rowico["statut_img"] <> "")
						{
							$statint = $rowico["statut_desc"]." (".$statut.")";
							echo "<img src=\"".$rowico["statut_img"]."\" title=\"".$statint."\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\">";
						}
						else
						{
							 echo "<span class=\"annot_std_it\">";
							 echo $statut;
							 echo "</span>";
						}
					}
				}
			 
				mysql_free_result($rsico);
	
			 echo "</div>";
			 echo "</td>\n";
	
			// CREATION lien dynamique sur icône (édition, suppression, etc...)
			 echo "<td>";
			 echo "<div align=\"center\">";
	
			$lst_maj = TRUE;
	
			echo "<a href=\"int_maj.php?td=edit&ci=".$row["int_code"]."\"><img src=\"../img/edit.png\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
			echo " ";
	
			$lst_imp = TRUE;
			
			 $urlimp = "int_pdf.php?ci=".$row["int_code"];
			 echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/print.gif\" title=\"Imprimer la fiche\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
			 echo " ";
			 if ($row["int_codestatut"] <> "CLOT")
			 {
				$lst_del = TRUE;
	
				echo "<a href=\"int_maj.php?td=del&ci=".$row["int_code"]."&cc=".$row["int_codecli"]."&ct=".$row["int_codetec"]."&cte=".$row["int_codetece"]."&ca=".$row["int_codeage"]."\"><img src=\"../img/del.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
			 }
	
			 echo "</div>";
			 echo "</td>\n";
	
			 echo "</tr>\n";
		 // Fin affichage résumé intervention
			
			$i++;    
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
		
		mysql_free_result($rs);
	}
	else
	{
		echo "<span class=\"annot_gras_it\">";
		echo "Pas d'intervention en cours";
		echo "</span>";
	}	

	mysql_close($conn);  
	
	$taille_piedla="";
	include("../inc/piedla.php"); 
?>
<br>
<p align="center"><span class="rubNormal">RELEVES DE PARCS AVEC PROBLEMES</span><br>
<span class="annot_std_it">(D&eacute;clar&eacute;s et non affect&eacute;s &agrave; une intervention)</span></p>
<?PHP
	$lst_maj = FALSE;
	$lst_imp = FALSE;
	$lst_del = FALSE;
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);

	$rech = cree_strrechlstrrel();
	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE ".TBREL.".rel_codeage='".@$HTTP_SESSION_VARS["code_age"]."'";
	else
		$rech .= " AND ".TBREL.".rel_codeage='".@$HTTP_SESSION_VARS["code_age"]."'";
	$rech .= crestr_triord($rel_titre_col,"rel_code",FALSE,$limit);
	// *** Fin de Chaîne de Recherche
		 
	$rs = mysql_query($rech) or die(mysql_error());
	$numrows = mysql_num_rows($rs); // Nombre de résultats à la requête
	

	if($numrows > 0)
	{
		// *** Affichage de la table
		 echo "<table class=\"Mtable\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";     
	
		// Création entête
		titlst(TRUE,$rel_titre_col);
		echo "<th>".ucfirst("Cliquer")."</th>\n";
		
		$i = 0;
		
		while ($row = mysql_fetch_assoc($rs)) 
		{         
		 // Affichage résumé relevé
	
			// Vérification si problème(s) non affecté(s)
			// Si oui, on affiche (sinon, non)
			$rexist2 = "SELECT * FROM ".TBRPBM."  WHERE rpbm_codecli = '".$row["cli_code"]."' AND rpbm_codeint IS NULL";
			$rs2 = mysql_query($rexist2) or die(mysql_error());
			if (mysql_num_rows($rs2) > 0)
			{
				// Création de l'entête de ligne (TR)
				creetrlst($i);
		
				 echo "<td>";
				 echo $row["rel_code"];
				 echo "</td>\n";
				 echo "<td>".formatedate($row["rel_datecrea"])."</td>\n";
				 echo "<td>".formatedate($row["rel_datemod"])."</td>\n";
				 echo "<td>".$row["rel_codecli"];
		
				 // Affichage détail client
		
					 $detailcli = "->";
					 if ($row["cli_ste"] <> "")
						$detailcli .= $row["cli_ste"].", ";
					 $detailcli .= $row["cli_civilite"]." ".$row["cli_nom"];
					 echo "<br>";
					 echo "<span class=\"annot_std_it\">";
					 echo $detailcli;
					 echo "</span>";
			
				 // Fin affichage détail client
		
				 echo "</td>\n";
				 if ($row["rel_codeage"] <> "")
					echo "<td>".$row["rel_codeage"]."</td>\n";
				 else
					echo "<td>&nbsp;</td>\n";
				 
				// CREATION lien dynamique sur icône (édition, suppression, etc...)
				 echo "<td>";
				 echo "<div align=\"center\">";
		
				$lst_maj = TRUE;
		
				echo "<a href=\"rel_maj.php?td=edit&cr=".$row["rel_code"]."\"><img src=\"../img/edit.png\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
				echo " ";
		
				$lst_imp = TRUE;
				
				 $urlimp = "rel_pdf.php?cr=".$row["rel_code"]."&pbm=0";
				 echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/print.gif\" title=\"Imprimer le dossier relevé\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
				 echo " ";
		
				$lst_impp = TRUE;
				
				 $urlimp = "rel_pdf.php?cr=".$row["rel_code"]."&pbm=1";
				 echo "<a href=\"javascript:;\" onclick=\"lanceimp('".$urlimp."');\")><img src=\"../img/printc.gif\" title=\"Imprimer le dossier relevé avec les problèmes\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
				 echo " ";
		
				$lst_del = TRUE;
		
				echo "<a href=\"rel_maj.php?td=del&cr=".$row["rel_code"]."&cc=".$row["rel_codecli"]."&ct=".$row["rel_codetec"]."&cte=".$row["rel_codetece"]."&ca=".$row["rel_codeage"]."\"><img src=\"../img/del.gif\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border=\"0\" align=\"absmiddle\"></a>";
		
				 echo "</div>";
				 echo "</td>\n";
		
				 echo "</tr>\n";
				 // Fin affichage résumé intervention
				
				$i++;
			}
		}  
		echo "</table>\n";
		// *** Fin affichage de la table
	
		mysql_free_result($rs);
	}
	else
	{
		echo "<span class=\"annot_gras_it\">";
		echo "Pas de problème déclaré non affecté";
		echo "</span>";
	}	

	mysql_close($conn);  
	
	$taille_piedla="";
	include("../inc/piedla.php"); 
?>

<?php 
	include ("pied.php")
?>
