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