Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

form_pdf.php

Go to the documentation of this file.
00001 <?
00002 
00003 /*
00004  *   This file is part of PhpCompta.
00005  *
00006  *   PhpCompta 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  *   PhpCompta 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 PhpCompta; 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 ddebontridder@yahoo.fr
00022 // $Revision: 1.5 $
00027 include_once("class_rapport.php");
00028 include_once("ac_common.php");
00029 include_once("postgres.php");
00030 include_once("class.ezpdf.php");
00031 include_once("impress_inc.php");
00032 
00033     $cn=DbConnect($_SESSION['g_dossier']);
00034 foreach ($HTTP_POST_VARS as $key=>$element) {
00035   ${"$key"}=$element;
00036 }
00037 
00038 $ret="";
00039 $pdf=& new Cezpdf();
00040 $pdf->selectFont('./addon/fonts/Helvetica.afm');
00041 
00042 $Form=new rapport($cn,$form_id);
00043 // Step ??
00044 //--
00045 if ( $_POST['p_step'] == 0 ) 
00046   {
00047     // No step asked
00048     //--
00049     $array=$Form->GetRow($from_periode,$to_periode);
00050   }
00051  else 
00052    {
00053      // yes with step
00054      //--
00055      for ($e=$_POST['from_periode'];$e<=$_POST['to_periode'];$e+=$_POST['p_step'])
00056        {
00057         $periode=getPeriodeName($cn,$e);
00058         if ( $periode == null ) continue;
00059         $array[]=$Form->GetRow($e,$e);
00060         $periode_name[]=$periode;
00061        }
00062 
00063    }
00064 
00065 $Libelle=sprintf("(%s) %s ",$Form->id,$Form->GetName());
00066     
00067     $pdf->ezText($Libelle,30);
00068 // without step 
00069 if ( $_POST['p_step'] == 0 ) 
00070   {
00071     $q=getPeriodeName($cn,$from_periode);
00072     if ( $from_periode != $to_periode){
00073       $periode=sprintf("Période %s à %s",$q,getPeriodeName($cn,$to_periode));
00074     } else {
00075       $periode=sprintf("Période %s",$q);
00076     }
00077     
00078     $pdf->ezText($periode,25);
00079     $pdf->ezTable($array,
00080                   array ('desc'=>'Description',
00081                          'montant' => 'Montant'
00082                        ),$Libelle,
00083                   array('shaded'=>0,'showHeadings'=>1,'width'=>500,
00084                         'cols'=>array('montant'=> array('justification'=>'right'),
00085                                       )));
00086     //New page
00087     //$pdf->ezNewPage();
00088     //}    
00089   } 
00090  else 
00091    { // With Step 
00092      $a=0;
00093      foreach ($array as $e) 
00094        {
00095          $pdf->ezText($periode_name[$a],25);
00096          $a++;
00097          $pdf->ezTable($e,
00098                        array ('desc'=>'Description',
00099                               'montant' => 'Montant'
00100                               ),$Libelle,
00101                        array('shaded'=>0,'showHeadings'=>1,'width'=>500,
00102                              'cols'=>array('montant'=> array('justification'=>'right'),
00103                                            )));
00104        }
00105    }
00106 $pdf->ezStream();
00107 
00108 ?>