From 0de1fd1ebfd1aa39e6d7adb3ee799eed68c26ed3 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 20 Jan 2011 14:53:01 +0000 Subject: [PATCH] #203 add button to change current year to another one --- include/balance.inc.php | 30 +++++++++++++++++++++++++----- include/class_iperiod.php | 19 +++++++++++++++---- include/impress_bilan.inc.php | 22 +++++++++++++++++++++- include/impress_jrn.inc.php | 24 ++++++++++++++++++++---- 4 files changed, 81 insertions(+), 14 deletions(-) diff --git a/include/balance.inc.php b/include/balance.inc.php index c95686934..f6561c980 100644 --- a/include/balance.inc.php +++ b/include/balance.inc.php @@ -33,30 +33,50 @@ require_once("class_icheckbox.php"); require_once("class_ihidden.php"); require_once('class_acc_ledger.php'); require_once('class_periode.php'); +require_once('class_exercice.php'); $User->can_request(IMPBAL); -require_once('class_ipopup.php'); -echo IPoste::ipopup('ipop_account'); +$exercice=(isset($_GET['exercice']))?$_GET['exercice']:$User->get_exercice(); + + echo '
'; +/* + * Let you change the exercice + */ +echo '
'._('Choississez un autre exercice').'';; +echo '
'; +echo 'Choississez un autre exercice :'; +$ex=new Exercice($cn); +$wex=$ex->select('exercice',$exercice,' onchange="submit(this)"'); +echo $wex->input(); +echo dossier::hidden(); +echo HtmlInput::get_to_hidden(array('p_action','type')); +echo '
'; +echo '
'; + // Show the form for period echo '
'; echo HtmlInput::hidden('p_action','impress'); echo HtmlInput::hidden('type','bal'); - +echo HtmlInput::get_to_hidden(array('exercice')); echo dossier::hidden(); + + + // filter on the current year $from=(isset($_GET["from_periode"]))?$_GET['from_periode']:""; -$input_from=new IPeriod("from_periode",$from); +$input_from=new IPeriod("from_periode",$from,$exercice); $input_from->show_end_date=false; $input_from->type=ALL; $input_from->cn=$cn; $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=new IPeriod("to_periode",$to,$exercice); $input_to->show_start_date=false; $input_to->filter_year=true; $input_to->type=ALL; diff --git a/include/class_iperiod.php b/include/class_iperiod.php index 618333bb3..665344c14 100644 --- a/include/class_iperiod.php +++ b/include/class_iperiod.php @@ -41,7 +41,7 @@ class IPeriod extends HtmlInput var $show_start_date; /*!< $show_start_date is not set or false, do not show the start date */ var $filter_year; /*!< $filter_year make a filter on the default exercice by default yes */ var $user; /*! $user if a filter is required then we need who is the user (object User)*/ - function __construct($p_name="",$p_value="") + function __construct($p_name="",$p_value="",$p_exercice='') { $this->name=$p_name; $this->readOnly=false; @@ -56,10 +56,13 @@ class IPeriod extends HtmlInput $this->extra2="all"; $this->show_start_date=true; $this->show_end_date=true; - + $this->exercice=$p_exercice; } /*! * \brief show the input html for a periode + *\param $p_name is the name of the widget + *\param $p_value is the default value + *\param $p_exercice is the exercice, if not set then the user preference is used * \return string containing html code for the HTML * * @@ -98,16 +101,24 @@ class IPeriod extends HtmlInput $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'); + if ( $this->exercice=='') + { + if (! isset($this->user) ) throw new Exception (__FILE__.':'.__LINE__.' user is not set'); + $this->exercice=$this->user->get_exercice(); + } + $cond=''; if ( $sql_closed=="") $and=" where " ; else $and=" and "; if ($this->type == 'all' ) $cond=$and.' true '; - $cond.=" $and p_exercice='".$this->user->get_exercice()."'"; + $cond.=" $and p_exercice='".FormatString($this->exercice)."'"; } + $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/impress_bilan.inc.php b/include/impress_bilan.inc.php index c1b63db3c..e8d63003e 100644 --- a/include/impress_bilan.inc.php +++ b/include/impress_bilan.inc.php @@ -18,6 +18,8 @@ */ /* $Revision$ */ require_once ('class_acc_bilan.php'); +require_once('class_exercice.php'); + //ini_set("memory_limit","150M"); /*! \file * \brief form who call the printing of the bilan in RTF @@ -34,17 +36,34 @@ require_once('class_database.php'); //----------------------------------------------------- // Form //----------------------------------------------------- -$filter_year=" where p_exercice='".$User->get_exercice()."'"; + $bilan=new Acc_Bilan($cn); $bilan->get_request_get(); echo '
'; +$exercice=(isset($_GET['exercice']))?$_GET['exercice']:$User->get_exercice(); +/* + * Let you change the exercice + */ +echo '
'._('Choississez un autre exercice').'';; +echo ''; +echo 'Choississez un autre exercice :'; +$ex=new Exercice($cn); +$wex=$ex->select('exercice',$exercice,' onchange="submit(this)"'); +echo $wex->input(); +echo dossier::hidden(); +echo HtmlInput::get_to_hidden(array('p_action','type')); +echo ''; +echo '
'; + +$filter_year=" where p_exercice='".FormatString($exercice)."'"; echo '
'; echo HtmlInput::hidden('p_action','impress'); echo HtmlInput::hidden('type','bilan'); echo dossier::hidden(); echo $bilan->display_form ($filter_year); echo HtmlInput::submit('verif',_('Verification comptabilite')); +echo HtmlInput::get_to_hidden(array('exercice')); echo '
'; @@ -58,6 +77,7 @@ if ( isset($_GET['verif'])) echo '
'; echo dossier::hidden(); + echo HtmlInput::get_to_hidden(array('exercice')); echo HtmlInput::hidden('b_id',$_GET['b_id']); echo HtmlInput::hidden('from_periode',$bilan->from); diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index fbaf2ecf2..56378d5df 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -25,7 +25,7 @@ require_once("class_ihidden.php"); require_once("class_iselect.php"); require_once("class_icheckbox.php"); - +require_once('class_exercice.php'); require_once('class_dossier.php'); load_all_script(); $gDossier=dossier::id(); @@ -70,16 +70,32 @@ if ( $NoPriv == 0 ) } if ( count($ret) < 1 ) NoAccess(); +$exercice=(isset($_GET['exercice']))?$_GET['exercice']:$User->get_exercice(); //----------------------------------------------------- // Form //----------------------------------------------------- - echo '
'; +/* + * Let you change the exercice + */ +echo '
'._('Choississez un autre exercice').'';; +echo ''; +echo 'Choississez un autre exercice :'; +$ex=new Exercice($cn); +$wex=$ex->select('exercice',$exercice,' onchange="submit(this)"'); +echo $wex->input(); +echo dossier::hidden(); +echo HtmlInput::get_to_hidden(array('p_action','type')); +echo ''; +echo '
'; + + + echo '
'.dossier::hidden(); echo HtmlInput::hidden('p_action','impress'); echo HtmlInput::hidden('type','jrn'); - +echo HtmlInput::get_to_hidden(array('exercice')); echo ''; $w=new ISelect(); $w->table=1; @@ -89,7 +105,7 @@ print td($label).$w->input("jrn_id",$ret); print ''; print ''; // filter on the current year -$filter_year=" where p_exercice='".$User->get_exercice()."'"; +$filter_year=" where p_exercice='".FormatString($exercice)."'"; $periode_start=$cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end"); $w->selected=(isset($_GET['from_periode']))?$_GET['from_periode']:'';