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
00027
00028 require_once('class_pdf.php');
00029
00030 class Print_Ledger_Simple extends PDF
00031 {
00032 public function __construct ($p_cn,$p_jrn)
00033 {
00034
00035 if($p_cn == null) die("No database connection. Abort.");
00036
00037 parent::__construct($p_cn,'L', 'mm', 'A4');
00038 $this->ledger=$p_jrn;
00039 $this->a_Tva=$this->ledger->existing_vat();
00040 foreach($this->a_Tva as $line_tva)
00041 {
00042
00043 $tmp1=$line_tva['tva_id'];
00044 $this->rap_tva[$tmp1]=0;
00045 }
00046 $this->jrn_type=$p_jrn->get_type();
00047
00048
00049
00050
00051
00052
00053 $this->previous=$this->ledger->previous_amount($_GET['from_periode']);
00054
00055
00056 foreach($this->previous['tva'] as $line_tva)
00057 {
00058
00059 $tmp1=$line_tva['tva_id'];
00060 $this->rap_tva[$tmp1]=$line_tva['sum_vat'];
00061 }
00062
00063 $this->rap_htva=$this->previous['price'];
00064 $this->rap_tvac=$this->previous['price']+$this->previous['vat'];
00065 $this->rap_priv=$this->previous['priv'];
00066 $this->rap_nd=$this->previous['tva_nd'];
00067 }
00068
00069 function setDossierInfo($dossier = "n/a")
00070 {
00071 $this->dossier = dossier::name()." ".$dossier;
00072 }
00073
00074
00075
00076 function Header()
00077 {
00078
00079 $this->SetFont('DejaVu', 'B', 12);
00080
00081 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
00082
00083 $this->Ln(20);
00084 $this->SetFont('DejaVu', 'B', 8);
00085
00086
00087
00088 foreach($this->a_Tva as $line_tva)
00089 {
00090
00091 $tmp1=$line_tva['tva_id'];
00092 $this->rap_tva[$tmp1]=(isset($this->rap_tva[$tmp1]))?$this->rap_tva[$tmp1]:0;
00093 }
00094 $this->Cell(15,6,'Pièce');
00095 $this->Cell(10,6,'Date');
00096 $this->Cell(13,6,'ref');
00097 if ( $this->jrn_type=='ACH')
00098 $this->Cell(40,6,'Client');
00099 else
00100 $this->Cell(40,6,'Fournisseur');
00101
00102 $flag_tva=(count($this->a_Tva) > 4)?true:false;
00103 if ( !$flag_tva ) $this->Cell(65,6,'Description');
00104
00105 $this->Cell(15,6,'HTVA',0,0,'R');
00106 if ( $this->jrn_type=='ACH')
00107 {
00108 $this->Cell(15,6,'Privé',0,0,'R');
00109 $this->Cell(15,6,'TVA ND',0,0,'R');
00110 }
00111 foreach($this->a_Tva as $line_tva)
00112 {
00113 $this->Cell(15,6,$line_tva['tva_label'],0,0,'R');
00114 }
00115 $this->Cell(15,6,'TVAC',0,0,'R');
00116 $this->Ln(5);
00117
00118 $this->SetFont('DejaVu','',6);
00119
00120 $this->Cell(143,6,'report',0,0,'R');
00121 $this->Cell(15,6,nbm($this->rap_htva),0,0,'R');
00122 if ( $this->jrn_type != 'VEN')
00123 {
00124 $this->Cell(15,6,nbm($this->rap_priv),0,0,'R');
00125 $this->Cell(15,6,nbm($this->rap_nd),0,0,'R');
00126 }
00127 foreach($this->rap_tva as $line_tva)
00128 $this->Cell(15,6,nbm($line_tva),0,0,'R');
00129 $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R');
00130
00131 $this->Ln(6);
00132
00133 $this->tp_htva=0.0;
00134 $this->tp_tvac=0.0;
00135 $this->tp_priv=0;
00136 $this->tp_nd=0;
00137 foreach($this->a_Tva as $line_tva)
00138 {
00139
00140 $tmp1=$line_tva['tva_id'];
00141 $this->tp_tva[$tmp1]=0.0;
00142 }
00143 }
00144
00145
00146
00147 function Footer()
00148 {
00149
00150 $this->SetY(-20);
00151
00152 $this->Cell(143,6,'Total page ','T',0,'R');
00153 $this->Cell(15,6,nbm($this->tp_htva),'T',0,'R');
00154 if ( $this->jrn_type !='VEN')
00155 {
00156 $this->Cell(15,6,nbm($this->tp_priv),'T',0,'R');
00157 $this->Cell(15,6,nbm($this->tp_nd),'T',0,'R');
00158 }
00159 foreach($this->a_Tva as $line_tva)
00160 {
00161 $l=$line_tva['tva_id'];
00162 $this->Cell(15,6,nbm($this->tp_tva[$l]),'T',0,'R');
00163 }
00164 $this->Cell(15,6,nbm($this->tp_tvac),'T',0,'R');
00165 $this->Ln(2);
00166
00167 $this->Cell(143,6,'report',0,0,'R');
00168 $this->Cell(15,6,nbm($this->rap_htva),0,0,'R');
00169 if ( $this->jrn_type !='VEN')
00170 {
00171 $this->Cell(15,6,nbm($this->rap_priv),0,0,'R');
00172 $this->Cell(15,6,nbm($this->rap_nd),0,0,'R');
00173 }
00174 foreach($this->a_Tva as $line_tva)
00175 {
00176 $l=$line_tva['tva_id'];
00177 $this->Cell(15,6,nbm($this->rap_tva[$l]),0,0,'R');
00178 }
00179 $this->Cell(15,6,nbm($this->rap_tvac),0,0,'R');
00180 $this->Ln(2);
00181
00182
00183 $this->SetFont('Arial', 'I', 8);
00184
00185 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
00186 $this->Ln(3);
00187
00188 $this->Cell(0,8,'Created by Phpcompta, online on http:
00189 }
00190
00191 function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
00192 {
00193 $txt = str_replace("\\", "", $txt);
00194 return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
00195 }
00196
00197
00198
00199 function export()
00200 {
00201 bcscale(2);
00202 $a_jrn=$this->ledger->get_operation($_GET['from_periode'],
00203 $_GET['to_periode']);
00204
00205 if ( $a_jrn == null ) return;
00206 for ( $i=0;$i<count($a_jrn);$i++)
00207 {
00208
00209 for ($f=0;$f<count($this->a_Tva);$f++)
00210 {
00211 $l=$this->a_Tva[$f]['tva_id'];
00212 $atva_amount[$l]=0;
00213 }
00214
00215
00216 $aAmountVat=$this->ledger->vat_operation($a_jrn[$i]['jr_grpt_id']);
00217
00218
00219 for ($f=0;$f<count($aAmountVat);$f++)
00220 {
00221 $l=$aAmountVat[$f]['tva_id'];
00222 $atva_amount[$l]=bcadd($atva_amount[$l],$aAmountVat[$f]['sum_vat']);
00223 $this->tp_tva[$l]=bcadd($this->tp_tva[$l],$aAmountVat[$f]['sum_vat']);
00224 $this->rap_tva[$l]=bcadd($this->rap_tva[$l],$aAmountVat[$f]['sum_vat']);
00225 }
00226
00227 $row=$a_jrn[$i];
00228 $this->Cell(15,5,($row['pj']),0,0);
00229 $this->Cell(10,5,$row['date_fmt'],0,0);
00230 $this->Cell(13,5,$row['internal'],0,0);
00231 list($qc,$name)=$this->get_tiers($row['id'],$this->jrn_type);
00232 $this->LongLine(40,5,"[".$qc."]".$name,0,'L');
00233
00234 $this->LongLine(65,5,mb_substr($row['comment'],0,150),0,'L');
00235
00236
00237 $other=$this->ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
00238 $this->tp_htva=bcadd($this->tp_htva,$other['price']);
00239 $this->tp_tvac=bcadd($this->tp_tvac,$other['price']+$other['vat']);
00240 $this->tp_priv=bcadd($this->tp_priv,$other['priv']);
00241 $this->tp_nd=bcadd($this->tp_nd,$other['tva_nd']);
00242 $this->rap_htva=bcadd($this->rap_htva,$other['price']);
00243 $this->rap_tvac=bcadd($this->rap_tvac,$other['price']+$other['vat']);
00244 $this->rap_priv=bcadd($this->rap_priv,$other['priv']);
00245 $this->rap_nd=bcadd($this->rap_nd,$other['tva_nd']);
00246
00247
00248 $this->Cell(15,5,nbm($other['price']),0,0,'R');
00249 if ( $this->jrn_type !='VEN')
00250 {
00251 $this->Cell(15,5,nbm($other['priv']),0,0,'R');
00252 $this->Cell(15,5,nbm($other['tva_nd']),0,0,'R');
00253 }
00254 foreach ($atva_amount as $row_atva_amount)
00255 {
00256 $this->Cell(15, 5, nbm($row_atva_amount), 0, 0, 'R');
00257 }
00258
00259 $l_tvac=bcadd($other['price'],$other['vat']);
00260 $l_tvac=bcadd($l_tvac,$other['tva_nd']);
00261 $this->Cell(15,5,nbm($l_tvac),0,0,'R');
00262 $this->Ln(5);
00263 }
00264 }
00265
00266 }