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_acc_ledger_sold.php';
00027 require_once 'class_acc_ledger_purchase.php';
00028 class Print_Ledger_Detail_Item extends PDFLand
00029 {
00030 public function __construct (Database $p_cn,Acc_Ledger $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
00038 }
00039
00040 function setDossierInfo($dossier = "n/a")
00041 {
00042 $this->dossier = dossier::name()." ".$dossier;
00043 }
00044
00045
00046
00047 function Header()
00048 {
00049
00050 $this->SetFont('DejaVu', 'B', 12);
00051
00052 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
00053
00054 $this->Ln(20);
00055 $high=6;
00056 $this->SetFont('DejaVu', '', 6);
00057 $this->LongLine(20, $high, _('Date'),0, 'L', false);
00058 $this->Cell(20, $high, _('Numéro interne'), 0, 0, 'L', false);
00059 $this->LongLine(50, $high, _('Code'),0,'L',false);
00060 $this->LongLine(80, $high, _('Libellé'),0,'L',false);
00061 $this->Cell(20, $high, _('Tot HTVA'), 0, 0, 'R', false);
00062 $this->Cell(20, $high, _('Tot TVA NP'), 0, 0, 'R', false);
00063 $this->Cell(20, $high, "", 0, 0, 'R', false);
00064 $this->Cell(20, $high, _('Tot TVA'), 0, 0, 'R', false);
00065 $this->Cell(20, $high, _('TVAC'), 0, 0, 'R', false);
00066 $this->Ln(6);
00067
00068 }
00069
00070
00071
00072 function Footer()
00073 {
00074 $this->Ln(2);
00075 $this->SetFont('Arial', 'I', 8);
00076 $this->Cell(50,8,' Journal '.$this->ledger->get_name(),0,0,'C');
00077
00078
00079 $this->Cell(30,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
00080
00081 $this->Cell(0,8,'Created by NOALYSS, online on http://www.aevalys.eu',0,0,'R',false,'http://www.aevalys.eu');
00082 }
00083
00084 function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
00085 {
00086 $txt = str_replace("\\", "", $txt);
00087 return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
00088 }
00089
00090
00091
00092 function export()
00093 {
00094 bcscale(2);
00095 $jrn_type=$this->ledger->get_type();
00096 switch ($jrn_type)
00097 {
00098 case 'VEN':
00099 $ledger=new Acc_Ledger_Sold($this->cn, $this->ledger->jrn_def_id);
00100 $ret_detail=$ledger->get_detail_sale($_GET['from_periode'],$_GET['to_periode']);
00101 break;
00102 case 'ACH':
00103 $ledger=new Acc_Ledger_Purchase($this->cn, $this->ledger->jrn_def_id);
00104 $ret_detail=$ledger->get_detail_purchase($_GET['from_periode'],$_GET['to_periode']);
00105 break;
00106 default:
00107 die (__FILE__.":".__LINE__.'Journal invalide');
00108 break;
00109 }
00110 if ( $ret_detail == null ) return;
00111 $nb=Database::num_row($ret_detail);
00112 $this->SetFont('DejaVu', '', 6);
00113 $internal="";
00114 $this->SetFillColor(220,221,255);
00115 $high=4;
00116 for ( $i=0;$i< $nb ;$i++)
00117 {
00118 $row=Database::fetch_array($ret_detail, $i);
00119 if ($internal != $row['jr_internal'])
00120 {
00121
00122 $this->LongLine(20, $high, $row['jr_date'],1, 'L', true);
00123 $this->Cell(20, $high, $row['jr_internal'], 1, 0, 'L', true);
00124 $this->LongLine(50, $high, $row['quick_code']." ".$row['tiers_name'],1,'L',true);
00125 $this->LongLine(80, $high, $row['jr_comment'],1,'L',true);
00126 $this->Cell(20, $high, nbm($row['htva']), 1, 0, 'R', true);
00127 $this->Cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 'R', true);
00128 $this->Cell(20, $high, "", 1, 0, 'R', true);
00129 $this->Cell(20, $high, nbm($row['tot_vat']), 1, 0, 'R', true);
00130 $sum=bcadd($row['htva'],$row['tot_vat']);
00131 $sum=bcsub($sum,$row['tot_tva_np']);
00132 $this->Cell(20, $high, nbm($sum), 1, 0, 'R', true);
00133 $internal=$row['jr_internal'];
00134 $this->Ln(6);
00135
00136
00137 $this->LongLine(30,$high,'QuickCode');
00138 $this->Cell(30,$high,'Poste');
00139 $this->LongLine(70,$high,'Libellé');
00140 $this->Cell(20,$high,'Prix/Unit',0,0,'R');
00141 $this->Cell(20,$high,'Quant.',0,0,'R');
00142 $this->Cell(20,$high,'HTVA',0,0,'R');
00143 $this->Cell(20,$high,'TVA NP',0,0,'R');
00144 $this->Cell(20,$high,'Code TVA');
00145 $this->Cell(20,$high,'TVA',0,0,'R');
00146 $this->Cell(20,$high,'TVAC',0,0,'R');
00147 $this->Ln(6);
00148 }
00149
00150 $this->LongLine(30,$high,$row['j_qcode']);
00151 $this->Cell(30,$high,$row['j_poste']);
00152 $comment=($row['j_text']=="")?$row['item_name']:$row['j_text'];
00153 $this->LongLine(70,$high,$comment);
00154 $this->Cell(20,$high,nbm($row['price_per_unit']),0,0,'R');
00155 $this->Cell(20,$high,nbm($row['quantity']),0,0,'R');
00156 $this->Cell(20,$high,nbm($row['price']),0,0,'R');
00157 $this->Cell(20,$high,nbm($row['vat_sided']),0,0,'R');
00158 $this->Cell(20,$high,$row['vat_code']." ".$row['tva_label']);
00159 $this->Cell(20,$high,nbm($row['vat']),0,0,'R');
00160 $sum=bcadd($row['price'],$row['vat']);
00161 $this->Cell(20,$high,nbm($sum),0,0,'R');
00162 $this->Ln(6);
00163
00164 }
00165 }
00166
00167 }
00168 ?>