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
00056 }
00057
00058
00059
00060 function Footer()
00061 {
00062 $this->Ln(2);
00063 $this->Cell(0,8,' Journal '.$this->ledger->get_name(),0,0,'C');
00064
00065 $this->SetFont('Arial', 'I', 8);
00066
00067 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
00068
00069 $this->Cell(0,8,'Created by NOALYSS, online on http://www.aevalys.eu',0,0,'R',false,'http://www.aevalys.eu');
00070 }
00071
00072 function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
00073 {
00074 $txt = str_replace("\\", "", $txt);
00075 return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
00076 }
00077
00078
00079
00080 function export()
00081 {
00082 bcscale(2);
00083 $jrn_type=$this->ledger->get_type();
00084 switch ($jrn_type)
00085 {
00086 case 'VEN':
00087 $ledger=new Acc_Ledger_Sold($this->cn, $this->ledger->jrn_def_id);
00088 $ret_detail=$ledger->get_detail_sale($_GET['from_periode'],$_GET['to_periode']);
00089 break;
00090 case 'ACH':
00091 $ledger=new Acc_Ledger_Purchase($this->cn, $this->ledger->jrn_def_id);
00092 $ret_detail=$ledger->get_detail_purchase($_GET['from_periode'],$_GET['to_periode']);
00093 break;
00094 default:
00095 die (__FILE__.":".__LINE__.'Journal invalide');
00096 break;
00097 }
00098 if ( $ret_detail == null ) return;
00099 $nb=Database::num_row($ret_detail);
00100 $this->SetFont('DejaVu', '', 6);
00101 $internal="";
00102 $this->SetFillColor(220,221,255);
00103 $high=4;
00104 for ( $i=0;$i< $nb ;$i++)
00105 {
00106 $row=Database::fetch_array($ret_detail, $i);
00107 if ($internal != $row['jr_internal'])
00108 {
00109
00110 $this->LongLine(20, $high, $row['jr_date'],1, 'L', true);
00111 $this->Cell(20, $high, $row['jr_internal'], 1, 0, 'L', true);
00112 $this->LongLine(70, $high, $row['quick_code']." ".$row['tiers_name'],1,'L',true);
00113 $this->LongLine(100, $high, $row['jr_comment'],1,'L',true);
00114 $this->Cell(20, $high, nbm($row['htva']), 1, 0, 'R', true);
00115 $this->Cell(20, $high, nbm($row['tot_vat']), 1, 0, 'R', true);
00116 $sum=bcadd($row['htva'],$row['tot_vat']);
00117 $this->Cell(20, $high, nbm($sum), 1, 0, 'R', true);
00118 $internal=$row['jr_internal'];
00119 $this->Ln(6);
00120
00121
00122 $this->LongLine(30,$high,'QuickCode');
00123 $this->Cell(30,$high,'Poste');
00124 $this->LongLine(90,$high,'Libellé');
00125 $this->Cell(20,$high,'Prix/Unit',0,0,'R');
00126 $this->Cell(20,$high,'Quant.',0,0,'R');
00127 $this->Cell(20,$high,'HTVA',0,0,'R');
00128 $this->Cell(20,$high,'Code TVA');
00129 $this->Cell(20,$high,'TVA',0,0,'R');
00130 $this->Cell(20,$high,'TVAC',0,0,'R');
00131 $this->Ln(6);
00132 }
00133
00134 $this->LongLine(30,$high,$row['j_qcode']);
00135 $this->Cell(30,$high,$row['j_poste']);
00136 $comment=($row['j_text']=="")?$row['item_name']:$row['j_text'];
00137 $this->LongLine(90,$high,$comment);
00138 $this->Cell(20,$high,nbm($row['price_per_unit']),0,0,'R');
00139 $this->Cell(20,$high,nbm($row['quantity']),0,0,'R');
00140 $this->Cell(20,$high,nbm($row['price']),0,0,'R');
00141 $this->Cell(20,$high,$row['vat_code']." ".$row['tva_label']);
00142 $this->Cell(20,$high,nbm($row['vat']),0,0,'R');
00143 $sum=bcadd($row['price'],$row['vat']);
00144 $this->Cell(20,$high,nbm($sum),0,0,'R');
00145 $this->Ln(6);
00146
00147 }
00148 }
00149
00150 }
00151 ?>