Qual: Removed duplicate code

This commit is contained in:
Laurent Destailleur 2008-07-29 19:20:33 +00:00
parent a37896ae65
commit 897152a924
11 changed files with 3619 additions and 3951 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,82 +20,93 @@
*/ */
/** /**
\file htdocs/includes/modules/commande/pdf_edison.modules.php \file htdocs/includes/modules/commande/pdf_edison.modules.php
\ingroup commande \ingroup commande
\brief Fichier de la classe permettant de g<EFBFBD>n<EFBFBD>rer les commandes au mod<EFBFBD>le Edison \brief Fichier de la classe permettant de generer les commandes au modele Edison
\version $Id$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
/** /**
\class pdf_edison \class pdf_edison
\brief Classe permettant de g<EFBFBD>n<EFBFBD>rer les commandes au mod<EFBFBD>le Edison \brief Classe permettant de g<EFBFBD>n<EFBFBD>rer les commandes au mod<EFBFBD>le Edison
*/ */
class pdf_edison extends ModelePDFCommandes class pdf_edison extends ModelePDFCommandes
{ {
var $emetteur; // Objet societe qui emet
/**
* \brief Constructeur
* \param db handler acc<EFBFBD>s base de donn<EFBFBD>e
*/
function pdf_edison($db=0)
{
global $conf,$langs,$mysoc;
$langs->load("main");
$langs->load("bills");
/** \brief Constructeur
\param db handler acc<EFBFBD>s base de donn<EFBFBD>e
*/
function pdf_edison($db=0)
{
$this->db = $db; $this->db = $db;
$this->name = "edison"; $this->name = "edison";
$this->description = "Modele de commande simple"; $this->description = "Modele de commande simple";
// 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);
$this->marge_gauche=10;
$this->marge_droite=10;
$this->marge_haute=10;
$this->marge_basse=10;
$this->option_multilang = 0; // Dispo en plusieurs langues $this->option_multilang = 0; // Dispo en plusieurs langues
$this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->option_draft_watermark = 1; //Support add of a watermark on drafts
$this->error = ""; $this->error = "";
} }
/** \brief Renvoi derni<EFBFBD>re erreur /** \brief Renvoi derni<EFBFBD>re erreur
\return string Derni<EFBFBD>re erreur \return string Derni<EFBFBD>re erreur
*/ */
function pdferror() function pdferror()
{ {
return $this->error; return $this->error;
} }
/** /**
\brief Fonction g<EFBFBD>n<EFBFBD>rant la commande sur le disque \brief Fonction generant la commande sur le disque
\param id id de la propale <EFBFBD> g<EFBFBD>n<EFBFBD>rer \param com id de la propale a generer
\return int 1=ok, 0=ko \return int 1=ok, 0=ko
*/ */
function write_file($com,$outputlangs='') function write_file($com,$outputlangs='')
{ {
global $user,$conf,$langs,$mysco; global $user,$conf,$langs,$mysco;
if (! is_object($outputlangs)) $outputlangs=$langs; if (! is_object($outputlangs)) $outputlangs=$langs;
$outputlangs->load("main"); $outputlangs->load("main");
$outputlangs->load("companies"); $outputlangs->load("companies");
$outputlangs->load("bills"); $outputlangs->load("bills");
$outputlangs->load("products"); $outputlangs->load("products");
$outputlangs->setPhpLang(); $outputlangs->setPhpLang();
// D<EFBFBD>finition de l'objet $com (pour compatibilite ascendante) // Definition de l'objet $com (pour compatibilite ascendante)
if (! is_object($com)) if (! is_object($com))
{ {
$id = $com; $id = $com;
$com = new Commande($this->db,"",$id); $com = new Commande($this->db,"",$id);
$ret=$com->fetch($id); $ret=$com->fetch($id);
} }
if ($conf->commande->dir_output) if ($conf->commande->dir_output)
{ {
// D<EFBFBD>finition de $dir et $file // Definition of $dir and $file
if ($com->specimen) if ($com->specimen)
{ {
$dir = $conf->commande->dir_output; $dir = $conf->commande->dir_output;
@ -118,37 +129,37 @@ class pdf_edison extends ModelePDFCommandes
} }
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
// Protection et encryption du pdf // Protection et encryption du pdf
if ($conf->global->PDF_SECURITY_ENCRYPTION) if ($conf->global->PDF_SECURITY_ENCRYPTION)
{ {
$pdf=new FPDI_Protection('P','mm',$this->format); $pdf=new FPDI_Protection('P','mm',$this->format);
$pdfrights = array('print'); // Ne permet que l'impression du document $pdfrights = array('print'); // Ne permet que l'impression du document
$pdfuserpass = ''; // Mot de passe pour l'utilisateur final $pdfuserpass = ''; // Mot de passe pour l'utilisateur final
$pdfownerpass = NULL; // Mot de passe du propri<72>taire, cr<63><72> al<61>atoirement si pas d<>fini $pdfownerpass = NULL; // Mot de passe du propri<72>taire, cr<63><72> al<61>atoirement si pas d<>fini
$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
} }
else else
{ {
$pdf=new FPDI('P','mm',$this->format); $pdf=new FPDI('P','mm',$this->format);
} }
$pdf->Open(); $pdf->Open();
$pdf->AddPage(); $pdf->AddPage();
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
$pdf->SetTitle($com->ref); $pdf->SetTitle($com->ref);
$pdf->SetSubject($langs->transnoentities("Order")); $pdf->SetSubject($langs->transnoentities("Order"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname); $pdf->SetAuthor($user->fullname);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
$this->_pagehead($pdf, $com, 1, $outputlangs); $this->_pagehead($pdf, $com, 1, $outputlangs);
$tab_top = 100; $tab_top = 100;
@ -209,8 +220,8 @@ class pdf_edison extends ModelePDFCommandes
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
/* /*
* *
*/ */
$tab2_top = 241; $tab2_top = 241;
$tab2_lh = 7; $tab2_lh = 7;
$tab2_height = $tab2_lh * 4; $tab2_height = $tab2_lh * 4;
@ -229,15 +240,9 @@ class pdf_edison extends ModelePDFCommandes
$pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalHT"), 0, 'R', 0); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalHT"), 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + $tab2_lh); $pdf->SetXY (132, $tab2_top + $tab2_lh);
$pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("Reduction"), 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + $tab2_lh*2);
$pdf->MultiCell(42, $tab2_lh, "Total HT apr<70>s remise", 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + $tab2_lh*3);
$pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalVAT"), 0, 'R', 0); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalVAT"), 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + ($tab2_lh*4)); $pdf->SetXY (132, $tab2_top + ($tab2_lh*2));
$pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalTTC"), 1, 'R', 1); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalTTC"), 1, 'R', 1);
$pdf->SetXY (174, $tab2_top + 0); $pdf->SetXY (174, $tab2_top + 0);
@ -255,80 +260,85 @@ class pdf_edison extends ModelePDFCommandes
$pdf->SetXY (174, $tab2_top + ($tab2_lh*4)); $pdf->SetXY (174, $tab2_top + ($tab2_lh*4));
$pdf->MultiCell(26, $tab2_lh, price($com->total_ttc), 1, 'R', 1); $pdf->MultiCell(26, $tab2_lh, price($com->total_ttc), 1, 'R', 1);
// Pied de page
$this->_pagefoot($pdf,$com,$outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file); $pdf->Output($file);
$langs->setPhpLang(); // On restaure langue session $langs->setPhpLang(); // On restaure langue session
return 1; return 1;
} }
} }
else else
{ {
$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
$langs->setPhpLang(); // On restaure langue session $langs->setPhpLang(); // On restaure langue session
return 0; return 0;
} }
$this->error=$outputlangs->transnoentities("ErrorUnknown"); $this->error=$outputlangs->transnoentities("ErrorUnknown");
$langs->setPhpLang(); // On restaure langue session $langs->setPhpLang(); // On restaure langue session
return 0; // Erreur par defaut return 0; // Erreur par defaut
} }
function _tableau(&$pdf, $tab_top, $tab_height, $nexY) function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
{ {
global $langs,$conf; global $langs,$conf;
$langs->load("main"); $langs->load("main");
$langs->load("bills"); $langs->load("bills");
$pdf->SetFont('Arial','',11); $pdf->SetFont('Arial','',11);
$pdf->Text(30,$tab_top + 5,$langs->transnoentities("Designation")); $pdf->Text(30,$tab_top + 5,$langs->transnoentities("Designation"));
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height); $pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->Text(134,$tab_top + 5,$langs->transnoentities("VAT")); $pdf->Text(134,$tab_top + 5,$langs->transnoentities("VAT"));
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height); $pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->Text(147,$tab_top + 5,$langs->transnoentities("Qty")); $pdf->Text(147,$tab_top + 5,$langs->transnoentities("Qty"));
$pdf->line(156, $tab_top, 156, $tab_top + $tab_height); $pdf->line(156, $tab_top, 156, $tab_top + $tab_height);
$pdf->Text(160,$tab_top + 5,$langs->transnoentities("PriceU")); $pdf->Text(160,$tab_top + 5,$langs->transnoentities("PriceU"));
$pdf->line(174, $tab_top, 174, $tab_top + $tab_height); $pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
$pdf->Text(187,$tab_top + 5,$langs->transnoentities("Total")); $pdf->Text(187,$tab_top + 5,$langs->transnoentities("Total"));
// $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top); // $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top);
$pdf->Rect(10, $tab_top, 190, $tab_height); $pdf->Rect(10, $tab_top, 190, $tab_height);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10); $pdf->SetFont('Arial','',10);
$titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie));
$pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre);
} }
function _pagehead(&$pdf, $com) function _pagehead(&$pdf, $com)
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
$langs->load("orders"); $langs->load("orders");
//Affiche le filigrane brouillon - Print Draft Watermark //Affiche le filigrane brouillon - Print Draft Watermark
if($com->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) if($com->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
{ {
$watermark_angle=atan($this->page_hauteur/$this->page_largeur); $watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$watermark_x=5; $watermark_x=5;
$watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems $watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems
$watermark_width=$this->page_hauteur; $watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50); $pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203); $pdf->SetTextColor(255,192,203);
//rotate //rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark //print watermark
$pdf->SetXY($watermark_x,$watermark_y); $pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,clean_html($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0); $pdf->Cell($watermark_width,25,clean_html($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate //antirotate
$pdf->_out('Q'); $pdf->_out('Q');
} }
//Print content //Print content
$pdf->SetXY(10,8); $pdf->SetXY(10,8);
if (defined("MAIN_INFO_SOCIETE_NOM")) if (defined("MAIN_INFO_SOCIETE_NOM"))
@ -338,7 +348,7 @@ class pdf_edison extends ModelePDFCommandes
$pdf->MultiCell(76, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L'); $pdf->MultiCell(76, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L');
} }
$pdf->SetX(10); $pdf->SetX(10);
$pdf->SetTextColor(70,70,170); $pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE")) if (defined("FAC_PDF_ADRESSE"))
{ {
@ -364,8 +374,8 @@ class pdf_edison extends ModelePDFCommandes
$pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R'); $pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R');
} }
/* /*
* Adresse Client * Adresse Client
*/ */
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$client = new Societe($this->db); $client = new Societe($this->db);
@ -383,10 +393,16 @@ class pdf_edison extends ModelePDFCommandes
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$pdf->Text(11, 88, "Date : " . dolibarr_print_date($com->date,'day')); $pdf->Text(11, 88, "Date : " . dolibarr_print_date($com->date,'day'));
$pdf->Text(11, 94, $langs->transnoentities("Order")." ".$com->ref); $pdf->Text(11, 94, $langs->transnoentities("Order")." ".$com->ref);
} }
/*
* \brief Affiche le pied de page
* \param pdf objet PDF
*/
function _pagefoot(&$pdf,$object,$outputlangs)
{
return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur);
}
} }
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@
/** /**
\file htdocs/includes/modules/facture/pdf_crabe.modules.php \file htdocs/includes/modules/facture/pdf_crabe.modules.php
\ingroup facture \ingroup facture
\brief Fichier de la classe permettant de g�n�rer les factures au mod�le Crabe \brief File of class to generate invoices from crab model
\author Laurent Destailleur \author Laurent Destailleur
\version $Id$ \version $Id$
*/ */
@ -43,9 +43,9 @@ class pdf_crabe extends ModelePDFFactures
/** /**
\brief Constructeur * \brief Constructor
\param db Handler accès base de donn�e * \param db Database handler
*/ */
function pdf_crabe($db) function pdf_crabe($db)
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
@ -384,7 +384,7 @@ class pdf_crabe extends ModelePDFFactures
} }
// Pied de page // Pied de page
$this->_pagefoot($pdf,$outputlangs); $this->_pagefoot($pdf,$fac,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -1174,82 +1174,13 @@ class pdf_crabe extends ModelePDFFactures
/** /**
* \brief Show footer of page * \brief Show footer of page
* \param pdf Object PDF * \param pdf Object PDF
* \param object Object invoice
* \param outputlang Object lang for output * \param outputlang Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
global $conf; return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur);
// Line of free text
$ligne=(! empty($conf->global->FACTURE_FREE_TEXT))?$conf->global->FACTURE_FREE_TEXT:"";
// Premiere ligne d'info réglementaires
$ligne1="";
if ($this->emetteur->forme_juridique_code)
{
$ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($this->emetteur->forme_juridique_code);
}
if ($this->emetteur->capital)
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$this->emetteur->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie);
}
// Prof Id
if ($this->emetteur->profid2)
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2;
}
if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR'))
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1;
}
// Deuxieme ligne d'info réglementaires
$ligne2="";
if ($this->emetteur->profid3)
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3;
}
if ($this->emetteur->profid4)
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4;
}
if ($this->emetteur->tva_intra != '')
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$this->emetteur->tva_intra;
}
$pdf->SetFont('Arial','',7);
$pdf->SetDrawColor(224,224,224);
// On positionne le debut du bas de page selon nbre de lignes de ce bas de page
$posy=$this->marge_basse + 1 + ($ligne?6:0) + ($ligne1?3:0) + ($ligne2?3:0);
if ($ligne)
{
$pdf->SetXY($this->marge_gauche,-$posy);
$pdf->MultiCell(190, 3, $ligne, 0, 'L', 0);
$posy-=9; // 6 of ligne + 3 of MultiCell
}
$pdf->SetY(-$posy);
$pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy);
$posy--;
if ($ligne1)
{
$pdf->SetXY($this->marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0);
}
if ($ligne2)
{
$posy-=3;
$pdf->SetXY($this->marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0);
}
$pdf->SetXY(-20,-$posy);
$pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -18,78 +18,81 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/ * or see http://www.gnu.org/
*
* $Id$
*/ */
/** /**
\file htdocs/includes/modules/facture/pdf_oursin.modules.php \file htdocs/includes/modules/facture/pdf_oursin.modules.php
\ingroup facture \ingroup facture
\brief Fichier de la classe permettant de générer les factures au modèle oursin \brief Fichier de la classe permettant de générer les factures au modèle oursin
\author Sylvain SCATTOLINI basé sur un modèle de Laurent Destailleur \author Sylvain SCATTOLINI basé sur un modèle de Laurent Destailleur
\version $Revision$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
/** /**
\class pdf_oursin \class pdf_oursin
\brief Classe permettant de générer les factures au modèle oursin \brief Classe permettant de générer les factures au modèle oursin
*/ */
class pdf_oursin extends ModelePDFFactures class pdf_oursin extends ModelePDFFactures
{ {
var $emetteur; // Objet societe qui emet var $emetteur; // Objet societe qui emet
var $marges=array("g"=>10,"h"=>5,"d"=>10,"b"=>15); var $marges=array("g"=>10,"h"=>5,"d"=>10,"b"=>15);
/** /**
\brief Constructeur \brief Constructeur
\param db handler accès base de donnée \param db handler accès base de donnée
*/ */
function pdf_oursin($db) function pdf_oursin($db)
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
$langs->load("main"); $langs->load("main");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
$this->db = $db; $this->db = $db;
$this->name = "oursin"; $this->name = "oursin";
$this->description = $langs->transnoentities('PDFOursinDescription'); $this->description = $langs->transnoentities('PDFOursinDescription');
// 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);
$this->marge_gauche=10;
$this->marge_droite=10;
$this->marge_haute=10;
$this->marge_basse=10;
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Gere choix mode règlement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER $this->option_modereg = 1; // Gere choix mode règlement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER
$this->option_condreg = 1; // Affiche conditions règlement $this->option_condreg = 1; // Affiche conditions règlement
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte $this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 1; // Gère les avoirs $this->option_credit_note = 1; // Gère les avoirs
$this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->option_draft_watermark = 1; //Support add of a watermark on drafts
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
$this->franchise=1; $this->franchise=1;
// Recupere emmetteur // Recupere emmetteur
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini
} }
/** /**
* \brief Fonction générant la facture sur le disque * \brief Fonction générant la facture sur le disque
* \param fac Objet facture à générer (ou id si ancienne methode) * \param fac Objet facture à générer (ou id si ancienne methode)
* \param outputlangs Lang object for output language * \param outputlangs Lang object for output language
* \return int 1=ok, 0=ko * \return int 1=ok, 0=ko
*/ */
function write_file($fac,$outputlangs='') function write_file($fac,$outputlangs='')
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
@ -342,7 +345,7 @@ class pdf_oursin extends ModelePDFFactures
} }
// Pied de page // Pied de page
$this->_pagefoot($pdf, $fac); $this->_pagefoot($pdf, $fac, $outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -372,9 +375,9 @@ class pdf_oursin extends ModelePDFFactures
/** /**
* \brief Affiche tableau des versement * \brief Affiche tableau des versement
* \param pdf Objet PDF * \param pdf Objet PDF
* \param fac Objet facture * \param fac Objet facture
* \param posy Position y in PDF * \param posy Position y in PDF
* \param outputlangs Object langs for output * \param outputlangs Object langs for output
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK
@ -412,7 +415,7 @@ class pdf_oursin extends ModelePDFFactures
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i=0; $i=0;
$invoice=new Facture($this->db); $invoice=new Facture($this->db);
while ($i < $num) while ($i < $num)
{ {
@ -421,25 +424,25 @@ class pdf_oursin extends ModelePDFFactures
$invoice->fetch($obj->fk_facture_source); $invoice->fetch($obj->fk_facture_source);
$pdf->SetXY ($tab3_posx, $tab3_top+$y ); $pdf->SetXY ($tab3_posx, $tab3_top+$y );
$pdf->MultiCell(20, 4,'', 0, 'L', 0); $pdf->MultiCell(20, 4,'', 0, 'L', 0);
$pdf->SetXY ($tab3_posx+21, $tab3_top+$y); $pdf->SetXY ($tab3_posx+21, $tab3_top+$y);
$pdf->MultiCell(20, 4, price($obj->amount_ttc), 0, 'L', 0); $pdf->MultiCell(20, 4, price($obj->amount_ttc), 0, 'L', 0);
$pdf->SetXY ($tab3_posx+41, $tab3_top+$y); $pdf->SetXY ($tab3_posx+41, $tab3_top+$y);
$pdf->MultiCell(20, 4, $outputlangs->trans("CreditNote"), 0, 'L', 0); $pdf->MultiCell(20, 4, $outputlangs->trans("CreditNote"), 0, 'L', 0);
$pdf->SetXY ($tab3_posx+60, $tab3_top+$y); $pdf->SetXY ($tab3_posx+60, $tab3_top+$y);
$pdf->MultiCell(20, 4, $invoice->ref, 0, 'L', 0); $pdf->MultiCell(20, 4, $invoice->ref, 0, 'L', 0);
$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 ); $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 );
$i++; $i++;
} }
} }
else else
{ {
$this->error=$outputlangs->trans("ErrorSQL")." sql=".$sql; $this->error=$outputlangs->trans("ErrorSQL")." sql=".$sql;
dolibarr_syslog($this->db,$this->error); dolibarr_syslog($this->db,$this->error);
return -1; return -1;
} }
// Loop on each payment // Loop on each payment
@ -465,27 +468,27 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY ($tab3_posx+41, $tab3_top+$y); $pdf->SetXY ($tab3_posx+41, $tab3_top+$y);
switch ($row[2]) switch ($row[2])
{ {
case 1: case 1:
$oper = 'TIP'; $oper = 'TIP';
break; break;
case 2: case 2:
$oper = 'VIR'; $oper = 'VIR';
break; break;
case 3: case 3:
$oper = 'PRE'; $oper = 'PRE';
break; break;
case 4: case 4:
$oper = 'LIQ'; $oper = 'LIQ';
break; break;
case 5: case 5:
$oper = 'VAD'; $oper = 'VAD';
break; break;
case 6: case 6:
$oper = 'CB'; $oper = 'CB';
break; break;
case 7: case 7:
$oper = 'CHQ'; $oper = 'CHQ';
break; break;
} }
$pdf->MultiCell(20, 4, $oper, 0, 'L', 0); $pdf->MultiCell(20, 4, $oper, 0, 'L', 0);
$pdf->SetXY ($tab3_posx+60, $tab3_top+$y); $pdf->SetXY ($tab3_posx+60, $tab3_top+$y);
@ -506,11 +509,11 @@ class pdf_oursin extends ModelePDFFactures
} }
/* /*
* \brief Affiche le total à payer * \brief Affiche le total à payer
* \param pdf objet PDF * \param pdf objet PDF
* \param fac objet facture * \param fac objet facture
* \param deja_regle montant deja regle * \param deja_regle montant deja regle
*/ */
function _tableau_tot(&$pdf, $fac, $deja_regle) function _tableau_tot(&$pdf, $fac, $deja_regle)
{ {
global $langs; global $langs;
@ -525,8 +528,8 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY ($this->marges['g'], $tab2_top + 0); $pdf->SetXY ($this->marges['g'], $tab2_top + 0);
/* /*
* If France, show VAT mention if not applicable * If France, show VAT mention if not applicable
*/ */
if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
{ {
$pdf->MultiCell(100, $tab2_hl, $langs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); $pdf->MultiCell(100, $tab2_hl, $langs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
@ -576,275 +579,233 @@ class pdf_oursin extends ModelePDFFactures
} }
} }
/* /*
* \brief Affiche la grille des lignes de factures * \brief Affiche la grille des lignes de factures
* \param pdf objet PDF * \param pdf objet PDF
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $fac) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $fac)
{
global $langs;
$langs->load("main");
$langs->load("bills");
$pdf->line( $this->marges['g'], $tab_top+8, 210-$this->marges['d'], $tab_top+8 );
$pdf->line( $this->marges['g'], $tab_top + $tab_height, 210-$this->marges['d'], $tab_top + $tab_height );
$pdf->SetFont('Arial','B',10);
$pdf->Text($this->marges['g']+2,$tab_top + 5, $langs->transnoentities("Designation"));
if ($this->franchise!=1) $pdf->Text($this->marges['g']+120, $tab_top + 5, $langs->transnoentities("VAT"));
$pdf->Text($this->marges['g']+135, $tab_top + 5,$langs->transnoentities("PriceUHT"));
$pdf->Text($this->marges['g']+153, $tab_top + 5, $langs->transnoentities("Qty"));
$nblignes = sizeof($fac->lignes);
$rem=0;
for ($i = 0 ; $i < $nblignes ; $i++)
if ($fac->lignes[$i]->remise_percent)
{ {
global $langs;
$langs->load("main");
$langs->load("bills");
$pdf->line( $this->marges['g'], $tab_top+8, 210-$this->marges['d'], $tab_top+8 );
$pdf->line( $this->marges['g'], $tab_top + $tab_height, 210-$this->marges['d'], $tab_top + $tab_height );
$pdf->SetFont('Arial','B',10);
$pdf->Text($this->marges['g']+2,$tab_top + 5, $langs->transnoentities("Designation"));
if ($this->franchise!=1) $pdf->Text($this->marges['g']+120, $tab_top + 5, $langs->transnoentities("VAT"));
$pdf->Text($this->marges['g']+135, $tab_top + 5,$langs->transnoentities("PriceUHT"));
$pdf->Text($this->marges['g']+153, $tab_top + 5, $langs->transnoentities("Qty"));
$nblignes = sizeof($fac->lignes);
$rem=0;
for ($i = 0 ; $i < $nblignes ; $i++)
if ($fac->lignes[$i]->remise_percent)
{
$rem=1; $rem=1;
}
if ($rem==1)
{
$pdf->Text($this->marges['g']+163, $tab_top + 5,'Rem.');
}
$pdf->Text($this->marges['g']+175, $tab_top + 5, $langs->transnoentities("TotalHT"));
} }
if ($rem==1)
{
$pdf->Text($this->marges['g']+163, $tab_top + 5,'Rem.');
}
$pdf->Text($this->marges['g']+175, $tab_top + 5, $langs->transnoentities("TotalHT"));
}
/* /*
* \brief Affiche en-tête facture * \brief Affiche en-tête facture
* \param pdf objet PDF * \param pdf objet PDF
* \param fac objet facture * \param fac objet facture
*/ */
function _pagehead(&$pdf, $fac) function _pagehead(&$pdf, $fac)
{
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
$langs->load("propal");
$langs->load("companies");
//Affiche le filigrane brouillon - Print Draft Watermark
if($fac->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
{ {
$watermark_angle=atan($this->page_hauteur/$this->page_largeur); global $langs,$conf;
$watermark_x=5; $langs->load("main");
$watermark_y=$this->page_hauteur-50; $langs->load("bills");
$watermark_width=$this->page_hauteur; $langs->load("propal");
$pdf->SetFont('Arial','B',50); $langs->load("companies");
$pdf->SetTextColor(255,192,203);
//rotate //Affiche le filigrane brouillon - Print Draft Watermark
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); if($fac->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
//print watermark {
$pdf->SetXY($watermark_x,$watermark_y); $watermark_angle=atan($this->page_hauteur/$this->page_largeur);
$pdf->Cell($watermark_width,25,clean_html($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0); $watermark_x=5;
//antirotate $watermark_y=$this->page_hauteur-50;
$pdf->_out('Q'); $watermark_width=$this->page_hauteur;
$pdf->SetFont('Arial','B',50);
$pdf->SetTextColor(255,192,203);
//rotate
$pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k));
//print watermark
$pdf->SetXY($watermark_x,$watermark_y);
$pdf->Cell($watermark_width,25,clean_html($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0);
//antirotate
$pdf->_out('Q');
}
//Print content
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13);
$pdf->SetXY($this->marges['g'],6);
// Logo
$logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (is_readable($logo))
{
$taille=getimagesize($logo);
$longueur=$taille[0]/2.835;
$pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, 24);
}
else
{
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(80, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
$pdf->MultiCell(80, 3, $langs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
}
else if (defined("FAC_PDF_INTITULE"))
{
$pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L');
}
/*
* Emetteur
*/
$posy=$this->marges['h']+24;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marges['g'],$posy-5);
$pdf->SetXY($this->marges['g'],$posy);
$pdf->SetFillColor(255,255,255);
$pdf->MultiCell(82, 34, "", 0, 'R', 1);
$pdf->SetXY($this->marges['g'],$posy+4);
// Nom emetteur
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',12);
if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) // Prioritaire sur MAIN_INFO_SOCIETE_NOM
{
$pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L');
}
else // Par defaut
{
$pdf->MultiCell(80, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L');
}
// Caractéristiques emetteur
$pdf->SetFont('Arial','',9);
if (defined("FAC_PDF_ADRESSE"))
{
$pdf->MultiCell(80, 4, FAC_PDF_ADRESSE);
}
if (defined("FAC_PDF_TEL") && FAC_PDF_TEL)
{
$pdf->MultiCell(80, 4, $langs->transnoentities("Phone").": ".FAC_PDF_TEL);
}
if (defined("FAC_PDF_MEL") && FAC_PDF_MEL)
{
$pdf->MultiCell(80, 4, $langs->transnoentities("Email").": ".FAC_PDF_MEL);
}
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW)
{
$pdf->MultiCell(80, 4, $langs->transnoentities("Web").": ".FAC_PDF_WWW);
}
$pdf->SetFont('Arial','',7);
if (defined("MAIN_INFO_SIREN") && MAIN_INFO_SIREN)
{
$pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".MAIN_INFO_SIREN);
}
elseif (defined("MAIN_INFO_SIRET") && MAIN_INFO_SIRET)
{
$pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".MAIN_INFO_SIRET);
}
/*
* Client
*/
$posy=45;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marges['g']+100,$posy-5);
$pdf->SetFont('Arial','B',11);
$fac->fetch_client();
$pdf->SetXY($this->marges['g']+100,$posy+4);
$pdf->MultiCell(86,4, $fac->client->nom, 0, 'L');
$pdf->SetFont('Arial','B',10);
$pdf->SetXY($this->marges['g']+100,$posy+12);
$pdf->MultiCell(86,4, $fac->client->adresse . "\n\n" . $fac->client->cp . " " . $fac->client->ville);
/*
* ref facture
*/
$posy=65;
$pdf->SetFont('Arial','B',13);
$pdf->SetXY($this->marges['g'],$posy);
$pdf->SetTextColor(0,0,0);
$pdf->MultiCell(100, 10, $langs->transnoentities("Bill").' '.$langs->transnoentities("Of").' '.dolibarr_print_date($fac->date,"%d %B %Y"), '' , 'L');
$pdf->SetFont('Arial','B',11);
$pdf->SetXY($this->marges['g'],$posy+6);
$pdf->SetTextColor(22,137,210);
$pdf->MultiCell(100, 10, $langs->transnoentities("RefBill")." : " . $fac->ref, '', 'L');
$pdf->SetTextColor(0,0,0);
/*
* ref projet
*/
if ($fac->projetid > 0)
{
$projet = New Project($fac->db);
$projet->fetch($fac->projetid);
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(60, 4, $langs->transnoentities("Project")." : ".$projet->title);
}
/*
* ref propal
*/
$sql = "SELECT ".$fac->db->pdate("p.datep")." as dp, p.ref, p.rowid as propalid";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id";
$result = $fac->db->query($sql);
if ($result)
{
$objp = $fac->db->fetch_object();
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(60, 4, $langs->transnoentities("RefProposal")." : ".$objp->ref);
}
/*
* monnaie
*/
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10);
$titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie));
$pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre);
/*
*/
} }
//Print content
$pdf->SetTextColor(0,0,60); /*
$pdf->SetFont('Arial','B',13); * \brief Affiche le pied de page de la facture
* \param pdf objet PDF
$pdf->SetXY($this->marges['g'],6); * \param fac objet facture
*/
// Logo function _pagefoot(&$pdf, $fac, $outputlangs)
$logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo; {
if ($this->emetteur->logo) return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur);
{ }
if (is_readable($logo))
{
$taille=getimagesize($logo);
$longueur=$taille[0]/2.835;
$pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, 24);
}
else
{
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(80, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
$pdf->MultiCell(80, 3, $langs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
}
else if (defined("FAC_PDF_INTITULE"))
{
$pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L');
}
/*
* Emetteur
*/
$posy=$this->marges['h']+24;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marges['g'],$posy-5);
$pdf->SetXY($this->marges['g'],$posy);
$pdf->SetFillColor(255,255,255);
$pdf->MultiCell(82, 34, "", 0, 'R', 1);
$pdf->SetXY($this->marges['g'],$posy+4);
// Nom emetteur
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',12);
if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) // Prioritaire sur MAIN_INFO_SOCIETE_NOM
{
$pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L');
}
else // Par defaut
{
$pdf->MultiCell(80, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L');
}
// Caractéristiques emetteur
$pdf->SetFont('Arial','',9);
if (defined("FAC_PDF_ADRESSE"))
{
$pdf->MultiCell(80, 4, FAC_PDF_ADRESSE);
}
if (defined("FAC_PDF_TEL") && FAC_PDF_TEL)
{
$pdf->MultiCell(80, 4, $langs->transnoentities("Phone").": ".FAC_PDF_TEL);
}
if (defined("FAC_PDF_MEL") && FAC_PDF_MEL)
{
$pdf->MultiCell(80, 4, $langs->transnoentities("Email").": ".FAC_PDF_MEL);
}
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW)
{
$pdf->MultiCell(80, 4, $langs->transnoentities("Web").": ".FAC_PDF_WWW);
}
$pdf->SetFont('Arial','',7);
if (defined("MAIN_INFO_SIREN") && MAIN_INFO_SIREN)
{
$pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".MAIN_INFO_SIREN);
}
elseif (defined("MAIN_INFO_SIRET") && MAIN_INFO_SIRET)
{
$pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".MAIN_INFO_SIRET);
}
/*
* Client
*/
$posy=45;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marges['g']+100,$posy-5);
$pdf->SetFont('Arial','B',11);
$fac->fetch_client();
$pdf->SetXY($this->marges['g']+100,$posy+4);
$pdf->MultiCell(86,4, $fac->client->nom, 0, 'L');
$pdf->SetFont('Arial','B',10);
$pdf->SetXY($this->marges['g']+100,$posy+12);
$pdf->MultiCell(86,4, $fac->client->adresse . "\n\n" . $fac->client->cp . " " . $fac->client->ville);
/*
* ref facture
*/
$posy=65;
$pdf->SetFont('Arial','B',13);
$pdf->SetXY($this->marges['g'],$posy);
$pdf->SetTextColor(0,0,0);
$pdf->MultiCell(100, 10, $langs->transnoentities("Bill").' '.$langs->transnoentities("Of").' '.dolibarr_print_date($fac->date,"%d %B %Y"), '' , 'L');
$pdf->SetFont('Arial','B',11);
$pdf->SetXY($this->marges['g'],$posy+6);
$pdf->SetTextColor(22,137,210);
$pdf->MultiCell(100, 10, $langs->transnoentities("RefBill")." : " . $fac->ref, '', 'L');
$pdf->SetTextColor(0,0,0);
/*
* ref projet
*/
if ($fac->projetid > 0)
{
$projet = New Project($fac->db);
$projet->fetch($fac->projetid);
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(60, 4, $langs->transnoentities("Project")." : ".$projet->title);
}
/*
* ref propal
*/
$sql = "SELECT ".$fac->db->pdate("p.datep")." as dp, p.ref, p.rowid as propalid";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id";
$result = $fac->db->query($sql);
if ($result)
{
$objp = $fac->db->fetch_object();
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(60, 4, $langs->transnoentities("RefProposal")." : ".$objp->ref);
}
/*
* monnaie
*/
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10);
$titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie));
$pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre);
/*
*/
}
/*
* \brief Affiche le pied de page de la facture
* \param pdf objet PDF
* \param fac objet facture
*/
function _pagefoot(&$pdf, $fac)
{
global $langs, $conf;
$langs->load("main");
$langs->load("bills");
$langs->load("companies");
$footy=13;
$pdf->SetFont('Arial','',8);
$ligne="";
if (defined('MAIN_INFO_CAPITAL') && MAIN_INFO_CAPITAL) {
$ligne=$langs->transnoentities('LimitedLiabilityCompanyCapital').' '. MAIN_INFO_CAPITAL." ".$langs->transnoentities("Currency".$conf->monnaie);
}
if (defined('MAIN_INFO_SIREN') && MAIN_INFO_SIREN) {
$ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".MAIN_INFO_SIREN;
}
if (defined('MAIN_INFO_SIRET') && MAIN_INFO_SIRET) {
$ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".MAIN_INFO_SIRET;
}
if (defined('MAIN_INFO_RCS') && MAIN_INFO_RCS) {
$ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".MAIN_INFO_RCS;
}
if ($ligne) {
$pdf->SetY(-$footy);
$pdf->MultiCell(190, 3, $ligne, 0, 'C');
$footy-=3;
}
// Affiche le numéro de TVA intracommunautaire
if (MAIN_INFO_TVAINTRA == 'MAIN_INFO_TVAINTRA') {
$pdf->SetY(-$footy);
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(190, 3, $langs->transnoentities("ErrorVATIntraNotConfigured"),0,'L',0);
$pdf->MultiCell(190, 3, $langs->transnoentities("ErrorGoToGlobalSetup"),0,'L',0);
$pdf->SetTextColor(0,0,0);
}
elseif (MAIN_INFO_TVAINTRA != '') {
$pdf->SetY(-$footy);
$pdf->MultiCell(190, 3, $langs->transnoentities("IntracommunityVATNumber")." : ".MAIN_INFO_TVAINTRA, 0, 'C');
}
$pdf->SetXY(-15,-15);
$pdf->MultiCell(11, 3, $pdf->PageNo().'/{nb}', 0, 'R');
}
} }

