function getTab()
 {
     $tab['id_evenement'] = $this->id_evenement;
     $tab['id_utilisateur'] = $this->id_utilisateur;
     $tab['id_pere'] = $this->id_pere;
     $tab['type_pere'] = $this->type_pere;
     $tab['date_evenement'] = $this->date_evenement;
     $tab['type_evenement'] = Sql_prepareTexteAffichage($this->type_evenement);
     $tab['info_evenement'] = Sql_prepareTexteAffichage($this->info_evenement);
     return $tab;
 }
 function Arbo_construire($code_arbo = '', $type = 'article')
 {
     /*=============*/
     Lib_myLog("Recuperation de l'arbo a partir de la BDD");
     if ($type == 'tache') {
         // On récupère tous les taches de la base
         $args_taches['id_tache'] = '*';
         $liste_taches = Taches_chercher($args_taches);
         $tab_intitules = array();
         foreach ($liste_taches as $tache) {
             $tab_intitules[$tache['id_tache']] = $tache['titre'];
             $tab_etats[$tache['id_tache']] = $tache['etat'];
             $tab_priorites[$tache['id_tache']] = $tache['data1'];
         }
     }
     if ($type == 'article') {
         // On récupère tous les articles de la base
         $args_articles['id_article'] = '*';
         $liste_articles = Articles_chercher($args_articles);
         $tab_intitules = array();
         $tab_urls = array();
         foreach ($liste_articles as $article) {
             $tab_intitules[$article['id_article']] = $article['titre'];
             $tab_etats[$article['id_article']] = $article['etat'];
             $tab_urls[$article['id_article']] = $article['meta_url'];
         }
     }
     $sql = " SELECT * \n\t\t\tFROM " . $GLOBALS['prefix'] . "arbo\n\t\t\tWHERE code_arbo = '{$code_arbo}'\n\t\t\tORDER BY famille ASC, ordre ASC";
     $result = Sql_query($sql);
     $tab_sql = array();
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_arbo'];
             $id_pere = $row['id_pere'];
             $type_pere = $row['type_pere'];
             $tab_sql[$id]["id_arbo"] = $id;
             $tab_sql[$id]["id_arbo_pere"] = $row['id_arbo_pere'];
             $tab_sql[$id]["code_arbo"] = $row['code_arbo'];
             $tab_sql[$id]["famille"] = $row['famille'];
             $tab_sql[$id]["id_pere"] = $id_pere;
             if ($type == 'tache') {
                 $tab_sql[$id]["tache"] = $liste_taches[$id_pere];
             }
             if ($type == 'article') {
                 $tab_sql[$id]["article"] = $liste_articles[$id_pere];
             }
             $tab_sql[$id]["type_pere"] = $type_pere;
             $tab_sql[$id]["ordre"] = $row['ordre'];
             $tab_sql[$id]["couleur"] = $row['couleur'];
             $tab_sql[$id]["etat"] = ($type_pere == 'article' || $type_pere == 'tache') && isset($tab_etats[$id_pere]) && $tab_etats[$id_pere] != '' ? $tab_etats[$id_pere] : $row['etat'];
             $tab_sql[$id]["intitule"] = ($type_pere == 'article' || $type_pere == 'tache') && isset($tab_intitules[$id_pere]) && $tab_intitules[$id_pere] != '' ? $tab_intitules[$id_pere] : Sql_prepareTexteAffichage($row['intitule']);
             $tab_sql[$id]["intitule_canonize"] = $row['intitule_canonize'];
             $tab_sql[$id]["priorite"] = $type_pere == 'tache' && isset($tab_priorites[$id_pere]) && $tab_priorites[$id_pere] != '' ? $tab_priorites[$id_pere] : '';
             if ($type_pere == 'tache' && isset($tab_etats[$id_pere]) && $tab_etats[$id_pere] == 'inactif') {
                 if ($row['famille'] != '' && $row['id_arbo_pere'] == 0) {
                     $tab_famille = explode('-', $row['famille']);
                     $index_pere = count($tab_famille) - 2;
                     $tab_sql[$tab_famille[$index_pere]]['nb_taches_a_faire']++;
                     if (!empty($tab_famille[$index_pere - 1])) {
                         $tab_sql[$tab_famille[$index_pere - 1]]['nb_taches_a_faire']++;
                     }
                 } else {
                     $tab_sql[$id]['nb_taches_a_faire'] = 0;
                 }
             }
             if ($type_pere == 'tache' && isset($tab_etats[$id_pere]) && $tab_etats[$id_pere] == 'actif') {
                 if ($row['famille'] != '' && $row['id_arbo_pere'] == 0) {
                     $tab_famille = explode('-', $row['famille']);
                     $index_pere = count($tab_famille) - 2;
                     $tab_sql[$tab_famille[$index_pere]]['nb_taches_terminees']++;
                     if (!empty($tab_famille[$index_pere - 1])) {
                         $tab_sql[$tab_famille[$index_pere - 1]]['nb_taches_terminees']++;
                     }
                 } else {
                     $tab_sql[$id]['nb_taches_terminees'] = 0;
                 }
             }
             // On détermine le niveau de profondeur dans l'arborescence
             $tab_sql[$id]["niveau"] = substr_count($row['famille'], "-");
         }
     }
     /*=============*/
     Lib_myLog("Tab sql:", $tab_sql);
     /*=============*/
     Lib_myLog("Construction de l'arbo");
     $tab_result = Arbo_getTab($tab_sql, 0, '');
     return $tab_result;
 }
 /**
 Retourne un tableau de saveurs correspondant aux champs du tableau en argument.
 @param $args
 */
 function Saveurs_chercher($args)
 {
     $count = 0;
     $tab_result = array();
     if (isset($args['count'])) {
         $sql = " SELECT count(*) nb_enregistrements \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "saveur\n\t\t\t\t\tWHERE 1";
     } else {
         $sql = " SELECT * \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "saveur\n\t\t\t\t\tWHERE 1";
     }
     if (!isset($args['id_saveur']) && !isset($args['pourcent_eth0_dans_arome_pur_1']) && !isset($args['pourcent_eth0_dans_arome_pur_2']) && !isset($args['pourcent_eth0_dans_arome_pur_3']) && !isset($args['pourcent_eth0_dans_arome_pur_4']) && !isset($args['pourcent_eth0_dans_arome_pur_5']) && !isset($args['pourcent_eth0_dans_arome_pur_6']) && !isset($args['pourcent_arome_pur_dans_arome_prod_1']) && !isset($args['pourcent_arome_pur_dans_arome_prod_2']) && !isset($args['pourcent_arome_pur_dans_arome_prod_3']) && !isset($args['pourcent_arome_pur_dans_arome_prod_4']) && !isset($args['pourcent_arome_pur_dans_arome_prod_5']) && !isset($args['pourcent_arome_pur_dans_arome_prod_6']) && !isset($args['pourcent_alcool_prod_dans_arome_prod']) && !isset($args['pourcent_eau_dans_arome_prod']) && !isset($args['pourcent_arome_prod_dans_e_liquide_1']) && !isset($args['pourcent_arome_prod_dans_e_liquide_2']) && !isset($args['pourcent_arome_prod_dans_e_liquide_3']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['tab_ids_saveurs'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_saveur']) && $args['id_saveur'] != "*") {
         $condition .= " AND id_saveur = '" . $args['id_saveur'] . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_1']) && $args['pourcent_eth0_dans_arome_pur_1'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_1 = '" . strtr($this->pourcent_eth0_dans_arome_pur_1, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_2']) && $args['pourcent_eth0_dans_arome_pur_2'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_2 = '" . strtr($this->pourcent_eth0_dans_arome_pur_2, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_3']) && $args['pourcent_eth0_dans_arome_pur_3'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_3 = '" . strtr($this->pourcent_eth0_dans_arome_pur_3, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_4']) && $args['pourcent_eth0_dans_arome_pur_4'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_4 = '" . strtr($this->pourcent_eth0_dans_arome_pur_4, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_5']) && $args['pourcent_eth0_dans_arome_pur_5'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_5 = '" . strtr($this->pourcent_eth0_dans_arome_pur_5, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eth0_dans_arome_pur_6']) && $args['pourcent_eth0_dans_arome_pur_6'] != "*") {
         $condition .= " AND pourcent_eth0_dans_arome_pur_6 = '" . strtr($this->pourcent_eth0_dans_arome_pur_6, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_1']) && $args['pourcent_arome_pur_dans_arome_prod_1'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_1 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_1, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_2']) && $args['pourcent_arome_pur_dans_arome_prod_2'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_2 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_2, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_3']) && $args['pourcent_arome_pur_dans_arome_prod_3'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_3 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_3, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_4']) && $args['pourcent_arome_pur_dans_arome_prod_4'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_4 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_4, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_5']) && $args['pourcent_arome_pur_dans_arome_prod_5'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_5 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_5, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_pur_dans_arome_prod_6']) && $args['pourcent_arome_pur_dans_arome_prod_6'] != "*") {
         $condition .= " AND pourcent_arome_pur_dans_arome_prod_6 = '" . strtr($this->pourcent_arome_pur_dans_arome_prod_6, ",", ".") . "' ";
     }
     if (isset($args['pourcent_alcool_prod_dans_arome_prod']) && $args['pourcent_alcool_prod_dans_arome_prod'] != "*") {
         $condition .= " AND pourcent_alcool_prod_dans_arome_prod = '" . strtr($this->pourcent_alcool_prod_dans_arome_prod, ",", ".") . "' ";
     }
     if (isset($args['pourcent_eau_dans_arome_prod']) && $args['pourcent_eau_dans_arome_prod'] != "*") {
         $condition .= " AND pourcent_eau_dans_arome_prod = '" . strtr($this->pourcent_eau_dans_arome_prod, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_prod_dans_e_liquide_1']) && $args['pourcent_arome_prod_dans_e_liquide_1'] != "*") {
         $condition .= " AND pourcent_arome_prod_dans_e_liquide_1 = '" . strtr($this->pourcent_arome_prod_dans_e_liquide_1, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_prod_dans_e_liquide_2']) && $args['pourcent_arome_prod_dans_e_liquide_2'] != "*") {
         $condition .= " AND pourcent_arome_prod_dans_e_liquide_2 = '" . strtr($this->pourcent_arome_prod_dans_e_liquide_2, ",", ".") . "' ";
     }
     if (isset($args['pourcent_arome_prod_dans_e_liquide_3']) && $args['pourcent_arome_prod_dans_e_liquide_3'] != "*") {
         $condition .= " AND pourcent_arome_prod_dans_e_liquide_3 = '" . strtr($this->pourcent_arome_prod_dans_e_liquide_3, ",", ".") . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_saveurs']) && $args['tab_ids_saveurs'] != "*") {
         $ids = implode(",", $args['tab_ids_saveurs']);
         $condition .= " AND id_saveur IN (0" . $ids . ") ";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if (isset($args['count'])) {
         if ($result && Sql_errorCode($result) === "00000") {
             $row = Sql_fetch($result);
             $count = $row['nb_enregistrements'];
         }
         return $count;
     } else {
         if ($result && Sql_errorCode($result) === "00000") {
             while ($row = Sql_fetch($result)) {
                 $id = $row['id_saveur'];
                 $tab_result[$id]["id_saveur"] = $id;
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_1"] = $row['pourcent_eth0_dans_arome_pur_1'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_2"] = $row['pourcent_eth0_dans_arome_pur_2'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_3"] = $row['pourcent_eth0_dans_arome_pur_3'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_4"] = $row['pourcent_eth0_dans_arome_pur_4'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_5"] = $row['pourcent_eth0_dans_arome_pur_5'];
                 $tab_result[$id]["pourcent_eth0_dans_arome_pur_6"] = $row['pourcent_eth0_dans_arome_pur_6'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_1"] = $row['pourcent_arome_pur_dans_arome_prod_1'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_2"] = $row['pourcent_arome_pur_dans_arome_prod_2'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_3"] = $row['pourcent_arome_pur_dans_arome_prod_3'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_4"] = $row['pourcent_arome_pur_dans_arome_prod_4'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_5"] = $row['pourcent_arome_pur_dans_arome_prod_5'];
                 $tab_result[$id]["pourcent_arome_pur_dans_arome_prod_6"] = $row['pourcent_arome_pur_dans_arome_prod_6'];
                 $tab_result[$id]["pourcent_alcool_prod_dans_arome_prod"] = $row['pourcent_alcool_prod_dans_arome_prod'];
                 $tab_result[$id]["pourcent_eau_dans_arome_prod"] = $row['pourcent_eau_dans_arome_prod'];
                 $tab_result[$id]["pourcent_arome_prod_dans_e_liquide_1"] = $row['pourcent_arome_prod_dans_e_liquide_1'];
                 $tab_result[$id]["pourcent_arome_prod_dans_e_liquide_2"] = $row['pourcent_arome_prod_dans_e_liquide_2'];
                 $tab_result[$id]["pourcent_arome_prod_dans_e_liquide_3"] = $row['pourcent_arome_prod_dans_e_liquide_3'];
                 $tab_result[$id]["etat"] = $row['etat'];
                 $tab_result[$id]["date_add"] = $row['date_add'];
                 $tab_result[$id]["date_upd"] = $row['date_upd'];
                 $tab_result[$id]["info_saveur"] = Sql_prepareTexteAffichage($row['info_saveur']);
             }
         }
         if (count($tab_result) == 1 && ($args['id_saveur'] != '' && $args['id_saveur'] != '*')) {
             $tab_result = array_pop($tab_result);
         }
     }
     return $tab_result;
 }
 /**
 Retourne un tableau de fiches correspondant aux champs du tableau en argument.
 @param $args
 */
 function Fiches_chercher($args)
 {
     $count = 0;
     $tab_result = array();
     if (isset($args['count'])) {
         $sql = " SELECT count(*) nb_enregistrements\n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "fiche\n\t\t\t\t\tWHERE 1";
     } else {
         $sql = " SELECT * \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "fiche\n\t\t\t\t\tWHERE 1";
     }
     if (!isset($args['id_fiche']) && !isset($args['id_type_fiche']) && !isset($args['fic_prenom']) && !isset($args['fic_nom']) && !isset($args['fic_email']) && !isset($args['order_by']) && !isset($args['tab_ids_fiches'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_fiche']) && $args['id_fiche'] != "*") {
         $condition .= " AND id_fiche = '" . $args['id_fiche'] . "' ";
     }
     if (isset($args['id_type_fiche']) && $args['id_type_fiche'] != "*") {
         $condition .= " AND id_type_fiche = '" . $args['id_type_fiche'] . "' ";
     }
     if (isset($args['fic_prenom']) && $args['fic_prenom'] != "*") {
         $condition .= " AND fic_prenom LIKE '" . Sql_prepareTexteStockage($args['fic_prenom']) . "' ";
     }
     if (isset($args['fic_nom']) && $args['fic_nom'] != "*") {
         $condition .= " AND fic_nom LIKE '" . Sql_prepareTexteStockage($args['fic_nom']) . "' ";
     }
     if (isset($args['fic_email']) && $args['fic_email'] != "*") {
         $condition .= " AND fic_email LIKE '" . Sql_prepareTexteStockage($args['fic_email']) . "' ";
     }
     if (isset($args['tab_ids_fiches']) && $args['tab_ids_fiches'] != "*") {
         $ids = implode(",", $args['tab_ids_fiches']);
         $condition .= " AND id_fiche IN (0" . $ids . ") ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if (isset($args['count'])) {
         if ($result && Sql_errorCode($result) === "00000") {
             $row = Sql_fetch($result);
             $count = $row['nb_enregistrements'];
         }
         return $count;
     } else {
         if ($result && Sql_errorCode($result) === "00000") {
             while ($row = Sql_fetch($result)) {
                 $id = $row['id_fiche'];
                 $tab_result[$id]["id_fiche"] = $id;
                 $tab_result[$id]["id_type_fiche"] = $row['id_type_fiche'];
                 $tab_result[$id]["fic_prenom"] = Sql_prepareTexteAffichage($row['fic_prenom']);
                 $tab_result[$id]["fic_nom"] = Sql_prepareTexteAffichage($row['fic_nom']);
                 $tab_result[$id]["fic_adresse1"] = Sql_prepareTexteAffichage($row['fic_adresse1']);
                 $tab_result[$id]["fic_adresse2"] = Sql_prepareTexteAffichage($row['fic_adresse2']);
                 $tab_result[$id]["fic_adresse3"] = Sql_prepareTexteAffichage($row['fic_adresse3']);
                 $tab_result[$id]["fic_cp"] = Sql_prepareTexteAffichage($row['fic_cp']);
                 $tab_result[$id]["fic_ville"] = Sql_prepareTexteAffichage($row['fic_ville']);
                 $tab_result[$id]["fic_email"] = Sql_prepareTexteAffichage($row['fic_email']);
                 $tab_result[$id]["fic_document"] = Sql_prepareTexteAffichage($row['fic_document']);
                 $tab_result[$id]["date_add"] = Sql_prepareTexteAffichage($row['date_add']);
                 $tab_result[$id]["date_upd"] = Sql_prepareTexteAffichage($row['date_upd']);
                 $tab_result[$id]["info_fiche"] = Sql_prepareTexteAffichage($row['info_fiche']);
             }
         }
         if (count($tab_result) == 1 && ($args['id_fiche'] != '' && $args['id_fiche'] != '*')) {
             $tab_result = array_pop($tab_result);
         }
         return $tab_result;
     }
 }
 /**
  Renvoie le nom, le prénom et l'identifiant des personnes ayant les données passées en argument sous forme d'un tableau
  @param IdForm
  @param NomPersonne
  @param PrenomPersonne
  ...
 */
 function Forms_chercher($id_form = '', $form0 = '')
 {
     $tab_result = array();
     $sql = " SELECT * \n\t\t\tFROM " . $GLOBALS['prefix'] . "forms\n\t\t\tWHERE 1";
     if ("{$id_form}" == "" && $form0 == "") {
         return $tab_result;
     }
     $condition = "";
     if ($id_form != "" && $id_form != "*") {
         $condition .= " AND id_form = {$id_form} ";
     }
     if ($form0 != "" && $form0 != "*") {
         $condition .= " AND form0 = '{$form0}' ";
     }
     $sql .= $condition;
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_form'];
             $tab_result[$id]["id_form"] = $id;
             $tab_result[$id]["nom"] = Sql_prepareTexteAffichage($row['nom']);
             $tab_result[$id]["prenom"] = Sql_prepareTexteAffichage($row['prenom']);
             $tab_result[$id]["date_add"] = $row['date_add'];
             for ($i = 0; $i <= 30; $i++) {
                 $tab_result[$id]['form' . $i] = Sql_prepareTexteAffichage($row['form' . $i]);
             }
         }
     }
     if (count($tab_result) == 1 && ("{$id_form}" != '' && "{$id_form}" != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
 Retourne un tableau de post_auteurs correspondant aux champs du tableau en argument.
 @param $args
 */
 function Post_auteurs_chercher($args)
 {
     $count = 0;
     $tab_result = array();
     if (isset($args['count'])) {
         $sql = " SELECT count(*) nb_enregistrements \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "post_auteur\n\t\t\t\t\tWHERE 1";
     } else {
         $sql = " SELECT * \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "post_auteur\n\t\t\t\t\tWHERE 1";
     }
     if (!isset($args['id_post_auteur']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['tab_ids_post_auteurs'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_post_auteur']) && $args['id_post_auteur'] != "*") {
         $condition .= " AND id_post_auteur = '" . $args['id_post_auteur'] . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_post_auteurs']) && $args['tab_ids_post_auteurs'] != "*") {
         $ids = implode(",", $args['tab_ids_post_auteurs']);
         $condition .= " AND id_post_auteur IN (0" . $ids . ") ";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if (isset($args['count'])) {
         if ($result && Sql_errorCode($result) === "00000") {
             $row = Sql_fetch($result);
             $count = $row['nb_enregistrements'];
         }
         return $count;
     } else {
         if ($result && Sql_errorCode($result) === "00000") {
             while ($row = Sql_fetch($result)) {
                 $id = $row['id_post_auteur'];
                 $tab_result[$id]["id_post_auteur"] = $id;
                 $tab_result[$id]["post_auteur_nom"] = Sql_prepareTexteAffichage($row['post_auteur_nom']);
                 $tab_result[$id]["post_auteur_prenom"] = Sql_prepareTexteAffichage($row['post_auteur_prenom']);
                 $tab_result[$id]["post_auteur_pseudo"] = Sql_prepareTexteAffichage($row['post_auteur_pseudo']);
                 $tab_result[$id]["post_auteur_avatar"] = Sql_prepareTexteAffichage($row['post_auteur_avatar']);
                 $tab_result[$id]["etat"] = $row['etat'];
                 $tab_result[$id]["date_add"] = $row['date_add'];
                 $tab_result[$id]["date_upd"] = $row['date_upd'];
                 $tab_result[$id]["info_post_auteur"] = Sql_prepareTexteAffichage($row['info_post_auteur']);
             }
         }
         if (count($tab_result) == 1 && ($args['id_post_auteur'] != '' && $args['id_post_auteur'] != '*')) {
             $tab_result = array_pop($tab_result);
         }
     }
     return $tab_result;
 }
 /**
  Renvoie le lang, le prélang et l'identifiant des personnes ayant les données passées en argument sous forme d'un tableau
  @param id_article
  @param langPersonne
  @param textePersonne
  ...
 */
 function Articles_chercher($args)
 {
     $tab_result = array();
     $sql = " SELECT * \n\t\t\tFROM " . $GLOBALS['prefix'] . "articles\n\t\t\tWHERE 1";
     if (!isset($args['id_article']) && !isset($args['code']) && !isset($args['code_news']) && !isset($args['date']) && !isset($args['lang']) && !isset($args['titre']) && !isset($args['position']) && !isset($args['titre_data1']) && !isset($args['data1']) && !isset($args['titre_data2']) && !isset($args['data2']) && !isset($args['titre_data3']) && !isset($args['data3']) && !isset($args['titre_data4']) && !isset($args['data4']) && !isset($args['titre_data5']) && !isset($args['data5']) && !isset($args['titre_data6']) && !isset($args['data6']) && !isset($args['contenu']) && !isset($args['etat']) && !isset($args['position_une']) && !isset($args['not_position_une']) && !isset($args['code']) && !isset($args['titre_canonize']) && !isset($args['not_code_news']) && !isset($args['tab_ids_articles']) && !isset($args['tab_codes']) && !isset($args['tab_codes_news']) && !isset($args['categorie'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_article']) && $args['id_article'] != "*") {
         $condition .= " AND id_article = " . Sql_prepareTexteStockage($args['id_article']) . " ";
     }
     if (isset($args['code_news'])) {
         $condition .= " AND code_news LIKE '" . Sql_prepareTexteStockage($args['code_news']) . "' ";
     }
     if (isset($args['not_code_news'])) {
         $condition .= " AND code_news NOT LIKE '" . Sql_prepareTexteStockage($args['not_code_news']) . "' ";
     }
     if (isset($args['position']) && $args['position'] != "*") {
         $condition .= " AND position = '" . $args['position'] . "' ";
     }
     if (isset($args['position_une'])) {
         $condition .= " AND position_une = " . $args['position_une'] . " ";
     }
     if (isset($args['not_position_une'])) {
         $condition .= " AND position_une != " . $args['not_position_une'] . " ";
     }
     if (isset($args['position_une_min'])) {
         $condition .= " AND position_une >= " . $args['position_une_min'] . " ";
     }
     if (isset($args['code'])) {
         $condition .= " AND code = '" . $args['code'] . "' ";
     }
     if (isset($args['lang'])) {
         $condition .= " AND lang = '" . $args['lang'] . "' ";
     }
     if (isset($args['contenu'])) {
         $condition .= " AND contenu LIKE '" . Sql_prepareTexteStockage($args['contenu']) . "' ";
     }
     if (isset($args['titre'])) {
         $condition .= " AND titre LIKE '" . Sql_prepareTexteStockage($args['titre']) . "' ";
     }
     if (isset($args['etat'])) {
         $condition .= " AND etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['meta_titre'])) {
         $condition .= " AND meta_titre = '" . $args['meta_titre'] . "' ";
     }
     if (isset($args['meta_description'])) {
         $condition .= " AND meta_description = '" . $args['meta_description'] . "' ";
     }
     if (isset($args['meta_mots_clefs'])) {
         $condition .= " AND meta_mots_clefs = '" . $args['meta_mots_clefs'] . "' ";
     }
     if (isset($args['meta_url'])) {
         $condition .= " AND meta_url = '" . $args['meta_url'] . "' ";
     }
     if (isset($args['titre_canonize'])) {
         $condition .= " AND titre_canonize LIKE '" . $args['titre_canonize'] . "' ";
     }
     if (isset($args['categorie'])) {
         $condition .= " AND categorie LIKE '" . $args['categorie'] . "' ";
     }
     if (isset($args['titre_data1'])) {
         $condition .= " AND titre_data1 LIKE '" . $args['titre_data1'] . "' ";
     }
     if (isset($args['titre_data2'])) {
         $condition .= " AND titre_data2 LIKE '" . $args['titre_data2'] . "' ";
     }
     if (isset($args['titre_data3'])) {
         $condition .= " AND titre_data3 LIKE '" . $args['titre_data3'] . "' ";
     }
     if (isset($args['titre_data4'])) {
         $condition .= " AND titre_data4 LIKE '" . $args['titre_data4'] . "' ";
     }
     if (isset($args['titre_data5'])) {
         $condition .= " AND titre_data5 LIKE '" . $args['titre_data5'] . "' ";
     }
     if (isset($args['titre_data6'])) {
         $condition .= " AND titre_data6 LIKE '" . $args['titre_data6'] . "' ";
     }
     if (isset($args['titre_data7'])) {
         $condition .= " AND titre_data7 LIKE '" . $args['titre_data7'] . "' ";
     }
     if (isset($args['titre_data8'])) {
         $condition .= " AND titre_data8 LIKE '" . $args['titre_data8'] . "' ";
     }
     if (isset($args['titre_data9'])) {
         $condition .= " AND titre_data9 LIKE '" . $args['titre_data9'] . "' ";
     }
     if (isset($args['titre_data10'])) {
         $condition .= " AND titre_data10 LIKE '" . $args['titre_data10'] . "' ";
     }
     if (isset($args['titre_data11'])) {
         $condition .= " AND titre_data11 LIKE '" . $args['titre_data11'] . "' ";
     }
     if (isset($args['titre_data12'])) {
         $condition .= " AND titre_data12 LIKE '" . $args['titre_data12'] . "' ";
     }
     if (isset($args['titre_data13'])) {
         $condition .= " AND titre_data13 LIKE '" . $args['titre_data13'] . "' ";
     }
     if (isset($args['titre_data14'])) {
         $condition .= " AND titre_data14 LIKE '" . $args['titre_data14'] . "' ";
     }
     if (isset($args['titre_data15'])) {
         $condition .= " AND titre_data15 LIKE '" . $args['titre_data15'] . "' ";
     }
     if (isset($args['titre_data16'])) {
         $condition .= " AND titre_data16 LIKE '" . $args['titre_data16'] . "' ";
     }
     if (isset($args['titre_data17'])) {
         $condition .= " AND titre_data17 LIKE '" . $args['titre_data17'] . "' ";
     }
     if (isset($args['titre_data18'])) {
         $condition .= " AND titre_data18 LIKE '" . $args['titre_data18'] . "' ";
     }
     if (isset($args['titre_data19'])) {
         $condition .= " AND titre_data19 LIKE '" . $args['titre_data19'] . "' ";
     }
     if (isset($args['titre_data20'])) {
         $condition .= " AND titre_data620 LIKE '" . $args['titre_data20'] . "' ";
     }
     if (isset($args['data1'])) {
         $condition .= " AND data1 LIKE '" . $args['data1'] . "' ";
     }
     if (isset($args['data2'])) {
         $condition .= " AND data2 LIKE '" . $args['data2'] . "' ";
     }
     if (isset($args['data3'])) {
         $condition .= " AND data3 LIKE '" . $args['data3'] . "' ";
     }
     if (isset($args['data4'])) {
         $condition .= " AND data4 LIKE '" . $args['data4'] . "' ";
     }
     if (isset($args['data5'])) {
         $condition .= " AND data5 LIKE '" . $args['data5'] . "' ";
     }
     if (isset($args['data6'])) {
         $condition .= " AND data6 LIKE '" . $args['data6'] . "' ";
     }
     if (isset($args['data7'])) {
         $condition .= " AND data7 LIKE '" . $args['data7'] . "' ";
     }
     if (isset($args['data8'])) {
         $condition .= " AND data8 LIKE '" . $args['data8'] . "' ";
     }
     if (isset($args['data9'])) {
         $condition .= " AND data9 LIKE '" . $args['data9'] . "' ";
     }
     if (isset($args['data10'])) {
         $condition .= " AND data10 LIKE '" . $args['data10'] . "' ";
     }
     if (isset($args['data11'])) {
         $condition .= " AND data11 LIKE '" . $args['data11'] . "' ";
     }
     if (isset($args['data12'])) {
         $condition .= " AND data12 LIKE '" . $args['data12'] . "' ";
     }
     if (isset($args['data13'])) {
         $condition .= " AND data13 LIKE '" . $args['data13'] . "' ";
     }
     if (isset($args['data14'])) {
         $condition .= " AND data14 LIKE '" . $args['data14'] . "' ";
     }
     if (isset($args['data15'])) {
         $condition .= " AND data15 LIKE '" . $args['data15'] . "' ";
     }
     if (isset($args['data16'])) {
         $condition .= " AND data16 LIKE '" . $args['data16'] . "' ";
     }
     if (isset($args['data17'])) {
         $condition .= " AND data17 LIKE '" . $args['data17'] . "' ";
     }
     if (isset($args['data18'])) {
         $condition .= " AND data18 LIKE '" . $args['data18'] . "' ";
     }
     if (isset($args['data19'])) {
         $condition .= " AND data19 LIKE '" . $args['data19'] . "' ";
     }
     if (isset($args['data20'])) {
         $condition .= " AND data20 LIKE '" . $args['data20'] . "' ";
     }
     if (isset($args['tab_ids_articles'])) {
         $ids = implode(",", $args['tab_ids_articles']);
         $condition .= " AND id_article IN (" . $ids . ") ";
     }
     if (isset($args['tab_codes']) && $args['tab_codes'] != "*") {
         $condition .= " AND (";
         $nb = 0;
         foreach ($args['tab_codes'] as $code) {
             $nb++;
             $condition .= " code LIKE '" . $code . "' ";
             if ($nb < count($args['tab_codes'])) {
                 $condition .= "OR";
             } else {
                 $condition .= ")";
             }
         }
     }
     if (isset($args['tab_codes_news']) && $args['tab_codes_news'] != "*") {
         $condition .= " AND (";
         $nb = 0;
         foreach ($args['tab_codes_news'] as $code) {
             $nb++;
             $condition .= " code_news LIKE '" . $code . "' ";
             if ($nb < count($args['tab_codes_news'])) {
                 $condition .= "OR";
             } else {
                 $condition .= ")";
             }
         }
     }
     if (!isset($args['etat'])) {
         $condition .= " AND etat != 'supprime' ";
     }
     if (isset($args['order_by']) && $args['order_by'] != "*") {
         $condition .= " ORDER BY " . $args['order_by'] . " ASC ";
     } else {
         $condition .= " ORDER BY id_article ASC ";
     }
     $sql .= $condition;
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_article'];
             $tab_result[$id]["id_article"] = $id;
             $tab_result[$id]["code"] = $row['code'];
             $tab_result[$id]["lang"] = $row['lang'];
             $tab_result[$id]["position_une"] = $row['position_une'];
             $tab_result[$id]["position"] = $row['position'];
             $tab_result[$id]["code_news"] = $row['code_news'];
             $tab_result[$id]["libelle"] = Sql_prepareTexteAffichage($row['libelle']);
             $tab_result[$id]["contenu"] = Sql_prepareTexteAffichage($row['contenu']);
             $tab_result[$id]["date"] = $row['date'];
             $tab_result[$id]["texte"] = Sql_prepareTexteAffichage($row['contenu']);
             $tab_result[$id]["etat"] = $row['etat'];
             $tab_result[$id]["image_intro"] = Sql_prepareTexteAffichage($row['image_intro']);
             $tab_result[$id]["texte_intro"] = Sql_prepareTexteAffichage($row['texte_intro']);
             $tab_result[$id]["titre"] = Sql_prepareTexteAffichage($row['titre']);
             $tab_result[$id]["titre_page"] = Sql_prepareTexteAffichage($row['titre_page']);
             $tab_result[$id]["meta_titre"] = Sql_prepareTexteAffichage($row['meta_titre']);
             $tab_result[$id]["meta_description"] = Sql_prepareTexteAffichage($row['meta_description']);
             $tab_result[$id]["meta_mots_clefs"] = Sql_prepareTexteAffichage($row['meta_mots_clefs']);
             $tab_result[$id]["meta_url"] = Sql_prepareTexteAffichage($row['meta_url']);
             $tab_result[$id]["titre_canonize"] = $row['titre_canonize'];
             $tab_result[$id]["url_vignette"] = $row['url_vignette'];
             $tab_result[$id]["url_image"] = $row['url_image'];
             $tab_result[$id]["url_image2"] = $row['url_image2'];
             $tab_result[$id]["categorie"] = $row['categorie'];
             $tab_result[$id]["titre_data1"] = Sql_prepareTexteAffichage($row['titre_data1']);
             $tab_result[$id]["data1"] = Sql_prepareTexteAffichage($row['data1']);
             $tab_result[$id]["titre_data2"] = Sql_prepareTexteAffichage($row['titre_data2']);
             $tab_result[$id]["data2"] = Sql_prepareTexteAffichage($row['data2']);
             $tab_result[$id]["titre_data3"] = Sql_prepareTexteAffichage($row['titre_data3']);
             $tab_result[$id]["data3"] = Sql_prepareTexteAffichage($row['data3']);
             $tab_result[$id]["titre_data4"] = Sql_prepareTexteAffichage($row['titre_data4']);
             $tab_result[$id]["data4"] = Sql_prepareTexteAffichage($row['data4']);
             $tab_result[$id]["titre_data5"] = Sql_prepareTexteAffichage($row['titre_data5']);
             $tab_result[$id]["data5"] = Sql_prepareTexteAffichage($row['data5']);
             $tab_result[$id]["titre_data6"] = Sql_prepareTexteAffichage($row['titre_data6']);
             $tab_result[$id]["data6"] = Sql_prepareTexteAffichage($row['data6']);
             $tab_result[$id]["titre_data7"] = Sql_prepareTexteAffichage($row['titre_data7']);
             $tab_result[$id]["data7"] = Sql_prepareTexteAffichage($row['data7']);
             $tab_result[$id]["titre_data8"] = Sql_prepareTexteAffichage($row['titre_data8']);
             $tab_result[$id]["data8"] = Sql_prepareTexteAffichage($row['data8']);
             $tab_result[$id]["titre_data9"] = Sql_prepareTexteAffichage($row['titre_data9']);
             $tab_result[$id]["data9"] = Sql_prepareTexteAffichage($row['data9']);
             $tab_result[$id]["titre_data10"] = Sql_prepareTexteAffichage($row['titre_data10']);
             $tab_result[$id]["data10"] = Sql_prepareTexteAffichage($row['data10']);
             $tab_result[$id]["titre_data11"] = Sql_prepareTexteAffichage($row['titre_data11']);
             $tab_result[$id]["data11"] = Sql_prepareTexteAffichage($row['data11']);
             $tab_result[$id]["titre_data12"] = Sql_prepareTexteAffichage($row['titre_data12']);
             $tab_result[$id]["data12"] = Sql_prepareTexteAffichage($row['data12']);
             $tab_result[$id]["titre_data13"] = Sql_prepareTexteAffichage($row['titre_data13']);
             $tab_result[$id]["data13"] = Sql_prepareTexteAffichage($row['data13']);
             $tab_result[$id]["titre_data14"] = Sql_prepareTexteAffichage($row['titre_data14']);
             $tab_result[$id]["data14"] = Sql_prepareTexteAffichage($row['data14']);
             $tab_result[$id]["titre_data15"] = Sql_prepareTexteAffichage($row['titre_data15']);
             $tab_result[$id]["data15"] = Sql_prepareTexteAffichage($row['data15']);
             $tab_result[$id]["titre_data16"] = Sql_prepareTexteAffichage($row['titre_data16']);
             $tab_result[$id]["data16"] = Sql_prepareTexteAffichage($row['data16']);
             $tab_result[$id]["titre_data17"] = Sql_prepareTexteAffichage($row['titre_data17']);
             $tab_result[$id]["data17"] = Sql_prepareTexteAffichage($row['data17']);
             $tab_result[$id]["titre_data18"] = Sql_prepareTexteAffichage($row['titre_data18']);
             $tab_result[$id]["data18"] = Sql_prepareTexteAffichage($row['data18']);
             $tab_result[$id]["titre_data19"] = Sql_prepareTexteAffichage($row['titre_data19']);
             $tab_result[$id]["data19"] = Sql_prepareTexteAffichage($row['data19']);
             $tab_result[$id]["titre_data20"] = Sql_prepareTexteAffichage($row['titre_data20']);
             $tab_result[$id]["data20"] = Sql_prepareTexteAffichage($row['data20']);
             $tab_result[$id]["titre_fichier1"] = Sql_prepareTexteAffichage($row['titre_fichier1']);
             $tab_result[$id]["fichier1"] = Sql_prepareTexteAffichage($row['fichier1']);
             $tab_result[$id]["titre_fichier2"] = Sql_prepareTexteAffichage($row['titre_fichier1']);
             $tab_result[$id]["fichier2"] = Sql_prepareTexteAffichage($row['fichier2']);
             $tab_result[$id]["titre_fichier3"] = Sql_prepareTexteAffichage($row['titre_fichier3']);
             $tab_result[$id]["fichier3"] = Sql_prepareTexteAffichage($row['fichier3']);
             $tab_result[$id]["titre_fichier4"] = Sql_prepareTexteAffichage($row['titre_fichier4']);
             $tab_result[$id]["fichier4"] = Sql_prepareTexteAffichage($row['fichier4']);
             $tab_result[$id]["titre_fichier5"] = Sql_prepareTexteAffichage($row['titre_fichier5']);
             $tab_result[$id]["fichier5"] = Sql_prepareTexteAffichage($row['fichier5']);
             $tab_result[$id]["date_add"] = $row['date_add'];
             $tab_result[$id]["date_upd"] = $row['date_upd'];
             $tab_result[$id]["info_article"] = Sql_prepareTexteAffichage($row['info_article']);
         }
     }
     if (count($tab_result) == 1 && ($args['id_article'] != '' && $args['id_article'] != '*')) {
         $tab_result = array_pop($tab_result);
     }
     if (count($tab_result) == 1 && $args['code'] != '' && $args['lang'] != '') {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
 Retourne un tableau de adherents correspondant aux champs du tableau en argument.
 @param $args
 */
 function Adherents_chercher($args)
 {
     $tab_result = array();
     $sql = " SELECT A.*, U.nom_utilisateur, U.password\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "adherent A, " . $GLOBALS['prefix'] . "sys_utilisateurs U\n\t\t\t\tWHERE A.id_utilisateur = U.id_utilisateur";
     if (!isset($args['id_adherent']) && !isset($args['id_interne']) && !isset($args['id_utilisateur']) && !isset($args['nom']) && !isset($agrs['prenom']) && !isset($args['enseigne']) && !isset($args['email']) && !isset($args['not_email']) && !isset($args['raison_sociale']) && !isset($args['cp']) && !isset($args['ville']) && !isset($args['not_latitude']) && !isset($args['categorie']) && !isset($args['nature_lien']) && !isset($args['categorie1']) && !isset($args['categorie2']) && !isset($args['categorie3']) && !isset($args['categorie4']) && !isset($args['categorie5']) && !isset($args['categorie6']) && !isset($args['categorie7']) && !isset($args['categorie8']) && !isset($args['categorie9']) && !isset($args['categorie10']) && !isset($args['tab_categorie1']) && !isset($args['tab_categorie2']) && !isset($args['tab_categorie3']) && !isset($args['pays']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['entreprise_qualifiee']) && !isset($args['tab_ids_adherents']) && !isset($args['tab_cps'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_adherent']) && $args['id_adherent'] != "*") {
         $condition .= " AND id_adherent = '" . $args['id_adherent'] . "' ";
     }
     if (isset($args['id_interne'])) {
         $condition .= " AND id_interne = '" . $args['id_interne'] . "' ";
     }
     if (isset($args['id_utilisateur'])) {
         $condition .= " AND A.id_utilisateur = '" . $args['id_utilisateur'] . "' ";
     }
     if (isset($args['nom'])) {
         $condition .= " AND nom LIKE '" . Sql_prepareTexteStockage($args['nom']) . "' ";
     }
     if (isset($args['prenom'])) {
         $condition .= " AND prenom LIKE '" . Sql_prepareTexteStockage($args['prenom']) . "' ";
     }
     if (isset($args['enseigne'])) {
         $condition .= " AND enseigne LIKE '" . Sql_prepareTexteStockage($args['enseigne']) . "' ";
     }
     if (isset($args['email'])) {
         $condition .= " AND email LIKE '" . $args['email'] . "' ";
     }
     if (isset($args['not_email'])) {
         $condition .= " AND email NOT LIKE '" . $args['not_email'] . "' ";
     }
     if (isset($args['raison_sociale'])) {
         $condition .= " AND raison_sociale LIKE '" . Sql_prepareTexteStockage($args['raison_sociale']) . "' ";
     }
     if (isset($args['cp'])) {
         $condition .= " AND cp LIKE '" . Sql_prepareTexteStockage($args['cp']) . "' ";
     }
     if (isset($args['ville'])) {
         $condition .= " AND ville LIKE '" . Sql_prepareTexteStockage($args['ville']) . "' ";
     }
     if (isset($args['pays'])) {
         $condition .= " AND pays LIKE '" . Sql_prepareTexteStockage($args['pays']) . "' ";
     }
     if (isset($args['not_latitude'])) {
         $condition .= " AND latitude NOT LIKE '" . $args['not_latitude'] . "' ";
     }
     if (isset($args['entreprise_qualifiee'])) {
         $condition .= " AND entreprise_qualifiee = " . $args['entreprise_qualifiee'] . " ";
     }
     if (isset($args['categorie'])) {
         $condition .= " AND categorie LIKE '" . $args['categorie'] . "' ";
     }
     if (isset($args['nature_lien'])) {
         $condition .= " AND nature_lien LIKE '" . $args['nature_lien'] . "' ";
     }
     if (isset($args['categorie1'])) {
         $condition .= " AND categorie1 LIKE '" . $args['categorie1'] . "' ";
     }
     if (isset($args['categorie2'])) {
         $condition .= " AND categorie2 LIKE '" . $args['categorie2'] . "' ";
     }
     if (isset($args['categorie3'])) {
         $condition .= " AND categorie3 LIKE '" . $args['categorie3'] . "' ";
     }
     if (isset($args['categorie4'])) {
         $condition .= " AND categorie4 LIKE '" . $args['categorie4'] . "' ";
     }
     if (isset($args['categorie5'])) {
         $condition .= " AND categorie5 LIKE '" . $args['categorie5'] . "' ";
     }
     if (isset($args['categorie6'])) {
         $condition .= " AND categorie6 LIKE '" . $args['categorie6'] . "' ";
     }
     if (isset($args['categorie7'])) {
         $condition .= " AND categorie7 LIKE '" . $args['categorie7'] . "' ";
     }
     if (isset($args['categorie8'])) {
         $condition .= " AND categorie8 LIKE '" . $args['categorie8'] . "' ";
     }
     if (isset($args['categorie9'])) {
         $condition .= " AND categorie9 LIKE '" . $args['categorie9'] . "' ";
     }
     if (isset($args['categorie10'])) {
         $condition .= " AND categorie10 LIKE '" . $args['categorie10'] . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND A.etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_adherents']) && $args['tab_ids_adherents'] != "*") {
         $ids = implode(",", $args['tab_ids_adherents']);
         $condition .= " AND id_adherent IN (0" . $ids . ") ";
     }
     if (isset($args['tab_cps'])) {
         $condition .= " AND ( ";
         $nb = count($args['tab_cps']);
         for ($i = 1; $i <= $nb; $i++) {
             $cp = array_pop($args['tab_cps']);
             $condition .= " cp LIKE '" . $cp . "%' ";
             if ($i < $nb) {
                 $condition .= " OR ";
             }
         }
         $condition .= " ) ";
     }
     if (isset($args['tab_categorie'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie']); $i++) {
             $id = array_pop($args['tab_categorie']);
             $condition .= " categorie LIKE '%{$id}%' ";
             if (count($args['tab_categorie'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (isset($args['tab_categorie1'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie1']); $i++) {
             $id = array_pop($args['tab_categorie1']);
             $condition .= " categorie1 LIKE '%|{$id}|%' ";
             if (count($args['tab_categorie1'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (isset($args['tab_categorie2'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie2']); $i++) {
             $id = array_pop($args['tab_categorie2']);
             $condition .= " categorie2 LIKE '%|{$id}|%' ";
             if (count($args['tab_categorie2'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (isset($args['tab_categorie3'])) {
         $condition .= " AND (";
         for ($i = 0; count($args['tab_categorie3']); $i++) {
             $id = array_pop($args['tab_categorie3']);
             $condition .= " categorie3 LIKE '%|{$id}|%' ";
             if (count($args['tab_categorie3'])) {
                 $condition .= " OR ";
             }
         }
         $condition .= ")";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND A.etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_adherent'];
             $tab_result[$id]["id_adherent"] = $id;
             $tab_result[$id]["id_utilisateur"] = $row['id_utilisateur'];
             $tab_result[$id]["id_interne"] = $row['id_interne'];
             $tab_result[$id]["nom"] = Sql_prepareTexteAffichage($row['nom']);
             $tab_result[$id]["prenom"] = Sql_prepareTexteAffichage($row['prenom']);
             $tab_result[$id]["enseigne"] = Sql_prepareTexteAffichage($row['enseigne']);
             $tab_result[$id]["raison_sociale"] = Sql_prepareTexteAffichage($row['raison_sociale']);
             $tab_result[$id]["adresse1"] = Sql_prepareTexteAffichage($row['adresse1']);
             $tab_result[$id]["adresse2"] = Sql_prepareTexteAffichage($row['adresse2']);
             $tab_result[$id]["cp"] = Sql_prepareTexteAffichage($row['cp']);
             $tab_result[$id]["ville"] = Sql_prepareTexteAffichage($row['ville']);
             $tab_result[$id]["pays"] = Sql_prepareTexteAffichage($row['pays']);
             $tab_result[$id]["telephone"] = Sql_prepareTexteAffichage($row['telephone']);
             $tab_result[$id]["fax"] = Sql_prepareTexteAffichage($row['fax']);
             $tab_result[$id]["email"] = $row['email'];
             $tab_result[$id]["site_internet"] = $row['site_internet'];
             $tab_result[$id]["entreprise_qualifiee"] = $row['entreprise_qualifiee'];
             $tab_result[$id]["logo"] = $row['logo'];
             $tab_result[$id]["categorie"] = Sql_prepareTexteAffichage($row['categorie']);
             $tab_result[$id]["nature_lien"] = Sql_prepareTexteAffichage($row['nature_lien']);
             $tab_result[$id]["info_publique"] = Sql_prepareTexteAffichage($row['info_publique']);
             $tab_result[$id]["categorie1"] = $row['categorie1'];
             $tab_result[$id]["categorie2"] = $row['categorie2'];
             $tab_result[$id]["categorie3"] = $row['categorie3'];
             $tab_result[$id]["categorie4"] = $row['categorie4'];
             $tab_result[$id]["categorie5"] = $row['categorie5'];
             $tab_result[$id]["categorie6"] = $row['categorie6'];
             $tab_result[$id]["categorie7"] = $row['categorie7'];
             $tab_result[$id]["categorie8"] = $row['categorie8'];
             $tab_result[$id]["categorie9"] = $row['categorie9'];
             $tab_result[$id]["categorie10"] = $row['categorie10'];
             $tab_result[$id]["latitude"] = $row['latitude'];
             $tab_result[$id]["longitude"] = $row['longitude'];
             $tab_result[$id]["etat"] = $row['etat'];
             $tab_result[$id]["date_add"] = $row['date_add'];
             $tab_result[$id]["date_upd"] = $row['date_upd'];
             $tab_result[$id]["info_adherent"] = $row['info_adherent'];
             $tab_result[$id]["nom_utilisateur"] = $row['nom_utilisateur'];
             $tab_result[$id]["password"] = $row['password'];
         }
     }
     if (count($tab_result) == 1 && !isset($args['tab']) && ($args['id_adherent'] != '' && $args['id_adherent'] != '*')) {
         $tab_result = array_pop($tab_result);
     }
     if (count($tab_result) == 1 && !isset($args['tab']) && ($args['id_utilisateur'] != '' && $args['id_utilisateur'] != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
  Renvoie le position, le préposition et l'identifiant des personnes ayant les données passées en argument sous forme d'un tableau
  @param id_mobilier_image
  @param positionPersonne
  @param url_gde_imagePersonne
  ...
 */
 function Galeries_chercher($args)
 {
     $tab_result = array();
     $sql = " SELECT * \n\t\t\t FROM " . $GLOBALS['prefix'] . "galeries\n\t\t\t WHERE 1";
     if (!isset($args['id_galerie']) && !isset($args['id_pere']) && !isset($args['type_pere']) && !isset($args['position']) && !isset($args['order_by']) && !isset($args['code_pere'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_galerie']) && $args['id_galerie'] != "*") {
         $condition .= " AND id_galerie = " . $args['id_galerie'] . " ";
     }
     if (isset($args['id_pere']) && $args['id_pere'] != "*") {
         $condition .= " AND id_pere = '" . $args['id_pere'] . "' ";
     }
     if (isset($args['code_pere']) && $args['code_pere'] != "*") {
         $condition .= " AND code_pere LIKE '" . $args['code_pere'] . "' ";
     }
     if (isset($args['type_pere']) && $args['type_pere'] != "*") {
         $condition .= " AND type_pere LIKE '" . $args['type_pere'] . "' ";
     }
     if (isset($args['position']) && $args['position'] != "*") {
         $condition .= " AND position = '" . $args['position'] . "' ";
     }
     $condition .= " ORDER BY position ASC ";
     $sql .= $condition;
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_galerie'];
             $tab_result[$id]["id_galerie"] = $row['id_galerie'];
             $tab_result[$id]["id_pere"] = $row['id_pere'];
             $tab_result[$id]["code_pere"] = $row['code_pere'];
             $tab_result[$id]["type_pere"] = $row['type_pere'];
             $tab_result[$id]["position"] = $row['position'];
             $tab_result[$id]["url_vignette"] = $row['url_vignette'];
             $tab_result[$id]["largeur_vignette"] = $row['largeur_vignette'];
             $tab_result[$id]["hauteur_vignette"] = $row['hauteur_vignette'];
             $tab_result[$id]["url_gde_image"] = $row['url_gde_image'];
             $tab_result[$id]["info_galerie"] = $row['info_galerie'];
             // On récupère ensuite les données de la table modules
             $sql2 = "SELECT *\n\t\t\t\t\t  FROM " . $GLOBALS['prefix'] . "galeries_lang\n\t\t\t\t\t  WHERE id_galerie = {$id}";
             $result2 = Sql_query($sql2);
             $tab_result[$id]['versions'][$row2['lang']] = array();
             if ($result2) {
                 while ($row2 = Sql_fetch($result2)) {
                     $tab_result[$id]['versions'][$row2['lang']]['legende'] = Sql_prepareTexteAffichage($row2['legende']);
                     $tab_result[$id]['versions'][$row2['lang']]['data1'] = Sql_prepareTexteAffichage($row2['data1']);
                     $tab_result[$id]['versions'][$row2['lang']]['data2'] = Sql_prepareTexteAffichage($row2['data2']);
                     $tab_result[$id]['versions'][$row2['lang']]['data3'] = Sql_prepareTexteAffichage($row2['data3']);
                     $tab_result[$id]['versions'][$row2['lang']]['data4'] = Sql_prepareTexteAffichage($row2['data4']);
                     $tab_result[$id]['versions'][$row2['lang']]['data5'] = Sql_prepareTexteAffichage($row2['data5']);
                 }
             }
         }
     }
     return $tab_result;
 }
Beispiel #10
0
 function News_precedent($code_news, $position, $lang, $concours, $data)
 {
     $suivant = array();
     $suivants = array();
     $liste_news = $data;
     foreach ($liste_news as $new) {
         if ($new['code_news'] != $code_news) {
             continue;
         }
         if ($new['lang'] != $lang) {
             continue;
         }
         if ($new['position'] <= $position) {
             continue;
         }
         if ($new['code'] == 999999999) {
             continue;
         }
         if ($new['etat'] == 'supprime') {
             continue;
         }
         if (isset($concours) && $concours != '') {
             if ($new['titre_data2'] != $concours) {
                 continue;
             }
         }
         $suivants[$new['position']] = $new;
         asort($suivants);
     }
     /*=============*/
     Lib_myLog("Suivants:", $suivants);
     $suivant = array_shift($suivants);
     //SQL
     if (isset($concours) && $concours != '') {
         $cond_concours = "AND titre_data2 = '{$concours}' ";
     }
     $sql = " SELECT *\n\t\t\t\tFROM " . $GLOBALS['prefix'] . "new\n\t\t\t\tWHERE code_news = '{$code_news}'\n\t\t\t\tAND lang = '{$lang}'\n\t\t\t\tAND position > {$position}\n\t\t\t\tAND etat != 'supprime' " . $cond_concours . "\n\t\t\t\tORDER BY position ASC\n\t\t\t\tLIMIT 0, 1";
     if ($result && Sql_errorCode($result) === "00000") {
         $row = Sql_fetch($result);
         $suivant["id_new"] = $row['id_new'];
         $suivant["titre_data1"] = Sql_prepareTexteAffichage($row['titre_data1']);
         $suivant["data1"] = Sql_prepareTexteAffichage($row['data1']);
         $suivant["titre_data2"] = Sql_prepareTexteAffichage($row['titre_data2']);
         $suivant["data2"] = Sql_prepareTexteAffichage($row['data2']);
         $suivant["titre_data3"] = Sql_prepareTexteAffichage($row['titre_data3']);
         $suivant["data3"] = Sql_prepareTexteAffichage($row['data3']);
         $suivant["titre_data4"] = Sql_prepareTexteAffichage($row['titre_data4']);
         $suivant["data4"] = Sql_prepareTexteAffichage($row['data4']);
         $suivant["titre_data5"] = Sql_prepareTexteAffichage($row['titre_data5']);
         $suivant["data5"] = Sql_prepareTexteAffichage($row['data5']);
         $suivant["titre_data6"] = Sql_prepareTexteAffichage($row['titre_data6']);
         $suivant["data6"] = Sql_prepareTexteAffichage($row['data6']);
         $suivant["code_news"] = Sql_prepareTexteAffichage($row['code_news']);
         $suivant["code"] = $row['code'];
         $suivant["lang"] = Sql_prepareTexteAffichage($row['lang']);
         $suivant["etat"] = Sql_prepareTexteAffichage($row['etat']);
         $suivant["position"] = $row['position'];
         $suivant["titre"] = Sql_prepareTexteAffichage($row['titre']);
         $suivant["contenu"] = Sql_prepareTexteAffichage($row['contenu']);
         $suivant["texte_intro"] = Sql_prepareTexteAffichage($row['texte_intro']);
         $suivant["image_intro"] = Sql_prepareTexteAffichage($row['image_intro']);
         $suivant["date"] = Sql_prepareTexteAffichage($row['date']);
         $suivant["url_image"] = Sql_prepareTexteAffichage($row['url_image']);
         $suivant["url_image2"] = Sql_prepareTexteAffichage($row['url_image2']);
         $suivant["date_add"] = Sql_prepareTexteAffichage($row['date_add']);
         $suivant["date_upd"] = Sql_prepareTexteAffichage($row['date_upd']);
         $suivant["info_new"] = Sql_prepareTexteAffichage($row['info_new']);
     }
     return $suivant;
 }
 /**
 Retourne un tableau de fiche_memos correspondant aux champs du tableau en argument.
 @param $args
 */
 function FicheMemos_chercher($args)
 {
     $tab_result = array();
     $sql = " SELECT * \n\t\t\t\tFROM " . $GLOBALS['prefix'] . "fiche_memos\n\t\t\t\tWHERE 1";
     if (!isset($args['id_memo']) && !isset($args['id_fiche']) && !isset($args['order_by']) && !isset($args['tab_ids_memos']) && !isset($args['tab_ids_fiches'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_memo']) && $args['id_memo'] != "*") {
         $condition .= " AND id_memo = " . $args['id_memo'] . " ";
     }
     if (isset($args['id_fiche']) && $args['id_fiche'] != "*") {
         $condition .= " AND id_fiche = " . $args['id_fiche'] . " ";
     }
     if (isset($args['date_memo_min'])) {
         $condition .= " AND date_memo >= " . $args['date_memo_min'] . " ";
     }
     if (isset($args['date_memo_max'])) {
         $condition .= " AND date_memo <= " . $args['date_memo_max'] . " ";
     }
     if (isset($args['tab_ids_memos']) && $args['tab_ids_memos'] != "*") {
         $ids = implode(",", $args['tab_ids_memos']);
         $condition .= " AND id_memo IN (0" . $ids . ") ";
     }
     if (isset($args['tab_ids_fiches']) && $args['tab_ids_fiches'] != "*") {
         $ids = implode(",", $args['tab_ids_fiches']);
         $condition .= " AND id_fiche IN (0" . $ids . ") ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         while ($row = Sql_fetch($result)) {
             $id = $row['id_memo'];
             $tab_result[$id]["id_memo"] = $id;
             $tab_result[$id]["id_fiche"] = $row['id_fiche'];
             $tab_result[$id]["date_memo"] = $row['date_memo'];
             $tab_result[$id]["memo"] = Sql_prepareTexteAffichage($row['memo']);
             $tab_result[$id]["date_add"] = $row['date_add'];
             $tab_result[$id]["date_upd"] = $row['date_upd'];
             $tab_result[$id]["info_memo"] = Sql_prepareTexteAffichage($row['info_memo']);
         }
     }
     if (count($tab_result) == 1 && ($args['id_memo'] != '' && $args['id_memo'] != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
     Récupère tous les identifiants verifiant le etat fourni
     /param etat
     /param type_parametre
 */
 function Parametres_chercher($id_utilisateur = '', $code_parametre = '', $type_parametre = '', $designation = '', $etat = '')
 {
     $tab_result = array();
     $sql = " SELECT distinct(code_parametre), type_parametre, designation, etat, info_parametre\n            FROM " . $GLOBALS['prefix'] . "sys_parametres\n            WHERE 1";
     if ("{$id_utilisateur}" == "" && $code_parametre == "" && $etat == "" && $type_parametre == "" && $designation == "") {
         return $tab_result;
     }
     $condition = "";
     if ($id_utilisateur != "" && $id_utilisateur != "*") {
         $condition .= " AND id_utilisateur = {$id_utilisateur} ";
     }
     if ($code_parametre != "" && $code_parametre != "*") {
         $condition .= " AND code_parametre = '{$code_parametre}' ";
     }
     if ($etat != "" && $etat != "*") {
         $condition .= " AND etat = '{$etat}' ";
     }
     if ($type_parametre != "" && $type_parametre != "*") {
         $condition .= " AND type_parametre = '{$type_parametre}' ";
     }
     if ($designation != "" && $designation != "*") {
         $condition .= " AND designation LIKE '%{$designation}%' ";
     }
     $sql .= $condition;
     $result = Sql_query($sql);
     if ($result && Sql_errorCode($result) === "00000") {
         $i = 0;
         while ($row = Sql_fetch($result)) {
             $tab_result[$i]["id_utilisateur"] = $row['id_utilisateur'];
             $tab_result[$i]["code_parametre"] = $row['code_parametre'];
             $tab_result[$i]["type_parametre"] = $row['type_parametre'];
             $tab_result[$i]["designation"] = $row['designation'];
             $tab_result[$i]["etat"] = $row['etat'];
             $tab_result[$i]["info_parametre"] = Sql_prepareTexteAffichage($row['info_parametre']);
             $i++;
         }
     }
     if (count($tab_result) == 1 && ($code_parametre != '' && "{$id_utilisateur}" != '*')) {
         $tab_result = array_pop($tab_result);
     }
     return $tab_result;
 }
 /**
 Retourne un tableau de commandes correspondant aux champs du tableau en argument.
 @param $args
 */
 function Commandes_chercher($args)
 {
     $count = 0;
     $tab_result = array();
     if (isset($args['count'])) {
         $sql = " SELECT count(*) nb_enregistrements \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "commande\n\t\t\t\t\tWHERE 1";
     } else {
         $sql = " SELECT * \n\t\t\t\t\tFROM " . $GLOBALS['prefix'] . "commande\n\t\t\t\t\tWHERE 1";
     }
     if (!isset($args['id_commande']) && !isset($args['id_utilisateur']) && !isset($args['id_customer']) && !isset($args['id_pg_vg']) && !isset($args['date_commande']) && !isset($args['etat']) && !isset($args['order_by']) && !isset($args['etat']) && !isset($args['tab_ids_commandes'])) {
         return $tab_result;
     }
     $condition = "";
     if (isset($args['id_commande']) && $args['id_commande'] != "*") {
         $condition .= " AND id_commande = '" . $args['id_commande'] . "' ";
     }
     if (isset($args['id_utilisateur']) && $args['id_utilisateur'] != "*") {
         $condition .= " AND id_utilisateur = '" . $args['id_utilisateur'] . "' ";
     }
     if (isset($args['id_customer']) && $args['id_customer'] != "*") {
         $condition .= " AND id_customer = '" . $args['id_customer'] . "' ";
     }
     if (isset($args['id_pg_vg']) && $args['id_pg_vg'] != "*") {
         $condition .= " AND id_pg_vg = '" . $args['id_pg_vg'] . "' ";
     }
     if (isset($args['date_commande']) && $args['date_commande'] != "*") {
         $condition .= " AND date_commande = '" . Lib_frToEn($args['date_commande']) . "' ";
     }
     if (isset($args['etat']) && $args['etat'] != "*") {
         $condition .= " AND etat = '" . $args['etat'] . "' ";
     }
     if (isset($args['tab_ids_commandes']) && $args['tab_ids_commandes'] != "*") {
         $ids = implode(",", $args['tab_ids_commandes']);
         $condition .= " AND id_commande IN (0" . $ids . ") ";
     }
     if (!isset($args['etat'])) {
         $condition .= " AND etat != 'supprime' ";
     }
     $sql .= $condition;
     if (isset($args['order_by']) && !isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " ASC";
     }
     if (isset($args['order_by']) && isset($args['asc_desc'])) {
         $sql .= " ORDER BY " . $args['order_by'] . " " . $args['asc_desc'];
     }
     if (isset($args['limit']) && !isset($args['start'])) {
         $sql .= " LIMIT " . $args['limit'];
     }
     if (isset($args['limit']) && isset($args['start'])) {
         $sql .= " LIMIT " . $args['start'] . "," . $args['limit'];
     }
     /*=============*/
     Lib_myLog("SQL: {$sql}");
     $result = Sql_query($sql);
     if (isset($args['count'])) {
         if ($result && Sql_errorCode($result) === "00000") {
             $row = Sql_fetch($result);
             $count = $row['nb_enregistrements'];
         }
         return $count;
     } else {
         if ($result && Sql_errorCode($result) === "00000") {
             while ($row = Sql_fetch($result)) {
                 $id = $row['id_commande'];
                 $tab_result[$id]["id_commande"] = $id;
                 $tab_result[$id]["id_utilisateur"] = $row['id_utilisateur'];
                 $tab_result[$id]["id_customer"] = $row['id_customer'];
                 $tab_result[$id]["id_pg_vg"] = $row['id_pg_vg'];
                 $tab_result[$id]["date_commande"] = Lib_enToFr($row['date_commande']);
                 $tab_result[$id]["nb_imp"] = $row['nb_imp'];
                 $tab_result[$id]["num_lot"] = Sql_prepareTexteAffichage($row['num_lot']);
                 $tab_result[$id]["etat"] = $row['etat'];
                 $tab_result[$id]["date_add"] = $row['date_add'];
                 $tab_result[$id]["date_upd"] = $row['date_upd'];
                 $tab_result[$id]["info_commande"] = Sql_prepareTexteAffichage($row['info_commande']);
             }
         }
         if (count($tab_result) == 1 && ($args['id_commande'] != '' && $args['id_commande'] != '*')) {
             $tab_result = array_pop($tab_result);
         }
     }
     return $tab_result;
 }