<?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_fici.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");
include_once("../inc/down.inc.php");
include_once("../classes/ephpu/upload_class.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim(@$_GET['td']));

$pbm_logo=FALSE;

switch ($td)
{
	case "cge" :
		$titre = "LOGO CENTRE DE GESTION";
		break;
	case "age" :
		$titre = "LOGO AGENCE";
		break;
	case "do" :
		$titre = "LOGO DONNEUR D'ORDRES";
		break;
	case "st" :
		$titre = "LOGO SOUS-TRAITANT";
		break;
	default :
		$pbm_logo=TRUE;
		break;
}
?>
<!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; ?> : T&eacute;l&eacute;chargements Logo</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>

<!-- Définition Javascript pour calendrier popup -->

  <!-- Feuille de Style -->
  <link rel="stylesheet" type="text/css" media="all" href="../jscript/jscal/skins/aqua/theme.css" title="Aqua" />

  <!-- Script Javascript Principal -->
  <script type="text/javascript" src="../jscript/jscal/calendar.js"></script>

  <!-- Choix du langage -->
  <script type="text/javascript" src="../jscript/jscal/lang/calendar-<?PHP echo $_SESSION["lng"]; ?>.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="../jscript/jscal/calendar-setup.js"></script>

<!-- Fin de la définition Javascript pour calendrier popup -->

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

<?PHP if ($td=="age") { ?>
<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:codeage ; format:liste ; req:Y ; txt:Nom de l'agence ; vmn:1 ; stok:frmok ; stbad:frmbad");
//-->
</script>
<?PHP } ?>

<?PHP if ($td=="do") { ?>
<script language="javascript">
<!--
var tab1_champ=new Array(
	"nom:codedo ; format:liste ; req:Y ; txt:Nom du donneur d'ordres ; vmn:1 ; stok:frmok ; stbad:frmbad");
//-->
</script>
<?PHP } ?>

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

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

<!-- Barre d'attente Javascript -->
<script language="JavaScript" src="../jscript/progress/xp_progress.js"></script>

</head>

<body onLoad="metFocus();">
<?php 
include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage"><?PHP echo $titre ?></span></p>
<p align="center" class="annot_gras_it">Veuillez choisir le logo que vous souhaitez t&eacute;l&eacute;charger. </p>
<?PHP
if ($pbm_logo==FALSE)
{
?>
<!--- Formulaire d'Upload des Logos -->
<div id="attn" style="display:none" align="center">
<p class="annot_gras_it">T&eacute;l&eacute;chargement en cours...</p>
<img src="../img/wait30.gif" alt="attn" width="30" height="30" border="0" />
</div>
<div id="pas_wait" style="display:block;" align="center">
<?PHP if ($td=="age") { ?>
<form action="upll_enr.php" method="POST" enctype="multipart/form-data" name="upll_maj" id="upll_maj" onSubmit="javascript:; return (verif_upll(this,tab1_champ,'',''));">
<?PHP } else { ?>
<form action="upll_enr.php" method="POST" enctype="multipart/form-data" name="upll_maj" id="upll_maj"  onSubmit="javascript:; return (verif_upll2());">
<?PHP } ?>
<?PHP 
	$max_size = $taille_maxi_admin; // Taille maximum autorisée pour téléchargement
?>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size; ?>"><br>
<input name="td" type="hidden" id="td" value="<?PHP echo $td; ?>">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?PHP if ($td=="age") { ?>
<tr>
	<td class="rubfrm" nowrap align="right" valign="top" id="f_age">
	<label for="agence">
	Pour quelle agence ? 
	</label>
	</td>
	<td nowrap align="left">
	<?PHP
	// Création de la liste des agences ouvertes
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$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" style="margin-left:5px;">
		<?PHP
			echo "<option value=\"\">".$sel_lst_age."</option>";

			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				$age_nomcode = $age_nom." (".$age_code.")";
				if (exist_logo($age_code))
					$age_nomcode.=" --- Logos OK";
				else
				{
					$existpng=exist_logopng($age_code);
					$existgif=exist_logogif($age_code);
					if (($existpng==FALSE) AND ($existgif==FALSE))
						$age_nomcode.=" --- Les 2 formats manquent";
					else
					{
						if ($existpng==FALSE)
							$age_nomcode.=" --- Le format PNG manque";
						if ($existgif==FALSE)
							$age_nomcode.=" --- Le format GIF manque";
					}						
				}
				echo '<option value="'.$age_code.'">'.$age_nomcode.'</option>';
			}
		?>
		</select>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	}
	else
		echo " Pas d'agence";
	?>		
	</td>
</tr>
<?PHP } ?>
<?PHP if ($td=="do") { ?>
<tr>
	<td class="rubfrm" nowrap align="right" valign="top" id="f_do">
	<label for="dordre">
	Pour quel donneur d'ordres ? 
	</label>
	</td>
	<td nowrap align="left">
	<?PHP
	// Création de la liste des donneurs d'ordres actifs
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBDO." WHERE `do_ouvert` = '1' ORDER BY do_nom";
	$rs = mysql_query($rech) or die(mysql_error());

	if (mysql_num_rows($rs) <> 0)
	{
	?>
		<select name="codedo" id="codedo" style="margin-left:5px;">
		<?PHP
			echo "<option>-- Choisissez un donneur d'ordres --</option>";

			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				$do_nomcode = $do_nom." (".$do_code.")";
				if (exist_logo($do_code))
					$do_nomcode.=" --- Logos OK";
				echo '<option value="'.$do_code.'">'.$do_nomcode.'</option>';
			}
		?>
		</select>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	}
	else
		echo " Pas de donneur d'ordres";
	?>		
	</td>
