noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_form_pdf.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 /*! \file
00023  * \brief Send a report in PDF
00024  */
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 include_once("class_acc_report.php");
00027 include_once("ac_common.php");
00028 require_once('class_database.php');
00029 include_once("class_impress.php");
00030 require_once('class_user.php');
00031 require_once ('header_print.php');
00032 require_once('class_dossier.php');
00033 require_once('class_acc_report.php');
00034 require_once('class_pdf.php');
00035 
00036 $gDossier=dossier::id();
00037 
00038 $cn=new Database($gDossier);
00039 
00040 extract($_GET);
00041 $ret="";
00042 $Form=new Acc_Report($cn,$form_id);
00043 $Libelle=sprintf("%s ",$Form->get_name());
00044 $pdf= new PDF($cn);
00045 $pdf->setDossierInfo($Libelle);
00046 $pdf->AliasNbPages();
00047 $pdf->AddPage();
00048 $pdf->SetAuthor('NOALYSS');
00049 $pdf->setTitle("Rapport ".$Libelle,true);
00050 
00051 // Step ??
00052 //--
00053 $step=HtmlInput::default_value_get("p_step", 0);
00054 
00055 if ( $step == 0 )
00056 {
00057     // No step asked
00058     //--
00059     if ( $_GET ['type_periode'] == 0 )
00060         $array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']);
00061     else
00062         $array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']);
00063 
00064 }
00065 else
00066 {
00067     // yes with step
00068     //--
00069     for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step'])
00070     {
00071         $periode=getPeriodeName($cn,$e);
00072         if ( $periode == null ) continue;
00073         $array[]=$Form->get_row($e,$e,'periode');
00074         $periode_name[]=$periode;
00075     }
00076 
00077 }
00078 
00079 
00080 $pdf->SetFont('DejaVuCond','',8);
00081 
00082 // without step
00083 if ( $step == 0 )
00084 {
00085     if ( $_GET['type_periode'] == 0 )
00086     {
00087         $q=getPeriodeName($cn,$from_periode);
00088         if ( $from_periode != $to_periode)
00089         {
00090             $periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode));
00091         }
00092         else
00093         {
00094             $periode=sprintf("Période %s",$q);
00095         }
00096     }
00097     else
00098     {
00099         $periode=sprintf("Date %s jusque %s",$_GET['from_date'],$_GET['to_date']);
00100     }
00101     $pdf->Cell(0,7,$periode,'B');
00102     $pdf->Ln();
00103     for ($i=0;$i<count($array);$i++)
00104     {
00105         $pdf->Cell(160,6,$array[$i]['desc']);
00106         $pdf->Cell(30,6,sprintf('% 12.2f',$array[$i]['montant']),0,0,'R');
00107         $pdf->Ln();
00108     }
00109 }
00110 else
00111 { // With Step
00112     $a=0;
00113     foreach ($array as $e)
00114     {
00115         $pdf->Cell(0,7,$periode_name[$a],'B');
00116         $pdf->Ln();
00117         $a++;
00118         for ($i=0;$i<count($e);$i++)
00119         {
00120             $pdf->Cell(160,6,$e[$i]['desc']);
00121             $pdf->Cell(30,6,sprintf('% 12.2f',$e[$i]['montant']),0,0,'R');
00122             $pdf->Ln();
00123         }
00124     }
00125 }
00126 
00127 $fDate=date('dmy-Hi');
00128 $pdf->Output('rapport-'.$fDate.'.pdf','D');
00129 
00130 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations