addworksheet();
$worksheet->write(0,0,$titre_page);
break;
case "TABLEAUHTML":
echo "
".$titre_page."
" ;
break;
default:
echo "
".$titre_page."
" ;
break;
}
// Pour localiser les éditions : $deflt2docs_location, $pmb_lecteurs_localises, $empr_location_id ;
// Calcul du nombre de pages à afficher
$sql = "SELECT count(1) ";
$sql.= "FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) ";
$sql.= "LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) ";
$sql.= "LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), ";
$sql.= "docs_type , pret, empr ";
$sql.= "WHERE ";
if ($pmb_lecteurs_localises) {
if ($empr_location_id=="")
$empr_location_id = $deflt2docs_location ;
if ($empr_location_id!=0)
$sql.= "empr_location='$empr_location_id' AND ";
}
$sql.= "expl_typdoc = idtyp_doc and pret_idexpl = expl_id and empr.id_empr = pret.pret_idempr ";
$sql.= $critere_requete;
$req_nombre_lignes_pret = mysql_query($sql, $dbh);
$nombre_lignes_pret = mysql_result($req_nombre_lignes_pret, 0, 0);
//Si aucune limite_page n'a été passée, valeur par défaut : 10
if ($limite_page=="") {
$limite_page = 10;
}
$nbpages= $nombre_lignes_pret / $limite_page;
// on arrondit 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;
// si la variable numero de page a une valeur ou est différente de 0,
// on multiplie la limite par le numero de la page passée par l'url
// sinon, pas de variable numero_page
if(isset($numero_page) || $numero_page != 0 ) {
$limite_mysql = $limite_page * $numero_page;
} else {
$limite_mysql = 0; // la limite est de 0
}
// Comptage retard/en cours
$sql_count = "SELECT IF(pret_retour>=CURDATE(),'ENCOURS','RETARDS') as retard, count(pret_idexpl) as combien ";
$sql_count.= "FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) ";
$sql_count.= "LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) ";
$sql_count.= "LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), ";
$sql_count.= "pret, empr ";
$sql_count.= "WHERE ";
if ($pmb_lecteurs_localises) {
if ($empr_location_id!=0)
$sql_count.= "empr_location='$empr_location_id' AND ";
}
$sql_count.= "pret_idexpl = expl_id and empr.id_empr = pret.pret_idempr ";
$sql_count.=(($pmb_short_loan_management==1 && strpos($sub,'short_loans')!==false)?"and short_loan_flag='1' ":' ');
$sql_count.= "group by retard ";
$req_count = mysql_query($sql_count) or die("Erreur SQL ! ".$sql_count." ".mysql_error());
while ($data_count = mysql_fetch_object($req_count)) {
$nbtotal_prets[$data_count->retard]=$data_count->combien;
}
// construction du message ## prêts en retard sur un total de ##
$msg['n_retards_sur_total_de'] = str_replace ("!!nb_retards!!",$nbtotal_prets['RETARDS']*1,$msg['n_retards_sur_total_de']);
$msg['n_retards_sur_total_de'] = str_replace ("!!nb_total!!",($nbtotal_prets['RETARDS']+$nbtotal_prets[ENCOURS])*1,$msg['n_retards_sur_total_de']);
//REINITIALISATION DE LA REQUETE SQL
$sql = "SELECT date_format(pret_date, '".$msg['format_date']."') as aff_pret_date, ";
$sql .= "date_format(pret_retour, '".$msg['format_date']."') as aff_pret_retour, ";
$sql .= "IF(pret_retour>=CURDATE(),0,1) as retard, ";
$sql .= "id_empr, empr_nom, empr_prenom, empr_mail, id_empr, empr_cb, expl_cote, expl_cb, expl_notice, expl_bulletin, notices_m.notice_id as idnot, trim(concat(ifnull(notices_m.tit1,''),ifnull(notices_s.tit1,''),' ',ifnull(bulletin_numero,''), if (mention_date, concat(' (',mention_date,')') ,''))) as tit, tdoc_libelle, ";
$sql .= "short_loan_flag ";
$sql .= "FROM (((exemplaires LEFT JOIN notices AS notices_m ON expl_notice = notices_m.notice_id ) ";
$sql .= "LEFT JOIN bulletins ON expl_bulletin = bulletins.bulletin_id) ";
$sql .= "LEFT JOIN notices AS notices_s ON bulletin_notice = notices_s.notice_id), ";
$sql .= "docs_type, pret, empr ";
$sql .= "WHERE ";
if ($pmb_lecteurs_localises) {
if ($empr_location_id!=0)
$sql.= "empr_location='$empr_location_id' AND ";
}
$sql.= "expl_typdoc = idtyp_doc and pret_idexpl = expl_id and empr.id_empr = pret.pret_idempr ";
$sql.= $critere_requete;
if ($nombre_lignes_pret > 0) {
switch($dest) {
case "TABLEAU":
$res = @mysql_query($sql, $dbh);
$nbr_champs = @mysql_num_fields($res);
for($n=0; $n < $nbr_champs; $n++) {
$worksheet->write(2,$n,mysql_field_name($res,$n));
}
for($i=0; $i < $nombre_lignes_pret; $i++) {
$row = mysql_fetch_row($res);
$j=0;
foreach($row as $dummykey=>$col) {
if(!$col) $col=" ";
$worksheet->write(($i+3),$j,$col);
$j++;
}
}
$workbook->close();
$fh=fopen($fname, "rb");
fpassthru($fh);
unlink($fname);
break;
case "TABLEAUHTML":
$res = @mysql_query($sql, $dbh);
$expl_list .= "