task #4450 : Rapport Mensuels

This commit is contained in:
sparkyx 2005-07-27 12:23:00 +00:00
parent b1d823fabb
commit 471a7ae908
3 changed files with 165 additions and 45 deletions

View file

@ -36,23 +36,60 @@ $User->Check();
$Form=new rapport($cn,$_POST['form_id']);
$Form->GetName();
$array=$Form->GetRow( $_POST['from_periode'],
$_POST['to_periode']
);
if ( count($Form->row ) == 0 )
exit;
echo "\"Description\"\t,".
"\"Montant\"\t";
// Step ?
//--
if ( $_POST['p_step'] == 0 )
{
$array=$Form->GetRow( $_POST['from_periode'],
$_POST['to_periode']
);
if ( count($Form->row ) == 0 )
exit;
echo "\"Description\"\t,".
"\"Montant\"\t";
foreach ( $Form->row as $op ) {
foreach ( $Form->row as $op ) {
echo '"'.$op['desc'].'"'."\t,".
sprintf("%8.2f",$op['montant'])."\t".
"\n";
}
}
}
else
{
// Gather all the data
//---
for ($e=$_POST['from_periode'];$e<=$_POST['to_periode'];$e+=$_POST['p_step'])
{
$array[]=$Form->GetRow($e,$e);
$periode_name[]=getPeriodeName($cn,$e);
}
// Display column heading
//--
$x="";
foreach ($array[0] as $e)
{
printf("%s%s",$x,$e['desc']);
$x=";";
}
printf("\n");
// Display value for each line
//--
$a=0;
foreach ($array as $e )
{
print $periode_name[$a];
$a++;
foreach ($e as $elt)
{
printf(";%s",$elt['montant']);
}
printf("\n");
}
}
exit;
?>

View file

@ -37,29 +37,67 @@ $pdf=& new Cezpdf();
$pdf->selectFont('./addon/fonts/Helvetica.afm');
$Form=new rapport($cn,$form_id);
$array=$Form->GetRow($from_periode,$to_periode);
// Step ??
//--
if ( $_POST['p_step'] == 0 )
{
// No step asked
//--
$array=$Form->GetRow($from_periode,$to_periode);
}
else
{
// yes with step
//--
for ($e=$_POST['from_periode'];$e<=$_POST['to_periode'];$e+=$_POST['p_step'])
{
$array[]=$Form->GetRow($e,$e);
$periode_name[]=getPeriodeName($cn,$e);
}
}
$Libelle=sprintf("(%s) %s ",$Form->id,$Form->GetName());
$pdf->ezText($Libelle,30);
$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);
}
$pdf->ezText($periode,25);
// without step
if ( $_POST['p_step'] == 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);
}
$pdf->ezText($periode,25);
$pdf->ezTable($array,
array ('desc'=>'Description',
'montant' => 'Montant'
'montant' => 'Montant'
),$Libelle,
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
'cols'=>array('montant'=> array('justification'=>'right'),
)));
//New page
//$pdf->ezNewPage();
//}
array('shaded'=>0,'showHeadings'=>1,'width'=>500,
'cols'=>array('montant'=> array('justification'=>'right'),
)));
//New page
//$pdf->ezNewPage();
//}
}
else
{ // With Step
$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->ezStream();
?>

View file

@ -27,9 +27,22 @@ if ( isset( $_POST['bt_html'] ) ) {
include("class_rapport.php");
$Form=new rapport($cn,$_POST['form_id']);
$Form->GetName();
$array=$Form->GetRow( $_POST['from_periode'],
$_POST['to_periode']
);
// step asked ?
//--
if ($_POST['p_step'] == 0 ) {
$array=$Form->GetRow( $_POST['from_periode'],
$_POST['to_periode']
);
} else {
// step are asked
//--
for ($e=$_POST['from_periode'];$e<=$_POST['to_periode'];$e+=$_POST['p_step'])
{
$array[]=$Form->GetRow($e,$e);
$periode_name[]=getPeriodeName($cn,$e);
}
}
$rep="";
$submit=new widget();
@ -51,7 +64,9 @@ include("class_rapport.php");
$hid->IOValue("type","rapport").
$hid->IOValue("form_id",$Form->id).
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
$hid->IOValue("to_periode",$_POST['to_periode']).
$hid->IOValue("p_step",$_POST['p_step']);
echo "</form></TD>";
echo '<TD><form method="POST" ACTION="form_csv.php">'.
@ -59,7 +74,8 @@ include("class_rapport.php");
$hid->IOValue("type","form").
$hid->IOValue("form_id",$Form->id).
$hid->IOValue("from_periode",$_POST['from_periode']).
$hid->IOValue("to_periode",$_POST['to_periode']);
$hid->IOValue("to_periode",$_POST['to_periode']).
$hid->IOValue("p_step",$_POST['p_step']);
echo "</form></TD>";
@ -69,20 +85,21 @@ include("class_rapport.php");
if ( count($Form->row ) == 0 )
exit;
echo "<TABLE width=\"100%\">";
echo "<TR>".
"<TH> Description </TH>".
"<TH> montant </TH>".
"</TR>";
if ( $_POST['p_step'] == 0)
{ // check the step
// show tables
ShowReportResult($Form->row);
}
else
{
$a=0;
foreach ( $array as $e) {
echo '<h2 class="info">Periode : '.$periode_name[$a]."</h2>";
$a++;
ShowReportResult($e);
}
}
foreach ( $Form->row as $op ) {
echo "<TR>".
"<TD>".$op['desc']."</TD>".
"<TD align=\"right\">".sprintf("% 8.2f",$op['montant'])."</TD>".
"</TR>";
}
echo "</table>";
echo "</div>";
exit;
}
@ -118,9 +135,37 @@ $w->label=" jusqu'
$periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode order by p_id");
print $w->IOValue('to_periode',$periode_end);
print "</TR>";
$aStep=array(
array('value'=>0,'label'=>'Pas d\'étape'),
array('value'=>1,'label'=>'1 mois')
);
$w->label='Par étape de';
echo '<TR> '.$w->IOValue('p_step',$aStep);
echo '</TR>';
echo '</TABLE>';
print $w->Submit('bt_html','Impression');
echo '</FORM>';
echo '</div>';
////////////////////////////////////////////////////////////////////////////////
// Function
////////////////////////////////////////////////////////////////////////////////
function ShowReportResult($p_array) {
echo "<TABLE width=\"100%\">";
echo "<TR>".
"<TH> Description </TH>".
"<TH> montant </TH>".
"</TR>";
foreach ( $p_array as $op ) {
echo "<TR>".
"<TD>".$op['desc']."</TD>".
"<TD align=\"right\">".sprintf("% 8.2f",$op['montant'])."</TD>".
"</TR>";
}
echo "</table>";
}
?>