From 8f0346782abfa38f6cfa9110c221c63b4960e135 Mon Sep 17 00:00:00 2001
From: Okhin <okhin@okhin.fr>
Date: Thu, 20 Dec 2018 15:23:51 +0100
Subject: [PATCH] Updating the history

---
 app/controller/perso.php | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/app/controller/perso.php b/app/controller/perso.php
index ada08ea..ca2e079 100644
--- a/app/controller/perso.php
+++ b/app/controller/perso.php
@@ -67,8 +67,8 @@ class Perso extends Controller
         // Chargement des dons de l'utilisateur
         $db = $f3->get('DB');
         $dons = $f3->get('container')['donation_finder']->findByUserId((int) $f3->get('SESSION.id'));
-        $dons = array_filter($dons, function ($id) {
-            return in_array((int) $id, [1, 4, 102]);
+        $dons = array_filter($dons, function ($don) {
+            return in_array((int) $don['status'], [1, 4]);
         });
         $f3->set('dons', $dons);
     }
@@ -77,12 +77,11 @@ class Perso extends Controller
     {
         // Chargement des abonnements de l'utilisateur
         $db = $f3->get('DB');
-        $result = $db->query("SELECT datec, somme, status, id, pdf, identifier FROM dons WHERE user_id='".$f3->get('infos.id')."' AND status IN (101) ORDER BY datec ASC");
-        $data = array();
-        foreach ($result->fetchAll(\PDO::FETCH_ASSOC) as $row) {
-            $data[] = $row;
-        }
-        $f3->set('dons_recurrents', $data);
+        $dons = $f3->get('container')['donation_finder']->findByUserId((int) $f3->get('SESSION.id'));
+        $dons = array_filter($dons, function ($don) {
+            return in_array((int) $don['status'], [101, 102]);
+        });
+        $f3->set('dons_recurrents', $dons);
     }
 
     public function login($f3, $args)
-- 
GitLab