</tr>
<?PHP } ?>
<?PHP if ($td=="st") { ?>
<tr>
	<td class="rubfrm" nowrap align="right" valign="top" id="f_st">
	<label for="sttant">
	Pour quel sous-traitant ? 
	</label>
	</td>
	<td nowrap align="left">
	<?PHP
	// Création de la liste des sous-traitants actifs
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rech = "SELECT * FROM ".TBST." WHERE `st_ouvert` = '1' ORDER BY st_nom";
	$rs = mysql_query($rech) or die(mysql_error());

	if (mysql_num_rows($rs) <> 0)
	{
	?>
		<select name="codest" id="codest" style="margin-left:5px;">
		<?PHP
			echo "<option>-- Choisissez un sous-traitant --</option>";

			while ($resultat = mysql_fetch_array($rs)) 
			{
				extract($resultat);
				$st_nomcode = $st_nom." (".$st_code.")";
				if (exist_logo($st_code))
					$st_nomcode.=" --- Logos OK";
				echo '<option value="'.$st_code.'">'.$st_nomcode.'</option>';
			}
		?>
		</select>
		<img src="../img/oblig.png" align="absmiddle" alt="<?PHP echo $alt_chp_oblig; ?>">
	<?PHP
	}
	else
		echo " Pas de sous-traitant";
	?>		
	</td>
</tr>
<?PHP } ?>
<tr>
	<td class="rubfrm" nowrap align="right" valign="top" id="f_upload">
	<label for="upload">
	Logo &agrave; t&eacute;l&eacute;charger
	<span class="annot_petit_it">(Dans le r&eacute;pertoire des logos) </span>
	: 
	</label>
	</td>
	<td nowrap align="left">
		<input  style="margin-left:5px;" type="file" name="upload" size="100"> <br>
		<span class="annot_petit_it" style="margin-left:200px;">
		Doit faire au minimum 195x36 dpi
		</span>
	</td>
</tr>
<tr>
	<td nowrap align="right" class="annot_std_gras" valign="middle">
	<label for="replace">Remplacer sur le serveur :		</label>
	</td>
	<td nowrap align="left">
	<input type="checkbox" name="replace" value="y" style="background : #FFFFFF;">
	</td>
</tr>
<tr>
	<td nowrap align="right" class="annot_std_gras" valign="middle">
	<label for="check">
	V&eacute;rifier le nom du fichier :
	</label>
	</td>
	<td nowrap valign="middle" align="left">
	<?PHP
	if ($niv_util <> 9)
	{
	?>
		<input name="check" type="checkbox" value="y" style="background : #FFFFFF;" checked disabled="disabled">
	<?PHP
	}
	else
	{
	?>
		<input name="check" type="checkbox" value="y" style="background : #FFFFFF;" checked>
	<?PHP
	}
	?>
	</td>
</tr>
<tr>
	<td nowrap>&nbsp;</td>
	<td nowrap align="left">
		<input name="ok" type="submit" class="bton_std" id="ok" value="<?PHP echo $but_envoyer; ?>">
		<input name="RAZ" type="reset" class="bton_std" id="RAZ" value="<?PHP echo $but_reinit; ?>">
	</td>
</tr>
</table>
</form>
</div>
<!--- Fin du Formulaire d'upload -->
<?PHP
}
else
	aff_ret_pbm_auto("index.php",2000);
include_once("pied.php");
?>
