addworksheet();
$worksheet->write(0,0,$titre_page);
break;
case "TABLEAUHTML":
echo "
".$titre_page." " ;
break;
default:
echo "".$titre_page." " ;
break;
}
// nombre de références par pages
if ($nb_per_page_empr != "")
$nb_per_page = $nb_per_page_empr ;
else
$nb_per_page = 10;
// restriction localisation le cas échéant
if ($pmb_lecteurs_localises) {
if ($empr_location_id=="")
$empr_location_id = $deflt2docs_location ;
if ($empr_location_id!=0)
$restrict_localisation = " AND empr_location='$empr_location_id' ";
else
$restrict_localisation = "";
}
// filtré par un statut sélectionné
if ($empr_statut_edit) {
if ($empr_statut_edit!=0)
$restrict_statut = " AND empr_statut='$empr_statut_edit' ";
else
$restrict_statut="";
}
// on récupére le nombre de lignes
if(!$nbr_lignes) {
$requete = "SELECT COUNT(1) FROM empr, empr_statut, empr_categ where empr.empr_categ=empr_categ.id_categ_empr ";
$requete = $requete.$restrict_localisation.$restrict_statut." and ".$restrict;
$requete .= " and empr_statut=idstatut";
$res = mysql_query($requete, $dbh);
$nbr_lignes = @mysql_result($res, 0, 0);
}
//Si aucune limite_page n'a été passée, valeur par défaut $nb_per_page
if (!$limite_page)
$limite_page = $nb_per_page;
else
$nb_per_page = $limite_page;
$nbpages= $nbr_lignes / $limite_page;
if(!$page) $page=1;
$debut =($page-1)*$nb_per_page;
if($nbr_lignes) {
if ($statut_action=="modify") {
$requete="UPDATE empr, empr_categ set empr_statut='$empr_chang_statut_edit' where empr.empr_categ=empr_categ.id_categ_empr ".$restrict_localisation.$restrict_statut." and ".$restrict;
$restrict_statut = " AND empr_statut='$empr_chang_statut_edit' ";
@mysql_query($requete);
}
// on lance la vraie requête
$requete = "SELECT empr.*, date_format(empr_date_adhesion, '".$msg["format_date"]."') as aff_empr_date_adhesion, date_format(empr_date_expiration, '".$msg["format_date"]."') as aff_empr_date_expiration, statut_libelle, empr_categ.libelle as categ_libelle FROM empr, empr_statut, empr_categ ";
$restrict_empr = " WHERE empr.empr_categ=empr_categ.id_categ_empr ";
$restrict_requete = $restrict_empr.$restrict_localisation.$restrict_statut." and ".$restrict;
$requete .= $restrict_requete;
$requete .= " and empr_statut=idstatut ";
if (!isset($sortby))
$sortby = 'empr_nom';
$requete .= " ORDER BY $sortby ";
switch($dest) {
case "TABLEAU":
$res = @mysql_query($requete, $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 < $nbr_lignes; $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($requete, $dbh);
$empr_list = "" ;
$empr_list .="
$msg[code_barre_empr]
$msg[nom_prenom_empr]
$msg[adresse_empr]
$msg[ville_empr]
$msg[year_empr]
$msg[readerlist_dateexpiration]
$msg[statut_empr]
";
while(($empr=mysql_fetch_object($res))) {
$empr_list .= "";
$empr_list .= "
$empr->empr_cb
$empr->empr_nom $empr->empr_prenom
$empr->empr_adr1
$empr->empr_adr2
$empr->empr_ville
$empr->empr_year ";
$empr_list .= "".$empr->aff_empr_date_expiration." ";
$empr_list .= "".$empr->statut_libelle." ";
$empr_list .= " ";
}
$empr_list .= "
" ;
echo $empr_list ;
break;
default:
$requete .= "LIMIT $debut,$nb_per_page ";
$res = @mysql_query($requete, $dbh);
$parity=1;
$empr_list .="
$msg[code_barre_empr]
$msg[nom_prenom_empr]
$msg[adresse_empr]
$msg[ville_empr]
$msg[year_empr]
$msg[readerlist_dateexpiration]
$msg[statut_empr] ";
switch ($sub) {
case "encours" :
$empr_list .=" ";
break;
case "categ_change" :
$empr_list .="$msg[categ_empr]
$msg[empr_categ_change_prochain] ";
break;
default :
$empr_list .=" ";
break;
}
$empr_list .=" ";
while(($empr=mysql_fetch_object($res))) {
if ($parity % 2)
$pair_impair = "even";
else
$pair_impair = "odd";
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" ";
$script="onclick=\"document.location='./circ.php?categ=pret&form_cb=".rawurlencode($empr->empr_cb)."';\"";
$empr_list .= "";
$empr_list .= "
$empr->empr_cb
$empr->empr_nom $empr->empr_prenom
$empr->empr_adr1
$empr->empr_ville
$empr->empr_year ";
$empr_list .= "".$empr->aff_empr_date_expiration." ";
$empr_list .= "".$empr->statut_libelle." ";
switch ($sub) {
case "encours" :
$empr_list .= ""." ";
break;
case "categ_change" :
$empr_list.="".$empr->categ_libelle." ";
$empr_list.="";
$today = getdate();
$age_lecteur = $today["year"] - $empr->empr_year;
// on construit le select catégorie
$query = "SELECT id_categ_empr, libelle FROM empr_categ WHERE (".$age_lecteur." >= age_min or age_min=0) and (".$age_lecteur." <= age_max or age_max=0) ORDER BY age_min ";
$result = mysql_query($query, $dbh);
$nbr_rows = mysql_num_rows($result);
$empr_list.= " ";
$empr_list .= "";
$empr_list .="".$msg["change_categ_do_nothing"]." ";
for($i=0; $i < $nbr_rows; $i++) {
$row = mysql_fetch_row($result);
$empr_list.= " ";
break;
default :
$empr_list.="";
$action_relance_courrier = "onclick=\"openPopUp('./pdf.php?pdfdoc=lettre_relance_adhesion&id_empr=".$empr->id_empr."', 'lettre', 600, 500, -2, -2, 'toolbar=no, dependent=yes, resizable=yes'); return(false) \"";
$empr_list .= " ";
if ($empr->empr_mail) {
$mail_click = "onclick=\"if (confirm('".$msg["mail_retard_confirm"]."')) {openPopUp('./mail.php?type_mail=mail_relance_adhesion&id_empr=".$empr->id_empr."', 'mail', 600, 500, -2, -2, 'toolbar=no, dependent=yes, resizable=yes, scrollbars=yes');} return(false) \"";
$empr_list .= " ";
}
$empr_list.=" ";
$empr_list .= ""." ";
break;
}
$empr_list .= " ";
$parity += 1;
}
mysql_free_result($res);
// constitution des liens
$nbepages = ceil($nbr_lignes/$nb_per_page);
$suivante = $page+1;
$precedente = $page-1;
// affichage du lien précédent si nécéssaire
if($precedente > 0)
$nav_bar .= " ";
for($i = 1; $i <= $nbepages; $i++) {
if($i==$page)
$nav_bar .= "page $i/$nbepages ";
}
if($suivante<=$nbepages)
$nav_bar .= " ";
// affichage du résultat
echo "
";
print "";
switch ($sub) {
case "categ_change" :
print pmb_bidi("");
break;
default :
print pmb_bidi("");
break;
}
echo "
";
break;
} //switch($dest)
} else {
// la requête n'a produit aucun résultat
switch($dest) {
case "TABLEAU":
break;
case "TABLEAUHTML":
break;
default:
error_message($msg[46], str_replace('!!form_cb!!', $form_cb, $msg['edit_lect_aucun_trouve']), 1, './edit.php?categ=empr&sub='.$sub);
}
}