]> git.agnieray.net Git - galette.git/commitdiff
Filter on member must precede filter on children
authorJohan Cwiklinski <johan@x-tnd.be>
Sat, 9 Oct 2021 06:03:57 +0000 (08:03 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 17 Oct 2021 04:15:40 +0000 (06:15 +0200)
galette/lib/Galette/Repository/Contributions.php
galette/lib/Galette/Repository/Transactions.php

index 8a23c9bd193615d437b08fde0649e2e57da6b80b..77a68c28cb8407d0548da7ea3d9566020716a0d8 100644 (file)
@@ -365,32 +365,17 @@ class Contributions
             }
 
             $member_clause = null;
-            if ($this->filters->filtre_cotis_children !== false) {
-                $member_clause = [$this->login->id];
-                $member = new Adherent(
-                    $this->zdb,
-                    (int)$this->filters->filtre_cotis_children,
-                    [
-                        'picture'   => false,
-                        'groups'    => false,
-                        'dues'      => false,
-                        'children'  => true
-                    ]
-                );
-                foreach ($member->children as $child) {
-                    $member_clause[] = $child->id;
-                }
-            } elseif ($this->filters->filtre_cotis_adh != null) {
+            if ($this->filters->filtre_cotis_adh != null) {
                 $member_clause = [$this->filters->filtre_cotis_adh];
                 if (!$this->login->isAdmin() && !$this->login->isStaff() && $this->filters->filtre_cotis_adh != $this->login->id) {
                     $member = new Adherent(
                         $this->zdb,
                         (int)$this->filters->filtre_cotis_adh,
                         [
-                            'picture'   => false,
-                            'groups'    => false,
-                            'dues'      => false,
-                            'parent'    => true
+                            'picture' => false,
+                            'groups' => false,
+                            'dues' => false,
+                            'parent' => true
                         ]
                     );
                     if (
@@ -405,6 +390,21 @@ class Contributions
                         $member_clause = [$this->login->id];
                     }
                 }
+            } elseif ($this->filters->filtre_cotis_children !== false) {
+                $member_clause = [$this->login->id];
+                $member = new Adherent(
+                    $this->zdb,
+                    (int)$this->filters->filtre_cotis_children,
+                    [
+                        'picture'   => false,
+                        'groups'    => false,
+                        'dues'      => false,
+                        'children'  => true
+                    ]
+                );
+                foreach ($member->children as $child) {
+                    $member_clause[] = $child->id;
+                }
             } elseif (!$this->login->isAdmin() && !$this->login->isStaff()) {
                 //non staff members can only view their own contributions
                 $member_clause = $this->login->id;
index 19dbfe24a13d19ac53f408cd8788d0b8d2d1e774..8c103d8883f3d3250eab6a5953899b03f30b536f 100644 (file)
@@ -266,32 +266,17 @@ class Transactions
             }
 
             $member_clause = null;
-            if ($this->filters->filtre_cotis_children !== false) {
-                $member_clause = [$this->login->id];
-                $member = new Adherent(
-                    $this->zdb,
-                    (int)$this->filters->filtre_cotis_children,
-                    [
-                        'picture'   => false,
-                        'groups'    => false,
-                        'dues'      => false,
-                        'children'  => true
-                    ]
-                );
-                foreach ($member->children as $child) {
-                    $member_clause[] = $child->id;
-                }
-            } elseif ($this->filters->filtre_cotis_adh != null) {
+            if ($this->filters->filtre_cotis_adh != null) {
                 $member_clause = [$this->filters->filtre_cotis_adh];
                 if (!$this->login->isAdmin() && !$this->login->isStaff() && $this->filters->filtre_cotis_adh != $this->login->id) {
                     $member = new Adherent(
                         $this->zdb,
                         (int)$this->filters->filtre_cotis_adh,
                         [
-                            'picture'   => false,
-                            'groups'    => false,
-                            'dues'      => false,
-                            'parent'    => true
+                            'picture' => false,
+                            'groups' => false,
+                            'dues' => false,
+                            'parent' => true
                         ]
                     );
                     if (
@@ -306,6 +291,21 @@ class Transactions
                         $member_clause = [$this->login->id];
                     }
                 }
+            } elseif ($this->filters->filtre_cotis_children !== false) {
+                $member_clause = [$this->login->id];
+                $member = new Adherent(
+                    $this->zdb,
+                    (int)$this->filters->filtre_cotis_children,
+                    [
+                        'picture'   => false,
+                        'groups'    => false,
+                        'dues'      => false,
+                        'children'  => true
+                    ]
+                );
+                foreach ($member->children as $child) {
+                    $member_clause[] = $child->id;
+                }
             } elseif (!$this->login->isAdmin() && !$this->login->isStaff()) {
                 $member_clause = $this->login->id;
             }