basket\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 = pmb_mysql_query($rqt,$dbh); $nb = pmb_mysql_fetch_object($res); return "".$msg['empr_nb_pret']." : ".$nb->prets.""; } $clause = ''; if(!isset($empr_location_id)) $empr_location_id = ''; 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["param_empr"]."] ".$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_LIST_QUERY']=''; $_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=""; $requete="select count(1) from $table"; $res = pmb_mysql_query($requete); if($res) $nbr_lignes=pmb_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_extended"); $res=pmb_mysql_query($requete); $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 = pmb_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) { $elts = explode(' ', $form_cb); if(count($elts)>1) { $sql_elts = array(); foreach ($elts as $elt) { $elt = str_replace("*", "%", trim($elt)); if($elt) { $sql_elts[] = "(empr_nom like '".$elt."%' OR empr_nom like '% ".$elt."%' OR empr_nom like '%-".$elt."%' OR empr_prenom like '".$elt."%' OR empr_prenom like '% ".$elt."%' OR empr_prenom like '%-".$elt."%')"; } } if(count($sql_elts)) { $clause = "WHERE ((".implode(' AND ',$sql_elts).") OR empr_cb like '".str_replace("*", "%", $form_cb)."%')" ; } } if(!$clause) { $elt = str_replace("*", "%", $form_cb); $clause = "WHERE (empr_nom like '".$elt."%' OR empr_nom like '%-".$elt."%' OR empr_prenom like '".$elt."%' OR empr_prenom like '%-".$elt."%' OR empr_cb like '".$elt."%')" ; } /** * Publication d'un évenement à l'affichage d'un lecteur */ $evt_handler = events_handler::get_instance(); $event = new event_query_overload("empr", "search_query_overload"); $evt_handler->send($event); if($event->get_query_overload()){ $clause.= $event->get_query_overload(); } } 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 (!isset($nbr_lignes)) { $requete = "SELECT COUNT(1) FROM empr $clause "; $res = pmb_mysql_query($requete); $nbr_lignes = @pmb_mysql_result($res, 0, 0); } break; } if ($nbr_lignes == 1) { // on lance la vraie requête $requete = "SELECT id_empr as id FROM empr $clause "; $res = @pmb_mysql_query($requete); $id = @pmb_mysql_result($res, '0', 'id'); if ($id) { $erreur_affichage="
   "; $erreur_affichage.="  "; $erreur_affichage.="
"; if ($id_notice || $id_bulletin) { //type_resa : on est en prévision if ($type_resa) { echo ""; } else { echo ""; } } else { $empr = new emprunteur($id, $erreur_affichage, FALSE, 1); $affichage = $empr->fiche; } } } else if($nbr_lignes) { $aff_search_back=""; if (($empr_sort_rows)||($empr_show_rows)||($empr_filter_rows)) { $filter = emprunteur::get_instance_filter_list($clause); list_readers_circ_ui::set_used_filter_list_mode(true); list_readers_circ_ui::set_filter_list($filter); // ER : trouver ici nbr_lignes $nbr_lignes = $filter->nb_lines_query(); if (!$filter->error) { switch ($sub) { case "launch": $aff_search_back.=""; break; default: if ($empr_location_id == -1) $empr_location_id = 0; break; } } } else { switch ($sub) { case "launch": $aff_search_back.=""; break; default: break; } } // affichage du résultat $filters = array(); $filters['simple_search'] = (!empty($form_cb) ? $form_cb : ''); if ($empr_location_id && $pmb_lecteurs_localises) { $filters['empr_location_id'] = $empr_location_id; } if(!empty($tab_id_empr)) { $filters['empr_ids'] = $tab_id_empr; } elseif(!empty($_POST['form_cb'])) { // en provenance de la recherche simple (POST de la variable), on élimine l'éventuel filtre sur une précédente recherche avancée $filters['empr_ids'] = array(); } $list_readers_circ_ui = new list_readers_circ_ui($filters); print $aff_search_back; print $list_readers_circ_ui->get_display_list(); } 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&id_bulletin=$id_bulletin&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; } }