View File

@ -20,65 +20,65 @@
*/ */
/** /**
\file htdocs/includes/modules/fichinter/pdf_soleil.modules.php \file htdocs/includes/modules/fichinter/pdf_soleil.modules.php
\ingroup ficheinter \ingroup ficheinter
\brief Fichier de la classe permettant de générer les fiches d'intervention au modèle Soleil \brief Fichier de la classe permettant de générer les fiches d'intervention au modèle Soleil
\version $Id$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
/** /**
\class pdf_soleil \class pdf_soleil
\brief Classe permettant de générer les fiches d'intervention au modèle Soleil \brief Classe permettant de générer les fiches d'intervention au modèle Soleil
*/ */
class pdf_soleil extends ModelePDFFicheinter class pdf_soleil extends ModelePDFFicheinter
{ {
/** /**
\brief Constructeur \brief Constructeur
\param db Handler accès base de donnée \param db Handler accès base de donnée
*/ */
function pdf_soleil($db=0) function pdf_soleil($db=0)
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
$this->db = $db; $this->db = $db;
$this->name = 'soleil'; $this->name = 'soleil';
$this->description = "Modèle de fiche d'intervention standard"; $this->description = "Modèle de fiche d'intervention standard";
// 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);
$this->marge_gauche=10; $this->marge_gauche=10;
$this->marge_droite=10; $this->marge_droite=10;
$this->marge_haute=10; $this->marge_haute=10;
$this->marge_basse=10; $this->marge_basse=10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 0; // Affiche mode règlement $this->option_modereg = 0; // Affiche mode règlement
$this->option_condreg = 0; // Affiche conditions règlement $this->option_condreg = 0; // Affiche conditions règlement
$this->option_codeproduitservice = 0; // Affiche code produit-service $this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 0; // Dispo en plusieurs langues $this->option_multilang = 0; // Dispo en plusieurs langues
$this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->option_draft_watermark = 1; //Support add of a watermark on drafts
// Recupere code pays de l'emmetteur // Recupere code pays de l'emmetteur
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (! $this->emetteur->code_pays) $this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini if (! $this->emetteur->code_pays) $this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini
} }
/** /**
\brief Fonction générant la fiche d'intervention sur le disque \brief Fonction générant la fiche d'intervention sur le disque
\param fichinter Object fichinter \param fichinter Object fichinter
\return int 1=ok, 0=ko \return int 1=ok, 0=ko
*/ */
function write_file($fichinter,$outputlangs='') function write_file($fichinter,$outputlangs='')
{ {
global $user,$langs,$conf,$mysoc; global $user,$langs,$conf,$mysoc;
@ -137,6 +137,9 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->Open(); $pdf->Open();
$pdf->AddPage(); $pdf->AddPage();
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
//Affiche le filigrane brouillon - Print Draft Watermark //Affiche le filigrane brouillon - Print Draft Watermark
if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) ) if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
{ {
@ -222,8 +225,8 @@ class pdf_soleil extends ModelePDFFicheinter
/* /*
* Adresse Client * Adresse Client
*/ */
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$fichinter->fetch_client(); $fichinter->fetch_client();
@ -264,19 +267,19 @@ class pdf_soleil extends ModelePDFFicheinter
if ($num) if ($num)
{ {
while ($i < $num) while ($i < $num)
{ {
$fichinterligne = $fichinter->lignes[$i]; $fichinterligne = $fichinter->lignes[$i];
$valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0; $valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0;
if ($valide>0) if ($valide>0)
{ {
$pdf->SetXY (20, $tab_top + 16 + $i * 20); $pdf->SetXY (20, $tab_top + 16 + $i * 20);
$pdf->writeHTMLCell(190, 8, 20, $tab_top + 16 + $i * 20, $pdf->writeHTMLCell(190, 8, 20, $tab_top + 16 + $i * 20,
dol_htmlentitiesbr($langs->transnoentities("Date")." : ".dolibarr_print_date($fichinterligne->datei)." - ".$langs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration)), 0, 'J', 0); dol_htmlentitiesbr($langs->transnoentities("Date")." : ".dolibarr_print_date($fichinterligne->datei)." - ".$langs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration)), 0, 'J', 0);
$pdf->SetXY (20, $tab_top + 22 + $i * 20); $pdf->SetXY (20, $tab_top + 22 + $i * 20);
$pdf->writeHTMLCell(170, 8, 20, $tab_top + 22 + $i * 20, $pdf->writeHTMLCell(170, 8, 20, $tab_top + 22 + $i * 20,
dol_htmlentitiesbr($fichinterligne->desc,1), 0, 'L', 0); dol_htmlentitiesbr($fichinterligne->desc,1), 0, 'L', 0);
$tab_height+=20; $tab_height+=20;
} }
$i++; $i++;
@ -284,26 +287,30 @@ class pdf_soleil extends ModelePDFFicheinter
} }
$pdf->Rect(10, $tab_top, 190, $tab_height); $pdf->Rect(10, $tab_top, 190, $tab_height);
$pdf->SetXY (10, $pdf->GetY() + 20 ); $pdf->SetXY (10, $pdf->GetY() + 20 );
$pdf->MultiCell(60, 5, '', 0, 'J', 0); $pdf->MultiCell(60, 5, '', 0, 'J', 0);
$pdf->SetXY(20,220); $pdf->SetXY(20,220);
$pdf->MultiCell(66,5, $langs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); $pdf->MultiCell(66,5, $langs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
$pdf->SetXY(20,225); $pdf->SetXY(20,225);
$pdf->MultiCell(80,30, '', 1); $pdf->MultiCell(80,30, '', 1);
$pdf->SetXY(110,220); $pdf->SetXY(110,220);
$pdf->MultiCell(80,5, $langs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); $pdf->MultiCell(80,5, $langs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
$pdf->SetXY(110,225); $pdf->SetXY(110,225);
$pdf->MultiCell(80,30, '', 1); $pdf->MultiCell(80,30, '', 1);
$pdf->SetFont('Arial','', 9); // On repositionne la police par defaut $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
$this->_pagefoot($pdf,$outputlangs); $this->_pagefoot($pdf,$outputlangs);
$pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
$pdf->Output($file); $pdf->Output($file);
$langs->setPhpLang(); // On restaure langue session
return 1; return 1;
} }
else else
@ -321,76 +328,14 @@ class pdf_soleil extends ModelePDFFicheinter
return 0; // Erreur par defaut return 0; // Erreur par defaut
} }
/* /*
* \brief Affiche le pied de page * \brief Affiche le pied de page
* \param pdf objet PDF * \param pdf objet PDF
*/ */
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$outputlangs)
{ {
global $conf; return pdf_pagefoot($pdf,$outputlangs,'FICHEINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur);
}
// Premiere ligne d'info reglementaires
$ligne1="";
if ($this->emetteur->forme_juridique_code)
{
$ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($this->emetteur->forme_juridique_code);
}
if ($this->emetteur->capital)
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$this->emetteur->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie);
}
if ($this->emetteur->profid2)
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2;
}
if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR'))
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1;
}
// Deuxieme ligne d'info reglementaires
$ligne2="";
if ($this->emetteur->profid3)
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3;
}
if ($this->emetteur->profid4)
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4;
}
if ($this->emetteur->tva_intra != '')
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$this->emetteur->tva_intra;
}
$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
//Todo: correction provisoire afin de régler le problème du bas de page
//$posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0);
$posy=$this->marge_basse + 11 + ($ligne1?3:0) + ($ligne2?3:0);
$pdf->SetY(-$posy);
$pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy);
$posy--;
if ($ligne1)
{
$pdf->SetXY($this->marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0);
}
if ($ligne2)
{
$posy-=3;
$pdf->SetXY($this->marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0);
}
//$pdf->SetXY(-20,-$posy);
//$pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -20,68 +20,88 @@
*/ */
/** \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php /** \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
\ingroup propale \ingroup propale
\brief Fichier de la classe permettant de générer les propales au modèle Jaune \brief Fichier de la classe permettant de générer les propales au modèle Jaune
\version $Id$ \version $Id$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
/** \class pdf_propale_jaune /**
\brief Classe permettant de générer les propales au modèle Jaune * \class pdf_propale_jaune
*/ * \brief Classe permettant de générer les propales au modèle Jaune
*/
class pdf_propale_jaune extends ModelePDFPropales class pdf_propale_jaune extends ModelePDFPropales
{ {
var $emetteur; // Objet societe qui emet var $emetteur; // Objet societe qui emet
/** \brief Constructeur /**
\param db handler accès base de donnée * \brief Constructeur
*/ * \param db handler accès base de donnée
function pdf_propale_jaune($db=0) */
{ function pdf_propale_jaune($db=0)
global $conf,$langs,$mysoc; {
global $conf,$langs,$mysoc;
$this->db = $db; $langs->load("main");
$this->name = "jaune"; $langs->load("bills");
$this->description = "Modèle de proposition Jaune";
// Dimension page pour format A4 $this->db = $db;
$this->type = 'pdf'; $this->name = "jaune";
$this->page_largeur = 210; $this->description = "Modèle de proposition Jaune";
$this->page_hauteur = 297;
$this->format = array($this->page_largeur,$this->page_hauteur); // Dimension page pour format A4
$this->type = 'pdf';
$this->page_largeur = 210;
$this->page_hauteur = 297;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10;
$this->marge_droite=10;
$this->marge_haute=10;
$this->marge_basse=10;
$this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->option_draft_watermark = 1; //Support add of a watermark on drafts
$this->error = ""; $this->error = "";
// Recupere emmetteur // Recupere emmetteur
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas
} }
/** \brief Renvoi dernière erreur /** \brief Renvoi dernière erreur
\return string Dernière erreur \return string Dernière erreur
*/ */
function pdferror() function pdferror()
{ {
return $this->error; return $this->error;
} }
/** /**
\brief Fonction générant la propale sur le disque \brief Fonction générant la propale sur le disque
\param propale Objet propal \param propale Objet propal
\param outputlangs Lang object for output language \param outputlangs Lang object for output language
\return int 1=ok, 0=ko \return int 1=ok, 0=ko
*/ */
function write_file($propale,$outputlangs='') function write_file($propale,$outputlangs='')
{ {
global $user,$conf,$langs; global $user,$langs,$conf;
if (! is_object($outputlangs)) $outputlangs=$langs;
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("propal");
$outputlangs->load("products");
$outputlangs->setPhpLang();
if ($conf->propal->dir_output) if ($conf->propal->dir_output)
{ {
@ -117,38 +137,41 @@ class pdf_propale_jaune extends ModelePDFPropales
if (file_exists($dir)) if (file_exists($dir))
{ {
// Protection et encryption du pdf // Protection et encryption du pdf
if ($conf->global->PDF_SECURITY_ENCRYPTION) if ($conf->global->PDF_SECURITY_ENCRYPTION)
{ {
$pdf=new FPDI_Protection('P','mm',$this->format); $pdf=new FPDI_Protection('P','mm',$this->format);
$pdfrights = array('print'); // Ne permet que l'impression du document $pdfrights = array('print'); // Ne permet que l'impression du document
$pdfuserpass = ''; // Mot de passe pour l'utilisateur final $pdfuserpass = ''; // Mot de passe pour l'utilisateur final
$pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini
$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
} }
else else
{ {
$pdf=new FPDI('P','mm',$this->format); $pdf=new FPDI('P','mm',$this->format);
} }
$pdf->Open(); $pdf->Open();
$pdf->AddPage();
$pdf->SetTitle($propale->ref); $pdf->SetTitle($propale->ref);
$pdf->SetSubject("Proposition commerciale"); $pdf->SetSubject("Proposition commerciale");
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname); $pdf->SetAuthor($user->fullname);
$pdf->AddPage(); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
$this->_pagehead($pdf, $propale); // Tete de page
$this->_pagehead($pdf, $propale, $outputlangs);
/* /*
*/ */
$tab_top = 100; $tab_top = 100;
$tab_height = 150; $tab_height = 150;
/* /*
* *
*/ */
$pdf->SetFillColor(242,239,119); $pdf->SetFillColor(242,239,119);
@ -190,10 +213,12 @@ class pdf_propale_jaune extends ModelePDFPropales
if ($nexY > 240 && $i < $nblignes - 1) if ($nexY > 240 && $i < $nblignes - 1)
{ {
$this->_pagefoot($pdf,$propale,$outputlangs);
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$pdf->AddPage(); $pdf->AddPage();
$nexY = $iniY; $nexY = $iniY;
$this->_pagehead($pdf, $propale); $this->_pagehead($pdf, $propale, $outputlangs);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10); $pdf->SetFont('Arial','', 10);
} }
@ -201,8 +226,8 @@ class pdf_propale_jaune extends ModelePDFPropales
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
/* /*
* *
*/ */
$tab2_top = 254; $tab2_top = 254;
$tab2_lh = 7; $tab2_lh = 7;
$tab2_height = $tab2_lh * 3; $tab2_height = $tab2_lh * 3;
@ -218,13 +243,13 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
$pdf->SetXY (132, $tab2_top + 0); $pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0); $pdf->MultiCell(42, $tab2_lh, $outputlangs->trans("TotalHT"), 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + $tab2_lh); $pdf->SetXY (132, $tab2_top + $tab2_lh);
$pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0); $pdf->MultiCell(42, $tab2_lh, $outputlangs->trans("TotalTVA"), 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + ($tab2_lh*2)); $pdf->SetXY (132, $tab2_top + ($tab2_lh*2));
$pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1); $pdf->MultiCell(42, $tab2_lh, $outputlangs->trans("TotalTTC"), 1, 'R', 1);
$pdf->SetXY (174, $tab2_top + 0); $pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0); $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0);
@ -235,57 +260,59 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetXY (174, $tab2_top + ($tab2_lh*2)); $pdf->SetXY (174, $tab2_top + ($tab2_lh*2));
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1); $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1);
/* // Pied de page
* $this->_pagefoot($pdf,$propale,$outputlangs);
*/ $pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file); $pdf->Output($file);
$langs->setPhpLang(); // On restaure langue session
return 1; return 1;
} }
} }
} }
function _tableau(&$pdf, $tab_top, $tab_height, $nexY) function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
{ {
global $langs,$conf; global $langs,$conf;
$langs->load("main"); $langs->load("main");
$langs->load("bills"); $langs->load("bills");
$pdf->SetFont('Arial','',11); $pdf->SetFont('Arial','',11);
$pdf->SetXY(10,$tab_top); $pdf->SetXY(10,$tab_top);
$pdf->MultiCell(20,10,$langs->transnoentities("Ref"),0,'C',1); $pdf->MultiCell(20,10,$langs->transnoentities("Ref"),0,'C',1);
$pdf->SetXY(30,$tab_top); $pdf->SetXY(30,$tab_top);
$pdf->MultiCell(102,10,$langs->transnoentities("Designation"),0,'L',1); $pdf->MultiCell(102,10,$langs->transnoentities("Designation"),0,'L',1);
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height); $pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->SetXY(132,$tab_top); $pdf->SetXY(132,$tab_top);
$pdf->MultiCell(12, 10,$langs->transnoentities("VAT"),0,'C',1); $pdf->MultiCell(12, 10,$langs->transnoentities("VAT"),0,'C',1);
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height); $pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->SetXY(144,$tab_top); $pdf->SetXY(144,$tab_top);
$pdf->MultiCell(10,10,$langs->transnoentities("Qty"),0,'C',1); $pdf->MultiCell(10,10,$langs->transnoentities("Qty"),0,'C',1);
$pdf->line(154, $tab_top, 154, $tab_top + $tab_height); $pdf->line(154, $tab_top, 154, $tab_top + $tab_height);
$pdf->SetXY(154,$tab_top); $pdf->SetXY(154,$tab_top);
$pdf->MultiCell(22,10,$langs->transnoentities("PriceU"),0,'R',1); $pdf->MultiCell(22,10,$langs->transnoentities("PriceU"),0,'R',1);
$pdf->line(176, $tab_top, 176, $tab_top + $tab_height); $pdf->line(176, $tab_top, 176, $tab_top + $tab_height);
$pdf->SetXY(176,$tab_top); $pdf->SetXY(176,$tab_top);
$pdf->MultiCell(24,10,$langs->transnoentities("Total"),0,'R',1); $pdf->MultiCell(24,10,$langs->transnoentities("Total"),0,'R',1);
$pdf->Rect(10, $tab_top, 190, $tab_height); $pdf->Rect(10, $tab_top, 190, $tab_height);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10); $pdf->SetFont('Arial','',10);
$titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); }
$pdf->Text(10,280, $titre);
}
function _pagehead(&$pdf, $propale) function _pagehead(&$pdf, $propale, $outputlangs)
{ {
//Affiche le filigrane brouillon - Print Draft Watermark //Affiche le filigrane brouillon - Print Draft Watermark
if($propale->statut==0 && defined("PROPALE_DRAFT_WATERMARK") ) if($propale->statut==0 && defined("PROPALE_DRAFT_WATERMARK") )
{ {
$watermark_angle=deg2rad(55); $watermark_angle=deg2rad(55);
@ -303,65 +330,76 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->_out('Q'); $pdf->_out('Q');
} }
//print Content //print Content
$pdf->SetXY(12,42); $pdf->SetXY(12,42);
if (defined("FAC_PDF_INTITULE")) if (defined("FAC_PDF_INTITULE"))
{ {
$pdf->SetTextColor(0,0,200); $pdf->SetTextColor(0,0,200);
$pdf->SetFont('Arial','B',14); $pdf->SetFont('Arial','B',14);
$pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L'); $pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L');
} }
$pdf->SetTextColor(70,70,170); $pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE")) if (defined("FAC_PDF_ADRESSE"))
{ {
$pdf->SetX(12); $pdf->SetX(12);
$pdf->SetFont('Arial','',12); $pdf->SetFont('Arial','',12);
$pdf->MultiCell(76, 5, FAC_PDF_ADRESSE); $pdf->MultiCell(76, 5, FAC_PDF_ADRESSE);
} }
if (defined("FAC_PDF_TEL")) if (defined("FAC_PDF_TEL"))
{ {
$pdf->SetX(12); $pdf->SetX(12);
$pdf->SetFont('Arial','',10); $pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL); $pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL);
} }
if (defined("MAIN_INFO_SIREN")) if (defined("MAIN_INFO_SIREN"))
{ {
$pdf->SetX(12); $pdf->SetX(12);
$pdf->SetFont('Arial','',10); $pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN); $pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN);
}
$pdf->rect(10, 40, 80, 40);
$pdf->SetXY(10,5);
$pdf->SetFont('Arial','B',16);
$pdf->SetTextColor(0,0,200);
$pdf->MultiCell(200, 20, "PROPOSITION COMMERCIALE", '' , 'C');
/*
* Adresse Client
*/
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12);
$propale->fetch_client();
$pdf->SetXY(102,42);
$pdf->MultiCell(96,5, $propale->client->nom);
$pdf->SetFont('Arial','B',11);
$pdf->SetXY(102,$pdf->GetY());
$pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville);
$pdf->rect(100, 40, 100, 40);
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',12);
$pdf->rect(10, 90, 100, 10);
$pdf->rect(110, 90, 90, 10);
$pdf->SetXY(10,90);
$pdf->MultiCell(110, 10, $outputlangs->trans("Ref")." : ".$propale->ref);
$pdf->SetXY(110,90);
$pdf->MultiCell(100, 10, $outputlangs->trans("Date")." : " . dolibarr_print_date($propale->date,'day'));
} }
$pdf->rect(10, 40, 80, 40);
$pdf->SetXY(10,5); /*
$pdf->SetFont('Arial','B',16); * \brief Affiche le pied de page
$pdf->SetTextColor(0,0,200); * \param pdf Object PDF
$pdf->MultiCell(200, 20, "PROPOSITION COMMERCIALE", '' , 'C'); * \param object Object proposal
*/
function _pagefoot(&$pdf,$object,$outputlangs)
{
return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur);
}
/*
* Adresse Client
*/
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',12);
$propale->fetch_client();
$pdf->SetXY(102,42);
$pdf->MultiCell(96,5, $propale->client->nom);
$pdf->SetFont('Arial','B',11);
$pdf->SetXY(102,$pdf->GetY());
$pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville);
$pdf->rect(100, 40, 100, 40);
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',12);
$pdf->rect(10, 90, 100, 10);
$pdf->rect(110, 90, 90, 10);
$pdf->SetXY(10,90);
$pdf->MultiCell(110, 10, "Numéro : ".$propale->ref);
$pdf->SetXY(110,90);
$pdf->MultiCell(100, 10, "Date : " . dolibarr_print_date($propale->date,'day'));
}
} }
?> ?>

