";
$requete_vue = "select * from statopac_vues";
$res = mysql_query($requete_vue,$dbh);
$vue_affichage="";
if(mysql_num_rows($res) == 0){
$vue_affichage="
".$msg["stat_no_view_created"]."
";
return $vue_affichage;
} else {
$vue_affichage="";
$parity=1;
while(($vue = mysql_fetch_object($res))){
$rqt="select * from statopac_request where num_vue='".addslashes($vue->id_vue)."'";
$result = mysql_query($rqt);
$liste_requete ="";
while(($request = mysql_fetch_object($result))){
if ($parity % 2) {
$pair_impair = "even";
} else {
$pair_impair = "odd";
}
$parity++;
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./edit.php?categ=stat_opac&sub=&action=execute&id_proc=$request->idproc';\" ";
$liste_requete.="\n
$request->name
$request->comment |
";
}
if($liste_requete){
$tab_list="".stripslashes(htmlentities($vue->nom_vue,ENT_QUOTES))." |
".$liste_requete."
";
$vue_affichage .= "";
$lien = stripslashes(htmlentities($vue->nom_vue,ENT_QUOTES));
$space = "
";
$vue_affichage .= "
id_vue."',true);return false;\" title='requete' name='imEx' src=\"./images/plus.gif\" >";
$vue_affichage .= "$space
$lien";
$vue_affichage .= "
";
$vue_affichage .= "$tab_list
";
}
}
}
return $vue_affichage;
}
function show_results_stats($id_proc=0){
global $msg, $dbh, $form_type, $categ, $numero_page,$limite_page, $sub;
@set_time_limit ($pmb_set_time_limit);
//Récupération des variables postées, on en aura besoin pour les liens
$page=$_SERVER[SCRIPT_NAME];
$requete = "SELECT idproc, name, requete, comment, num_vue FROM statopac_request where idproc='".$id_proc."' ";
$res = mysql_query($requete, $dbh);
$row=mysql_fetch_row($res);
//Requete et calcul du nombre de pages à afficher selon la taille de la base 'pret'
//********************************************************************************/
// récupérer ici la procédure à lancer
$sql = $row[2];
$sql = str_replace("VUE()","statopac_vue_$row[4]",$sql);
if (preg_match_all("|!!(.*)!!|U",$sql,$query_parameters) && $form_type=="") {
$hp=new parameters($id_proc,"statopac_request");
$hp->gen_form("edit.php?categ=stat_opac&sub=&action=execute&id_proc=$id_proc");
} else {
if (preg_match_all("|!!(.*)!!|U",$sql,$query_parameters)) {
$hp=new parameters($id_proc,"statopac_request");
$hp->get_final_query();
$sql=$hp->final_query;
$isparameters=1;
}
$sql = str_replace("VUE()","statopac_vue_$row[4]",$sql);
// la procédure n'a pas de parm ou les paramètres ont été reçus
if (!explain_requete($sql)) die("
".$sql."
".$msg["proc_param_explain_failed"]."
".$erreur_explain_rqt);
$req_nombre_lignes = mysql_query($sql, $dbh);
$nombre_lignes = mysql_numrows($req_nombre_lignes);
//Si aucune limite_page n'a été passée, valeur par défaut : 10
if (!$limite_page) $limite_page = 10;
$nbpages= $nombre_lignes / $limite_page;
// on arondi le nombre de page pour ne pas avoir de virgules, ici au chiffre supérieur
$nbpages_arrondi = ceil($nbpages);
// on enlève 1 au nombre de pages, car la 1ere page affichée ne fait pas partie des pages suivantes
$nbpages_arrondi = $nbpages_arrondi - 1;
if (!$numero_page) $numero_page=0;
$limite_mysql = $limite_page * $numero_page;
//REINITIALISATION DE LA REQUETE SQL
switch($dest) {
case "TABLEAU":
case "TABLEAUHTML":
case "TABLEAUCSV":
break;
default:
echo "$row[1]
$row[3]
";
$sql = $sql." LIMIT ".$limite_mysql.", ".$limite_page;
echo "";
break;
}
// on compte tout et on avise
if (!explain_requete($sql)) die("
".$sql."
".$msg["proc_param_explain_failed"]);
$res = @mysql_query($sql, $dbh) or die($sql."
".mysql_error());
$nbr_lignes = @mysql_num_rows($res);
$nbr_champs = @mysql_num_fields($res);
if ($nbr_lignes) {
switch($dest) {
case "TABLEAU":
$worksheet->write(0,0,$row[1]);
$worksheet->write(0,1,$row[3]);
for($i=0; $i < $nbr_champs; $i++) {
// entête de colonnes
$fieldname = mysql_field_name($res, $i);
$worksheet->write(1,$i,${fieldname});
}
for($i=0; $i < $nbr_lignes; $i++) {
$row = mysql_fetch_row($res);
$j=0;
foreach($row as $dummykey=>$col) {
if(trim($col)=='') $col=" ";
$worksheet->write(($i+2),$j,$col);
$j++;
}
}
$workbook->close();
header("Content-Type: application/x-msexcel; name=\""."Procedure_$id_proc".".xls"."\"");
header("Content-Disposition: inline; filename=\""."Procedure_$id_proc".".xls"."\"");
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
break;
case "TABLEAUHTML":
echo "
$row[1]
$row[3]
$sql
";
echo "";
for($i=0; $i < $nbr_champs; $i++) {
$fieldname = mysql_field_name($res, $i);
print("${fieldname} | ");
}
for($i=0; $i < $nbr_lignes; $i++) {
$row = mysql_fetch_row($res);
echo "";
foreach($row as $dummykey=>$col) {
if (is_numeric($col)){
$col = "'".$col ;
}
if(trim($col)=='') $col=" ";
print ''.$col.' | ';
}
echo "
";
}
echo "
";
break;
case "TABLEAUCSV":
for($i=0; $i < $nbr_champs; $i++) {
$fieldname = mysql_field_name($res, $i);
print("${fieldname}\t");
}
for($i=0; $i < $nbr_lignes; $i++) {
$row = mysql_fetch_row($res);
echo "\n";
foreach($row as $dummykey=>$col) {
/* if (is_numeric($col)) {
$col = "\"'".(string)$col."\"" ;
} */
print "$col\t";
}
}
break;
default:
echo "";
for($i=0; $i < $nbr_champs; $i++) {
$fieldname = mysql_field_name($res, $i);
print("${fieldname} | ");
}
$odd_even=0;
for($i=0; $i < $nbr_lignes; $i++) {
$row = mysql_fetch_row($res);
if ($odd_even==0) {
echo " ";
$odd_even=1;
} elseif ($odd_even==1) {
echo "
";
$odd_even=0;
}
foreach($row as $dummykey=>$col) {
if(trim($col)=='') $col=" ";
print ''.$col.' | ';
}
echo "
";
}
echo "
";
echo "
";
break;
}
} else {
echo $msg["etatperso_aucuneligne"];
}
mysql_free_result ($res);
}
}
if(!$id_proc){
print show_stats($dbh);
} else {
print show_results_stats($id_proc);
}
?>