diff --git a/html/form_csv.php b/html/form_csv.php index 87b8e354b..3f8dc0f6d 100644 --- a/html/form_csv.php +++ b/html/form_csv.php @@ -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; ?> diff --git a/html/form_pdf.php b/html/form_pdf.php index 300a1faac..553e6d274 100644 --- a/html/form_pdf.php +++ b/html/form_pdf.php @@ -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(); ?> diff --git a/include/impress_rapport.php b/include/impress_rapport.php index a9fd4483d..0a49c8008 100644 --- a/include/impress_rapport.php +++ b/include/impress_rapport.php @@ -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 ""; echo '
'. @@ -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 "
"; @@ -69,20 +85,21 @@ include("class_rapport.php"); if ( count($Form->row ) == 0 ) exit; - echo ""; - echo "". - "". - "". - ""; + if ( $_POST['p_step'] == 0) + { // check the step + // show tables + ShowReportResult($Form->row); + } + else + { + $a=0; + foreach ( $array as $e) { + echo '

Periode : '.$periode_name[$a]."

"; + $a++; + ShowReportResult($e); + } + } - foreach ( $Form->row as $op ) { - echo "". - "". - "". - ""; - - } - echo "
Description montant
".$op['desc']."".sprintf("% 8.2f",$op['montant'])."
"; echo ""; 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 ""; +$aStep=array( + array('value'=>0,'label'=>'Pas d\'étape'), + array('value'=>1,'label'=>'1 mois') + ); +$w->label='Par étape de'; +echo ' '.$w->IOValue('p_step',$aStep); +echo ''; + echo ''; print $w->Submit('bt_html','Impression'); echo ''; echo ''; +//////////////////////////////////////////////////////////////////////////////// +// Function +//////////////////////////////////////////////////////////////////////////////// + function ShowReportResult($p_array) { + + echo ""; + echo "". + "". + "". + ""; + foreach ( $p_array as $op ) { + echo "". + "". + "". + ""; + } + echo "
Description montant
".$op['desc']."".sprintf("% 8.2f",$op['montant'])."
"; + + } + ?>