1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
<?php
set_time_limit(300);
//Appel de Fonctions
require('../fonctions_affichage.php');
if($_REQUEST['action'] == 'submitted' and $_REQUEST['submit2'] == 'Export dans un tableur'){
require('../config.php');
require('../fonctions_login.php');
}
else
{
include('../header.php');
initiation_formulaire_php();
?>
<!-- Panneau de sélection des parametres -->
<div id="parametres">
<?php include("../js/calendrier.php"); ?>
<span class="titre_choix">Sélectionnez vos paramètres :</span>
<table CLASS="parametres">
<tr>
<td><span class="lib_para">Société - Centre exec. : </span></td>
<td>
<input type="text" name="P_SOC" size="3" maxlength= "3" value="<?php echo (isset($_REQUEST['P_SOC']))? $_REQUEST['P_SOC']: '' ;?>" >
<input type="text" name="P_MAG" size="3" maxlength= "3" value="<?php echo (isset($_REQUEST['P_MAG']))? $_REQUEST['P_MAG']: '' ;?>">
</td>
</tr>
<tr>
<td><span class="lib_para">Lieu. exec.</span></td>
<td><input type="text" name="P_OELIEU" size="6" MAXLENGTH="5" value="<?php echo (isset($_REQUEST['P_OELIEU']))? $_REQUEST['P_OELIEU']: '' ;?>"></td>
</tr>
<tr>
<td><span class="lib_para">Date exécution OE, du :</span></td>
<td>
<?php affiche_calendrier("P_JOURDEB","P_JOURFIN",'dd/MM/yyyy');?>
<span class="lib_para"> au :</span>
</td>
<td><?php affiche_calendrier("P_JOURFIN","P_SOC",'dd/MM/yyyy');?></td>
</tr>
</table>
<?php
cloture_formulaire_php('h');
}
//Prise en compte des parametre souhaité par l'utilisateur
if ($_REQUEST['action'] == 'submitted') {
// DEBUT DE REQUETE SQL PERSONNALISEE
$datedeb = substr($_REQUEST['P_JOURDEB'],6,4)."-".substr($_REQUEST['P_JOURDEB'],3,2)."-".substr($_REQUEST['P_JOURDEB'],0,2);
$datefin = substr($_REQUEST['P_JOURFIN'],6,4)."-".substr($_REQUEST['P_JOURFIN'],3,2)."-".substr($_REQUEST['P_JOURFIN'],0,2);
// Lien pour fichier XLS
$url = "'<a href=\"detail.php?P_SOC=\'||SOCIETE_EXC||\'&P_MAG=\'||MAGASIN_EXC||\'&P_OELIEU=\'||SERVICE_EXC||\'&P_JOURDEB=date_deb&P_JOURFIN=date_fin\">Détail</a>' AS DETAIL";
// Restriction
// Gestion date complète
$restrictions = " date(DATE_OE) between '".$datedeb."' and '".$datefin."' ";
// Gestion soc
if ($_REQUEST['P_SOC'] != "") {$restrictions .= " and SOCIETE_EXC = '".strtoupper($_REQUEST['P_SOC'])."' ";}
// Gestion magasin
if ($_REQUEST['P_MAG'] != "") {$restrictions .= " and MAGASIN_EXC = '".strtoupper($_REQUEST['P_MAG'])."' ";}
// Gestion lieu
if ($_REQUEST['P_OELIEU'] != "") {$restrictions .= " and SERVICE_EXC = '".strtoupper($_REQUEST['P_OELIEU'])."' ";}
// Requête
$requete = str_replace('date_fin', $_REQUEST['P_JOURFIN'],
str_replace('date_deb', $_REQUEST['P_JOURDEB'], str_replace("<URL>", $url, str_replace("<RESTRICTIONS>", $restrictions,
'SELECT
SOCIETE_EXC
, MAGASIN_EXC
, SERVICE_EXC
, SERVICE_LIB
, NBOE
, <URL>
FROM
(
SELECT
SOCIETE_EXC
, MAGASIN_EXC
, SERVICE_EXC
, SERVICE_LIB
, COUNT(DISTINCT NUMERO_OE) AS NBOE
FROM NB_DOC
WHERE <RESTRICTIONS>
GROUP BY SOCIETE_EXC, MAGASIN_EXC, SERVICE_EXC, SERVICE_LIB
ORDER BY SOCIETE_EXC, MAGASIN_EXC, SERVICE_EXC
) as SYNTHESE
ORDER BY SOCIETE_EXC, MAGASIN_EXC, SERVICE_EXC', fread ($handle, filesize ($filename))))));
echo $requete;
// Initialisation des en-têtes de colonnes
$nom_field = array("Soc. exec.", "Cent. exec.", "Service exec.", "Libellé service exec.", "Nb OE", "Info");
// FIN DE REQUETE SQL PERSONNALISEE
//Execution de la requete
$connect = connexion($_MYSQL);
$result = mysql_query($requete) or die(mysql_error());
//Format de sortie
include('../format_sortie.php');
}
include("../footer.php");
?> |
Partager