View File

@ -20,11 +20,11 @@
*/ */
/** /**
\file htdocs/lib/company.lib.php \file htdocs/lib/company.lib.php
\brief Ensemble de fonctions de base pour le module societe \brief Ensemble de fonctions de base pour le module societe
\ingroup societe \ingroup societe
\version $Id$ \version $Id$
*/ */
function societe_prepare_head($objsoc) function societe_prepare_head($objsoc)
{ {
@ -133,36 +133,36 @@ function societe_prepare_head2($objsoc)
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id; $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Card"); $head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'company'; $head[$h][2] = 'company';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$objsoc->id; $head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("BankAccount")." $account->number"; $head[$h][1] = $langs->trans("BankAccount")." $account->number";
$head[$h][2] = 'rib'; $head[$h][2] = 'rib';
$h++; $h++;
$head[$h][0] = 'lien.php?socid='.$objsoc->id; $head[$h][0] = 'lien.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Links"); $head[$h][1] = $langs->trans("Links");
$head[$h][2] = 'links'; $head[$h][2] = 'links';
$h++; $h++;
$head[$h][0] = 'commerciaux.php?socid='.$objsoc->id; $head[$h][0] = 'commerciaux.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("SalesRepresentative"); $head[$h][1] = $langs->trans("SalesRepresentative");
$head[$h][2] = 'salesrepresentative'; $head[$h][2] = 'salesrepresentative';
$h++; $h++;
return $head; return $head;
} }
/** /**
* \brief Retourne le nom traduit ou code+nom d'un pays * \brief Retourne le nom traduit ou code+nom d'un pays
* \param id id du pays * \param id id du pays
* \param withcode 1=affiche code + nom * \param withcode 1=affiche code + nom
* \return string Nom traduit du pays * \return string Nom traduit du pays
*/ */
function getCountryLabel($id,$withcode=0) function getCountryLabel($id,$withcode=0)
{ {
global $db,$langs; global $db,$langs;
@ -236,114 +236,114 @@ function show_contacts($conf,$langs,$db,$objsoc)
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
if ($conf->clicktodial->enabled) if ($conf->clicktodial->enabled)
{ {
$user->fetch_clicktodial(); // lecture des infos de clicktodial $user->fetch_clicktodial(); // lecture des infos de clicktodial
} }
print_titre($langs->trans("ContactsForCompany")); print_titre($langs->trans("ContactsForCompany"));
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Name").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Poste").'</td><td>'.$langs->trans("Tel").'</td>'; print '<td>'.$langs->trans("Poste").'</td><td>'.$langs->trans("Tel").'</td>';
print '<td>'.$langs->trans("Fax").'</td><td>'.$langs->trans("EMail").'</td>'; print '<td>'.$langs->trans("Fax").'</td><td>'.$langs->trans("EMail").'</td>';
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
{ {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
print "</tr>"; print "</tr>";
$sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note "; $sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note ";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$objsoc->id; $sql .= " WHERE p.fk_soc = ".$objsoc->id;
$sql .= " ORDER by p.datec"; $sql .= " ORDER by p.datec";
$result = $db->query($sql); $result = $db->query($sql);
$i = 0; $i = 0;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=true; $var=true;
if ($num) if ($num)
{ {
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$var = !$var; $var = !$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
print '<td>'; print '<td>';
$contactstatic->id = $obj->rowid; $contactstatic->id = $obj->rowid;
$contactstatic->name = $obj->name; $contactstatic->name = $obj->name;
$contactstatic->firstname = $obj->firstname; $contactstatic->firstname = $obj->firstname;
print $contactstatic->getNomUrl(1); print $contactstatic->getNomUrl(1);
print '</td>'; print '</td>';
print '<td>'.$obj->poste.'</td>'; print '<td>'.$obj->poste.'</td>';
// Lien click to dial // Lien click to dial
print '<td>'; print '<td>';
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
print '<a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_TEL&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">'; print '<a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_TEL&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">';
print dolibarr_print_phone($obj->phone); print dolibarr_print_phone($obj->phone);
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
print '</a>'; print '</a>';
if ($obj->phone) print dol_phone_link($obj->phone); if ($obj->phone) print dol_phone_link($obj->phone);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
print '<a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_FAX&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">'; print '<a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_FAX&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">';
print dolibarr_print_phone($obj->fax); print dolibarr_print_phone($obj->fax);
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
print '</a>'; print '</a>';
print '&nbsp;</td>'; print '&nbsp;</td>';
print '<td>'; print '<td>';
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
print '<a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_EMAIL&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">'; print '<a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_EMAIL&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">';
print $obj->email; print $obj->email;
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
print '</a>'; print '</a>';
// \TODO // \TODO
//if ($obj->email) print dol_email_link($obj->email); //if ($obj->email) print dol_email_link($obj->email);
print '&nbsp;</td>'; print '&nbsp;</td>';
print '<td align="center">'; print '<td align="center">';
print "<a href=\"../contact/fiche.php?action=edit&amp;id=".$obj->rowid."\">"; print "<a href=\"../contact/fiche.php?action=edit&amp;id=".$obj->rowid."\">";
print img_edit(); print img_edit();
print '</a></td>'; print '</a></td>';
if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) if ($conf->agenda->enabled && $user->rights->agenda->myactions->create)
{ {
print '<td align="center"><a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_RDV&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">'; print '<td align="center"><a href="action/fiche.php?action=create&backtopage=1&actioncode=AC_RDV&contactid='.$obj->rowid.'&socid='.$objsoc->id.'">';
print img_object($langs->trans("Rendez-Vous"),"action"); print img_object($langs->trans("Rendez-Vous"),"action");
print '</a></td>'; print '</a></td>';
} }
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
} }
else else
{ {
//print "<tr ".$bc[$var].">"; //print "<tr ".$bc[$var].">";
//print '<td>'.$langs->trans("NoContactsYetDefined").'</td>'; //print '<td>'.$langs->trans("NoContactsYetDefined").'</td>';
//print "</tr>\n"; //print "</tr>\n";
} }
print "</table>\n"; print "</table>\n";
print "<br>\n"; print "<br>\n";
} }
/** /**
* \brief Show html area with actions to do * \brief Show html area with actions to do
*/ */
function show_actions_todo($conf,$langs,$db,$objsoc) function show_actions_todo($conf,$langs,$db,$objsoc)
{ {
global $bc; global $bc;
if ($conf->agenda->enabled) if ($conf->agenda->enabled)
{ {
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
$actionstatic=new ActionComm($db); $actionstatic=new ActionComm($db);
$userstatic=new User($db); $userstatic=new User($db);
@ -351,50 +351,50 @@ function show_actions_todo($conf,$langs,$db,$objsoc)
print_titre($langs->trans("ActionsOnCompany")); print_titre($langs->trans("ActionsOnCompany"));
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="11"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$objsoc->id.'&amp;status=todo">'.$langs->trans("ActionsToDoShort").'</a></td><td align="right">&nbsp;</td>'; print '<td colspan="11"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$objsoc->id.'&amp;status=todo">'.$langs->trans("ActionsToDoShort").'</a></td><td align="right">&nbsp;</td>';
print '</tr>'; print '</tr>';
$sql = "SELECT a.id, a.label,"; $sql = "SELECT a.id, a.label,";
$sql.= " ".$db->pdate("a.datep")." as dp,"; $sql.= " ".$db->pdate("a.datep")." as dp,";
$sql.= " ".$db->pdate("a.datea")." as da,"; $sql.= " ".$db->pdate("a.datea")." as da,";
$sql.= " a.percent,"; $sql.= " a.percent,";
$sql.= " c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, a.fk_contact,"; $sql.= " c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, a.fk_contact,";
$sql.= " u.login, u.rowid,"; $sql.= " u.login, u.rowid,";
$sql.= " sp.name, sp.firstname"; $sql.= " sp.name, sp.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql.= " WHERE a.fk_soc = ".$objsoc->id; $sql.= " WHERE a.fk_soc = ".$objsoc->id;
$sql.= " AND u.rowid = a.fk_user_author"; $sql.= " AND u.rowid = a.fk_user_author";
$sql.= " AND c.id=a.fk_action AND a.percent < 100"; $sql.= " AND c.id=a.fk_action AND a.percent < 100";
$sql.= " ORDER BY a.datep DESC, a.id DESC"; $sql.= " ORDER BY a.datep DESC, a.id DESC";
dolibarr_syslog("company.lib::show_actions_todo sql=".$sql); dolibarr_syslog("company.lib::show_actions_todo sql=".$sql);
$result=$db->query($sql); $result=$db->query($sql);
if ($result) if ($result)
{ {
$i = 0 ; $i = 0 ;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=true; $var=true;
if ($num) if ($num)
{ {
while ($i < $num) while ($i < $num)
{ {
$var = !$var; $var = !$var;
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td width="30" align="center">'.strftime("%Y",$obj->dp)."</td>\n"; print '<td width="30" align="center">'.strftime("%Y",$obj->dp)."</td>\n";
$oldyear = strftime("%Y",$obj->dp); $oldyear = strftime("%Y",$obj->dp);
print '<td width="30" align="center">' .strftime("%b",$obj->dp)."</td>\n"; print '<td width="30" align="center">' .strftime("%b",$obj->dp)."</td>\n";
$oldmonth = strftime("%Y%b",$obj->dp); $oldmonth = strftime("%Y%b",$obj->dp);
print '<td width="20">'.strftime("%d",$obj->dp)."</td>\n"; print '<td width="20">'.strftime("%d",$obj->dp)."</td>\n";
print '<td width="30" nowrap="nowrap">'.strftime("%H:%M",$obj->dp).'</td>'; print '<td width="30" nowrap="nowrap">'.strftime("%H:%M",$obj->dp).'</td>';
// Picto warning // Picto warning
print '<td width="16">'; print '<td width="16">';
@ -402,146 +402,146 @@ function show_actions_todo($conf,$langs,$db,$objsoc)
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
// Status/Percent // Status/Percent
print '<td width="30">&nbsp;</td>'; print '<td width="30">&nbsp;</td>';
if ($obj->propalrowid) if ($obj->propalrowid)
{ {
print '<td><a href="propal.php?propalid='.$obj->propalrowid.'">'.img_object($langs->trans("ShowAction"),"task"); print '<td><a href="propal.php?propalid='.$obj->propalrowid.'">'.img_object($langs->trans("ShowAction"),"task");
$transcode=$langs->trans("Action".$obj->acode); $transcode=$langs->trans("Action".$obj->acode);
$libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle);
print $libelle; print $libelle;
print '</a></td>'; print '</a></td>';
} }
else else
{ {
$actionstatic->code=$obj->acode; $actionstatic->code=$obj->acode;
$actionstatic->libelle=$obj->libelle; $actionstatic->libelle=$obj->libelle;
$actionstatic->id=$obj->id; $actionstatic->id=$obj->id;
print '<td>'.$actionstatic->getNomUrl(1,16).'</td>'; print '<td>'.$actionstatic->getNomUrl(1,16).'</td>';
} }
print '<td colspan="2">'.$obj->label.'</td>'; print '<td colspan="2">'.$obj->label.'</td>';
// Contact pour cette action // Contact pour cette action
if ($obj->fk_contact > 0) if ($obj->fk_contact > 0)
{ {
$contactstatic->name=$obj->name; $contactstatic->name=$obj->name;
$contactstatic->firstname=$obj->firstname; $contactstatic->firstname=$obj->firstname;
$contactstatic->id=$obj->fk_contact; $contactstatic->id=$obj->fk_contact;
print '<td>'.$contactstatic->getNomUrl(1).'</td>'; print '<td>'.$contactstatic->getNomUrl(1).'</td>';
} }
else else
{ {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
print '<td width="80" nowrap="nowrap">'; print '<td width="80" nowrap="nowrap">';
$userstatic->id=$obj->fk_user_author; $userstatic->id=$obj->fk_user_author;
$userstatic->login=$obj->login; $userstatic->login=$obj->login;
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
print '</td>'; print '</td>';
// Statut // Statut
print '<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($obj->percent,3).'</td>'; print '<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($obj->percent,3).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
} }
else else
{ {
// Aucun action a faire // Aucun action a faire
} }
$db->free($result); $db->free($result);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print "</table>\n"; print "</table>\n";
print "<br>\n"; print "<br>\n";
} }
} }
/** /**
* \brief Show html area with actions done * \brief Show html area with actions done
*/ */
function show_actions_done($conf,$langs,$db,$objsoc) function show_actions_done($conf,$langs,$db,$objsoc)
{ {
global $bc; global $bc;
if ($conf->agenda->enabled) if ($conf->agenda->enabled)
{ {
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
$actionstatic=new ActionComm($db); $actionstatic=new ActionComm($db);
$userstatic=new User($db); $userstatic=new User($db);
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
$facturestatic=new Facture($db); $facturestatic=new Facture($db);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="12"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$objsoc->id.'&amp;status=done">'.$langs->trans("ActionsDoneShort").'</a></td>'; print '<td colspan="12"><a href="'.DOL_URL_ROOT.'/comm/action/listactions.php?socid='.$objsoc->id.'&amp;status=done">'.$langs->trans("ActionsDoneShort").'</a></td>';
print '</tr>'; print '</tr>';
$sql = "SELECT a.id, a.label,"; $sql = "SELECT a.id, a.label,";
$sql.= " ".$db->pdate("a.datep")." as dp,"; $sql.= " ".$db->pdate("a.datep")." as dp,";
$sql.= " ".$db->pdate("a.datep2")." as dp2,"; $sql.= " ".$db->pdate("a.datep2")." as dp2,";
$sql.= " a.percent,"; $sql.= " a.percent,";
$sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,";
$sql.= " c.code as acode, c.libelle,"; $sql.= " c.code as acode, c.libelle,";
$sql.= " u.login, u.rowid,"; $sql.= " u.login, u.rowid,";
$sql.= " sp.name, sp.firstname"; $sql.= " sp.name, sp.firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql.= " WHERE a.fk_soc = ".$objsoc->id; $sql.= " WHERE a.fk_soc = ".$objsoc->id;
$sql.= " AND u.rowid = a.fk_user_author"; $sql.= " AND u.rowid = a.fk_user_author";
$sql.= " AND c.id=a.fk_action AND a.percent = 100"; $sql.= " AND c.id=a.fk_action AND a.percent = 100";
$sql.= " ORDER BY a.datep2 DESC, a.id DESC"; $sql.= " ORDER BY a.datep2 DESC, a.id DESC";
dolibarr_syslog("comm/fiche.php sql=".$sql); dolibarr_syslog("comm/fiche.php sql=".$sql);
$result=$db->query($sql); $result=$db->query($sql);
if ($result) if ($result)
{ {
$i = 0 ; $i = 0 ;
$num = $db->num_rows($result); $num = $db->num_rows($result);
$oldyear=''; $oldyear='';
$oldmonth=''; $oldmonth='';
$var=true; $var=true;
while ($i < $num) while ($i < $num)
{ {
$var = !$var; $var = !$var;
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
// Champ date // Champ date
print '<td width="30" align="center">'.strftime("%Y",$obj->dp2)."</td>\n"; print '<td width="30" align="center">'.strftime("%Y",$obj->dp2)."</td>\n";
$oldyear = strftime("%Y",$obj->dp2); $oldyear = strftime("%Y",$obj->dp2);
print '<td width="30" align="center">'.strftime("%b",$obj->dp2)."</td>\n"; print '<td width="30" align="center">'.strftime("%b",$obj->dp2)."</td>\n";
$oldmonth = strftime("%Y%b",$obj->dp2); $oldmonth = strftime("%Y%b",$obj->dp2);
print '<td width="20">'.strftime("%d",$obj->dp2)."</td>\n"; print '<td width="20">'.strftime("%d",$obj->dp2)."</td>\n";
print '<td width="30">'.strftime("%H:%M",$obj->dp2)."</td>\n"; print '<td width="30">'.strftime("%H:%M",$obj->dp2)."</td>\n";
// Picto // Picto
print '<td width="16">&nbsp;</td>'; print '<td width="16">&nbsp;</td>';
// Espace // Espace
print '<td width="30">&nbsp;</td>'; print '<td width="30">&nbsp;</td>';
// Action // Action
print '<td>'; print '<td>';
$actionstatic->code=$obj->acode; $actionstatic->code=$obj->acode;
$actionstatic->libelle=$obj->libelle; $actionstatic->libelle=$obj->libelle;
$actionstatic->id=$obj->id; $actionstatic->id=$obj->id;
print $actionstatic->getNomUrl(1,16); print $actionstatic->getNomUrl(1,16);
print '</td>'; print '</td>';
// Objet lie // Objet lie
print '<td>'; print '<td>';
if ($obj->propalrowid) if ($obj->propalrowid)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$obj->propalrowid.'">'.img_object($langs->trans("ShowPropal"),"propal"); print '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$obj->propalrowid.'">'.img_object($langs->trans("ShowPropal"),"propal");
@ -556,47 +556,136 @@ function show_actions_done($conf,$langs,$db,$objsoc)
print $facturestatic->getNomUrl(1,'compta'); print $facturestatic->getNomUrl(1,'compta');
} }
else print '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
// Libelle // Libelle
print '<td>'.$obj->label.'</td>'; print '<td>'.$obj->label.'</td>';
// Contact pour cette action // Contact pour cette action
if ($obj->fk_contact > 0) if ($obj->fk_contact > 0)
{ {
$contactstatic->name=$obj->name; $contactstatic->name=$obj->name;
$contactstatic->firstname=$obj->firstname; $contactstatic->firstname=$obj->firstname;
$contactstatic->id=$obj->fk_contact; $contactstatic->id=$obj->fk_contact;
print '<td>'.$contactstatic->getNomUrl(1).'</td>'; print '<td>'.$contactstatic->getNomUrl(1).'</td>';
} }
else else
{ {
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
} }
// Auteur // Auteur
print '<td nowrap="nowrap" width="80">'; print '<td nowrap="nowrap" width="80">';
$userstatic->id=$obj->rowid; $userstatic->id=$obj->rowid;
$userstatic->login=$obj->login; $userstatic->login=$obj->login;
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
print '</td>'; print '</td>';
// Statut // Statut
print '<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($obj->percent,3).'</td>'; print '<td nowrap="nowrap" width="20">'.$actionstatic->LibStatut($obj->percent,3).'</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
$db->free($result); $db->free($result);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print "</table>\n"; print "</table>\n";
print "<br>\n"; print "<br>\n";
} }
}
/**
* \brief Show footer of page for PDF generation
* \param pdf Object PDF
* \param outputlang Object lang for output
* \param paramfreetext Constant name of free text
* \param fromcompany Object company
* \param marge_basse
* \param marge_gauche
* \param page_hauteur
*/
function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur)
{
global $conf;
//$paramfreetext='FACTURE_FREE_TEXT';
// Line of free text
$ligne=(! empty($conf->global->$paramfreetext))?$conf->global->$paramfreetext:"";
// First line of company infos
$ligne1="";
if ($fromcompany->forme_juridique_code)
{
$ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
}
if ($fromcompany->capital)
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$fromcompany->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie);
}
// Prof Id
if ($fromcompany->profid1 && ($fromcompany->pays_code != 'FR' || ! $fromcompany->profid2))
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$fromcompany->pays_code).": ".$fromcompany->profid1;
}
if ($fromcompany->profid2)
{
$ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$fromcompany->pays_code).": ".$fromcompany->profid2;
}
// Second line of company infos
$ligne2="";
if ($fromcompany->profid3)
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$fromcompany->pays_code).": ".$fromcompany->profid3;
}
if ($fromcompany->profid4)
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$fromcompany->pays_code).": ".$fromcompany->profid4;
}
if ($fromcompany->tva_intra != '')
{
$ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
}
$pdf->SetFont('Arial','',7);
$pdf->SetDrawColor(224,224,224);
// On positionne le debut du bas de page selon nbre de lignes de ce bas de page
$posy=$marge_basse + 1 + ($ligne?6:0) + ($ligne1?3:0) + ($ligne2?3:0);
if ($ligne)
{
$pdf->SetXY($marge_gauche,-$posy);
$pdf->MultiCell(190, 3, $ligne, 0, 'L', 0);
$posy-=9; // 6 of ligne + 3 of MultiCell
}
$pdf->SetY(-$posy);
$pdf->line($marge_gauche, $page_hauteur-$posy, 200, $page_hauteur-$posy);
$posy--;
if ($ligne1)
{
$pdf->SetXY($marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0);
}
if ($ligne2)
{
$posy-=3;
$pdf->SetXY($marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0);
}
$pdf->SetXY(-20,-$posy);
$pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
} }
?> ?>

