function show_list_coord($id_bibli)
{
    global $msg, $charset;
    global $search_form;
    global $nb_per_page_acq;
    global $class_path;
    global $user_input, $page, $nbr_lignes, $tri_param, $limit_param, $last_param;
    global $tab_bib;
    //Creation selecteur etablissement
    $sel_bibli = "<select class='saisie-50em' id='id_bibli' name='id_bibli' onchange=\"submit();\" >";
    foreach ($tab_bib[0] as $k => $v) {
        $sel_bibli .= "<option value='" . $v . "' ";
        if ($v == $id_bibli) {
            $sel_bibli .= "selected='selected' ";
        }
        $sel_bibli .= ">" . htmlentities($tab_bib[1][$k], ENT_QUOTES, $charset) . "</option>";
    }
    $sel_bibli .= "</select>";
    $search_form = str_replace('<!-- sel_bibli -->', $sel_bibli, $search_form);
    //Affichage form de recherche
    $titre = htmlentities($msg['recherche'] . ' : ' . $msg['acquisition_ach_fou'], ENT_QUOTES, $charset);
    $action = "./acquisition.php?categ=ach&sub=fourn&action=list&user_input=";
    $bouton_add = "<input class='bouton' type='button' value=' " . $msg[acquisition_ajout_fourn] . " ' onclick=\"document.location='./acquisition.php?categ=ach&sub=fourn&action=add&id_bibli=" . $id_bibli . "';\" />";
    $lien_last_fou = "";
    $search_form = str_replace('!!form_title!!', $titre, $search_form);
    $search_form = str_replace('!!action!!', $action, $search_form);
    $search_form = str_replace('<!-- bouton_add -->', $bouton_add, $search_form);
    $search_form = str_replace('<!-- lien_last -->', $lien_last_fou, $search_form);
    $search_form = str_replace('!!user_input!!', $user_input, $search_form);
    print $search_form;
    print "<script type='text/javascript' >document.forms['search'].elements['user_input'].focus();\n\tdocument.forms['search'].elements['user_input'].select();</script>";
    //Prise en compte du formulaire de recherche
    // nombre de références par pages
    if ($nb_per_page_acq != "") {
        $nb_per_page = $nb_per_page_acq;
    } else {
        $nb_per_page = 10;
    }
    // traitement de la saisie utilisateur
    require_once $class_path . "/analyse_query.class.php";
    // on récupére le nombre de lignes qui vont bien
    if (!$nbr_lignes) {
        if (!$user_input) {
            $nbr_lignes = entites::getNbFournisseurs($id_bibli);
        } else {
            $aq = new analyse_query(stripslashes($user_input), 0, 0, 0, 0);
            if ($aq->error) {
                error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message));
                exit;
            }
            $nbr_lignes = entites::getNbFournisseurs($id_bibli, $aq);
        }
    } else {
        $aq = new analyse_query(stripslashes($user_input), 0, 0, 0, 0);
    }
    if (!$page) {
        $page = 1;
    }
    $debut = ($page - 1) * $nb_per_page;
    if ($nbr_lignes) {
        $url_base = "{$PHP_SELF}?categ=ach&sub=fourn&action=list&id_bibli=" . $id_bibli . "&user_input=" . rawurlencode(stripslashes($user_input));
        // on lance la vraie requête
        if (!$user_input) {
            $res = entites::list_fournisseurs($id_bibli, $debut, $nb_per_page);
        } else {
            $res = entites::list_fournisseurs($id_bibli, $debut, $nb_per_page, $aq);
        }
        //Affichage liste des fournisseurs
        print "<table>";
        $nbr = pmb_mysql_num_rows($res);
        $parity = 1;
        for ($i = 0; $i < $nbr; $i++) {
            $row = pmb_mysql_fetch_object($res);
            if ($parity % 2) {
                $pair_impair = "even";
            } else {
                $pair_impair = "odd";
            }
            $parity += 1;
            $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='" . $pair_impair . "'\" ";
            $dn_javascript = " onmousedown=\"document.location='./acquisition.php?categ=ach&sub=fourn&action=modif&id_bibli=" . $id_bibli . "&id=" . $row->id_entite . "'\" ";
            print "<tr class='" . $pair_impair . "' " . $tr_javascript . " >\n\t\t\t\t\t\t<td " . $dn_javascript . " style='cursor: pointer'><i>" . htmlentities($row->raison_sociale, ENT_QUOTES, $charset) . "</i></td>\n\t\t\t\t\t\t<td ><a href='./acquisition.php?categ=ach&sub=fourn&action=cond&id_bibli=" . $id_bibli . "&id=" . $row->id_entite . "' >" . htmlentities($msg['acquisition_cond_fourn'], ENT_QUOTES, $charset) . "</a></td>\n\t\t\t\t\t\t<td ><a href='./acquisition.php?categ=ach&sub=fourn&action=histrel&id_bibli=" . $id_bibli . "&id=" . $row->id_entite . "' >" . htmlentities($msg['acquisition_hist_rel_fou'], ENT_QUOTES, $charset) . "</a></td>\n\t\t\t\t\t</tr>";
        }
        print "</table>";
        if (!$last_param) {
            $nav_bar = aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page);
        } else {
            $nav_bar = "";
        }
        print $nav_bar;
    } else {
        // la requête n'a produit aucun résultat
        error_message($msg['acquisition_fou_rech'], str_replace('!!fou_cle!!', stripslashes($user_input), $msg['acquisition_fou_rech_error']), 0, './categ=ach&sub=fourn&action=list&id_bibli=' . $id_bibli);
    }
}
Example #2
0
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0)
{
    global $nb_per_page;
    global $base_url;
    global $caller;
    global $charset;
    global $msg;
    global $id_bibli;
    //comptage
    if ($user_input == "") {
        $nbr_lignes = entites::getNbFournisseurs($id_bibli);
    } else {
        $aq = new analyse_query(stripslashes($user_input));
        if ($aq->error) {
            error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message));
            exit;
        }
        $nbr_lignes = entites::getNbFournisseurs($id_bibli, $aq);
    }
    if (!$page) {
        $page = 1;
    }
    $debut = ($page - 1) * $nb_per_page;
    if ($nbr_lignes) {
        //liste
        if ($user_input == "") {
            $res = entites::list_fournisseurs($id_bibli, $debut, $nb_per_page);
        } else {
            $res = entites::list_fournisseurs($id_bibli, $debut, $nb_per_page, $aq);
        }
        while ($row = mysql_fetch_object($res)) {
            $entry = $row->raison_sociale;
            $adresse = '';
            if ($caller != 'form_abonnement') {
                $coord = entites::get_coordonnees($row->id_entite, '1');
                if (mysql_num_rows($coord) != 0) {
                    $coord = mysql_fetch_object($coord);
                    if ($coord->libelle != '') {
                        $adresse = htmlentities(addslashes($coord->libelle), ENT_QUOTES, $charset) . "\\n";
                    }
                    if ($coord->contact != '') {
                        $adresse .= htmlentities(addslashes($coord->contact), ENT_QUOTES, $charset) . "\\n";
                    }
                    if ($coord->adr1 != '') {
                        $adresse .= htmlentities(addslashes($coord->adr1), ENT_QUOTES, $charset) . "\\n";
                    }
                    if ($coord->adr2 != '') {
                        $adresse .= htmlentities(addslashes($coord->adr2), ENT_QUOTES, $charset) . "\\n";
                    }
                    if ($coord->cp != '') {
                        $adresse .= htmlentities(addslashes($coord->cp), ENT_QUOTES, $charset) . ' ';
                    }
                    if ($coord->ville != '') {
                        $adresse .= htmlentities(addslashes($coord->ville), ENT_QUOTES, $charset);
                    }
                }
            }
            print pmb_bidi("\n\t\t\t<a href='#' onclick=\"set_parent('{$caller}', '{$row->id_entite}', '" . htmlentities(addslashes($entry), ENT_QUOTES, $charset) . "', '{$adresse}' )\">{$entry}</a>");
            print "<br />";
        }
        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écessaire
        print '<hr /><div align=center>';
        if ($precedente > 0) {
            print "<a href='{$base_url}&page={$precedente}&nbr_lignes={$nbr_lignes}&user_input=" . rawurlencode(stripslashes($user_input)) . "&no_display={$no_display}'><img src='./images/left.gif' border='0' title='{$msg['48']}' alt='[{$msg['48']}]' hspace='3' align='middle' /></a>";
        }
        for ($i = 1; $i <= $nbepages; $i++) {
            if ($i == $page) {
                print "<b>{$i}/{$nbepages}</b>";
            }
        }
        if ($suivante <= $nbepages) {
            print "<a href='{$base_url}&page={$suivante}&nbr_lignes={$nbr_lignes}&user_input=" . rawurlencode(stripslashes($user_input)) . "&no_display={$no_display}'><img src='./images/right.gif' border='0' title='{$msg['49']}' alt='[{$msg['49']}]' hspace='3' align='middle' /></a>";
        }
    }
    print '</div>';
}