[SPIP] ~version 3.0.7-->3.0.10
[ptitvelo/web/www.git] / www / ecrire / public / criteres.php
index 562414a..254e373 100644 (file)
@@ -1604,7 +1604,9 @@ function calculer_critere_infixe_date($idb, &$boucles, $col){
        if (!preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,", $col, $regs)) return '';
        $boucle = $boucles[$idb];
        $table = $boucle->show;
-       
+       // si c'est une colonne de la table, ne rien faire
+       if(isset($table['field'][$col])) return '';
+
        if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) return '';
        $pred = $date_orig = isset($GLOBALS['table_date'][$table['id_table']])? $GLOBALS['table_date'][$table['id_table']] : $table['date'];
        $col = $regs[1];
@@ -1612,7 +1614,7 @@ function calculer_critere_infixe_date($idb, &$boucles, $col){
                # Recherche de l'existence du champ date_xxxx,
                # si oui choisir ce champ, sinon choisir xxxx
 
-               if ($table['field']["date$suite"])
+               if (isset($table['field']["date$suite"]))
                        $date_orig = 'date'.$suite;
                else
                        $date_orig = substr($suite, 1);
@@ -1653,12 +1655,7 @@ function calculer_critere_infixe_date($idb, &$boucles, $col){
                        $col_vraie = "";// comparer a un int (par defaut)
                        break;
                case 'jour_relatif':
-                       $col = "LEAST(TO_DAYS(".$date_compare.")-TO_DAYS(".
-                              $date_orig."), DAYOFMONTH(".$date_compare.
-                              ")-DAYOFMONTH(".$date_orig.")+30.4368*(MONTH(".
-                              $date_compare.")-MONTH(".$date_orig.
-                              "))+365.2422*(YEAR(".$date_compare.")-YEAR(".
-                              $date_orig.")))";
+                       $col = "(TO_DAYS(".$date_compare.")-TO_DAYS(".$date_orig."))";
                        $col_vraie = "";// comparer a un int (par defaut)
                        break;
                case 'mois_relatif':