\n";
}
return $img_ajout_empr_caddie;
}
function get_nbpret($id_emprunteur){
global $dbh, $msg;
$rqt = "select count(pret_idexpl) as prets from empr left join pret on pret_idempr=id_empr where id_empr='".$id_emprunteur."' group by id_empr";
$res = mysql_query($rqt,$dbh);
$nb = mysql_fetch_object($res);
return "
".$msg['empr_nb_pret']." : ".$nb->prets."
";
}
// nombre de références par pages
if ($nb_per_page_empr != "")
$nb_per_page = $nb_per_page_empr ;
else
$nb_per_page = 10;
switch ($sub) {
case "launch":
$sc=new search(true,"search_fields_empr");
if ((string)$page=="") {
$_SESSION["CURRENT"]=count($_SESSION["session_history"]);
$_SESSION["session_history"][$_SESSION["CURRENT"]]["QUERY"]["URI"]="./circ.php?categ=search";
$_SESSION["session_history"][$_SESSION["CURRENT"]]["QUERY"]["POST"]=$_POST;
$_SESSION["session_history"][$_SESSION["CURRENT"]]["QUERY"]["GET"]=$_GET;
$_SESSION["session_history"][$_SESSION["CURRENT"]]["QUERY"]["GET"]["sub"]="";
$_SESSION["session_history"][$_SESSION["CURRENT"]]["QUERY"]["POST"]["sub"]="";
$_SESSION["session_history"][$_SESSION["CURRENT"]]["QUERY"]["HUMAN_QUERY"]=$sc->make_human_query();
$_SESSION["session_history"][$_SESSION["CURRENT"]]["QUERY"]["HUMAN_TITLE"]=$msg["search_emprunteur"];
$_POST["page"]=0;
$page=0;
}
if ($_SESSION["CURRENT"]!==false) {
$_SESSION["session_history"][$_SESSION["CURRENT"]]["EMPR"]["URI"]="./circ.php?categ=search&sub=launch";
$_SESSION["session_history"][$_SESSION["CURRENT"]]["EMPR"]["POST"]=$_POST;
$_SESSION["session_history"][$_SESSION["CURRENT"]]["EMPR"]["GET"]=$_GET;
$_SESSION["session_history"][$_SESSION["CURRENT"]]["EMPR"]["PAGE"]=$page+1;
$_SESSION["session_history"][$_SESSION["CURRENT"]]["EMPR"]["HUMAN_QUERY"]=$sc->make_human_query();
$_SESSION["session_history"][$_SESSION["CURRENT"]]["EMPR"]["SEARCH_TYPE"]="empr";
$_SESSION["session_history"][$_SESSION["CURRENT"]]["EMPR"]["TEXT_QUERY"]="";
}
$table=$sc->get_results("./circ.php?categ=search&sub=launch","./circ.php?categ=search",true);
$sc->link ='./circ.php?categ=empr_saisie&id=!!id!!';
$url = "./circ.php?categ=search&sub=launch";
$url_to_search_form = "./circ.php?categ=search";
$search_target="";
if (!$page) $page=1;
$debut =($page-1)*$nb_per_page;
$requete="select count(1) from $table";
$res = mysql_query($requete);
if($res)
$nbr_lignes=mysql_result($res,0,0);
else $nbr_lignes=0;
if ($nbr_lignes) {
$requete="select $table.* from ".$table.", empr where empr.id_empr=$table.id_empr";
//Y-a-t-il une erreur lors de la recherche ?
if ($sc->error_message) {
error_message_history("", $sc->error_message, 1);
exit();
}
print $sc->make_hidden_search_form($url,"form_filters");
$res=mysql_query($requete,$dbh);
$human_requete = $sc->make_human_query();
print "".$msg["search_search_emprunteur"]." : ".$human_requete ;
if ($nbr_lignes) {
print " => ".$nbr_lignes." ".$msg["search_empr_nb_result"]." \n";
$tab_id_empr=array();
while ($row = mysql_fetch_object($res)) {
$tab_id_empr[] = $row->id_empr;
}
$clause = "WHERE id_empr in('".implode("','",$tab_id_empr)."')";
} else print " ".$msg["1915"]." ";
}
break;
default :
if ($form_cb) {
$clause = "WHERE empr_nom like '".str_replace("*", "%", $form_cb)."%' " ;
}
if ($empr_location_id && $pmb_lecteurs_localises)
$clause .= " and empr_location='$empr_location_id'" ;
// on récupére le nombre de lignes qui vont bien
if (!$nbr_lignes) {
$requete = "SELECT COUNT(1) FROM empr $clause ";
$res = mysql_query($requete, $dbh);
$nbr_lignes = @mysql_result($res, 0, 0);
}
break;
}
if (!$page) $page=1;
$debut =($page-1)*$nb_per_page;
if ($nbr_lignes == 1) {
// on lance la vraie requête
$requete = "SELECT id_empr as id FROM empr $clause ";
$res = @mysql_query($requete, $dbh);
$id = @mysql_result($res, '0', 'id');
if ($id) {
$erreur_affichage="
";
$erreur_affichage.=" ";
$erreur_affichage.="
";
if ($id_notice) {
//type_resa : on est en prévision
if ($type_resa)
echo "";
else
echo "";
} elseif($id_bulletin) {
echo "";
} else {
$empr = new emprunteur($id, $erreur_affichage, FALSE, 1);
$affichage = $empr->fiche;
}
}
} else if($nbr_lignes) {
if ($empr_location_id && $pmb_lecteurs_localises) {
$docs_location=new docs_location($empr_location_id);
$where_intitule=$msg["empr_location_intitule"]. " \"".$docs_location->libelle."\"";
} else
$where_intitule="";
if ($empr_show_caddie) {
$script_filters = "
";
} else {
$script_filters = "";
}
$aff_filters="";
if (($empr_sort_rows)||($empr_show_rows)||($empr_filter_rows)) {
require_once($class_path."/filter_list.class.php");
$filter=new filter_list("empr","empr_list",$empr_show_rows,$empr_filter_rows,$empr_sort_rows);
if (!$empr_location_id) $empr_location_id=-1;
if (array_search("l",explode(",",$empr_filter_rows))!==FALSE) {
$lo="f".$filter->fixedfields["l"]["ID"];
global $$lo;
if (!$$lo) {
$tableau=array();
$tableau[0]=$empr_location_id;
$$lo=$tableau;
}
}
$requete = "SELECT id_empr,empr_cb,empr_nom,empr_prenom,empr_adr1,empr_ville,empr_year FROM empr $clause group by id_empr ORDER BY empr_nom, empr_prenom ";
$filter->original_query=$requete;
$filter->page=$page;
$filter->nb_per_page=$nb_per_page;
$filter->multiple=1;
$t=array();
$t["row_even"]["style"]="cursor: pointer";
$t["row_even"]["class"]="even";
$t["row_odd"]["class"]="odd";
$t["row_odd"]["style"]="cursor: pointer";
$t["cols"][0]["style"]="font-weight: bold";
$filter->css=$t;
$t=array();
// si on est en résa on a un id de notice ou de bulletin
if ($id_notice || $id_bulletin) {
//type_resa : on est en prévision
if ($type_resa)
$t["row"]["onmousedown"]="document.location=\"./circ.php?categ=resa_planning&resa_action=add_resa&id_empr=!!id_empr!!&groupID=$groupID&id_notice=$id_notice\";";
else
$t["row"]["onmousedown"]="document.location=\"./circ.php?categ=resa&id_empr=!!id_empr!!&groupID=$groupID&id_notice=$id_notice&id_bulletin=$id_bulletin\";";
} else {
$t["row"]["onmousedown"]="document.location=\"./circ.php?categ=pret&form_cb=!!b!!\";";
}
$t["row"]["onmouseout"]="this.className='!!parity!!'";
$filter->scripts=$t;
$filter->activate_filters();
$filtered_query = $filter->filtered_query;
if ($empr_show_caddie) $script_filters = str_replace("!!filtered_query_hidden!!","", $script_filters);
// ER : trouver ici nbr_lignes
$nbr_lignes = $filter->nb_lines_query();
if (!$filter->error) {
$aff_filters.="";
switch ($sub) {
case "launch":
$url_base = "./circ.php?categ=search&sub=launch";
$aff_filters.="";
if ($empr_show_caddie)
$aff_filters.=" ";
break;
default:
if ($empr_location_id == -1) $empr_location_id = 0;
$url_base = "./circ.php?categ=pret&form_cb=".rawurlencode($form_cb)."&id_notice=$id_notice"."&id_bulletin=$id_bulletin&empr_location_id=$empr_location_id";
$aff_filters.="";
break;
}
$aff_filters.=" ".$filter->make_human_filters();
$aff_filters.=$script_filters;
$empr_list_tmpl=str_replace("!!filters_list!!",$aff_filters,$empr_list_tmpl);
$nav_bar=$filter->display_pager();
$empr_list=$filter->display_result();
} else $empr_list_tmpl=str_replace("!!filters_list!!",$filter->error_message,$empr_list_tmpl);
} else {
// on lance la vraie requête
$requete = "SELECT *, count(pret_idexpl) as nb_pret FROM empr left join pret on id_empr=pret_idempr $clause group by id_empr ORDER BY empr_nom, empr_prenom LIMIT $debut,$nb_per_page ";
$res = @mysql_query($requete, $dbh);
// $nbr_lignes = mysql_num_rows($res);
$parity = 0;
switch ($sub) {
case "launch":
$url_base = "./circ.php?categ=search&sub=launch";
$aff_filters.="";
if ($empr_show_caddie) {
$script_filters = str_replace("!!filtered_query_hidden!!","", $script_filters);
$aff_filters.=" ";
}
$empr_list_tmpl=str_replace("!!filters_list!!",$aff_filters.$script_filters,$empr_list_tmpl);
break;
default:
if ($empr_show_caddie) {
$script_filters = str_replace("!!filtered_query_hidden!!","", $script_filters);
$aff_filters.=" ";
}
$empr_list_tmpl=str_replace("!!filters_list!!",$aff_filters.$script_filters,$empr_list_tmpl);
break;
}
$empr_list .= "
";
while(($empr=mysql_fetch_object($res))) {
$recherche_groupe=@mysql_query("SELECT libelle_groupe FROM empr_groupe, groupe WHERE empr_id=".$empr->id_empr." AND groupe_id=id_groupe ORDER BY libelle_groupe");
$grp=array();
while ($gr=mysql_fetch_object($recherche_groupe)) {
$grp[]=$gr->libelle_groupe;
}
if ($parity % 2) {
$pair_impair = "even";
} else {
$pair_impair = "odd";
}
// si on est en résa on a un id de notice ou de bulletin
if ($id_notice || $id_bulletin) {
//type_resa : on est en prévision
if ($type_resa)
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./circ.php?categ=resa_planning&resa_action=add_resa&id_empr=$empr->id_empr&groupID=$groupID&id_notice=$id_notice';\" ";
else
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./circ.php?categ=resa&id_empr=$empr->id_empr&groupID=$groupID&id_notice=$id_notice&id_bulletin=$id_bulletin';\" ";
} else {
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./circ.php?categ=pret&form_cb=".rawurlencode($empr->empr_cb)."';\" ";
}
// **************** ajout icône ajout panier
$img_ajout_empr_caddie = iconepanier($empr->id_empr);
$empr_list .= "
";
// si on est en résa on a un id de notice ou de bulletin
if ($id_notice || $id_bulletin) {
//type_resa : on est en prévision
if ($type_resa)
$url_base = "./circ.php?categ=resa_planning&resa_action=add_resa&id_empr=$id&groupID=$groupID&id_notice=$id_notice";
else
$url_base = "./circ.php?categ=resa&id_empr=$id&groupID=$groupID&id_notice=$id_notice&id_bulletin=$id_bulletin";
} else {
$url_base = "./circ.php?categ=pret&nbr_lignes=$nbr_lignes&form_cb=".rawurlencode($form_cb)."&empr_location_id=$empr_location_id";
}
$nav_bar = aff_pagination ($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true) ;
}
// affichage du résultat
list_empr($form_cb, $empr_list, $nav_bar, $nbr_lignes, $where_intitule);
} else {
switch($sub) {
case "launch":
$human_requete = $sc->make_human_query();
print "".$msg["search_search_emprunteur"]." : ".$human_requete ;
print $sc->make_hidden_search_form($url,"form_filters");
print " ".$msg[1915]."";
break;
default:
// la requête de recherche d'emprunteur n'a produit aucun résultat
// si on est en résa on a un id de notice ou de bulletin
if ($id_notice || $id_bulletin) {
//type_resa : on est en prévision
if ($type_resa)
get_cb( $msg['prevision_doc'], $msg[34], $msg[circ_tit_form_cb_empr], "./circ.php?categ=pret&id_notice=".$id_notice."&type_resa=1", 0);
else
get_cb( $msg['reserv_doc'], $msg[34], $msg[circ_tit_form_cb_empr], "./circ.php?categ=pret&id_notice=".$id_notice."&id_bulletin=$id_bulletin", 0);
} else {
get_cb( $msg[13], $msg[34], $msg[circ_tit_form_cb_empr], "./circ.php?categ=pret", 0, 0);
}
error_message($msg[46], str_replace('!!form_cb!!', $form_cb, $msg[47]), 0, './circ.php');
break;
}
}