New: Sur page config choix module génération facture, un clic sur info affiche un aperçu d'un specimen.

This commit is contained in:
Laurent Destailleur 2006-06-11 00:36:17 +00:00
parent 085274aa92
commit b89b5f8a31
10 changed files with 930 additions and 734 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
* *
@ -30,6 +30,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/facture.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("companies"); $langs->load("companies");
@ -40,11 +41,36 @@ if (!$user->admin)
accessforbidden(); accessforbidden();
$typeconst=array('yesno','texte','chaine'); $typeconst=array('yesno','texte','chaine');
$dir = DOL_DOCUMENT_ROOT."/includes/modules/facture/";
/* /*
* Actions * Actions
*/ */
if ($_GET["action"] == 'specimen')
{
$modele=$_GET["module"];
$facture = new Facture($db);
$facture->initAsSpecimen();
// Charge le modele
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/facture/";
$file = "pdf_".$modele.".modules.php";
if (file_exists($dir.$file))
{
$classname = "pdf_".$modele;
require_once($dir.$file);
$obj = new $classname($db);
if ($obj->write_pdf_file($facture) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
return;
}
}
}
if ($_GET["action"] == 'set') if ($_GET["action"] == 'set')
{ {
@ -81,7 +107,7 @@ if ($_GET["action"] == 'setdoc')
// On active le modele // On active le modele
$type='invoice'; $type='invoice';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql_del .= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'"; $sql_del.= " WHERE nom = '".$_GET["value"]."' AND type = '".$type."'";
$result1=$db->query($sql_del); $result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql); $result2=$db->query($sql);
@ -142,7 +168,6 @@ if ($_GET["action"] == 'delete')
llxHeader("",""); llxHeader("","");
$dir = "../includes/modules/facture/";
$html=new Form($db); $html=new Form($db);
$h = 0; $h = 0;
@ -285,6 +310,7 @@ while (($file = readdir($handle))!==false)
print '<tr '.$bc[$var].'><td width="100">'; print '<tr '.$bc[$var].'><td width="100">';
echo "$name"; echo "$name";
print "</td><td>\n"; print "</td><td>\n";
require_once($dir.$file); require_once($dir.$file);
$module = new $classname($db); $module = new $classname($db);
print $module->description; print $module->description;
@ -333,7 +359,9 @@ while (($file = readdir($handle))!==false)
$htmltooltip.='<br><b>'.$langs->trans("Logo").'</b>: '.yn($module->option_logo); $htmltooltip.='<br><b>'.$langs->trans("Logo").'</b>: '.yn($module->option_logo);
$htmltooltip.='<br><b>'.$langs->trans("PaymentMode").'</b>: '.yn($module->option_modereg); $htmltooltip.='<br><b>'.$langs->trans("PaymentMode").'</b>: '.yn($module->option_modereg);
$htmltooltip.='<br><b>'.$langs->trans("PaymentConditions").'</b>: '.yn($module->option_condreg); $htmltooltip.='<br><b>'.$langs->trans("PaymentConditions").'</b>: '.yn($module->option_condreg);
print '<td align="center" '.$html->tooltip_properties($htmltooltip).'>'.img_help(0).'</td>'; print '<td align="center" '.$html->tooltip_properties($htmltooltip).'>';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'" alt="" title="">'.img_help(0,0).'</a>';
print '</td>';
print "</tr>\n"; print "</tr>\n";
} }

View File

@ -954,7 +954,7 @@ class Facture
} }
/** /**
* \brief Ajoute un produit dans l'objet facture * \brief Ajoute un produit dans les tableaux products, products_qty, products_date_start|end
* \param idproduct * \param idproduct
* \param qty * \param qty
* \param remise_percent * \param remise_percent
@ -1235,6 +1235,8 @@ class Facture
$sql .= ' WHERE rowid = '.$facid; $sql .= ' WHERE rowid = '.$facid;
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
// \TODO Supprimer l'utilisation de facture_tva_sum non utilisable
// dans un context compta propre.
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture='.$this->id; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture='.$this->id;
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
@ -1351,6 +1353,8 @@ class Facture
*/ */
function getSumTva() function getSumTva()
{ {
$tvs=array();
$sql = 'SELECT amount, tva_tx FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$this->id; $sql = 'SELECT amount, tva_tx FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -1366,6 +1370,7 @@ class Facture
} }
else else
{ {
dolibarr_print_error($this->db);
return -1; return -1;
} }
} }
@ -2228,6 +2233,81 @@ class Facture
return $this->getIdContact('external','SHIPPING'); return $this->getIdContact('external','SHIPPING');
} }
/**
* \brief Initialise la facture avec valeurs fictives aléatoire
* Sert à générer une facture pour l'aperu des modèles ou demo
*/
function initAsSpecimen()
{
global $user,$langs;
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs)
{
$i++;
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
}
// Charge tableau des produits prodids
$prodids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
$resql = $this->db->query($sql);
if ($resql)
{
$num_prods = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_prods)
{
$i++;
$row = $this->db->fetch_row($resql);
$prodids[$i] = $row[0];
}
}
// Initialise paramètres
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$socid = rand(1, $num_socs);
$this->socidp = $socids[$socid];
$this->date = time();
$this->date_lim_reglement=$this->date+3600*24*30;
$this->cond_reglement_id = 3;
$this->mode_reglement_id = 3;
$this->note_public='SPECIMEN';
$nbp = rand(1, 9);
$xnbp = 0;
while ($xnbp < $nbp)
{
$ligne=new FactureLigne($this->db);
$ligne->desc=$langs->trans("Description")." ".$xnbp;
$ligne->qty=1;
$ligne->subprice=100;
$ligne->price=100;
$ligne->tva_taux=19.6;
$prodid = rand(1, $num_prods);
$ligne->produit_id=$prodids[$prodid];
$this->lignes[$xnbp]=$ligne;
$xnbp++;
}
$this->amount_ht = $xnbp*100;
$this->total_ht = $xnbp*100;
$this->total_tva = $xnbp*19.6;
$this->total_ttc = $xnbp*119.6;
}
} }

