From 2dd99ad8e2a8bc0ff0315b0117ebf5ac698252b3 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 16 Jan 2011 14:57:56 +0000 Subject: [PATCH] Filter year on the current year --- include/balance.inc.php | 4 ++-- include/class_iperiod.php | 10 +++++++--- include/pref.inc.php | 2 ++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/balance.inc.php b/include/balance.inc.php index 181e86dbf..c95686934 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -51,14 +51,14 @@ $input_from=new IPeriod("from_periode",$from); $input_from->show_end_date=false; $input_from->type=ALL; $input_from->cn=$cn; -$input_from->filter_year; +$input_from->filter_year=true; $input_from->user=$User; echo 'Depuis :'.$input_from->input(); // filter on the current year $to=(isset($_GET["to_periode"]))?$_GET['to_periode']:""; $input_to=new IPeriod("to_periode",$to); $input_to->show_start_date=false; -$input_to->filter_year; +$input_to->filter_year=true; $input_to->type=ALL; $input_to->cn=$cn; $input_to->user=$User; diff --git a/include/class_iperiod.php b/include/class_iperiod.php index 46276e3e9..618333bb3 100644 --- a/include/class_iperiod.php +++ b/include/class_iperiod.php @@ -95,15 +95,19 @@ class IPeriod extends HtmlInput to_char(p_end,'DD.MM.YYYY') as p_end_string from parm_periode $sql_closed "; + + $cond=""; + /* Create a filter on the current exercice */ if ( ! isset($this->filter_year) || (isset($this->filter_year) && $this->filter_year==true)) { if (! isset($this->user) ) throw new Exception (__FILE__.':'.__LINE__.' user is not set'); $cond=''; - if ($this->type == 'all' ) $cond=' where true '; - $cond.=" and p_exercice='".$this->user->get_exercice()."'"; + if ( $sql_closed=="") $and=" where " ; else $and=" and "; + if ($this->type == 'all' ) $cond=$and.' true '; + $cond.=" $and p_exercice='".$this->user->get_exercice()."'"; } - $sql.=" order by p_start,p_end"; + $sql.=$cond." order by p_start,p_end"; $Res=$this->cn->exec_sql($sql); $Max=$this->cn->size($Res); if ( $Max == 0 ) throw new Exception(_('Aucune periode trouvée'),1); diff --git a/include/pref.inc.php b/include/pref.inc.php index a3e475b88..17865c718 100644 --- a/include/pref.inc.php +++ b/include/pref.inc.php @@ -135,6 +135,7 @@ if ( isset ($_REQUEST['gDossier'])) // if periode is closed then warns the users $period=new Periode($cn,$l_user_per); + $period->p_id=$l_user_per; $period->jrn_def_id=0; if ( $period->is_closed($l_user_per)==1) @@ -147,6 +148,7 @@ if ( isset ($_REQUEST['gDossier'])) $period=new IPeriod("period"); $period->user=$User; $period->cn=$cn; + $period->filter_year=false; $period->value=$l_user_per; $period->type=ALL; $l_form_per=$period->input();