Project

General

Profile

Anomalie #619

Recherche avancée sur plusieurs champs dynamique de type choix

Added by Johan Cwiklinski over 6 years ago. Updated over 6 years ago.

Status:
Fermé
Priority:
Normal
Category:
Core
Target version:
-
Start date:
06/07/2013
Due date:
% Done:

0%

Estimated time:
Version utilisée:
Vote:

Description

La requête construite est incorrecte dans les jointures requises pour les champs de type choix

Associated revisions

Revision fe7325f3 (diff)
Added by Johan Cwiklinski over 6 years ago

SQL error trying to search on multiple choice dynamic fields; fixes #619

History

#1

Updated by Johan Cwiklinski over 6 years ago

  • Status changed from Nouveau to In Progress

Le correctif (à priori) :

diff --git a/galette/lib/Galette/Repository/Members.php b/galette/lib/Galette/Repository/Members.php
index 861f98c..2b77b8b 100644
--- a/galette/lib/Galette/Repository/Members.php
+++ b/galette/lib/Galette/Repository/Members.php
@@ -622,8 +622,7 @@ class Members
                 }
             }

-
-            //check if tehre are dynamic fields for contributions in filter
+            //check if there are dynamic fields for contributions in filter
             $hasDfc = false;
             $hasCdfc = false;
             if ( $this->_filters instanceof AdvancedMembersList
@@ -668,9 +667,14 @@ class Members
                     $cdf_field .= '::text';
                 }
                 foreach ( $cdfs as $cdf ) {
+                    $rcdf_field = str_replace(
+                        'cdf.',
+                        'cdf' . $cdf . '.',
+                        $cdf_field
+                    );
                     $select->joinLeft(
-                        array('cdf' => DynamicFields::getFixedValuesTableName($cdf)),
-                        $cdf_field . '=df.field_val',
+                        array('cdf' . $cdf => DynamicFields::getFixedValuesTableName($cdf)),
+                        $rcdf_field . '=df.field_val',
                         array()
                     );
                 }
@@ -680,9 +684,14 @@ class Members
                     $cdf_field .= '::text';
                 }
                 foreach ( $cdfcs as $cdf ) {
+                    $rcdf_field = str_replace(
+                        'cdfc.',
+                        'cdfc' . $cdf . '.',
+                        $cdf_field
+                    );
                     $select->joinLeft(
-                        array('cdfc' => DynamicFields::getFixedValuesTableName($cdf)),
-                        $cdf_field . '=dfc.field_val',
+                        array('cdfc' . $cdf => DynamicFields::getFixedValuesTableName($cdf)),
+                        $rcdf_field . '=dfc.field_val',
                         array()
                     );
                 }
@@ -1198,7 +1207,7 @@ class Members

                         if ( is_array($cd) ) {
                             //dynamic choice spotted!
-                            $prefix = 'cdfc.';
+                            $prefix = 'cdfc' . $k . '.';
                             $qry = 'dfc.field_form = \'contrib\' AND ' .
                                 'dfc.field_id = ' . $k . ' AND ';
                             $field = 'id';
@@ -1267,7 +1276,8 @@ class Members
                         $prefix = 'a.';
                         if ( strpos($fs['field'], 'dync_') === 0 ) {
                             //dynamic choice spotted!
-                            $prefix = 'cdf.';
+                            $index = str_replace('dync_', '', $fs['field']);
+                            $prefix = 'cdf' . $index . '.';
                             $qry = 'df.field_form = \'adh\' AND df.field_id = ' .
                                 str_replace('dync_', '', $fs['field']) . ' AND ';
                             $fs['field'] = 'val';

#2

Updated by Johan Cwiklinski over 6 years ago

  • Status changed from In Progress to Fermé

Also available in: Atom PDF