task 7263 Add the date for the report

This commit is contained in:
sparkyx 2007-09-01 17:57:23 +00:00
parent 8cdc4e075c
commit c244f96231
4 changed files with 82 additions and 60 deletions

View file

@ -39,20 +39,23 @@ $User=new cl_user($cn);
$User->Check();
$Form=new rapport($cn,$_POST['form_id']);
$Form=new rapport($cn,$_GET['form_id']);
$Form->GetName();
// Step ?
//--
if ( $_POST['p_step'] == 0 )
if ( $_GET['p_step'] == 0 )
{
$array=$Form->GetRow( $_POST['from_periode'],
$_POST['to_periode']
);
if ( $_GET ['type_periode'] == 0 )
$array=$Form->GetRow( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']);
else
$array=$Form->GetRow( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']);
if ( count($Form->row ) == 0 )
exit;
echo "\"Mois,\";\"Description\";".
"\"Montant\"\t";
echo "\"Description\";".
"\"Montant\"\n";
@ -67,12 +70,12 @@ if ( $_POST['p_step'] == 0 )
{
// Gather all the data
//---
for ($e=$_POST['from_periode'];$e<=$_POST['to_periode'];$e+=$_POST['p_step'])
for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step'])
{
$periode=getPeriodeName($cn,$e);
if ( $periode == null ) continue;
$array[]=$Form->GetRow($e,$e);
$periode_name[]=$periode;
$periode=getPeriodeName($cn,$e);
if ( $periode == null ) continue;
$array[]=$Form->GetRow($e,$e);
$periode_name[]=$periode;
}
// Display column heading
//--

View file

@ -36,7 +36,7 @@ $gDossier=dossier::id();
$cn=DbConnect($gDossier);
foreach ($_POST as $key=>$element) {
foreach ($_GET as $key=>$element) {
${"$key"}=$element;
}
@ -48,39 +48,46 @@ header_pdf($cn,$pdf);
$Form=new rapport($cn,$form_id);
// Step ??
//--
if ( $_POST['p_step'] == 0 )
if ( $_GET['p_step'] == 0 )
{
// No step asked
//--
$array=$Form->GetRow($from_periode,$to_periode);
if ( $_GET ['type_periode'] == 0 )
$array=$Form->GetRow( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']);
else
$array=$Form->GetRow( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']);
}
else
{
// yes with step
//--
for ($e=$_POST['from_periode'];$e<=$_POST['to_periode'];$e+=$_POST['p_step'])
for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step'])
{
$periode=getPeriodeName($cn,$e);
if ( $periode == null ) continue;
$array[]=$Form->GetRow($e,$e);
$periode_name[]=$periode;
$periode=getPeriodeName($cn,$e);
if ( $periode == null ) continue;
$array[]=$Form->GetRow($e,$e);
$periode_name[]=$periode;
}
}
$Libelle=sprintf("(%s) %s ",$Form->id,$Form->GetName());
$pdf->ezText($Libelle,30);
$pdf->ezText($Libelle,30);
// without step
if ( $_POST['p_step'] == 0 )
if ( $_GET['p_step'] == 0 )
{
$q=getPeriodeName($cn,$from_periode);
if ( $from_periode != $to_periode){
$periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode));
if ( $_GET['type_periode'] == 0 ) {
$q=getPeriodeName($cn,$from_periode);
if ( $from_periode != $to_periode){
$periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode));
} else {
$periode=sprintf("Période %s",$q);
}
} else {
$periode=sprintf("Période %s",$q);
}
$periode=sprintf("Date %s jusque %s",$_GET['from_date'],$_GET['to_date']);
}
$pdf->ezText($periode,25);
$pdf->ezTable($array,
array ('desc'=>'Description',
@ -98,15 +105,15 @@ if ( $_POST['p_step'] == 0 )
$a=0;
foreach ($array as $e)
{
$pdf->ezText($periode_name[$a],25);
$a++;
$pdf->ezTable($e,
array ('desc'=>'Description',
'montant' => 'Montant'
),$Libelle,
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
'cols'=>array('montant'=> array('justification'=>'right'),
)));
$pdf->ezText($periode_name[$a],25);
$a++;
$pdf->ezTable($e,
array ('desc'=>'Description',
'montant' => 'Montant'
),$Libelle,
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
'cols'=>array('montant'=> array('justification'=>'right'),
)));
}
}
$pdf->ezStream();

View file

@ -48,9 +48,10 @@ class rapport {
* from a report
* \param $p_start start periode
* \param $p_end end periode
* \param $p_type_date type of the date : periode or calendar
*/
function GetRow($p_start,$p_end) {
function GetRow($p_start,$p_end,$p_type_date) {
$Res=ExecSql($this->db,"select fo_id ,
fo_fr_id,
@ -66,11 +67,13 @@ class rapport {
$col=array();
for ($i=0;$i<$Max;$i++) {
$l_line=pg_fetch_array($Res,$i);
$col[]=ParseFormula($this->db,
$l_line['fo_label'],
$l_line['fo_formula'],
$p_start,
$p_end
$col[]=ParseFormula($this->db,
$l_line['fo_label'],
$l_line['fo_formula'],
$p_start,
$p_end,
true,
$p_type_date
);
} //for ($i
@ -78,4 +81,4 @@ class rapport {
return $col;
}
}
?>
?>

View file

@ -747,11 +747,13 @@ function GetRappel($p_cn,$p_jrnx_id,$p_jrn_id,$p_exercice,$which,$p_type,$p_cent
* \param $p_formula
* \param $p_eval true if we eval here otherwise the function returns
* a string which must be evaluated
* \param $p_type_date : type of the date 0 for accountant period or 1
* for calendar
* \return array
*
*
*/
function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true)
function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true,$p_type_date=0)
{
echo_debug('impress_inc',__LINE__,'ParseFormula');
if ( CheckFormula($p_formula) == false) {
@ -762,7 +764,10 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true)
return $p_formula;
}
$cond=sql_filter_per($p_cn,$p_start,$p_end,'p_id','j_tech_per');
if ( $p_type_date == 0 )
$cond=sql_filter_per($p_cn,$p_start,$p_end,'p_id','j_tech_per');
else
$cond="( j_date >= to_date('$p_start','DD.MM.YYYY') and j_date <= to_date('$p_end','DD.MM.YYYY'))";
include_once("class_poste.php");
while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) {
@ -774,7 +779,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true)
echo_debug('impress_inc',__LINE__,"p_formula is $p_formula");
// If there is a FROM clause we must recompute
// the time cond
if ( ereg ("FROM=[0-9]+\.[0-9]+", $p_formula,$afrom) == true ){
if ($p_type_date == 0 && ereg ("FROM=[0-9]+\.[0-9]+", $p_formula,$afrom) == true ){
// There is a FROM clause
// then we must modify the cond for the periode
$from=str_replace("FROM=","",$afrom[0]);
@ -782,28 +787,32 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true)
/*! \note special value for the clause FROM=00.0000
*/
if ( $from == '00.0000' ) {
// retrieve the first month of this periode
$User=new cl_user($p_cn);
$user_periode=$User->getPeriode();
$periode=getDbValue($p_cn,
"select p_exercice from parm_periode where p_id=$user_periode");
$sql_per="select to_char(p_start,'MM.YYYY') as start from parm_periode where ".
" p_exercice='".$periode."' order by p_start";
$ret=getArray($p_cn,$sql_per);
$from=$ret[0]['start'];
// retrieve the first month of this periode
$User=new cl_user($p_cn);
$user_periode=$User->getPeriode();
$periode=getDbValue($p_cn,
"select p_exercice from parm_periode where p_id=$user_periode");
$sql_per="select to_char(p_start,'MM.YYYY') as start from parm_periode where ".
" p_exercice='".$periode."' order by p_start";
$ret=getArray($p_cn,$sql_per);
$from=$ret[0]['start'];
}
$from=getPeriodeFromMonth($p_cn,$from);
// the clause from is something else
// Compute the cond
$cond=sql_filter_per($p_cn,$from,$p_end,'p_id','j_tech_per');
$cond=sql_filter_per($p_cn,$p_start,$p_end,'p_id','j_tech_per');
// We remove FROM out of the p_formula
$p_formula=substr_replace($p_formula,"",strpos($p_formula,"FROM"));
}
}
if ( strpos($p_formula,"FROM") != 0) {
// We remove FROM out of the p_formula
$p_formula=substr_replace($p_formula,"",strpos($p_formula,"FROM"));
}
// Get sum of account
$P=new poste($p_cn,$e[0]);
echo_debug(__FILE__.":".__LINE__." condition is $cond");
$i=$P->GetSolde($cond);
$p_formula=str_replace($x,$i,$p_formula);
}