#203 add button to change current year to another one

This commit is contained in:
Dany De Bontridder 2011-01-20 14:53:01 +00:00
parent 458826f56d
commit 0de1fd1ebf
4 changed files with 81 additions and 14 deletions

View file

@ -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 '<div class="content">';
/*
* Let you change the exercice
*/
echo '<fieldset><legend>'._('Choississez un autre exercice').'</legend>';;
echo '<form method="GET">';
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 '</form>';
echo '</fieldset>';
// Show the form for period
echo '<FORM method="get">';
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;

View file

@ -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);

View file

@ -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 '<div class="content">';
$exercice=(isset($_GET['exercice']))?$_GET['exercice']:$User->get_exercice();
/*
* Let you change the exercice
*/
echo '<fieldset><legend>'._('Choississez un autre exercice').'</legend>';;
echo '<form method="GET">';
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 '</form>';
echo '</fieldset>';
$filter_year=" where p_exercice='".FormatString($exercice)."'";
echo '<FORM METHOD="GET">';
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 '</FORM>';
@ -58,6 +77,7 @@ if ( isset($_GET['verif']))
echo '<FORM METHOD="GET" ACTION="bilan.php">';
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);

View file

@ -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 '<div class="content">';
/*
* Let you change the exercice
*/
echo '<fieldset><legend>'._('Choississez un autre exercice').'</legend>';;
echo '<form method="GET">';
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 '</form>';
echo '</fieldset>';
echo '<FORM METHOD="GET">'.dossier::hidden();
echo HtmlInput::hidden('p_action','impress');
echo HtmlInput::hidden('type','jrn');
echo HtmlInput::get_to_hidden(array('exercice'));
echo '<TABLE ><TR>';
$w=new ISelect();
$w->table=1;
@ -89,7 +105,7 @@ print td($label).$w->input("jrn_id",$ret);
print '</TR>';
print '<TR>';
// 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']:'';