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

session_start(); 
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/func_log.inc.php");
if (CheckURLLog(FALSE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("6-7")==FALSE) header("Location: ../index.php");
include_once("../inc/fic_fici.inc.php");
include_once("../inc/func.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/func_geo.inc.php");
include_once("../inc/lst.inc.php");
Archivelog(@$_SESSION["code_log"]);
$pbm_conf=FALSE;
if (!exist_logo("cge")) $pbm_conf=TRUE;
if (!exist_logo(@$_SESSION["code_do"])) $pbm_conf=TRUE;
if (!existe_cdg()) $pbm_conf=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; ?> : Index Donneur d'Ordres</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="set_mnu_ageidx('m1');">

<?php
if ($pbm_conf==FALSE)
{
include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage">VOTRE TABLEAU DE BORD</span><br></p>
<br>
<div id="menu_ageidx" class="menu_ongletfull">
<a class="ongleti" id="m1" href="javascript:;" onclick="set_mnu_ageidx(this.id);" onFocus="this.blur();">Interventions en cours</a>
</div>
<br>

<div id="detailm1" style="display:none">
<?PHP
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);

	$rech = cree_strrechlstint($niv_urgence);
	if(!stristr($rech,"WHERE "))
		$rech .= " WHERE ".TBINT.".int_codedo='".@$_SESSION["code_do"]."' AND ".TBINT.".int_datefin = '0000-00-00'";
	else
		$rech .= " AND ".TBINT.".int_codedo='".@$_SESSION["code_do"]."' AND ".TBINT.".int_datefin = '0000-00-00'";
		
	$rech .= "ORDER BY ".TBINT.".int_code DESC";
	// *** 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 "(Lieu/Statut : laisser la souris sur l'icône pour le d&eacute;tail)<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($int_titre_col);
		echo "<th>".ucfirst($txt_ent_lst_clic)."</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"];
			$detfic=">>Mat&eacute;riel :<br />".$row["int_mat"]."<br /><br />>>Travail &agrave; effectuer :<br />".$row["int_pbm"];
			if ($detfic<>"")
				echo " <a href=\"#\" class=\"pop\"><img src=\"../img/help.png\" alt=\"D&eacute;tail\" border=\"0\" align=\"absmiddle\"><span>".formatetxtbr($detfic)."</span></a>";
			 echo "</td>\n";
			 echo "<td>".formatedate($row["int_datedde"])."</td>\n";
	
			 // Affichage Icône Lieu
			 echo "<td align=\"center\">";
			 
			 $lieu = $row["int_codelieu"];
			 $rechlieu = "SELECT * FROM ".TBLIEU." WHERE lieu_code = '$lieu'";
			 
			 $rslieu = mysql_query($rechlieu) or die(mysql_error());
			 
			if (mysql_num_rows($rslieu) <> 0)
			{
				 while ($rowlieu = mysql_fetch_array($rslieu)) 
				{
					extract ($rowlieu);
					if ($rowlieu["lieu_img"] <> "")
					{
						$lieuint = $rowlieu["lieu_desc"]." (".$lieu.")";
						echo "<img src=\"".$rowlieu["lieu_img"]."\" title=\"".$lieuint."\" border=\"0\" align=\"absmiddle\">";
					}
					else
					{
						 echo "<span class=\"annot_std_it\">";
						 echo $lieu;
						 echo "</span>";
					}
				}
			}
		 
			mysql_free_result($rslieu);
			 echo "</td>\n";

			 // Affichage détail urgence
			 echo "<td align=\"center\">";
			 echo $niv_urgence[$row["int_urg"]];
			 echo "</td>\n";
			 // Fin affichage détail urgence

			 echo "<td>".$row["int_codecli"];
	
			 // Affichage détail client
			 $detailcli = "->";
			 if ($row["cli_ste"] <> "")
				$detailcli .= htmlspecialchars($row["cli_ste"]).", ";
			 $detailcli .= htmlspecialchars($row["cli_civilite"])." ".htmlspecialchars($row["cli_nom"]);
			 echo "<br>";
			 echo "<span class=\"annot_std_it\">";
			 echo $detailcli;
			 echo "</span>";
			 // Fin affichage détail client
	
			 echo "<td align=\"center\">";
			if (($row["int_codetec"] <> "") AND ($row["int_codetec"] <> "-1"))
			{
				echo $row["int_codetec"];
				echo "<br> agence : ".$row["int_codeage"];
			}
			else
				echo "&nbsp;";
			echo "</td>\n";
			 
			 // Affichage Icône Statut
			 echo "<td 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."\" border=\"0\" align=\"absmiddle\">";
					}
					else
					{
						 echo "<span class=\"annot_std_it\">";
						 echo $statut;
						 echo "</span>";
					}
				}
			}
		 
			mysql_free_result($rsico);
			 echo "</td>\n";
	
			// CREATION lien dynamique sur icône (édition, suppression, etc...)
			 echo "<td align=\"center\">";
	
			$lst_maj = TRUE;
			$voir=FALSE;
			
			if (int_closed($row["int_code"],FALSE) == FALSE)
			{
				if (($row["int_codetec"] <> "") AND ($row["int_codetec"] <> "-1"))
					$voir=TRUE;
			}
			else
				$voir=TRUE;

			if ($voir==FALSE)
			{
				$lst_maj = TRUE;
				echo "<a href=\"int_maj.php?td=edit&ci=".$row["int_code"]."&cc=".$row["int_codecli"]."&ca=".$row["int_codeage"]."\"><img src=\"../img/edit.png\" border=\"0\" align=\"absmiddle\"></a>";
				echo " ";
			}
			else
			{
				$lst_voir = TRUE;
				echo "<a href=\"int_maj.php?td=view&ci=".$row["int_code"]."&cc=".$row["int_codecli"]."\"><img src=\"../img/eye.png\" 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.png\" title=\"".$alt_impfic."\" border=\"0\" align=\"absmiddle\"></a>";
			 echo " ";
			if (int_closed($row["int_code"],FALSE) == FALSE)
			{
				$del=TRUE;

				if (($row["int_codetec"] <> "") AND ($row["int_codetec"] <> "-1"))
					$del=FALSE;
		
				if ($del==TRUE)
				{
					$lst_del = TRUE;
					echo "<a href=\"int_maj.php?td=del&ci=".$row["int_code"]."&cc=".$row["int_codecli"]."&ct=".$row["int_codetec"]."\"><img src=\"../img/del.png\" border=\"0\" align=\"absmiddle\"></a>";
				}
			}
			 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 "<div class=\"annot_gras_it\">";
		echo "<br />".$alert_nointc;
		echo "</div>";
	}	

	mysql_close($conn);  
	
	$taille_piedla="";
	include("../inc/piedla.inc.php"); ?>
</div>
<?PHP
include_once("pied.php");
}
else
{
?>
<p align="center"><span class="titrepageerr"><?PHP echo $alert_pbmconf; ?></span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div align="center" class="annot_gras_it"><?PHP echo $alert_sminoconfc; ?><br /><br />
<?PHP echo $txt_div_ctactadmincge; ?></div>
<script type="text/javascript">
<!--
window.setTimeout("location=('../index.php');",2000)
//-->
</script>
<?PHP
}
?>