View File

@ -39,16 +39,20 @@ require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
class pdf_typhon extends ModelePDFDeliveryOrder class pdf_typhon extends ModelePDFDeliveryOrder
{ {
var $emetteur; // Objet societe qui emet
/** /**
\brief Constructeur * \brief Constructor
\param db Handler acc<EFBFBD>s base de donn<EFBFBD>e * \param db Database handler
*/ */
function pdf_typhon($db) function pdf_typhon($db)
{ {
global $conf,$langs; global $conf,$langs,$mysoc;
$this->db = $db; $langs->load("main");
$langs->load("bills");
$this->db = $db;
$this->name = "typhon"; $this->name = "typhon";
$this->description = "Modele de bon de livraison complet (logo...)"; $this->description = "Modele de bon de livraison complet (logo...)";
@ -67,10 +71,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->option_modereg = 1; // Gere choix mode reglement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER $this->option_modereg = 1; // Gere choix mode reglement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
$this->franchise=1; $this->franchise=1;
// Recupere code pays de l'emmetteur // Recupere emmetteur
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'<27>tait pas d<>fini $this->emetteur=$mysoc;
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini
$this->tva=array(); $this->tva=array();
@ -271,7 +276,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if ($nexY > 200 && $i < ($nblignes - 1)) if ($nexY > 200 && $i < ($nblignes - 1))
{ {
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY); $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY);
$this->_pagefoot($pdf); $this->_pagefoot($pdf,$outputlangs);
// Nouvelle page // Nouvelle page
$pdf->AddPage(); $pdf->AddPage();
@ -300,7 +305,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
/* /*
* Pied de page * Pied de page
*/ */
$this->_pagefoot($pdf); $this->_pagefoot($pdf,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -518,76 +523,13 @@ class pdf_typhon extends ModelePDFDeliveryOrder
} }
/* /**
* \brief Affiche le pied de page * \brief Affiche le pied de page
* \param pdf objet PDF * \param pdf objet PDF
*/ */
function _pagefoot(&$pdf) function _pagefoot(&$pdf,$outputlangs)
{ {
global $langs, $conf; return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur);
$langs->load("main");
$langs->load("bills");
$langs->load("companies");
// Premiere ligne d'info r<>glementaires
$ligne1="";
if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)
{
$ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE);
}
if ($conf->global->MAIN_INFO_CAPITAL)
{
$ligne1.=($ligne1?" - ":"").$langs->transnoentities("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$langs->transnoentities("Currency".$conf->monnaie);
}
if ($conf->global->MAIN_INFO_SIRET)
{
$ligne1.=($ligne1?" - ":"").$langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_SIRET;
}
if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->pays_code != 'FR'))
{
$ligne1.=($ligne1?" - ":"").$langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_SIREN;
}
if ($conf->global->MAIN_INFO_APE)
{
$ligne1.=($ligne1?" - ":"").$langs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".MAIN_INFO_APE;
}
// Deuxieme ligne d'info reglementaires
$ligne2="";
if ($conf->global->MAIN_INFO_RCS)
{
$ligne2.=($ligne2?" - ":"").$langs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_RCS;
}
if ($conf->global->MAIN_INFO_TVAINTRA != '')
{
$ligne2.=($ligne2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA;
}
$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
$posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0);
$pdf->SetY(-$posy);
$pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy);
$posy--;
if ($ligne1)
{
$pdf->SetXY($this->marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0);
}
if ($ligne2)
{
$posy-=3;
$pdf->SetXY($this->marge_gauche,-$posy);
$pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0);
}
$pdf->SetXY(-20,-$posy);
$pdf->MultiCell(10, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0);
} }
} }