2004-10-20 00:24:10 +02:00
< ? php
2005-01-08 02:02:27 +01:00
/* Copyright ( C ) 2004 - 2005 Laurent Destailleur < eldy @ users . sourceforge . net >
2004-05-15 17:47:01 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
* or see http :// www . gnu . org /
*
* $Id $
* $Source $
*/
2004-02-08 17:58:42 +01:00
2005-03-20 02:19:35 +01:00
/**
\file htdocs / includes / modules / facture / pdf_crabe . modules . php
2004-10-20 00:24:10 +02:00
\ingroup facture
2004-08-15 17:05:44 +02:00
\brief Fichier de la classe permettant de g<EFBFBD> n<EFBFBD> rer les factures au mod<EFBFBD> le Crabe
\author Laurent Destailleur
\version $Revision $
2004-07-25 15:12:15 +02:00
*/
2005-11-11 21:11:57 +01:00
require_once ( DOL_DOCUMENT_ROOT . " /includes/modules/facture/modules_facture.php " );
2005-09-11 18:51:41 +02:00
require_once ( DOL_DOCUMENT_ROOT . " /product.class.php " );
2004-08-07 19:14:42 +02:00
2005-03-20 02:19:35 +01:00
/**
\class pdf_crabe
2005-01-08 02:02:27 +01:00
\brief Classe permettant de g<EFBFBD> n<EFBFBD> rer les factures au mod<EFBFBD> le Crabe
2004-08-07 19:14:42 +02:00
*/
2004-08-15 17:05:44 +02:00
class pdf_crabe extends ModelePDFFactures
{
2004-07-25 15:12:15 +02:00
2005-03-20 02:19:35 +01:00
/**
\brief Constructeur
2005-08-14 03:24:13 +02:00
\param db Handler acc<EFBFBD> s base de donn<EFBFBD> e
2004-07-25 15:12:15 +02:00
*/
2004-08-07 19:14:42 +02:00
function pdf_crabe ( $db )
2004-02-08 17:58:42 +01:00
{
2005-08-26 21:22:23 +02:00
global $conf , $langs ;
2005-03-20 02:19:35 +01:00
2004-05-15 17:47:01 +02:00
$this -> db = $db ;
2005-08-14 03:24:13 +02:00
$this -> name = " crabe " ;
$this -> description = " Mod<EFBFBD> le de facture complet (G<> re l'option fiscale de facturation TVA, le choix du mode de r<> glement <20> afficher, logo...) " ;
2005-11-04 02:07:33 +01:00
// Dimension page pour format A4
$this -> page_largeur = 210 ;
$this -> page_hauteur = 297 ;
$this -> format = array ( $this -> page_largeur , $this -> page_hauteur );
2005-11-08 00:35:58 +01:00
$this -> marge_gauche = 10 ;
$this -> marge_droite = 10 ;
2005-11-04 21:42:07 +01:00
$this -> marge_haute = 10 ;
$this -> marge_basse = 10 ;
2005-08-20 23:54:16 +02:00
2004-07-25 17:31:16 +02:00
$this -> option_logo = 1 ; // Affiche logo FAC_PDF_LOGO
$this -> option_tva = 1 ; // Gere option tva FACTURE_TVAOPTION
$this -> option_modereg = 1 ; // Gere choix mode r<> glement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER
2005-08-20 23:54:16 +02:00
$this -> option_codeproduitservice = 1 ; // Affiche code produit-service
2004-07-25 17:31:16 +02:00
$this -> option_tvaintra = 1 ; // Affiche tva intra MAIN_INFO_TVAINTRA
$this -> option_capital = 1 ; // Affiche capital MAIN_INFO_CAPITAL
2005-03-20 02:19:35 +01:00
if ( defined ( " FACTURE_TVAOPTION " ) && FACTURE_TVAOPTION == 'franchise' )
$this -> franchise = 1 ;
2005-08-26 21:22:23 +02:00
// Recupere code pays de l'emmetteur
$this -> emetteur -> code_pays = substr ( $langs -> defaultlang , - 2 ); // Par defaut, si on trouve pas
2005-03-20 02:19:35 +01:00
$sql = " SELECT code from " . MAIN_DB_PREFIX . " c_pays " ;
2005-08-26 21:22:23 +02:00
$sql .= " WHERE rowid = ' " . $conf -> global -> MAIN_INFO_SOCIETE_PAYS . " ' " ;
2005-03-20 02:19:35 +01:00
$result = $this -> db -> query ( $sql );
if ( $result ) {
$obj = $this -> db -> fetch_object ( $result );
2005-08-26 21:22:23 +02:00
if ( $obj -> code ) $this -> emetteur -> code_pays = $obj -> code ;
2005-03-20 02:19:35 +01:00
}
else {
dolibarr_print_error ( $this -> db );
}
$this -> db -> free ( $result );
2005-08-20 23:36:58 +02:00
2005-08-21 18:33:38 +02:00
$this -> tva = array ();
2005-08-20 23:36:58 +02:00
// Defini position des colonnes
2005-11-08 00:35:58 +01:00
$this -> posxdesc = $this -> marge_gauche + 1 ;
2005-08-20 23:36:58 +02:00
$this -> posxtva = 121 ;
2005-10-04 01:00:53 +02:00
$this -> posxup = 132 ;
2005-08-20 23:36:58 +02:00
$this -> posxqty = 151 ;
2005-09-01 21:27:06 +02:00
$this -> posxdiscount = 162 ;
$this -> postotalht = 177 ;
2005-11-08 00:35:58 +01:00
$this -> atleastoneratenotnull = 0 ;
$this -> atleastonediscount = 0 ;
2004-02-08 17:58:42 +01:00
}
2004-07-25 15:12:15 +02:00
2005-01-08 02:02:27 +01:00
/**
2004-12-31 19:27:07 +01:00
\brief Fonction g<EFBFBD> n<EFBFBD> rant la facture sur le disque
2005-11-04 21:42:07 +01:00
\param id Id de la facture <EFBFBD> g<EFBFBD> n<EFBFBD> rer
2004-09-18 13:55:56 +02:00
\return int 1 = ok , 0 = ko
2004-12-31 19:27:07 +01:00
\remarks Variables utilis<EFBFBD> es
2005-03-20 02:49:20 +01:00
\remarks MAIN_INFO_SOCIETE_NOM
2005-11-13 02:46:25 +01:00
\remarks MAIN_INFO_ADRESSE
\remarks MAIN_INFO_CP
\remarks MAIN_INFO_VILLE
\remarks MAIN_INFO_TEL
\remarks MAIN_INFO_FAX
\remarks MAIN_INFO_WEB
2005-03-20 02:49:20 +01:00
\remarks MAIN_INFO_SIRET
\remarks MAIN_INFO_SIREN
\remarks MAIN_INFO_RCS
\remarks MAIN_INFO_CAPITAL
\remarks MAIN_INFO_TVAINTRA
2005-11-13 02:46:25 +01:00
\remarks MAIN_INFO_LOGO
2004-12-31 19:27:07 +01:00
\remarks FACTURE_CHQ_NUMBER
\remarks FACTURE_RIB_NUMBER
2004-07-25 15:12:15 +02:00
*/
2005-11-04 21:42:07 +01:00
function write_pdf_file ( $id )
2004-02-08 17:58:42 +01:00
{
2004-12-23 19:28:58 +01:00
global $user , $langs , $conf ;
2004-09-18 13:55:56 +02:00
$langs -> load ( " main " );
$langs -> load ( " bills " );
$langs -> load ( " products " );
2004-12-23 19:28:58 +01:00
if ( $conf -> facture -> dir_output )
2004-05-15 17:47:01 +02:00
{
2005-11-04 21:42:07 +01:00
$fac = new Facture ( $this -> db , " " , $id );
$ret = $fac -> fetch ( $id );
2005-11-08 00:35:58 +01:00
$nblignes = sizeof ( $fac -> lignes );
2004-05-15 17:47:01 +02:00
2005-07-16 13:10:39 +02:00
$facref = sanitize_string ( $fac -> ref );
2004-12-23 19:28:58 +01:00
$dir = $conf -> facture -> dir_output . " / " . $facref ;
$file = $dir . " / " . $facref . " .pdf " ;
2004-05-15 17:47:01 +02:00
if ( ! file_exists ( $dir ))
{
2005-06-29 00:13:53 +02:00
if ( create_exdir ( $dir ) < 0 )
2004-05-15 17:47:01 +02:00
{
2004-09-18 13:55:56 +02:00
$this -> error = $langs -> trans ( " ErrorCanNotCreateDir " , $dir );
2004-07-25 15:12:15 +02:00
return 0 ;
2004-05-15 17:47:01 +02:00
}
}
if ( file_exists ( $dir ))
{
2005-11-04 21:42:07 +01:00
// Initialisation document vierge
2005-11-04 02:07:33 +01:00
$pdf = new FPDF ( 'P' , 'mm' , $this -> format );
2004-05-15 17:47:01 +02:00
$pdf -> Open ();
$pdf -> AddPage ();
2005-08-20 23:36:58 +02:00
$pdf -> SetDrawColor ( 128 , 128 , 128 );
2004-05-15 17:47:01 +02:00
$pdf -> SetTitle ( $fac -> ref );
2004-09-18 13:55:56 +02:00
$pdf -> SetSubject ( $langs -> trans ( " Bill " ));
2004-05-15 17:47:01 +02:00
$pdf -> SetCreator ( " Dolibarr " . DOL_VERSION );
$pdf -> SetAuthor ( $user -> fullname );
2004-07-25 17:31:16 +02:00
2005-11-08 00:35:58 +01:00
$pdf -> SetMargins ( $this -> marge_gauche , $this -> marge_haute , $this -> marge_droite ); // Left, Top, Right
2004-07-25 17:31:16 +02:00
$pdf -> SetAutoPageBreak ( 1 , 0 );
2004-05-15 17:47:01 +02:00
2005-11-08 00:35:58 +01:00
// Positionne $this->atleastonediscount si on a au moins une remise
for ( $i = 0 ; $i < $nblignes ; $i ++ )
{
if ( $fac -> lignes [ $i ] -> remise_percent )
{
$this -> atleastonediscount ++ ;
}
}
2005-08-20 23:36:58 +02:00
$this -> _pagehead ( $pdf , $fac );
2006-02-18 22:46:02 +01:00
// Affiches lignes
2005-11-28 01:02:08 +01:00
$pagenb = 1 ;
$tab_top = 90 ;
$tab_top_newpage = 50 ;
2004-05-15 17:47:01 +02:00
$tab_height = 110 ;
2006-02-18 22:46:02 +01:00
// Affiche notes
if ( $fac -> note_public )
{
$tab_top = 88 ;
$pdf -> SetFont ( 'Arial' , '' , 9 ); // Dans boucle pour g<> rer multi-page
$pdf -> SetXY ( $this -> posxdesc - 1 , $tab_top );
$pdf -> MultiCell ( 190 , 3 , $fac -> note_public , 0 , 'J' );
$nexY = $pdf -> GetY ();
$height_note = $nexY - $tab_top ;
// Rect prend une longueur en 3eme param
$pdf -> SetDrawColor ( 192 , 192 , 192 );
$pdf -> Rect ( $this -> marge_gauche , $tab_top - 1 , $this -> page_largeur - $this -> marge_gauche - $this -> marge_droite , $height_note + 1 );
$tab_height = $tab_height - $height_note ;
$tab_top = $nexY + 6 ;
}
else
{
$height_note = 0 ;
}
2005-08-20 23:36:58 +02:00
$iniY = $tab_top + 8 ;
$curY = $tab_top + 8 ;
$nexY = $tab_top + 8 ;
2004-05-15 17:47:01 +02:00
2005-08-14 03:24:13 +02:00
// Boucle sur les lignes
2004-05-15 17:47:01 +02:00
for ( $i = 0 ; $i < $nblignes ; $i ++ )
{
$curY = $nexY ;
2006-01-04 21:20:05 +01:00
// Description de la ligne produit
2005-08-14 03:24:13 +02:00
$libelleproduitservice = $fac -> lignes [ $i ] -> libelle ;
2006-01-05 11:24:16 +01:00
if ( $fac -> lignes [ $i ] -> desc && $fac -> lignes [ $i ] -> desc != $fac -> lignes [ $i ] -> libelle )
2005-08-14 03:24:13 +02:00
{
if ( $libelleproduitservice ) $libelleproduitservice .= " \n " ;
2006-01-05 11:24:16 +01:00
$libelleproduitservice .= $fac -> lignes [ $i ] -> desc ;
2005-08-14 03:24:13 +02:00
}
2006-01-04 21:20:05 +01:00
// Si ligne associ<63> e <20> un code produit
2005-08-20 23:36:58 +02:00
if ( $fac -> lignes [ $i ] -> produit_id )
2005-08-14 03:24:13 +02:00
{
2004-07-25 17:31:16 +02:00
$prodser = new Product ( $this -> db );
$prodser -> fetch ( $fac -> lignes [ $i ] -> produit_id );
2004-08-15 17:05:44 +02:00
if ( $prodser -> ref ) {
2005-08-20 23:36:58 +02:00
$libelleproduitservice = $langs -> trans ( " Product " ) . " " . $prodser -> ref . " - " . $libelleproduitservice ;
2004-08-15 17:05:44 +02:00
}
2006-01-04 21:20:05 +01:00
// Ajoute description du produit
2006-02-12 14:28:14 +01:00
if ( $conf -> global -> FAC_ADD_PROD_DESC && ! $conf -> global -> CHANGE_PROD_DESC )
2006-01-04 21:20:05 +01:00
{
if ( $fac -> lignes [ $i ] -> product_desc && $fac -> lignes [ $i ] -> product_desc != $fac -> lignes [ $i ] -> libelle && $fac -> lignes [ $i ] -> product_desc != $fac -> lignes [ $i ] -> desc )
{
if ( $libelleproduitservice ) $libelleproduitservice .= " \n " ;
$libelleproduitservice .= $fac -> lignes [ $i ] -> product_desc ;
}
}
2004-05-17 19:07:16 +02:00
}
2006-01-04 21:20:05 +01:00
2004-05-17 19:07:16 +02:00
if ( $fac -> lignes [ $i ] -> date_start && $fac -> lignes [ $i ] -> date_end ) {
// Affichage dur<75> e si il y en a une
2005-08-14 03:24:13 +02:00
$libelleproduitservice .= " \n ( " . $langs -> trans ( " From " ) . " " . dolibarr_print_date ( $fac -> lignes [ $i ] -> date_start ) . " " . $langs -> trans ( " to " ) . " " . dolibarr_print_date ( $fac -> lignes [ $i ] -> date_end ) . " ) " ;
2004-05-15 17:47:01 +02:00
}
2005-09-01 21:27:06 +02:00
2005-11-28 01:02:08 +01:00
$pdf -> SetFont ( 'Arial' , '' , 9 ); // Dans boucle pour g<> rer multi-page
2005-09-01 21:27:06 +02:00
$pdf -> SetXY ( $this -> posxdesc - 1 , $curY );
2005-09-03 16:04:15 +02:00
$pdf -> MultiCell ( 108 , 4 , $libelleproduitservice , 0 , 'J' );
2004-05-15 17:47:01 +02:00
$nexY = $pdf -> GetY ();
// TVA
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $this -> posxtva , $curY );
2005-09-03 16:04:15 +02:00
$pdf -> MultiCell ( 10 , 4 , ( $fac -> lignes [ $i ] -> tva_taux < 0 ? '*' : '' ) . abs ( $fac -> lignes [ $i ] -> tva_taux ), 0 , 'R' );
2004-05-15 17:47:01 +02:00
2005-02-13 01:18:32 +01:00
// Prix unitaire HT avant remise
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $this -> posxup , $curY );
2005-10-04 01:00:53 +02:00
$pdf -> MultiCell ( 18 , 4 , price ( $fac -> lignes [ $i ] -> subprice ), 0 , 'R' , 0 );
2004-05-15 17:47:01 +02:00
// Quantit<69>
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $this -> posxqty , $curY );
2005-09-03 16:04:15 +02:00
$pdf -> MultiCell ( 10 , 4 , $fac -> lignes [ $i ] -> qty , 0 , 'R' );
2004-05-15 17:47:01 +02:00
// Remise sur ligne
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $this -> posxdiscount , $curY );
2005-09-01 21:27:06 +02:00
if ( $fac -> lignes [ $i ] -> remise_percent )
{
2005-09-03 16:04:15 +02:00
$pdf -> MultiCell ( 14 , 4 , $fac -> lignes [ $i ] -> remise_percent . " % " , 0 , 'R' );
2004-05-15 17:47:01 +02:00
}
2005-08-20 23:54:16 +02:00
// Total HT ligne
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $this -> postotalht , $curY );
2004-05-15 17:47:01 +02:00
$total = price ( $fac -> lignes [ $i ] -> price * $fac -> lignes [ $i ] -> qty );
2005-09-03 16:04:15 +02:00
$pdf -> MultiCell ( 23 , 4 , $total , 0 , 'R' , 0 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
// Collecte des totaux par valeur de tva
// dans le tableau tva["taux"]=total_tva
$tvaligne = $fac -> lignes [ $i ] -> price * $fac -> lignes [ $i ] -> qty ;
if ( $fac -> remise_percent ) $tvaligne -= ( $tvaligne * $fac -> remise_percent ) / 100 ;
$this -> tva [ ( string ) $fac -> lignes [ $i ] -> tva_taux ] += $tvaligne ;
2004-05-15 17:47:01 +02:00
2005-09-01 21:27:06 +02:00
$nexY += 2 ; // Passe espace entre les lignes
2006-02-18 22:46:02 +01:00
if ( $nexY > ( $tab_top + $tab_height ) && $i < ( $nblignes - 1 ))
2004-05-15 17:47:01 +02:00
{
2005-11-28 01:02:08 +01:00
$this -> _tableau ( $pdf , $tab_top , $tab_height + 20 , $nexY );
$this -> _pagefoot ( $pdf );
// Nouvelle page
2004-05-15 17:47:01 +02:00
$pdf -> AddPage ();
2005-11-28 01:02:08 +01:00
$pagenb ++ ;
$this -> _pagehead ( $pdf , $fac , 0 );
$nexY = $tab_top_newpage + 8 ;
2004-05-15 17:47:01 +02:00
$pdf -> SetTextColor ( 0 , 0 , 0 );
$pdf -> SetFont ( 'Arial' , '' , 10 );
}
}
2005-11-28 01:02:08 +01:00
// Affiche cadre tableau
if ( $pagenb == 1 )
{
$this -> _tableau ( $pdf , $tab_top , $tab_height , $nexY );
$bottomlasttab = $tab_top + $tab_height + 1 ;
}
else
{
$this -> _tableau ( $pdf , $tab_top_newpage , $tab_height , $nexY );
$bottomlasttab = $tab_top_newpage + $tab_height + 1 ;
}
2004-05-20 16:19:32 +02:00
$deja_regle = $fac -> getSommePaiement ();
2005-11-28 01:02:08 +01:00
$posy = $this -> _tableau_tot ( $pdf , $fac , $deja_regle , $bottomlasttab );
2004-05-15 17:47:01 +02:00
2004-05-20 16:19:32 +02:00
if ( $deja_regle ) {
2005-08-20 23:36:58 +02:00
$this -> _tableau_versements ( $pdf , $fac , $posy );
2004-05-20 16:19:32 +02:00
}
2004-05-15 17:47:01 +02:00
/*
2005-08-20 23:36:58 +02:00
* Mode de r<EFBFBD> glement
*/
2005-11-08 00:35:58 +01:00
if (( ! defined ( " FACTURE_CHQ_NUMBER " ) || ! FACTURE_CHQ_NUMBER ) && ( ! defined ( " FACTURE_RIB_NUMBER " ) || ! FACTURE_RIB_NUMBER ))
{
$pdf -> SetXY ( $this -> marge_gauche , 228 );
2004-05-15 17:47:01 +02:00
$pdf -> SetTextColor ( 200 , 0 , 0 );
$pdf -> SetFont ( 'Arial' , 'B' , 8 );
2004-09-18 13:55:56 +02:00
$pdf -> MultiCell ( 90 , 3 , $langs -> trans ( " ErrorNoPaiementModeConfigured " ), 0 , 'L' , 0 );
$pdf -> MultiCell ( 90 , 3 , $langs -> trans ( " ErrorCreateBankAccount " ), 0 , 'L' , 0 );
2004-05-15 17:47:01 +02:00
$pdf -> SetTextColor ( 0 , 0 , 0 );
}
/*
2005-08-20 23:36:58 +02:00
* Propose mode r<EFBFBD> glement par CHQ
*/
2004-05-15 17:47:01 +02:00
if ( defined ( " FACTURE_CHQ_NUMBER " ))
{
if ( FACTURE_CHQ_NUMBER > 0 )
{
$account = new Account ( $this -> db );
$account -> fetch ( FACTURE_CHQ_NUMBER );
2005-11-08 00:35:58 +01:00
$pdf -> SetXY ( $this -> marge_gauche , 227 );
2004-05-15 17:47:01 +02:00
$pdf -> SetFont ( 'Arial' , 'B' , 8 );
$pdf -> MultiCell ( 90 , 3 , " R<EFBFBD> glement par ch<63> que <20> l'ordre de " . $account -> proprio . " envoy<6F> <20> : " , 0 , 'L' , 0 );
2005-11-08 00:35:58 +01:00
$pdf -> SetXY ( $this -> marge_gauche , 231 );
2004-05-15 17:47:01 +02:00
$pdf -> SetFont ( 'Arial' , '' , 8 );
$pdf -> MultiCell ( 80 , 3 , $account -> adresse_proprio , 0 , 'L' , 0 );
}
}
/*
2005-08-20 23:36:58 +02:00
* Propose mode r<EFBFBD> glement par RIB
*/
2004-05-15 17:47:01 +02:00
if ( defined ( " FACTURE_RIB_NUMBER " ))
{
if ( FACTURE_RIB_NUMBER > 0 )
{
$account = new Account ( $this -> db );
$account -> fetch ( FACTURE_RIB_NUMBER );
2005-11-08 00:35:58 +01:00
$this -> marges [ 'g' ] = $this -> marge_gauche ;
2005-01-24 22:46:27 +01:00
2005-06-29 00:13:53 +02:00
$cury = 242 ;
$pdf -> SetXY ( $this -> marges [ 'g' ], $cury );
$pdf -> SetFont ( 'Arial' , 'B' , 8 );
$pdf -> MultiCell ( 90 , 3 , " R<EFBFBD> glement par virement sur le compte bancaire suivant: " , 0 , 'L' , 0 );
$cury += 4 ;
$pdf -> SetFont ( 'Arial' , 'B' , 6 );
$pdf -> line ( $this -> marges [ 'g' ] + 1 , $cury , $this -> marges [ 'g' ] + 1 , $cury + 10 );
$pdf -> SetXY ( $this -> marges [ 'g' ], $cury );
$pdf -> MultiCell ( 18 , 3 , " Code banque " , 0 , 'C' , 0 );
$pdf -> line ( $this -> marges [ 'g' ] + 18 , $cury , $this -> marges [ 'g' ] + 18 , $cury + 10 );
$pdf -> SetXY ( $this -> marges [ 'g' ] + 18 , $cury );
$pdf -> MultiCell ( 18 , 3 , " Code guichet " , 0 , 'C' , 0 );
$pdf -> line ( $this -> marges [ 'g' ] + 36 , $cury , $this -> marges [ 'g' ] + 36 , $cury + 10 );
$pdf -> SetXY ( $this -> marges [ 'g' ] + 36 , $cury );
$pdf -> MultiCell ( 24 , 3 , " Num<EFBFBD> ro compte " , 0 , 'C' , 0 );
$pdf -> line ( $this -> marges [ 'g' ] + 60 , $cury , $this -> marges [ 'g' ] + 60 , $cury + 10 );
$pdf -> SetXY ( $this -> marges [ 'g' ] + 60 , $cury );
$pdf -> MultiCell ( 13 , 3 , " Cl<EFBFBD> RIB " , 0 , 'C' , 0 );
$pdf -> line ( $this -> marges [ 'g' ] + 73 , $cury , $this -> marges [ 'g' ] + 73 , $cury + 10 );
$pdf -> SetFont ( 'Arial' , '' , 8 );
$pdf -> SetXY ( $this -> marges [ 'g' ], $cury + 5 );
$pdf -> MultiCell ( 18 , 3 , $account -> code_banque , 0 , 'C' , 0 );
$pdf -> SetXY ( $this -> marges [ 'g' ] + 18 , $cury + 5 );
$pdf -> MultiCell ( 18 , 3 , $account -> code_guichet , 0 , 'C' , 0 );
$pdf -> SetXY ( $this -> marges [ 'g' ] + 36 , $cury + 5 );
$pdf -> MultiCell ( 24 , 3 , $account -> number , 0 , 'C' , 0 );
$pdf -> SetXY ( $this -> marges [ 'g' ] + 60 , $cury + 5 );
$pdf -> MultiCell ( 13 , 3 , $account -> cle_rib , 0 , 'C' , 0 );
$pdf -> SetXY ( $this -> marges [ 'g' ], $cury + 12 );
$pdf -> MultiCell ( 90 , 3 , " Domiciliation : " . $account -> domiciliation , 0 , 'L' , 0 );
$pdf -> SetXY ( $this -> marges [ 'g' ], $cury + 22 );
$pdf -> MultiCell ( 90 , 3 , " Prefix IBAN : " . $account -> iban_prefix , 0 , 'L' , 0 );
$pdf -> SetXY ( $this -> marges [ 'g' ], $cury + 25 );
$pdf -> MultiCell ( 90 , 3 , " BIC : " . $account -> bic , 0 , 'L' , 0 );
2005-01-24 22:46:27 +01:00
2004-05-15 17:47:01 +02:00
}
}
/*
2005-08-20 23:36:58 +02:00
* Conditions de r<EFBFBD> glements
*/
2006-02-18 22:46:02 +01:00
if ( $fac -> cond_reglement_facture )
{
$pdf -> SetFont ( 'Arial' , 'B' , 8 );
$pdf -> SetXY ( $this -> marge_gauche , 217 );
$titre = $langs -> trans ( " PaymentConditions " ) . ':' ;
$pdf -> MultiCell ( 80 , 5 , $titre , 0 , 'L' );
$pdf -> SetFont ( 'Arial' , '' , 8 );
$pdf -> SetXY ( 50 , 217 );
$pdf -> MultiCell ( 80 , 5 , $fac -> cond_reglement_facture , 0 , 'L' );
}
2004-07-25 17:31:16 +02:00
/*
* Pied de page
*/
2005-11-04 02:07:33 +01:00
$this -> _pagefoot ( $pdf );
2004-07-25 17:31:16 +02:00
$pdf -> AliasNbPages ();
2004-05-15 17:47:01 +02:00
$pdf -> Close ();
$pdf -> Output ( $file );
return 1 ; // Pas d'erreur
}
else
{
2004-09-18 13:55:56 +02:00
$this -> error = $langs -> trans ( " ErrorCanNotCreateDir " , $dir );
2004-07-25 15:12:15 +02:00
return 0 ;
2004-05-15 17:47:01 +02:00
}
}
else
{
2004-09-18 13:55:56 +02:00
$this -> error = $langs -> trans ( " ErrorConstantNotDefined " , " FAC_OUTPUTDIR " );
2004-07-25 15:12:15 +02:00
return 0 ;
2004-05-15 17:47:01 +02:00
}
2004-09-18 13:55:56 +02:00
$this -> error = $langs -> trans ( " ErrorUnknown " );
2004-05-15 17:47:01 +02:00
return 0 ; // Erreur par defaut
2004-02-08 17:58:42 +01:00
}
2004-05-15 17:47:01 +02:00
/*
2005-08-20 23:54:16 +02:00
* \brief Affiche tableau des versement
* \param pdf objet PDF
* \param fac objet facture
*/
2005-08-20 23:36:58 +02:00
function _tableau_versements ( & $pdf , $fac , $posy )
2004-02-08 17:58:42 +01:00
{
2004-09-18 13:55:56 +02:00
global $langs ;
$langs -> load ( " main " );
$langs -> load ( " bills " );
2005-08-20 23:36:58 +02:00
2004-05-20 16:19:32 +02:00
$tab3_posx = 120 ;
2005-11-28 01:02:08 +01:00
$tab3_top = $posy + 8 ;
2004-05-20 16:19:32 +02:00
$tab3_width = 80 ;
$tab3_height = 4 ;
2004-05-15 17:47:01 +02:00
$pdf -> SetFont ( 'Arial' , '' , 8 );
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $tab3_posx , $tab3_top - 5 );
2005-08-24 19:09:26 +02:00
$pdf -> MultiCell ( 60 , 5 , $langs -> trans ( " PaymentsAlreadyDone " ), 0 , 'L' , 0 );
2004-05-20 16:19:32 +02:00
$pdf -> Rect ( $tab3_posx , $tab3_top - 1 , $tab3_width , $tab3_height );
$pdf -> SetXY ( $tab3_posx , $tab3_top - 1 );
2004-09-18 13:55:56 +02:00
$pdf -> MultiCell ( 20 , 4 , $langs -> trans ( " Payment " ), 0 , 'L' , 0 );
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $tab3_posx + 21 , $tab3_top - 1 );
2004-09-18 13:55:56 +02:00
$pdf -> MultiCell ( 20 , 4 , $langs -> trans ( " Amount " ), 0 , 'L' , 0 );
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $tab3_posx + 41 , $tab3_top - 1 );
2004-09-18 13:55:56 +02:00
$pdf -> MultiCell ( 20 , 4 , $langs -> trans ( " Type " ), 0 , 'L' , 0 );
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $tab3_posx + 60 , $tab3_top - 1 );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( 20 , 4 , $langs -> trans ( " Num " ), 0 , 'L' , 0 );
2004-05-20 16:19:32 +02:00
$sql = " SELECT " . $this -> db -> pdate ( " p.datep " ) . " as date, p.amount as amount, p.fk_paiement as type, p.num_paiement as num " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " paiement as p, " . MAIN_DB_PREFIX . " paiement_facture as pf " ;
$sql .= " WHERE pf.fk_paiement = p.rowid and pf.fk_facture = " . $fac -> id . " " ;
$sql .= " ORDER BY p.datep " ;
if ( $this -> db -> query ( $sql ))
{
$pdf -> SetFont ( 'Arial' , '' , 6 );
$num = $this -> db -> num_rows ();
$i = 0 ; $y = 0 ;
while ( $i < $num ) {
$y += 3 ;
$row = $this -> db -> fetch_row ();
$pdf -> SetXY ( $tab3_posx , $tab3_top + $y );
$pdf -> MultiCell ( 20 , 4 , strftime ( " %d/%m/%y " , $row [ 0 ]), 0 , 'L' , 0 );
$pdf -> SetXY ( $tab3_posx + 21 , $tab3_top + $y );
$pdf -> MultiCell ( 20 , 4 , $row [ 1 ], 0 , 'L' , 0 );
$pdf -> SetXY ( $tab3_posx + 41 , $tab3_top + $y );
switch ( $row [ 2 ])
{
case 1 :
$oper = 'TIP' ;
break ;
case 2 :
$oper = 'VIR' ;
break ;
case 3 :
$oper = 'PRE' ;
break ;
case 4 :
$oper = 'LIQ' ;
break ;
case 5 :
2004-09-30 21:18:19 +02:00
$oper = 'VAD' ;
2004-05-20 16:19:32 +02:00
break ;
case 6 :
$oper = 'CB' ;
break ;
case 7 :
$oper = 'CHQ' ;
break ;
}
$pdf -> MultiCell ( 20 , 4 , $oper , 0 , 'L' , 0 );
$pdf -> SetXY ( $tab3_posx + 60 , $tab3_top + $y );
$pdf -> MultiCell ( 20 , 4 , $row [ 3 ], 0 , 'L' , 0 );
$pdf -> line ( $tab3_posx , $tab3_top + $y + 3 , $tab3_posx + $tab3_width , $tab3_top + $y + 3 );
2004-07-25 17:31:16 +02:00
2004-05-20 16:19:32 +02:00
$i ++ ;
}
}
else
{
2004-09-18 13:55:56 +02:00
$this -> error = $langs -> trans ( " ErrorSQL " ) . " $sql " ;
2004-07-25 15:12:15 +02:00
return 0 ;
2004-05-20 16:19:32 +02:00
}
2004-02-08 17:58:42 +01:00
}
2004-05-15 17:47:01 +02:00
2004-09-18 13:55:56 +02:00
/*
2005-08-20 23:54:16 +02:00
* \brief Affiche le total <EFBFBD> payer
* \param pdf Objet PDF
* \param fac Objet facture
* \param deja_regle Montant deja regle
* \return y Position pour suite
*/
2005-11-28 01:02:08 +01:00
function _tableau_tot ( & $pdf , $fac , $deja_regle , $posy )
2004-02-08 17:58:42 +01:00
{
2004-09-18 13:55:56 +02:00
global $langs ;
$langs -> load ( " main " );
$langs -> load ( " bills " );
2005-11-28 01:02:08 +01:00
$tab2_top = $posy ;
2004-05-15 17:47:01 +02:00
$tab2_hl = 5 ;
$tab2_height = $tab2_hl * 4 ;
$pdf -> SetFont ( 'Arial' , '' , 9 );
// Affiche la mention TVA non applicable selon option
2005-11-08 00:35:58 +01:00
$pdf -> SetXY ( $this -> marge_gauche , $tab2_top + 0 );
2005-03-20 02:19:35 +01:00
if ( $this -> franchise == 1 )
{
2004-05-15 17:47:01 +02:00
$pdf -> MultiCell ( 100 , $tab2_hl , " * TVA non applicable art-293B du CGI " , 0 , 'L' , 0 );
}
2004-05-20 16:19:32 +02:00
// Tableau total
2005-08-22 22:34:39 +02:00
$lltot = 200 ; $col1x = 120 ; $col2x = 182 ; $largcol2 = $lltot - $col2x ;
2005-08-20 23:36:58 +02:00
// Total HT
$pdf -> SetFillColor ( 256 , 256 , 256 );
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $col1x , $tab2_top + 0 );
2005-08-20 23:36:58 +02:00
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , $langs -> trans ( " TotalHT " ), 0 , 'L' , 1 );
2004-05-15 17:47:01 +02:00
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + 0 );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , price ( $fac -> total_ht + $fac -> remise ), 0 , 'R' , 1 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:54:16 +02:00
// Remise globale
2004-05-15 17:47:01 +02:00
if ( $fac -> remise > 0 )
{
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl );
2005-08-20 23:36:58 +02:00
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , $langs -> trans ( " GlobalDiscount " ), 0 , 'L' , 1 );
2004-05-15 17:47:01 +02:00
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + $tab2_hl );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , " - " . $fac -> remise_percent . " % " , 0 , 'R' , 1 );
2004-05-15 17:47:01 +02:00
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl * 2 );
2005-08-20 23:36:58 +02:00
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , " Total HT apr<70> s remise " , 0 , 'L' , 1 );
2004-05-15 17:47:01 +02:00
2004-05-20 16:19:32 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + $tab2_hl * 2 );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , price ( $fac -> total_ht ), 0 , 'R' , 1 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
$index = 2 ;
2004-05-15 17:47:01 +02:00
}
else
{
2005-08-20 23:36:58 +02:00
$index = 0 ;
2004-05-15 17:47:01 +02:00
}
2005-08-20 23:36:58 +02:00
// Affichage des totaux de TVA par taux (conform<72> ment <20> r<> glementation)
$pdf -> SetFillColor ( 248 , 248 , 248 );
foreach ( $this -> tva as $tvakey => $tvaval )
{
if ( $tvakey ) // On affiche pas taux 0
{
2005-11-08 00:35:58 +01:00
$this -> atleastoneratenotnull ++ ;
2005-08-20 23:36:58 +02:00
$index ++ ;
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl * $index );
2005-08-22 22:34:39 +02:00
$tvacompl = ( ( float ) $tvakey < 0 ) ? " ( " . $langs -> trans ( " NonPercuRecuperable " ) . " ) " : '' ;
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , $langs -> trans ( " TotalVAT " ) . ' ' . abs ( $tvakey ) . '%' . $tvacompl , 0 , 'L' , 1 );
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + $tab2_hl * $index );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , price ( $tvaval * ( float ) $tvakey / 100 ), 0 , 'R' , 1 );
2005-08-20 23:36:58 +02:00
}
}
2005-11-08 00:35:58 +01:00
if ( ! $this -> atleastoneratenotnull )
2005-08-20 23:36:58 +02:00
{
$index ++ ;
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl * $index );
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , $langs -> trans ( " TotalVAT " ), 0 , 'L' , 1 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + $tab2_hl * $index );
2005-11-08 00:35:58 +01:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , price ( $fac -> total_tva ), 0 , 'R' , 1 );
2005-08-20 23:36:58 +02:00
}
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
$useborder = 0 ;
$index ++ ;
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl * $index );
2005-01-24 22:46:27 +01:00
$pdf -> SetTextColor ( 0 , 0 , 60 );
2005-08-20 23:36:58 +02:00
$pdf -> SetFillColor ( 224 , 224 , 224 );
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , $langs -> trans ( " TotalTTC " ), $useborder , 'L' , 1 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + $tab2_hl * $index );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , price ( $fac -> total_ttc ), $useborder , 'R' , 1 );
2005-06-29 00:13:53 +02:00
$pdf -> SetFont ( 'Arial' , '' , 9 );
2005-01-24 22:46:27 +01:00
$pdf -> SetTextColor ( 0 , 0 , 0 );
2004-05-15 17:47:01 +02:00
if ( $deja_regle > 0 )
{
2005-08-20 23:36:58 +02:00
$index ++ ;
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl * $index );
2005-02-06 18:03:06 +01:00
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , $langs -> trans ( " AlreadyPayed " ), 0 , 'L' , 0 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + $tab2_hl * $index );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , price ( $deja_regle ), 0 , 'R' , 0 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
$index ++ ;
2005-01-24 22:46:27 +01:00
$pdf -> SetTextColor ( 0 , 0 , 60 );
2005-08-20 23:36:58 +02:00
//$pdf->SetFont('Arial','B', 9);
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl * $index );
$pdf -> MultiCell ( $col2x - $col1x , $tab2_hl , $langs -> trans ( " RemainderToPay " ), $useborder , 'L' , 1 );
2004-05-15 17:47:01 +02:00
2005-08-20 23:36:58 +02:00
$pdf -> SetXY ( $col2x , $tab2_top + $tab2_hl * $index );
2005-08-22 22:34:39 +02:00
$pdf -> MultiCell ( $largcol2 , $tab2_hl , price ( $fac -> total_ttc - $deja_regle ), $useborder , 'R' , 1 );
2005-06-29 00:13:53 +02:00
$pdf -> SetFont ( 'Arial' , '' , 9 );
2005-01-24 22:46:27 +01:00
$pdf -> SetTextColor ( 0 , 0 , 0 );
2004-05-15 17:47:01 +02:00
}
2005-08-20 23:36:58 +02:00
2005-08-22 22:34:39 +02:00
/* Ne semble pas requis par la r<EFBFBD> glementation
$index ++ ;
$pdf -> SetXY ( $col1x , $tab2_top + $tab2_hl * $index );
$pdf -> MultiCell ( $col2x - $col1x + $largcol2 , $tab2_hl , $langs -> trans ( 'DispenseMontantLettres' ), 0 , 'L' );
*/
2005-08-20 23:36:58 +02:00
$index ++ ;
return ( $tab2_top + ( $tab2_hl * $index ));
2004-02-08 17:58:42 +01:00
}
2004-05-20 16:19:32 +02:00
2004-05-15 17:47:01 +02:00
/*
2005-08-20 23:36:58 +02:00
* \brief Affiche la grille des lignes de factures
* \param pdf objet PDF
*/
2004-08-07 19:14:42 +02:00
function _tableau ( & $pdf , $tab_top , $tab_height , $nexY )
2004-02-08 17:58:42 +01:00
{
2005-11-28 01:02:08 +01:00
global $langs , $conf ;
2004-09-18 13:55:56 +02:00
$langs -> load ( " main " );
$langs -> load ( " bills " );
2005-11-28 01:02:08 +01:00
// Montants exprim<69> s en (en tab_top - 1)
$pdf -> SetTextColor ( 0 , 0 , 0 );
$pdf -> SetFont ( 'Arial' , '' , 8 );
$titre = $langs -> trans ( " AmountInCurrency " , $langs -> trans ( " Currency " . $conf -> monnaie ));
$pdf -> Text ( $this -> page_largeur - $this -> marge_droite - $pdf -> GetStringWidth ( $titre ), $tab_top - 1 , $titre );
$pdf -> SetDrawColor ( 128 , 128 , 128 );
2005-11-08 00:35:58 +01:00
// Rect prend une longueur en 3eme param
$pdf -> Rect ( $this -> marge_gauche , $tab_top , $this -> page_largeur - $this -> marge_gauche - $this -> marge_droite , $tab_height );
// line prend une position y en 3eme param
2006-02-18 22:46:02 +01:00
$pdf -> line ( $this -> marge_gauche , $tab_top + 5 , $this -> page_largeur - $this -> marge_droite , $tab_top + 5 );
2004-05-20 16:19:32 +02:00
2004-05-15 17:47:01 +02:00
$pdf -> SetFont ( 'Arial' , '' , 10 );
2005-09-01 21:27:06 +02:00
$pdf -> SetXY ( $this -> posxdesc - 1 , $tab_top + 2 );
$pdf -> MultiCell ( 108 , 2 , $langs -> trans ( " Designation " ), '' , 'L' );
2004-05-15 17:47:01 +02:00
2005-09-01 21:27:06 +02:00
$pdf -> line ( $this -> posxtva - 1 , $tab_top , $this -> posxtva - 1 , $tab_top + $tab_height );
$pdf -> SetXY ( $this -> posxtva - 1 , $tab_top + 2 );
2005-08-20 23:36:58 +02:00
$pdf -> MultiCell ( 12 , 2 , $langs -> trans ( " VAT " ), '' , 'C' );
2004-05-15 17:47:01 +02:00
2005-09-01 21:27:06 +02:00
$pdf -> line ( $this -> posxup - 1 , $tab_top , $this -> posxup - 1 , $tab_top + $tab_height );
$pdf -> SetXY ( $this -> posxup - 1 , $tab_top + 2 );
2005-08-20 23:36:58 +02:00
$pdf -> MultiCell ( 18 , 2 , $langs -> trans ( " PriceUHT " ), '' , 'C' );
2004-05-15 17:47:01 +02:00
2005-09-01 21:27:06 +02:00
$pdf -> line ( $this -> posxqty - 1 , $tab_top , $this -> posxqty - 1 , $tab_top + $tab_height );
$pdf -> SetXY ( $this -> posxqty - 1 , $tab_top + 2 );
$pdf -> MultiCell ( 11 , 2 , $langs -> trans ( " Qty " ), '' , 'C' );
2004-05-15 17:47:01 +02:00
2005-09-01 21:27:06 +02:00
$pdf -> line ( $this -> posxdiscount - 1 , $tab_top , $this -> posxdiscount - 1 , $tab_top + $tab_height );
2005-11-08 00:35:58 +01:00
if ( $this -> atleastonediscount )
{
$pdf -> SetXY ( $this -> posxdiscount - 1 , $tab_top + 2 );
$pdf -> MultiCell ( 16 , 2 , $langs -> trans ( " Discount " ), '' , 'C' );
}
if ( $this -> atleastonediscount )
{
2005-11-28 01:02:08 +01:00
$pdf -> line ( $this -> postotalht , $tab_top , $this -> postotalht , $tab_top + $tab_height );
2005-11-08 00:35:58 +01:00
}
2005-09-01 21:27:06 +02:00
$pdf -> SetXY ( $this -> postotalht - 1 , $tab_top + 2 );
2005-08-20 23:36:58 +02:00
$pdf -> MultiCell ( 23 , 2 , $langs -> trans ( " TotalHT " ), '' , 'C' );
2004-05-15 17:47:01 +02:00
2004-02-08 17:58:42 +01:00
}
2004-05-20 16:19:32 +02:00
2004-05-15 17:47:01 +02:00
/*
2005-11-28 01:02:08 +01:00
* \brief Affiche en - t<EFBFBD> te facture
* \param pdf Objet PDF
* \param fac Objet facture
* \param showadress 0 = non , 1 = oui
2005-08-20 23:36:58 +02:00
*/
2005-11-28 01:02:08 +01:00
function _pagehead ( & $pdf , $fac , $showadress = 1 )
2004-02-08 17:58:42 +01:00
{
2005-11-13 02:46:25 +01:00
global $langs , $conf , $mysoc ;
2004-09-18 13:55:56 +02:00
$langs -> load ( " main " );
$langs -> load ( " bills " );
2005-03-20 02:19:35 +01:00
$langs -> load ( " propal " );
$langs -> load ( " companies " );
2004-09-18 13:55:56 +02:00
2004-08-09 21:33:48 +02:00
$pdf -> SetTextColor ( 0 , 0 , 60 );
$pdf -> SetFont ( 'Arial' , 'B' , 13 );
2005-11-08 00:35:58 +01:00
$posy = $this -> marge_haute ;
2005-11-04 02:07:33 +01:00
2005-11-08 00:35:58 +01:00
$pdf -> SetXY ( $this -> marge_gauche , $posy );
2004-02-08 17:58:42 +01:00
2005-03-20 02:19:35 +01:00
// Logo
2005-11-13 02:46:25 +01:00
$logo = $mysoc -> logo ;
2005-12-17 18:52:15 +01:00
if ( defined ( " FAC_PDF_LOGO " ) && FAC_PDF_LOGO ) $logo = DOL_DATA_ROOT . FAC_PDF_LOGO ;
2005-11-13 02:46:25 +01:00
if ( $logo )
2004-08-09 21:33:48 +02:00
{
2005-11-13 02:46:25 +01:00
if ( is_readable ( $logo ))
2005-08-26 21:22:23 +02:00
{
2005-11-13 02:46:25 +01:00
$pdf -> Image ( $logo , $this -> marge_gauche , $posy , 0 , 24 );
2004-08-09 21:33:48 +02:00
}
2005-08-26 21:22:23 +02:00
else
{
2004-08-09 21:37:04 +02:00
$pdf -> SetTextColor ( 200 , 0 , 0 );
$pdf -> SetFont ( 'Arial' , 'B' , 8 );
2005-11-13 02:46:25 +01:00
$pdf -> MultiCell ( 100 , 3 , $langs -> trans ( " ErrorLogoFileNotFound " , $logo ), 0 , 'L' );
2005-11-04 02:07:33 +01:00
$pdf -> MultiCell ( 100 , 3 , $langs -> trans ( " ErrorGoToModuleSetup " ), 0 , 'L' );
2004-08-09 21:33:48 +02:00
}
}
else if ( defined ( " FAC_PDF_INTITULE " ))
2004-05-15 17:47:01 +02:00
{
2005-11-04 02:07:33 +01:00
$pdf -> MultiCell ( 100 , 4 , FAC_PDF_INTITULE , 0 , 'L' );
2004-05-15 17:47:01 +02:00
}
$pdf -> SetFont ( 'Arial' , 'B' , 13 );
2005-11-04 02:07:33 +01:00
$pdf -> SetXY ( 100 , $posy );
2004-05-15 17:47:01 +02:00
$pdf -> SetTextColor ( 0 , 0 , 60 );
2005-11-04 02:07:33 +01:00
$pdf -> MultiCell ( 100 , 4 , $langs -> trans ( " Bill " ) . " " . $fac -> ref , '' , 'R' );
2004-05-20 16:19:32 +02:00
$pdf -> SetFont ( 'Arial' , '' , 12 );
2005-11-28 01:02:08 +01:00
$posy += 6 ;
$pdf -> SetXY ( 100 , $posy );
2004-05-15 17:47:01 +02:00
$pdf -> SetTextColor ( 0 , 0 , 60 );
2005-11-04 02:07:33 +01:00
$pdf -> MultiCell ( 100 , 4 , $langs -> trans ( " Date " ) . " : " . dolibarr_print_date ( $fac -> date , " %d %b %Y " ), '' , 'R' );
2004-05-15 17:47:01 +02:00
2005-11-28 01:02:08 +01:00
if ( $showadress )
{
// Emetteur
$posy = 42 ;
$hautcadre = 40 ;
$pdf -> SetTextColor ( 0 , 0 , 0 );
$pdf -> SetFont ( 'Arial' , '' , 8 );
$pdf -> SetXY ( $this -> marge_gauche , $posy - 5 );
$pdf -> MultiCell ( 66 , 5 , $langs -> trans ( " BillFrom " ) . " : " );
$pdf -> SetXY ( $this -> marge_gauche , $posy );
$pdf -> SetFillColor ( 230 , 230 , 230 );
$pdf -> MultiCell ( 82 , $hautcadre , " " , 0 , 'R' , 1 );
$pdf -> SetXY ( $this -> marge_gauche + 2 , $posy + 3 );
// Nom emetteur
$pdf -> SetTextColor ( 0 , 0 , 60 );
$pdf -> SetFont ( 'Arial' , 'B' , 11 );
if ( defined ( " FAC_PDF_SOCIETE_NOM " ) && FAC_PDF_SOCIETE_NOM ) $pdf -> MultiCell ( 80 , 4 , FAC_PDF_SOCIETE_NOM , 0 , 'L' );
else $pdf -> MultiCell ( 80 , 4 , $mysoc -> nom , 0 , 'L' );
// Caract<63> ristiques emetteur
$carac_emetteur = '' ;
if ( defined ( " FAC_PDF_ADRESSE " ) && FAC_PDF_ADRESSE ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . FAC_PDF_ADRESSE ;
else {
$carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $mysoc -> adresse ;
$carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $mysoc -> cp . ' ' . $mysoc -> ville ;
}
$carac_emetteur .= " \n " ;
// Tel
if ( defined ( " FAC_PDF_TEL " ) && FAC_PDF_TEL ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Phone " ) . " : " . FAC_PDF_TEL ;
elseif ( $mysoc -> tel ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Phone " ) . " : " . $mysoc -> tel ;
// Fax
if ( defined ( " FAC_PDF_FAX " ) && FAC_PDF_FAX ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Fax " ) . " : " . FAC_PDF_FAX ;
elseif ( $mysoc -> fax ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Fax " ) . " : " . $mysoc -> fax ;
// EMail
if ( defined ( " FAC_PDF_MEL " ) && FAC_PDF_MEL ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Email " ) . " : " . FAC_PDF_MEL ;
elseif ( $mysoc -> email ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Email " ) . " : " . $mysoc -> email ;
// Web
if ( defined ( " FAC_PDF_WWW " ) && FAC_PDF_WWW ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Web " ) . " : " . FAC_PDF_WWW ;
elseif ( $mysoc -> url ) $carac_emetteur .= ( $carac_emetteur ? " \n " : '' ) . $langs -> trans ( " Web " ) . " : " . $mysoc -> url ;
$pdf -> SetFont ( 'Arial' , '' , 9 );
$pdf -> SetXY ( $this -> marge_gauche + 2 , $posy + 8 );
$pdf -> MultiCell ( 80 , 4 , $carac_emetteur );
// Client destinataire
$posy = 42 ;
$pdf -> SetTextColor ( 0 , 0 , 0 );
$pdf -> SetFont ( 'Arial' , '' , 8 );
$pdf -> SetXY ( 102 , $posy - 5 );
$pdf -> MultiCell ( 80 , 5 , $langs -> trans ( " BillTo " ) . " : " );
$fac -> fetch_client ();
// Cadre client destinataire
$pdf -> rect ( 100 , $posy , 100 , $hautcadre );
// Nom client
$pdf -> SetXY ( 102 , $posy + 3 );
$pdf -> SetFont ( 'Arial' , 'B' , 11 );
$pdf -> MultiCell ( 106 , 4 , $fac -> client -> nom , 0 , 'L' );
// Caract<63> ristiques client
$carac_client = $fac -> client -> adresse ;
$carac_client .= " \n " . $fac -> client -> cp . " " . $fac -> client -> ville . " \n " ;
if ( $fac -> client -> tva_intra ) $carac_client .= " \n " . $langs -> trans ( " VATIntraShort " ) . ': ' . $fac -> client -> tva_intra ;
$pdf -> SetFont ( 'Arial' , '' , 9 );
$pdf -> SetXY ( 102 , $posy + 8 );
$pdf -> MultiCell ( 86 , 4 , $carac_client );
2004-05-15 17:47:01 +02:00
}
2005-11-28 01:02:08 +01:00
2004-02-08 17:58:42 +01:00
}
2004-05-15 17:47:01 +02:00
2004-07-25 17:31:16 +02:00
/*
2005-11-04 02:07:33 +01:00
* \brief Affiche le pied de page
* \param pdf objet PDF
*/
function _pagefoot ( & $pdf )
2004-07-25 17:31:16 +02:00
{
2004-12-04 21:19:53 +01:00
global $langs , $conf ;
2004-09-18 13:55:56 +02:00
$langs -> load ( " main " );
$langs -> load ( " bills " );
$langs -> load ( " companies " );
2005-08-20 23:36:58 +02:00
$html = new Form ( $this -> db );
2005-08-22 02:27:31 +02:00
// Premiere ligne d'info r<> glementaires
2005-11-04 02:07:33 +01:00
$ligne1 = " " ;
2005-08-20 23:36:58 +02:00
if ( $conf -> global -> MAIN_INFO_SOCIETE_FORME_JURIDIQUE )
{
2005-11-04 02:07:33 +01:00
$ligne1 .= ( $ligne1 ? " - " : " " ) . $html -> forme_juridique_name ( $conf -> global -> MAIN_INFO_SOCIETE_FORME_JURIDIQUE );
2005-08-20 23:36:58 +02:00
}
if ( $conf -> global -> MAIN_INFO_CAPITAL )
{
2005-11-04 02:07:33 +01:00
$ligne1 .= ( $ligne1 ? " - " : " " ) . $langs -> trans ( " CapitalOf " , $conf -> global -> MAIN_INFO_CAPITAL ) . " " . $langs -> trans ( " Currency " . $conf -> monnaie );
2005-07-01 01:03:41 +02:00
}
2005-08-20 23:36:58 +02:00
if ( $conf -> global -> MAIN_INFO_SIRET )
{
2005-11-04 02:07:33 +01:00
$ligne1 .= ( $ligne1 ? " - " : " " ) . $langs -> transcountry ( " ProfId2 " , $this -> emetteur -> code_pays ) . " : " . $conf -> global -> MAIN_INFO_SIRET ;
2005-07-01 01:03:41 +02:00
}
2005-08-26 21:22:23 +02:00
if ( $conf -> global -> MAIN_INFO_SIREN && ( ! $conf -> global -> MAIN_INFO_SIRET || $this -> emetteur -> code_pays != 'FR' ))
2005-08-23 23:44:45 +02:00
{
2005-11-04 02:07:33 +01:00
$ligne1 .= ( $ligne1 ? " - " : " " ) . $langs -> transcountry ( " ProfId1 " , $this -> emetteur -> code_pays ) . " : " . $conf -> global -> MAIN_INFO_SIREN ;
2005-08-23 23:44:45 +02:00
}
2005-08-22 17:41:55 +02:00
if ( $conf -> global -> MAIN_INFO_APE )
{
2005-11-04 02:07:33 +01:00
$ligne1 .= ( $ligne1 ? " - " : " " ) . $langs -> transcountry ( " ProfId3 " , $this -> emetteur -> code_pays ) . " : " . MAIN_INFO_APE ;
2005-08-22 17:41:55 +02:00
}
2005-08-22 02:27:31 +02:00
// Deuxieme ligne d'info r<> glementaires
2005-11-04 02:07:33 +01:00
$ligne2 = " " ;
2005-08-22 02:27:31 +02:00
if ( $conf -> global -> MAIN_INFO_RCS )
{
2005-11-04 02:07:33 +01:00
$ligne2 .= ( $ligne2 ? " - " : " " ) . $langs -> transcountry ( " ProfId4 " , $this -> emetteur -> code_pays ) . " : " . $conf -> global -> MAIN_INFO_RCS ;
2004-07-25 17:31:16 +02:00
}
2005-08-22 02:27:31 +02:00
if ( $conf -> global -> MAIN_INFO_TVAINTRA != '' )
{
2005-11-04 02:07:33 +01:00
$ligne2 .= ( $ligne2 ? " - " : " " ) . $langs -> trans ( " VATIntraShort " ) . " : " . $conf -> global -> MAIN_INFO_TVAINTRA ;
2004-07-25 17:31:16 +02:00
}
2005-11-04 02:07:33 +01:00
$pdf -> SetFont ( 'Arial' , '' , 8 );
$pdf -> SetDrawColor ( 224 , 224 , 224 );
// On positionne le debut du bas de page selon nbre de lignes de ce bas de page
2005-11-04 21:42:07 +01:00
$posy = $this -> marge_basse + 1 + ( $ligne1 ? 3 : 0 ) + ( $ligne2 ? 3 : 0 );
2005-11-04 02:07:33 +01:00
$pdf -> SetY ( - $posy );
2005-11-08 00:35:58 +01:00
$pdf -> line ( $this -> marge_gauche , $this -> page_hauteur - $posy , 200 , $this -> page_hauteur - $posy );
2005-11-04 02:07:33 +01:00
$posy -- ;
2005-08-24 00:23:47 +02:00
2005-11-04 02:07:33 +01:00
if ( $ligne1 )
{
2005-11-08 00:35:58 +01:00
$pdf -> SetXY ( $this -> marge_gauche , - $posy );
2005-11-04 02:07:33 +01:00
$pdf -> MultiCell ( 200 , 2 , $ligne1 , 0 , 'C' , 0 );
}
if ( $ligne2 )
2005-08-24 00:23:47 +02:00
{
2005-11-04 02:07:33 +01:00
$posy -= 3 ;
2005-11-08 00:35:58 +01:00
$pdf -> SetXY ( $this -> marge_gauche , - $posy );
2005-11-04 02:07:33 +01:00
$pdf -> MultiCell ( 200 , 2 , $ligne2 , 0 , 'C' , 0 );
2005-08-24 00:23:47 +02:00
}
2005-11-04 02:07:33 +01:00
$pdf -> SetXY ( - 20 , - $posy );
2005-08-22 02:27:31 +02:00
$pdf -> MultiCell ( 10 , 2 , $pdf -> PageNo () . '/{nb}' , 0 , 'R' , 0 );
2004-07-25 17:31:16 +02:00
}
2004-02-08 17:58:42 +01:00
}
?>