Projet

Général

Profil

Actions

Evolution #813

fermé

Sélection de la date de filtrage des contributions

Ajouté par Johan Cwiklinski il y a presque 10 ans. Mis à jour il y a presque 10 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Catégorie:
Core
Version cible:
Début:
11/05/2014
Echéance:
% réalisé:

100%

Temps estimé:

Mis à jour par Johan Cwiklinski il y a presque 10 ans

diff --git a/galette/gestion_contributions.php b/galette/gestion_contributions.php
index b9e6ae1..6a68f3e 100644
--- a/galette/gestion_contributions.php
+++ b/galette/gestion_contributions.php
@@ -92,6 +92,7 @@ if ( isset($_GET['clear_filter']) ) {
     $contribs->reinit();
 } else {
     if ( isset($_GET['end_date_filter']) || isset($_GET['start_date_filter']) ) {
+        $contribs->date_field = (int)$_GET['date_field_filter'];
         try {
             if ( isset($_GET['start_date_filter']) ) {
                 $field = _T("start date filter");
diff --git a/galette/lib/Galette/Repository/Contributions.php b/galette/lib/Galette/Repository/Contributions.php
index 44e53c1..1b68a46 100644
--- a/galette/lib/Galette/Repository/Contributions.php
+++ b/galette/lib/Galette/Repository/Contributions.php
@@ -71,7 +71,12 @@ class Contributions extends Pagination
     const ORDERBY_DURATION = 6;
     const ORDERBY_PAYMENT_TYPE = 7;

+    const DATE_BEGIN = 0;
+    const DATE_END = 1;
+    const DATE_RECORD = 2;
+
     private $_count = null;
+    private $_date_field = null;
     private $_start_date_filter = null;
     private $_end_date_filter = null;
     private $_payment_type_filter = null;
@@ -88,6 +93,7 @@ class Contributions extends Pagination
     public function __construct()
     {
         parent::__construct();
+        $this->_date_field = self::DATE_BEGIN;
     }

     /**
@@ -350,11 +356,26 @@ class Contributions extends Pagination
     {
         global $zdb, $login;

+        $field = 'date_debut_cotis';
+
+        switch ( $this->_date_field ) {
+        case self::DATE_RECORD:
+            $field = 'date_enreg';
+            break;
+        case self::DATE_END:
+            $field = 'date_fin_cotis';
+            break;
+        case self::DATE_BEGIN:
+        default:
+            $field = 'date_debut_cotis';
+            break;
+        }
+
         try {
             if ( $this->_start_date_filter != null ) {
                 $d = new \DateTime($this->_start_date_filter);
                 $select->where->greaterThanOrEqualTo(
-                    'date_debut_cotis',
+                    $field,
                     $d->format('Y-m-d')
                 );
             }
@@ -362,7 +383,7 @@ class Contributions extends Pagination
             if ( $this->_end_date_filter != null ) {
                 $d = new \DateTime($this->_end_date_filter);
                 $select->where->lessThanOrEqualTo(
-                    'date_debut_cotis',
+                    $field,
                     $d->format('Y-m-d')
                 );
             }
@@ -425,6 +446,7 @@ class Contributions extends Pagination
     public function reinit()
     {
         parent::reinit();
+        $this->_date_field = self::DATE_BEGIN;
         $this->_start_date_filter = null;
         $this->_end_date_filter = null;
         $this->_payment_type_filter = null;
@@ -524,6 +546,7 @@ class Contributions extends Pagination
         } else {
             $return_ok = array(
                 'filtre_cotis_adh',
+                'date_field',
                 'start_date_filter',
                 'end_date_filter',
                 'payment_type_filter',
diff --git a/galette/templates/default/gestion_contributions.tpl b/galette/templates/default/gestion_contributions.tpl
index b810085..588599d 100644
--- a/galette/templates/default/gestion_contributions.tpl
+++ b/galette/templates/default/gestion_contributions.tpl
@@ -1,6 +1,12 @@
         <form action="gestion_contributions.php" method="get" id="filtre">
         <div id="listfilter">
-            <label for="start_date_filter">{_T string="Show contributions since"}</label>&nbsp;
+            <label for="date_field_filter">{_T string="Show contributions by"}</label>&nbsp;
+            <select name="date_field_filter" id="date_field_filter">
+                <option value="{php}echo Galette\Repository\Contributions::DATE_BEGIN;{/php}"{if $contributions->date_field eq constant('Galette\Repository\Contributions::DATE_BEGIN')} selected="selected"{/if}>{_T string="Begin"}</option
+                <option value="{php}echo Galette\Repository\Contributions::DATE_END;{/php}"{if $contributions->date_field eq constant('Galette\Repository\Contributions::DATE_END')} selected="selected"{/if}>{_T string="End"}</option>
+                <option value="{php}echo Galette\Repository\Contributions::DATE_RECORD;{/php}"{if $contributions->date_field eq constant('Galette\Repository\Contributions::DATE_RECORD')} selected="selected"{/if}>{_T string="Record"}</opt
+            </select>
+            <label for="start_date_filter">{_T string="since"}</label>&nbsp;
             <input type="text" name="start_date_filter" id="start_date_filter" maxlength="10" size="10" value="{$contributions->start_date_filter}"/>
             <label for="end_date_filter">{_T string="until"}</label>&nbsp;
             <input type="text" name="end_date_filter" id="end_date_filter" maxlength="10" size="10" value="{$contributions->end_date_filter}"/>

Mis à jour par Johan Cwiklinski il y a presque 10 ans

  • Statut changé de In Progress à Résolu
  • % réalisé changé de 0 à 100

Mis à jour par Johan Cwiklinski il y a presque 10 ans

  • Statut changé de Résolu à Fermé
Actions

Formats disponibles : Atom PDF