00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 require_once('class_pdf.php');
00027
00028 class Print_Ledger_Detail extends PDF
00029 {
00030 public function __construct ($p_cn = null, Acc_Ledger $ledger)
00031 {
00032
00033 if($p_cn == null) die("No database connection. Abort.");
00034
00035 parent::__construct($p_cn,'L', 'mm', 'A4');
00036 $this->ledger=$ledger;
00037 date_default_timezone_set ('Europe/Paris');
00038
00039 }
00040
00041 function setDossierInfo($dossier = "n/a")
00042 {
00043 $this->dossier = dossier::name()." ".$dossier;
00044 }
00045
00046 function Header()
00047 {
00048
00049 $this->SetFont('DejaVu', 'B', 12);
00050
00051 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
00052
00053 $this->Ln(20);
00054 }
00055 function Footer()
00056 {
00057
00058 $this->SetY(-20);
00059
00060 $this->SetFont('Arial', 'I', 8);
00061
00062 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
00063
00064 $this->Cell(0,8,'Created by NOALYSS, online on http://www.aevalys.eu',0,0,'R',false,'http://www.aevalys.eu');
00065
00066 }
00067 function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
00068 {
00069 $txt = str_replace("\\", "", $txt);
00070 return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
00071 }
00072
00073 function export()
00074 {
00075
00076
00077 $rap_deb=0;
00078 $rap_cred=0;
00079
00080 $array=$this->ledger->get_operation($_GET['from_periode'],$_GET['to_periode']);
00081
00082 $this->SetFont('DejaVu','BI',7);
00083 $this->Cell(215,7,'report Débit',0,0,'R');
00084 $this->Cell(30,7,nbm($rap_deb),0,0,'R');
00085 $this->Ln(4);
00086 $this->Cell(215,7,'report Crédit',0,0,'R');
00087 $this->Cell(30,7,nbm($rap_cred),0,0,'R');
00088 $this->Ln(4);
00089
00090
00091 for ($i=0;$i< count($array);$i++)
00092 {
00093 $this->SetFont('DejaVuCond','B',7);
00094 $row=$array[$i];
00095
00096 $this->LongLine(20,7,$row['pj']);
00097 $this->Cell(15,7,$row['date_fmt']);
00098 $this->Cell(20,7,$row['internal']);
00099 $this->LongLine(170,7,$row['comment']);
00100 $this->Cell(20,7,nbm($row['montant']),0,0,'R');
00101
00102 $this->Ln();
00103
00104 $aEntry=$this->cn->get_array("select j_id,j_poste,j_qcode,j_montant,j_debit, j_text,".
00105 " case when j_text='' or j_text is null then pcm_lib else j_text end as desc,".
00106 " pcm_lib ".
00107 " from jrnx join tmp_pcmn on (j_poste=pcm_val) where j_grpt = $1".
00108 " order by j_debit desc,j_id",
00109 array($row['jr_grpt_id']));
00110 for ($j=0;$j<count($aEntry);$j++)
00111 {
00112 $this->SetFont('DejaVuCond','',7);
00113 $entry=$aEntry[$j];
00114
00115 $this->Cell(32,6,$entry['j_qcode'],0,0,'R');
00116 $this->Cell(23,6,$entry['j_poste'],0,0,'R');
00117
00118
00119 if ( $entry['j_text'] =='' && $entry['j_qcode'] != '')
00120 {
00121 $f_id=$this->cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($entry['j_qcode']));
00122 if ($f_id != '')
00123 $name=$this->cn->get_value('select ad_value from fiche_detail where f_id=$1 and ad_id=1',
00124 array($f_id));
00125 else
00126 $name=$entry['pcm_lib'];
00127 }
00128 else
00129 $name=$entry['desc'];
00130 $this->Cell(150,6,$name,0,0,'L');
00131
00132
00133 $str_amount=nbm($entry['j_montant']);
00134 if ( $entry['j_debit']=='t')
00135 {
00136 $this->Cell(20,6,$str_amount,0,0,'R');
00137 $this->Cell(20,6,'',0,0,'R');
00138 }
00139 else
00140 {
00141 $this->Cell(20,6,'',0,0,'R');
00142 $this->Cell(20,6,$str_amount,0,0,'R');
00143 }
00144 $this->Ln(4);
00145 }
00146 }
00147 }
00148 }