]> git.agnieray.net Git - galette.git/commitdiff
Fix contributions date filters; closes #1469
authorJohan Cwiklinski <johan@x-tnd.be>
Mon, 3 Aug 2020 12:37:47 +0000 (14:37 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Mon, 3 Aug 2020 12:37:47 +0000 (14:37 +0200)
galette/lib/Galette/Filters/ContributionsList.php
galette/lib/Galette/Repository/Contributions.php

index c44c193b9ad5e5a6c8b13c69cec797905af4f425..6a98c0db6ed68dc49939ead4998e9f7106feb12f 100644 (file)
@@ -153,10 +153,15 @@ class ContributionsList extends Pagination
                     case 'start_date_filter':
                     case 'end_date_filter':
                         try {
-                            if ($this->$name !== null) {
-                                $d = new \DateTime($this->$name);
-                                return $d->format(__("Y-m-d"));
+                            $d = \DateTime::createFromFormat(__("Y-m-d"), $this->$name);
+                            if ($d === false) {
+                                //try with non localized date
+                                $d = \DateTime::createFromFormat("Y-m-d", $this->$name);
+                                if ($d === false) {
+                                    throw new \Exception('Incorrect format');
+                                }
                             }
+                            return $d->format(__("Y-m-d"));
                         } catch (\Exception $e) {
                             //oops, we've got a bad date :/
                             Analog::log(
index f89f4ebfc6785e2cc178341fa55c5ca1fde95322..05ba54c983f76e81879c3173f887c139f2875670 100644 (file)
@@ -323,7 +323,7 @@ class Contributions
 
         try {
             if ($this->filters->start_date_filter != null) {
-                $d = new \DateTime($this->filters->start_date_filter);
+                $d = new \DateTime($this->filters->rstart_date_filter);
                 $select->where->greaterThanOrEqualTo(
                     $field,
                     $d->format('Y-m-d')
@@ -331,7 +331,7 @@ class Contributions
             }
 
             if ($this->filters->end_date_filter != null) {
-                $d = new \DateTime($this->filters->end_date_filter);
+                $d = new \DateTime($this->filters->rend_date_filter);
                 $select->where->lessThanOrEqualTo(
                     $field,
                     $d->format('Y-m-d')