View File

@ -56,151 +56,170 @@ class pdf_bernique extends ModelePDFFactures {
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
} }
function write_pdf_file($facid) /**
{ * \brief Fonction générant la facture sur le disque
global $user,$langs,$conf; * \param fac Objet facture à générer (ou id si ancienne methode)
* \return int 1=ok, 0=ko
$fac = new Facture($this->db,"",$facid); */
$fac->fetch($facid); function write_pdf_file($fac,$outputlangs='')
if ($conf->facture->dir_output)
{ {
global $user,$langs,$conf,$mysoc;
$facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref . "/" ; if ($conf->facture->dir_output)
$file = $dir . $facref . ".pdf";
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
$this->_pagehead($pdf, $fac);
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
$tab_top = 100;
$tab_height = 110;
/*
*
*/
$pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9);
$pdf->SetXY (10, $tab_top + 10 );
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
for ($i = 0 ; $i < $nblignes ; $i++)
{ {
$curY = $nexY; // Définition de l'objet $fac (pour compatibilite ascendante)
if (! is_object($fac))
{
$fac = new Facture($this->db,"",$fac);
$ret=$fac->fetch($fac);
}
$pdf->SetXY (11, $curY ); // Définition de $dir et $file
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J'); if ($fac->specimen)
{
$dir = $conf->facture->dir_output;
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
}
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
$this->_pagehead($pdf, $fac);
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
$tab_top = 100;
$tab_height = 110;
/*
*
*/
$pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9);
$pdf->SetXY (10, $tab_top + 10 );
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
$pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J');
$nexY = $pdf->GetY();
$pdf->SetXY (133, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
$pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C');
$pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
$pdf->SetXY (174, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $fac);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$nexY = $pdf->GetY(); $this->_tableau_tot($pdf, $fac, $tab_top, $tab_height);
$pdf->SetXY (133, $curY); $this->_tableau_compl($pdf, $fac);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
/*
$pdf->SetXY (145, $curY); *
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C'); */
if (defined("FACTURE_RIB_NUMBER"))
$pdf->SetXY (156, $curY); {
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0); if (FACTURE_RIB_NUMBER > 0)
{
$pdf->SetXY (174, $curY); $account = new Account($this->db);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty); $account->fetch(FACTURE_RIB_NUMBER);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
$pdf->SetXY (10, 49);
if ($nexY > 200 && $i < $nblignes - 1) $pdf->SetFont('Arial','U',8);
{ $pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); $pdf->SetFont('Arial','',8);
$pdf->AddPage(); $pdf->MultiCell(40, 4, $langs->trans("BankCode").' : ' . $account->code_banque, 0, 'L', 0);
$nexY = $iniY; $pdf->MultiCell(40, 4, $langs->trans("DeskCode").' : ' . $account->code_guichet, 0, 'L', 0);
$this->_pagehead($pdf, $fac); $pdf->MultiCell(50, 4, $langs->trans("BankAccountNumber").' : ' . $account->number, 0, 'L', 0);
$pdf->SetTextColor(0,0,0); $pdf->MultiCell(40, 4, $langs->trans("BankAccountNumberKey").' : ' . $account->cle_rib, 0, 'L', 0);
$pdf->SetFont('Arial','', 10); $pdf->MultiCell(40, 4, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
} $pdf->MultiCell(40, 4, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
/*
*
*
*/
$pdf->SetFont('Arial','',9);
$pdf->SetXY(10, 260);
$pdf->MultiCell(190, 5, $langs->trans("IntracommunityVATNumber").' : '.MAIN_INFO_TVAINTRA, 0, 'J');
$pdf->MultiCell(190, 5, $langs->trans("PrettyLittleSentence"), 0, 'J');
$pdf->Close();
$pdf->Output($file);
return 1;
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
} }
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); else
$this->_tableau_tot($pdf, $fac, $tab_top, $tab_height);
$this->_tableau_compl($pdf, $fac);
/*
*
*/
if (defined("FACTURE_RIB_NUMBER"))
{ {
if (FACTURE_RIB_NUMBER > 0) $this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
{ return 0;
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
$pdf->SetXY (10, 49);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(40, 4, $langs->trans("BankCode").' : ' . $account->code_banque, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("DeskCode").' : ' . $account->code_guichet, 0, 'L', 0);
$pdf->MultiCell(50, 4, $langs->trans("BankAccountNumber").' : ' . $account->number, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BankAccountNumberKey").' : ' . $account->cle_rib, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
} }
/*
*
*
*/
$pdf->SetFont('Arial','',9);
$pdf->SetXY(10, 260);
$pdf->MultiCell(190, 5, $langs->trans("IntracommunityVATNumber").' : '.MAIN_INFO_TVAINTRA, 0, 'J');
$pdf->MultiCell(190, 5, $langs->trans("PrettyLittleSentence"), 0, 'J');
$pdf->Close();
$pdf->Output($file);
return 1;
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
} }
else
{
$this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
return 0;
}
}
/* /*
* *
* *
@ -252,6 +271,7 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
$tvas = $fac->getSumTva(); $tvas = $fac->getSumTva();
$i = 0; $i = 0;
$tab4_top = $tab2_top + 2 + ($tab2_hl * 2); $tab4_top = $tab2_top + 2 + ($tab2_hl * 2);

View File

@ -57,158 +57,175 @@ class pdf_bulot extends ModelePDFFactures {
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
} }
/**
function write_pdf_file($facid) * \brief Fonction générant la facture sur le disque
{ * \param fac Objet facture à générer (ou id si ancienne methode)
global $user,$langs,$conf; * \return int 1=ok, 0=ko
*/
if ($conf->facture->dir_output) function write_pdf_file($fac,$outputlangs='')
{ {
$fac = new Facture($this->db,"",$facid); global $user,$langs,$conf,$mysoc;
$fac->fetch($facid);
if ($conf->facture->dir_output)
$facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
$this->_pagehead($pdf, $fac);
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
$tab_top = 100;
$tab_height = 110;
/*
*
*/
$pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9);
$pdf->SetXY (10, $tab_top + 10 );
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
for ($i = 0 ; $i < $nblignes ; $i++)
{ {
$curY = $nexY; // Définition de l'objet $fac (pour compatibilite ascendante)
if (! is_object($fac))
{
$fac = new Facture($this->db,"",$fac);
$ret=$fac->fetch($fac);
}
$pdf->SetXY (11, $curY ); // Définition de $dir et $file
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J'); if ($fac->specimen)
{
$nexY = $pdf->GetY(); $dir = $conf->facture->dir_output;
$file = $dir . "/SPECIMEN.pdf";
$pdf->SetXY (133, $curY); }
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C'); else
{
$pdf->SetXY (145, $curY); $facref = sanitize_string($fac->ref);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C'); $dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
$pdf->SetXY (156, $curY); }
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
if (! file_exists($dir))
$pdf->SetXY (174, $curY); {
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty); if (create_exdir($dir) < 0)
$pdf->MultiCell(26, 5, $total, 0, 'R', 0); {
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
if ($nexY > 200 && $i < $nblignes - 1) return 0;
{ }
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); }
$pdf->AddPage();
$nexY = $iniY; if (file_exists($dir))
$this->_pagehead($pdf, $fac); {
$pdf->SetTextColor(0,0,0); // Initialisation facture vierge
$pdf->SetFont('Arial','', 10); $pdf=new FPDF('P','mm','A4');
} $pdf->Open();
$pdf->AddPage();
$this->_pagehead($pdf, $fac);
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
$tab_top = 100;
$tab_height = 110;
/*
*
*/
$pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9);
$pdf->SetXY (10, $tab_top + 10 );
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
$pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J');
$nexY = $pdf->GetY();
$pdf->SetXY (133, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
$pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C');
$pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
$pdf->SetXY (174, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $fac);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$this->_tableau_tot($pdf, $fac);
$this->_tableau_compl($pdf, $fac);
/*
*
*/
if (defined("FACTURE_RIB_NUMBER"))
{
if (FACTURE_RIB_NUMBER > 0)
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
$pdf->SetXY (10, 40);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(40, 4, $langs->trans("BankCode").' : '. $account->code_banque, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("DeskCode").' : ' . $account->code_guichet, 0, 'L', 0);
$pdf->MultiCell(50, 4, $langs->trans("BankAccountNumber").' : ' . $account->number, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BankAccountNumberKey").' : ' . $account->cle_rib, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
/*
*
*
*/
$pdf->SetFont('Arial','U',12);
$pdf->SetXY(10, 220);
$titre = $langs->trans("PaymentConditions").' : '.$fac->cond_reglement_facture;
$pdf->MultiCell(190, 5, $titre, 0, 'J');
$pdf->SetFont('Arial','',9);
$pdf->SetXY(10, 265);
$pdf->MultiCell(190, 5, $langs->trans("PrettyLittleSentence"), 0, 'J');
$pdf->Close();
$pdf->Output($file);
return 1;
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
} }
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); else
$this->_tableau_tot($pdf, $fac);
$this->_tableau_compl($pdf, $fac);
/*
*
*/
if (defined("FACTURE_RIB_NUMBER"))
{ {
if (FACTURE_RIB_NUMBER > 0) $this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
{ return 0;
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
$pdf->SetXY (10, 40);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(40, 4, $langs->trans("BankCode").' : '. $account->code_banque, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("DeskCode").' : ' . $account->code_guichet, 0, 'L', 0);
$pdf->MultiCell(50, 4, $langs->trans("BankAccountNumber").' : ' . $account->number, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BankAccountNumberKey").' : ' . $account->cle_rib, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
} }
$this->error=$langs->trans("ErrorUnknown");
/* return 0; // Erreur par defaut
*
*
*/
$pdf->SetFont('Arial','U',12);
$pdf->SetXY(10, 220);
$titre = $langs->trans("PaymentConditions").' : '.$fac->cond_reglement_facture;
$pdf->MultiCell(190, 5, $titre, 0, 'J');
$pdf->SetFont('Arial','',9);
$pdf->SetXY(10, 265);
$pdf->MultiCell(190, 5, $langs->trans("PrettyLittleSentence"), 0, 'J');
$pdf->Close();
$pdf->Output($file);
return 1;
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
} }
else
{
$this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
return 0;
}
$this->error=$langs->trans("ErrorUnknown");
return 0; // Erreur par defaut
}
/** /**
* \brief Affiche tableau des versement * \brief Affiche tableau des versement

View File

@ -48,7 +48,7 @@ class pdf_crabe extends ModelePDFFactures
{ {
global $conf,$langs; global $conf,$langs;
$langs->load("main"); $langs->load("main");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
@ -105,7 +105,7 @@ class pdf_crabe extends ModelePDFFactures
/** /**
* \brief Fonction générant la facture sur le disque * \brief Fonction générant la facture sur le disque
* \param id Id de la facture à générer * \param fac Objet facture à générer (ou id si ancienne methode)
* \return int 1=ok, 0=ko * \return int 1=ok, 0=ko
* \remarks Variables utilisées * \remarks Variables utilisées
* \remarks MAIN_INFO_SOCIETE_NOM * \remarks MAIN_INFO_SOCIETE_NOM
@ -124,19 +124,31 @@ class pdf_crabe extends ModelePDFFactures
* \remarks FACTURE_CHQ_NUMBER * \remarks FACTURE_CHQ_NUMBER
* \remarks FACTURE_RIB_NUMBER * \remarks FACTURE_RIB_NUMBER
*/ */
function write_pdf_file($id) function write_pdf_file($fac,$outputlangs='')
{ {
global $user,$langs,$conf,$mysoc; global $user,$langs,$conf,$mysoc;
if ($conf->facture->dir_output) if ($conf->facture->dir_output)
{ {
$fac = new Facture($this->db,"",$id); // Définition de l'objet $fac (pour compatibilite ascendante)
$ret=$fac->fetch($id); if (! is_object($fac))
$nblignes = sizeof($fac->lignes); {
$fac = new Facture($this->db,"",$fac);
$ret=$fac->fetch($fac);
}
$facref = sanitize_string($fac->ref); // Définition de $dir et $file
$dir = $conf->facture->dir_output . "/" . $facref; if ($fac->specimen)
$file = $dir . "/" . $facref . ".pdf"; {
$dir = $conf->facture->dir_output;
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
}
if (! file_exists($dir)) if (! file_exists($dir))
{ {
@ -149,6 +161,8 @@ class pdf_crabe extends ModelePDFFactures
if (file_exists($dir)) if (file_exists($dir))
{ {
$nblignes = sizeof($fac->lignes);
// Initialisation document vierge // Initialisation document vierge
$pdf=new FPDF('P','mm',$this->format); $pdf=new FPDF('P','mm',$this->format);
$pdf->Open(); $pdf->Open();
@ -574,7 +588,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($this->marge_gauche, $tab2_top + 0); $pdf->SetXY($this->marge_gauche, $tab2_top + 0);
if ($this->franchise==1) if ($this->franchise==1)
{ {
$pdf->MultiCell(100, $tab2_hl, $langs->trans("VATIsNotUsed"), 0, 'L', 0); $pdf->MultiCell(100, $tab2_hl, $langs->trans("VATIsNotUsedForInvoice"), 0, 'L', 0);
} }
// Tableau total // Tableau total

View File

@ -56,191 +56,212 @@ class pdf_huitre extends ModelePDFFactures {
$this->description = $langs->trans('PDFHuitreDescription'); $this->description = $langs->trans('PDFHuitreDescription');
// Dimension page pour format A4 // Dimension page pour format A4
$this->type = 'pdf'; $this->type = 'pdf';
$this->page_largeur = 210; $this->page_largeur = 210;
$this->page_hauteur = 297; $this->page_hauteur = 297;
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
} }
function write_pdf_file($facid)
{
global $user,$langs,$conf;
if ($conf->facture->dir_output)
{
$fac = new Facture($this->db,"",$facid);
$fac->fetch($facid);
$facref = sanitize_string($fac->ref); /**
$dir = $conf->facture->dir_output . "/" . $facref; * \brief Fonction générant la facture sur le disque
$file = $dir . "/" . $facref . ".pdf"; * \param fac Objet facture à générer (ou id si ancienne methode)
* \return int 1=ok, 0=ko
if (! file_exists($dir)) */
{ function write_pdf_file($fac,$outputlangs='')
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
$this->_pagehead($pdf, $fac);
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr (By ADYTEK)".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
$pdf->SetMargins(10, 10, 10);
$pdf->SetAutoPageBreak(1,0);
$tab_top = 100;
$tab_height = 110;
$pdf->SetFillColor(242,239,119);
$pdf->SetFont('Arial','', 9);
$pdf->SetXY (10, $tab_top + 10 );
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
// Boucle sur les lignes de factures
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
$pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J');
$nexY = $pdf->GetY();
$pdf->SetXY (133, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
$pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C');
$pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
$pdf->SetXY (174, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $fac);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$this->_tableau_tot($pdf, $fac);
$this->_tableau_compl($pdf, $fac);
/*
*
*/
if (defined("FACTURE_RIB_NUMBER"))
{
if (FACTURE_RIB_NUMBER > 0)
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
$pdf->SetXY (10, 40);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(40, 4, $langs->trans("BankCode").' : ' . $account->code_banque, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("DeskCode").' : ' . $account->code_guichet, 0, 'L', 0);
$pdf->MultiCell(50, 4, $langs->trans("BankAccountNumber").' : ' . $account->number, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BankAccountNumberKey").' : ' . $account->cle_rib, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
/*
*
*
*/
// if ( $fac->note >0 )
// {
$pdf->SetFont('Arial','',7);
$pdf->SetXY(10, 211);
$note = "Note : ".$fac->note;
$pdf->MultiCell(110, 3, $note, 0, 'J');
// }
$pdf->SetFont('Arial','U',11);
$pdf->SetXY(10, 225);
$titre = $langs->trans("PaymentConditions").' : '.$fac->cond_reglement_facture;
$pdf->MultiCell(190, 5, $titre, 0, 'J');
$pdf->SetFont('Arial','',6);
$pdf->SetXY(10, 265);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart1'), 0, 'J');
$pdf->SetXY(10, 267);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart2'), 0, 'J');
$pdf->SetXY(10, 269);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart3'), 0, 'J');
$pdf->SetXY(10, 271);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart4'), 0, 'J');
$pdf->SetFont('Arial','',7);
$pdf->SetXY(85, 271);
$pdf->MultiCell(90, 3, $langs->trans('VATDischarged'), 0, 'J');
$this->_pagefoot($pdf, $fac);
$pdf->AliasNbPages();
//----
$pdf->SetTextColor(0,0,0);
$pdf->SetFillColor(242,239,119);
$pdf->SetLineWidth(0.5);
$pdf->Close();
$pdf->Output($file);
return 1; // Pas d'erreur
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
else
{ {
$this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR"); global $user,$langs,$conf,$mysoc;
return 0;
if ($conf->facture->dir_output)
{
// Définition de l'objet $fac (pour compatibilite ascendante)
if (! is_object($fac))
{
$fac = new Facture($this->db,"",$fac);
$ret=$fac->fetch($fac);
}
// Définition de $dir et $file
if ($fac->specimen)
{
$dir = $conf->facture->dir_output;
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$facref = sanitize_string($fac->ref);
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
}
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
$this->_pagehead($pdf, $fac);
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr (By ADYTEK)".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
$pdf->SetMargins(10, 10, 10);
$pdf->SetAutoPageBreak(1,0);
$tab_top = 100;
$tab_height = 110;
$pdf->SetFillColor(242,239,119);
$pdf->SetFont('Arial','', 9);
$pdf->SetXY (10, $tab_top + 10 );
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
// Boucle sur les lignes de factures
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
$pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J');
$nexY = $pdf->GetY();
$pdf->SetXY (133, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
$pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C');
$pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
$pdf->SetXY (174, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $fac);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$this->_tableau_tot($pdf, $fac);
$this->_tableau_compl($pdf, $fac);
/*
*
*/
if (defined("FACTURE_RIB_NUMBER"))
{
if (FACTURE_RIB_NUMBER > 0)
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
$pdf->SetXY (10, 40);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(40, 4, $langs->trans("BankCode").' : ' . $account->code_banque, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("DeskCode").' : ' . $account->code_guichet, 0, 'L', 0);
$pdf->MultiCell(50, 4, $langs->trans("BankAccountNumber").' : ' . $account->number, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BankAccountNumberKey").' : ' . $account->cle_rib, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
/*
*
*
*/
if ( $fac->note_public)
{
$pdf->SetFont('Arial','',7);
$pdf->SetXY(10, 211);
$note = $langs->trans("Note").' : '.$fac->note_public;
$pdf->MultiCell(110, 3, $note, 0, 'J');
}
$pdf->SetFont('Arial','U',11);
$pdf->SetXY(10, 225);
$titre = $langs->trans("PaymentConditions").' : '.$fac->cond_reglement_facture;
$pdf->MultiCell(190, 5, $titre, 0, 'J');
$pdf->SetFont('Arial','',6);
$pdf->SetXY(10, 265);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart1'), 0, 'J');
$pdf->SetXY(10, 267);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart2'), 0, 'J');
$pdf->SetXY(10, 269);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart3'), 0, 'J');
$pdf->SetXY(10, 271);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart4'), 0, 'J');
$pdf->SetFont('Arial','',7);
$pdf->SetXY(85, 271);
$pdf->MultiCell(90, 3, $langs->trans('VATDischarged'), 0, 'J');
$this->_pagefoot($pdf, $fac);
$pdf->AliasNbPages();
//----
$pdf->SetTextColor(0,0,0);
$pdf->SetFillColor(242,239,119);
$pdf->SetLineWidth(0.5);
$pdf->Close();
$pdf->Output($file);
return 1; // Pas d'erreur
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
else
{
$this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
return 0;
}
$this->error=$langs->trans("ErrorUnknown");
return 0; // Erreur par defaut
} }
$this->error=$langs->trans("ErrorUnknown");
return 0; // Erreur par defaut
}
/* /*
* *
* *
@ -499,11 +520,12 @@ class pdf_huitre extends ModelePDFFactures {
/* /*
* Definition du document * Definition du document
*/ */
$pdf->SetXY(10,50); $pdf->SetXY(10,16);
$pdf->SetFont('Arial','B',16); $pdf->SetFont('Arial','B',16);
$pdf->SetTextColor(0,0,200); $pdf->SetTextColor(0,0,200);
$pdf->MultiCell(50, 8, "FACTURE", '' , 'C'); $pdf->MultiCell(50, 2, "FACTURE", '' , 'C');
/*
/*
* Adresse Client * Adresse Client
*/ */
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -528,15 +550,12 @@ class pdf_huitre extends ModelePDFFactures {
$pdf->Text(35, 88, ": " . strftime("%d %b %Y", $fac->date)); $pdf->Text(35, 88, ": " . strftime("%d %b %Y", $fac->date));
$pdf->Text(11, 94, $langs->trans('Invoice')); $pdf->Text(11, 94, $langs->trans('Invoice'));
$pdf->Text(35, 94, ": ".$fac->ref); $pdf->Text(35, 94, ": ".$fac->ref);
/*
*/ // Montants exprimes en euros
$pdf->line(200, 94, 205, 94 );
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10); $pdf->SetFont('Arial','',10);
$titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie)); $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie));
$pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre);
/*
*/
} }

View File

@ -108,254 +108,267 @@ class pdf_oursin extends ModelePDFFactures
* \remarks MAIN_INFO_CAPITAL * \remarks MAIN_INFO_CAPITAL
* \remarks MAIN_INFO_TVAINTRA * \remarks MAIN_INFO_TVAINTRA
*/ */
function write_pdf_file($facid) function write_pdf_file($fac,$outputlangs='')
{ {
global $user,$langs,$conf,$mysoc; global $user,$langs,$conf,$mysoc;
$langs->load("main");
$langs->load("bills");
$langs->load("products");
if ($conf->facture->dir_output)
{
// Définition de l'objet $fac (pour compatibilite ascendante)
if (! is_object($fac))
{
$fac = new Facture($this->db,"",$fac);
$ret=$fac->fetch($fac);
}
$langs->load("main"); // Définition de $dir et $file
$langs->load("bills"); if ($fac->specimen)
$langs->load("products"); {
$dir = $conf->facture->dir_output;
if ($conf->facture->dir_output) $file = $dir . "/SPECIMEN.pdf";
{ }
$fac = new Facture($this->db,"",$facid); else
$fac->fetch($facid); {
$facref = sanitize_string($fac->ref);
$facref = sanitize_string($fac->ref); $dir = $conf->facture->dir_output . "/" . $facref;
$dir = $conf->facture->dir_output . "/" . $facref; $file = $dir . "/" . $facref . ".pdf";
$file = $dir . "/" . $facref . ".pdf"; }
if (! file_exists($dir)) if (! file_exists($dir))
{ {
if (create_exdir($dir) < 0) if (create_exdir($dir) < 0)
{ {
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir); $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0; return 0;
} }
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
// Initialisation facture vierge // Initialisation facture vierge
$pdf=new FPDF('P','mm',$this->format); $pdf=new FPDF('P','mm',$this->format);
$pdf->Open(); $pdf->Open();
$pdf->AddPage(); $pdf->AddPage();
$this->_pagehead($pdf, $fac); $this->_pagehead($pdf, $fac);
$pdf->SetTitle($fac->ref); $pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill")); $pdf->SetSubject($langs->trans("Invoice"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname); $pdf->SetAuthor($user->fullname);
$pdf->SetMargins(10, 10, 10); $pdf->SetMargins(10, 10, 10);
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
$tab_top = $this->marges['h']+90; $tab_top = $this->marges['h']+90;
$tab_height = 110; $tab_height = 110;
$pdf->SetFillColor(220,220,220); $pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
$pdf->SetXY ($this->marges['g'], $tab_top + $this->marges['g'] ); $pdf->SetXY ($this->marges['g'], $tab_top + $this->marges['g'] );
$iniY = $pdf->GetY(); $iniY = $pdf->GetY();
$curY = $pdf->GetY(); $curY = $pdf->GetY();
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes); $nblignes = sizeof($fac->lignes);
// Boucle sur les lignes de factures // Boucle sur les lignes de factures
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
{ {
$curY = $nexY; $curY = $nexY;
// Description produit // Description produit
$codeproduitservice=""; $codeproduitservice="";
$pdf->SetXY ($this->marges['g']+ 1, $curY ); $pdf->SetXY ($this->marges['g']+ 1, $curY );
if (defined("FACTURE_CODEPRODUITSERVICE") && FACTURE_CODEPRODUITSERVICE) { if (defined("FACTURE_CODEPRODUITSERVICE") && FACTURE_CODEPRODUITSERVICE) {
// Affiche code produit si ligne associée à un code produit // Affiche code produit si ligne associée à un code produit
$prodser = new Product($this->db); $prodser = new Product($this->db);
$prodser->fetch($fac->lignes[$i]->produit_id); $prodser->fetch($fac->lignes[$i]->produit_id);
if ($prodser->ref) { if ($prodser->ref) {
$codeproduitservice=" - ".$langs->trans("ProductCode")." ".$prodser->ref; $codeproduitservice=" - ".$langs->trans("ProductCode")." ".$prodser->ref;
} }
}
if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) {
// Affichage durée si il y en a une
$codeproduitservice.=" (".$langs->trans("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")";
}
$pdf->MultiCell(108, 5, $fac->lignes[$i]->desc."$codeproduitservice", 0, 'J');
$nexY = $pdf->GetY();
// TVA
if ($this->franchise!=1)
{
$pdf->SetXY ($this->marges['g']+119, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
}
// Prix unitaire HT avant remise
$pdf->SetXY ($this->marges['g']+132, $curY);
$pdf->MultiCell(16, 5, price($fac->lignes[$i]->subprice), 0, 'R', 0);
// Quantit
$pdf->SetXY ($this->marges['g']+150, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'R');
// Remise sur ligne
$pdf->SetXY ($this->marges['g']+160, $curY);
if ($fac->lignes[$i]->remise_percent) {
$pdf->MultiCell(14, 5, $fac->lignes[$i]->remise_percent."%", 0, 'R');
}
// Total HT
$pdf->SetXY ($this->marges['g']+168, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(21, 5, $total, 0, 'R', 0);
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac);
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $fac);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac);
$deja_regle = $fac->getSommePaiement();
$this->_tableau_tot($pdf, $fac, $deja_regle);
if ($deja_regle) {
$this->_tableau_versements($pdf, $fac);
}
/*
* Mode de règlement
*/
if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) {
$pdf->SetXY ($this->marges['g'], 228);
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans("ErrorNoPaiementModeConfigured"),0,'L',0);
$pdf->MultiCell(90, 3, $langs->trans("ErrorCreateBankAccount"),0,'L',0);
$pdf->SetTextColor(0,0,0);
}
/*
* Propose mode règlement par CHQ
*/
if (defined("FACTURE_CHQ_NUMBER"))
{
if (FACTURE_CHQ_NUMBER > 0)
{
$account = new Account($this->db);
$account->fetch(FACTURE_CHQ_NUMBER);
$pdf->SetXY ($this->marges['g'], 225);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans('PaymentByChequeOrderedTo').' '.$account->proprio.' '.$langs->trans('SendTo').':',0,'L',0);
$pdf->SetXY ($this->marges['g'], 230);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0);
}
}
/*
* Propose mode règlement par RIB
*/
if (defined("FACTURE_RIB_NUMBER"))
{
if (FACTURE_RIB_NUMBER > 0)
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
$cury=240;
$pdf->SetXY ($this->marges['g'], $cury);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
$cury=245;
$pdf->SetFont('Arial','B',6);
$pdf->line($this->marges['g'], $cury, $this->marges['g'], $cury+10 );
$pdf->SetXY ($this->marges['g'], $cury);
$pdf->MultiCell(18, 3, $langs->trans("BankCode"), 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, $langs->trans("DeskCode"), 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, $langs->trans("BankAccountNumber"), 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, $langs->trans("BankAccountNumberKey"), 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+15);
$pdf->MultiCell(90, 3, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+25);
$pdf->MultiCell(90, 3, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+30);
$pdf->MultiCell(90, 3, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
/*
* Conditions de règlements
*/
if ($fac->cond_reglement_code)
{
$pdf->SetFont('Arial','B',10);
$pdf->SetXY($this->marges['g'], 217);
$titre = $langs->trans("PaymentConditions").':';
$pdf->MultiCell(80, 5, $titre, 0, 'L');
$pdf->SetFont('Arial','',10);
$pdf->SetXY($this->marges['g']+44, 217);
$pdf->MultiCell(80, 5, $fac->cond_reglement_facture,0,'L');
}
/*
* Pied de page
*/
$this->_pagefoot($pdf, $fac);
$pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file);
return 1; // Pas d'erreur
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
} }
if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) { else
// Affichage durée si il y en a une {
$codeproduitservice.=" (".$langs->trans("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")"; $this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
return 0;
} }
$pdf->MultiCell(108, 5, $fac->lignes[$i]->desc."$codeproduitservice", 0, 'J'); $this->error=$langs->trans("ErrorUnknown");
return 0; // Erreur par defaut
$nexY = $pdf->GetY(); }
// TVA
if ($this->franchise!=1)
{
$pdf->SetXY ($this->marges['g']+119, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
}
// Prix unitaire HT avant remise
$pdf->SetXY ($this->marges['g']+132, $curY);
$pdf->MultiCell(16, 5, price($fac->lignes[$i]->subprice), 0, 'R', 0);
// Quantité
$pdf->SetXY ($this->marges['g']+150, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'R');
// Remise sur ligne
$pdf->SetXY ($this->marges['g']+160, $curY);
if ($fac->lignes[$i]->remise_percent) {
$pdf->MultiCell(14, 5, $fac->lignes[$i]->remise_percent."%", 0, 'R');
}
// Total HT
$pdf->SetXY ($this->marges['g']+168, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(21, 5, $total, 0, 'R', 0);
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac);
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $fac);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac);
$deja_regle = $fac->getSommePaiement();
$this->_tableau_tot($pdf, $fac, $deja_regle);
if ($deja_regle) {
$this->_tableau_versements($pdf, $fac);
}
/*
* Mode de règlement
*/
if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) {
$pdf->SetXY ($this->marges['g'], 228);
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans("ErrorNoPaiementModeConfigured"),0,'L',0);
$pdf->MultiCell(90, 3, $langs->trans("ErrorCreateBankAccount"),0,'L',0);
$pdf->SetTextColor(0,0,0);
}
/*
* Propose mode règlement par CHQ
*/
if (defined("FACTURE_CHQ_NUMBER"))
{
if (FACTURE_CHQ_NUMBER > 0)
{
$account = new Account($this->db);
$account->fetch(FACTURE_CHQ_NUMBER);
$pdf->SetXY ($this->marges['g'], 225);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans('PaymentByChequeOrderedTo').' '.$account->proprio.' '.$langs->trans('SendTo').':',0,'L',0);
$pdf->SetXY ($this->marges['g'], 230);
$pdf->SetFont('Arial','',8);
$pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0);
}
}
/*
* Propose mode règlement par RIB
*/
if (defined("FACTURE_RIB_NUMBER"))
{
if (FACTURE_RIB_NUMBER > 0)
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
$cury=240;
$pdf->SetXY ($this->marges['g'], $cury);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0);
$cury=245;
$pdf->SetFont('Arial','B',6);
$pdf->line($this->marges['g'], $cury, $this->marges['g'], $cury+10 );
$pdf->SetXY ($this->marges['g'], $cury);
$pdf->MultiCell(18, 3, $langs->trans("BankCode"), 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, $langs->trans("DeskCode"), 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, $langs->trans("BankAccountNumber"), 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, $langs->trans("BankAccountNumberKey"), 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+15);
$pdf->MultiCell(90, 3, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+25);
$pdf->MultiCell(90, 3, $langs->trans("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+30);
$pdf->MultiCell(90, 3, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
/*
* Conditions de règlements
*/
if ($fac->cond_reglement_code)
{
$pdf->SetFont('Arial','B',10);
$pdf->SetXY($this->marges['g'], 217);
$titre = $langs->trans("PaymentConditions").':';
$pdf->MultiCell(80, 5, $titre, 0, 'L');
$pdf->SetFont('Arial','',10);
$pdf->SetXY($this->marges['g']+44, 217);
$pdf->MultiCell(80, 5, $fac->cond_reglement_facture,0,'L');
}
/*
* Pied de page
*/
$this->_pagefoot($pdf, $fac);
$pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file);
return 1; // Pas d'erreur
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
else
{
$this->error=$langs->trans("ErrorConstantNotDefined","FAC_OUTPUTDIR");
return 0;
}
$this->error=$langs->trans("ErrorUnknown");
return 0; // Erreur par defaut
}
/* /*
@ -469,7 +482,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY ($this->marges['g'], $tab2_top + 0); $pdf->SetXY ($this->marges['g'], $tab2_top + 0);
if ($this->franchise==1) if ($this->franchise==1)
{ {
$pdf->MultiCell(100, $tab2_hl, $langs->trans("VATIsNotUsed"), 0, 'L', 0); $pdf->MultiCell(100, $tab2_hl, $langs->trans("VATIsNotUsedForInvoice"), 0, 'L', 0);
} }
// Tableau total // Tableau total

View File

@ -175,7 +175,7 @@ IntracommunityVATNumber=Intracommunity number of VAT
PaymentByChequeOrderedTo=Règlement par chèque à l'ordre de PaymentByChequeOrderedTo=Règlement par chèque à l'ordre de
SendTo=envoyé à SendTo=envoyé à
PaymentByTransferOnThisBankAccount=Payment by transfer on the following bank account PaymentByTransferOnThisBankAccount=Payment by transfer on the following bank account
VATIsNotUsed=* TVA non applicable art-293B du CGI VATIsNotUsedForInvoice=* TVA non applicable art-293B du CGI
LawApplicationPart1=Par application de la loi 80.335 du 12/05/80 LawApplicationPart1=Par application de la loi 80.335 du 12/05/80
LawApplicationPart2=les marchandises demeurent la propriété du LawApplicationPart2=les marchandises demeurent la propriété du
LawApplicationPart3=vendeur jusqu'à complet encaissement de LawApplicationPart3=vendeur jusqu'à complet encaissement de

View File

@ -175,7 +175,7 @@ IntracommunityVATNumber=Num
PaymentByChequeOrderedTo=Règlement par chèque à l'ordre de PaymentByChequeOrderedTo=Règlement par chèque à l'ordre de
SendTo=envoyé à SendTo=envoyé à
PaymentByTransferOnThisBankAccount=Règlement par virement sur le compte bancaire suivant PaymentByTransferOnThisBankAccount=Règlement par virement sur le compte bancaire suivant
VATIsNotUsed=* TVA non applicable art-293B du CGI VATIsNotUsedForInvoice=* TVA non applicable art-293B du CGI
LawApplicationPart1=Par application de la loi 80.335 du 12/05/80 LawApplicationPart1=Par application de la loi 80.335 du 12/05/80
LawApplicationPart2=les marchandises demeurent la propriété du LawApplicationPart2=les marchandises demeurent la propriété du
LawApplicationPart3=vendeur jusqu'à complet encaissement de LawApplicationPart3=vendeur jusqu'à complet encaissement de

View File

@ -731,10 +731,15 @@ function img_disable($alt = "default")
\brief Affiche logo help avec curseur "?" \brief Affiche logo help avec curseur "?"
\return string Retourne tag img \return string Retourne tag img
*/ */
function img_help($usehelpcursor=1) function img_help($usehelpcursor=1,$usealttitle=1)
{ {
global $conf,$langs; global $conf,$langs;
return '<img '.($usehelpcursor?'style="cursor: help;" ':'').'src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/help.png" border="0" alt="'.$langs->trans("Info").'" title="'.$langs->trans("Info").'">'; $s ='<img ';
if ($usehelpcursor) $s.='style="cursor: help;" ';
$s.='src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/help.png" border="0"';
if ($usealttitle) $s.=' alt="'.$langs->trans("Info").'" title="'.$langs->trans("Info");
$s.='">';
return $s;
} }
/** /**