* ***************************************************************************** */ $module = FtaModel::TABLENAME; if (!$module_table) { $module_table = $module; } $etat_table = FtaEtatModel::TABLENAME; $id_recherche = FtaModel::KEYNAME; $id_recherche_etat = FtaEtatModel::KEYNAME; $abreviation_recherche_etat = FtaEtatModel::FIELDNAME_ABREVIATION; $nom_recherche_recherche_etat = FtaEtatModel::FIELDNAME_NOM_FTA_ETAT; if (!$champ_retour) { $champ_retour = FtaModel::TABLENAME . '.' . FtaModel::KEYNAME; } $image_bordure = "../lib/images/s7.gif"; $image_recherche = "../lib/images/search.gif"; $nb_limite_resultat = ModuleConfig::VALUE_MAX_PAR_PAGE; $html_search = MoteurDeRecherche::afficherMoteurDeRecherche($module, $id_recherche, $etat_table, $id_recherche_etat, $abreviation_recherche_etat, $nom_recherche_recherche_etat, $image_bordure, $image_recherche, $champ_retour, $nb_limite_resultat, $url_page_depart, $QUERY_STRING, $PHP_SELF, $nbligne, $nbcol, $champ_recherche, $operateur_recherche, $texte_recherche, $champ_courant, $operateur_courant, $texte_courant, $nb_col_courant, $ajout_col, $requete_resultat, $tab_resultat, $module_table, $nb_ligne_courant); echo $html_search; /* * ***************************************************************************** TABLEAU DE SYNTHESE * ***************************************************************************** */ /* * ********** Fin Code HTML * ********** */ /* * ********************* Inclusion de fin de page * ********************* */ include "../lib/fin_page.inc"; ?>
/** * MOTEUR DE RECHERCHE * Cette fonction retourne l'affiche de l'interface du moteur de recherche * @param type $module * @param type $id_recherche * @param type $etat_table * @param type $id_recherche_etat * @param type $abreviation_recherche_etat * @param type $nom_recherche_recherche_etat * @param string $paramImageBordure * @param string $paramImageRecherche * @param type $champ_retour * @param int $paramNbLimiteDeResultat * @param type $url_page_depart * @param type $QUERY_STRING * @param type $PHP_SELF * @param type $nbligne * @param type $nbcol * @param type $champ_recherche * @param type $operateur_recherche * @param type $texte_recherche * @param type $champ_courant * @param type $operateur_courant * @param type $texte_courant * @param type $nb_col_courant * @param type $ajout_col * @param type $paramRequete * @param type $tab_resultat * @param type $module_table * @return type */ public static function afficherMoteurDeRecherche($module, $id_recherche, $etat_table, $id_recherche_etat, $abreviation_recherche_etat, $nom_recherche_recherche_etat, $paramImageBordure, $paramImageRecherche, $champ_retour, $paramNbLimiteDeResultat, $url_page_depart, $QUERY_STRING, $PHP_SELF, $nbligne, $nbcol, $champ_recherche, $operateur_recherche, $texte_recherche, $champ_courant, $operateur_courant, $texte_courant, $nb_col_courant, $ajout_col, $paramRequete, $tab_resultat, $module_table, $nb_ligne_courant) { /* Définition des Variables */ if ($url_page_depart == '') { if ($QUERY_STRING) { $url_page_depart = '(' . $PHP_SELF . '?' . $QUERY_STRING . ')'; } else { $url_page_depart = '(' . $PHP_SELF . ')'; } } $return = ""; $_REQUEST['table_champ_retour'] = $module_table; // table du champ retour $_REQUEST['table_tous_champs_rech'] = $module_table . "_moteur_de_recherche"; $tab_resultat; //Construction du code HTML $return .= "\n <center>\n <img src=" . $paramImageBordure . ">                        \n <img src=" . $paramImageBordure . ">                        \n <img src=" . $paramImageBordure . ">                        \n <img src=" . $paramImageBordure . ">                        \n <img src=" . $paramImageBordure . ">                        \n <img src=" . $paramImageBordure . ">                        \n <img src=" . $paramImageBordure . ">\n <br>\n </center>\n <center>\n <table width=100% border=1 valign=top cellspacing=0>\n <tr>\n <td class=titre_principal><img src=" . $paramImageRecherche . " WIDTH=70 HEIGHT=50 align=left> <br> Recherche <br><br></td>\n </tr>\n <tr>\n <td colspan=3> "; $return .= MoteurDeRecherche::recuperationDesDonneesDeRecherche($module, $url_page_depart, $module_table, $champ_retour, $paramNbLimiteDeResultat, $nbligne, $nbcol, $champ_recherche, $operateur_recherche, $texte_recherche, $champ_courant, $operateur_courant, $texte_courant, $nb_col_courant, $nb_ligne_courant, $ajout_col); $return .= "</td>\n </tr>\n </table>\n "; if ($tab_resultat) { $tab_resultat = explode(';;', $tab_resultat); } $return .= "\n <table width=100% border=1 valign=top cellspacing=0>\n <tr>\n <td class=titre_principal> <br> Résultats <br><br></td>\n </tr>\n "; $choix = -1; // pour que l'on affiche les entetes du tableau une seule fois if ($paramRequete) { //On vérifie si le résultat n'est pas nul $result_requete_resultat = DatabaseOperation::convertSqlStatementWithoutKeyToArray($paramRequete); if (!$result_requete_resultat) { $titre = 'Moteur de Recherche'; $message = UserInterfaceMessage::FR_WARNING_RECHERE_ERREUR; Lib::showMessage($titre, $message, $redirection); } elseif (count($result_requete_resultat) > ModuleConfig::VALUE_MAX_MOTEUR_RECHERCHE) { $message = UserInterfaceMessage::FR_WARNING_RECHERE . ModuleConfig::VALUE_MAX_MOTEUR_RECHERCHE; $redirection = "recherche.php"; Lib::showMessage("Erreur", $message, $redirection); } //Regroupement par Etat du résultat $req = "SELECT * FROM {$etat_table} "; //Spécificité propre au module FTMP //Restriction par droit d'accès // $acces= $module."_modification"; // echo $SESSION[$acces]; if (!Acl::getValueAccesRights($module . "_modification") and $_SESSION["module"] == "fiches_mp_achats") { $req .= "WHERE " . $abreviation_recherche_etat . "='V' OR " . $abreviation_recherche_etat . "='E' "; } $result = DatabaseOperation::convertSqlStatementWithoutKeyToArray($req); foreach ($result as $rows) { //Construction de la reqûete de resultat propre à cet Etat $req1 = "{$paramRequete} AND " . $id_recherche_etat . "=" . $rows[$id_recherche_etat]; $arrayFta = DatabaseOperation::convertSqlStatementWithoutKeyToArray($req1); //Si il y a des résltat on commence la construction du tableau if ($arrayFta) { //Affichage de l'en-tête de regroupement $return .= "<tr><td class=titre>" . $rows["nom_" . $etat_table] . "</td></tr>"; //Affichage des fiches foreach ($arrayFta as $rowsFta) { //echo $choix; $return .= "<tr><td>" . TableauFicheView::getHtmlTable($rowsFta[$id_recherche], $choix, "0", "") . "</td></tr>"; } } $return .= "<br>"; } // Fin de l'affichage des résultats; } //Dans le cas où un résultat de recherche est proposé, affichage du tableau //if ($tab_resultat){ $return .= "</td></tr>\n </table>\n <br>\n <img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . ">\n <img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . ">\n <img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . ">\n <img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . "><img src=" . $paramImageBordure . ">\n "; return $return; /* * ***************************************************************************** FIN MOTEUR DE RECHERCHE * ***************************************************************************** */ }
// Récuperation du nom du champ correspondant a l'identifiant // contenu dans $champ_recherche[$i][$j] $tmp = $champ_recherche[$i][$j]; $nom1 = 'nom_champ_moteur_de_recherche'; $nom1bis = 'table_moteur_de_recherche'; $nom2 = $module_table . '_moteur_de_recherche'; $nom3 = 'id_moteur_de_recherche'; $sql = " SELECT {$nom1},{$nom1bis}\n FROM {$nom2}\n WHERE {$nom3} =' {$tmp}'"; //$res= DatabaseOperation::query($sql)or die('Erreur SQL !'.$sql.'<br>'.mysql_error()) ; $res = DatabaseOperation::convertSqlStatementKeyAndOneFieldToArray($sql); //nom du champ foreach ($res as $champ) { // recuperation des jointures //echo $GLOBALS['table_champ_retour']; // table du champ retour //echo $GLOBALS['table_tous_champs_rech']; $join[$j] = MoteurDeRecherche::rechercheDeJointure($champ[0], $url_page_depart, $module, $table_champ_retour, $table_tous_champs_rech); // Recuperation de l'operateur $tmp = $operateur_recherche[$i][$j]; $sql2 = " SELECT valeur_intranet_moteur_de_recherche_operateur_sur_champ\n FROM intranet_moteur_de_recherche_operateur_sur_champ\n WHERE id_intranet_moteur_de_recherche_operateur_sur_champ=' {$tmp}'"; //$res2= DatabaseOperation::query( $sql2)or die('Erreur SQL !'.$sql2.'<br>'.mysql_error()) ; $res2 = DatabaseOperation::convertSqlStatementKeyAndOneFieldToArray($sql2); //operateur foreach ($res2 as $operateur) { $table_et_champ = $champ[1] . '.' . $champ[0]; switch ($operateur_recherche[$i][$j]) { case 1: $where .= $table_et_champ . ' LIKE ( \'%' . $texte_recherche[$i][$j] . '%\' ) '; break; case 2: $where .= $table_et_champ . ' NOT LIKE ( \'%' . $texte_recherche[$i][$j] . '%\' ) '; break;