noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_print_ledger_detail_item.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 /**
00021  * Print detail of operation PURCHASE or SOLD plus the items
00022  * There is no report of the different amounts
00023  *
00024  * @author danydb
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      *@brief write the header of each page
00046      */
00047     function Header()
00048     {
00049         //Arial bold 12
00050         $this->SetFont('DejaVu', 'B', 12);
00051         //Title
00052         $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
00053         //Line break
00054         $this->Ln(20);
00055         
00056     }
00057     /**
00058      *@brief write the Footer
00059      */
00060     function Footer()
00061     {
00062         $this->Ln(2);
00063         $this->Cell(0,8,' Journal '.$this->ledger->get_name(),0,0,'C');
00064         //Arial italic 8
00065         $this->SetFont('Arial', 'I', 8);
00066         //Page number
00067         $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
00068         // Created by NOALYSS
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      *@brief export the ledger in  PDF
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                 // Print the general info line width=270mm
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                 // Header detail
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             // Print detail sale / purchase
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 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations