Gestion apercu modele dans page config pour commande fournisseur.

Gestion multilangue sur modele muscadet.
This commit is contained in:
Laurent Destailleur 2007-03-22 23:20:21 +00:00
parent f18fff97e2
commit fc415a0a8e
6 changed files with 609 additions and 417 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
@ -31,6 +31,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.commande.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("bills"); $langs->load("bills");
@ -41,10 +42,37 @@ if (!$user->admin)
accessforbidden(); accessforbidden();
/* /*
* Actions * Actions
*/ */
if ($_GET["action"] == 'specimen')
{
$modele=$_GET["module"];
$facture = new CommandeFournisseur($db);
$facture->initAsSpecimen();
// Charge le modele
$dir = DOL_DOCUMENT_ROOT . "/fourn/commande/modules/pdf/";
$file = "pdf_".$modele.".modules.php";
if (file_exists($dir.$file))
{
$classname = "pdf_".$modele;
require_once($dir.$file);
$obj = new $classname($db);
if ($obj->write_pdf_file($facture,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
return;
}
}
else
{
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
}
}
if ($_GET["action"] == 'set') if ($_GET["action"] == 'set')
{ {

View File

@ -2120,6 +2120,8 @@ class Commande extends CommonObject
{ {
global $user,$langs; global $user,$langs;
dolibarr_syslog("Commande::initAsSpecimen");
// Charge tableau des id de société socids // Charge tableau des id de société socids
$socids = array(); $socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10"; $sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
@ -2194,244 +2196,243 @@ class Commande extends CommonObject
* \class CommandeLigne * \class CommandeLigne
* \brief Classe de gestion des lignes de commande * \brief Classe de gestion des lignes de commande
*/ */
class CommandeLigne class CommandeLigne
{ {
var $db; var $db;
var $error; var $error;
// From llx_commandedet // From llx_commandedet
var $rowid; var $rowid;
var $fk_facture; var $fk_facture;
var $desc; // Description ligne var $desc; // Description ligne
var $fk_product; // Id produit prédéfini var $fk_product; // Id produit prédéfini
var $qty; var $qty;
var $tva_tx; var $tva_tx;
var $subprice; var $subprice;
var $remise_percent; var $remise_percent;
var $rang = 0; var $rang = 0;
var $coef; var $coef;
var $info_bits = 0; // Bit 0: 0 si TVA normal - 1 si TVA NPR var $info_bits = 0; // Bit 0: 0 si TVA normal - 1 si TVA NPR
// Bit 1: 0 ligne normale - 1 si ligne de remise fixe // Bit 1: 0 ligne normale - 1 si ligne de remise fixe
var $total_ht; // Total HT de la ligne toute quantité et incluant la remise ligne var $total_ht; // Total HT de la ligne toute quantité et incluant la remise ligne
var $total_tva; // Total TVA de la ligne toute quantité et incluant la remise ligne var $total_tva; // Total TVA de la ligne toute quantité et incluant la remise ligne
var $total_ttc; // Total TTC de la ligne toute quantité et incluant la remise ligne var $total_ttc; // Total TTC de la ligne toute quantité et incluant la remise ligne
// Ne plus utiliser // Ne plus utiliser
var $remise; var $remise;
var $price; var $price;
// From llx_product // From llx_product
var $ref; // Reference produit var $ref; // Reference produit
var $product_libelle; // Label produit var $product_libelle; // Label produit
var $product_desc; // Description produit var $product_desc; // Description produit
/** /**
* \brief Constructeur d'objets ligne de commande * \brief Constructeur d'objets ligne de commande
* \param DB handler d'accès base de donnée * \param DB handler d'accès base de donnée
*/ */
function CommandeLigne($DB) function CommandeLigne($DB)
{ {
$this->db= $DB ; $this->db= $DB ;
} }
/** /**
* \brief Recupére l'objet ligne de commande * \brief Recupére l'objet ligne de commande
* \param rowid id de la ligne de commande * \param rowid id de la ligne de commande
*/ */
function fetch($rowid) function fetch($rowid)
{ {
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.description, cd.price, cd.qty, cd.tva_tx,'; $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.description, cd.price, cd.qty, cd.tva_tx,';
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc, cd.coef, cd.rang,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc, cd.coef, cd.rang,';
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
$sql.= ' WHERE cd.rowid = '.$rowid; $sql.= ' WHERE cd.rowid = '.$rowid;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid; $this->rowid = $objp->rowid;
$this->fk_propal = $objp->fk_propal; $this->fk_propal = $objp->fk_propal;
$this->desc = $objp->description; $this->desc = $objp->description;
$this->qty = $objp->qty; $this->qty = $objp->qty;
$this->price = $objp->price; $this->price = $objp->price;
$this->subprice = $objp->subprice; $this->subprice = $objp->subprice;
$this->tva_tx = $objp->tva_tx; $this->tva_tx = $objp->tva_tx;
$this->remise = $objp->remise; $this->remise = $objp->remise;
$this->remise_percent = $objp->remise_percent; $this->remise_percent = $objp->remise_percent;
$this->fk_remise_except = $objp->fk_remise_except; $this->fk_remise_except = $objp->fk_remise_except;
$this->produit_id = $objp->fk_product; $this->produit_id = $objp->fk_product;
$this->info_bits = $objp->info_bits; $this->info_bits = $objp->info_bits;
$this->total_ht = $objp->total_ht; $this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva; $this->total_tva = $objp->total_tva;
$this->total_ttc = $objp->total_ttc; $this->total_ttc = $objp->total_ttc;
$this->coef = $objp->coef; $this->coef = $objp->coef;
$this->rang = $objp->rang; $this->rang = $objp->rang;
$this->ref = $objp->product_ref; $this->ref = $objp->product_ref;
$this->product_libelle = $objp->product_libelle; $this->product_libelle = $objp->product_libelle;
$this->product_desc = $objp->product_desc; $this->product_desc = $objp->product_desc;
$this->db->free($result); $this->db->free($result);
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
} }
} }
/** /**
* \brief Supprime la ligne de commande en base * \brief Supprime la ligne de commande en base
* \return int <0 si ko, 0 si ok * \return int <0 si ko, 0 si ok
*/ */
function Delete() function Delete()
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
dolibarr_syslog("CommandeLigne::Delete id=".$this->id); dolibarr_syslog("CommandeLigne::Delete id=".$this->id);
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';"; $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';";
if ($this->db->query($sql) ) if ($this->db->query($sql) )
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('LINEORDER_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('LINEORDER_DELETE',$this,$user,$langs,$conf);
// Fin appel triggers // Fin appel triggers
return 0; return 0;
} }
else else
{ {
dolibarr_syslog("CommandeLigne::Delete id=".$this->id." ERROR SQL $sql"); dolibarr_syslog("CommandeLigne::Delete id=".$this->id." ERROR SQL $sql");
return -1; return -1;
} }
} }
/** /**
* \brief Insère l'objet ligne de commande en base * \brief Insère l'objet ligne de commande en base
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function insert() function insert()
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
dolibarr_syslog("CommandeLigne.class::insert rang=".$this->rang); dolibarr_syslog("CommandeLigne.class::insert rang=".$this->rang);
$this->db->begin(); $this->db->begin();
$rangtouse=$this->rang; $rangtouse=$this->rang;
if ($rangtouse == -1) if ($rangtouse == -1)
{ {
// Récupère rang max de la commande dans $rangmax // Récupère rang max de la commande dans $rangmax
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'commandedet'; $sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'commandedet';
$sql.= ' WHERE fk_commande ='.$this->fk_commande; $sql.= ' WHERE fk_commande ='.$this->fk_commande;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$rangtouse = $obj->max + 1; $rangtouse = $obj->max + 1;
} }
else else
{ {
dolibarr_print_error($this->db); dolibarr_print_error($this->db);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
// Insertion dans base de la ligne // Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
$sql.= ' (fk_commande, description, price, qty, tva_tx,'; $sql.= ' (fk_commande, description, price, qty, tva_tx,';
$sql.= ' fk_product, remise_percent, subprice, remise, fk_remise_except, '; $sql.= ' fk_product, remise_percent, subprice, remise, fk_remise_except, ';
$sql.= ' rang, coef,'; $sql.= ' rang, coef,';
$sql.= ' info_bits, total_ht, total_tva, total_ttc)'; $sql.= ' info_bits, total_ht, total_tva, total_ttc)';
$sql.= " VALUES (".$this->fk_commande.","; $sql.= " VALUES (".$this->fk_commande.",";
$sql.= " '".addslashes($this->desc)."',"; $sql.= " '".addslashes($this->desc)."',";
$sql.= " '".price2num($this->price)."',"; $sql.= " '".price2num($this->price)."',";
$sql.= " '".price2num($this->qty)."',"; $sql.= " '".price2num($this->qty)."',";
$sql.= " '".price2num($this->tva_tx)."',"; $sql.= " '".price2num($this->tva_tx)."',";
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; } if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
else { $sql.='null,'; } else { $sql.='null,'; }
$sql.= " '".price2num($this->remise_percent)."',"; $sql.= " '".price2num($this->remise_percent)."',";
$sql.= " '".price2num($this->subprice)."',"; $sql.= " '".price2num($this->subprice)."',";
$sql.= " '".price2num($this->remise)."',"; $sql.= " '".price2num($this->remise)."',";
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.","; if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
else $sql.= 'null,'; else $sql.= 'null,';
$sql.= ' '.$rangtouse.','; $sql.= ' '.$rangtouse.',';
if (isset($this->coef)) $sql.= ' '.$this->coef.','; if (isset($this->coef)) $sql.= ' '.$this->coef.',';
else $sql.= ' null,'; else $sql.= ' null,';
$sql.= " '".$this->info_bits."',"; $sql.= " '".$this->info_bits."',";
$sql.= " '".price2num($this->total_ht)."',"; $sql.= " '".price2num($this->total_ht)."',";
$sql.= " '".price2num($this->total_tva)."',"; $sql.= " '".price2num($this->total_tva)."',";
$sql.= " '".price2num($this->total_ttc)."'"; $sql.= " '".price2num($this->total_ttc)."'";
$sql.= ')'; $sql.= ')';
dolibarr_syslog("CommandeLigne.class.php::insert sql=$sql"); dolibarr_syslog("CommandeLigne.class.php::insert sql=$sql");
if ($this->fk_product) if ($this->fk_product)
{ {
$product = new Product($this->db); $product = new Product($this->db);
$product->id = $this->fk_product; $product->id = $this->fk_product;
$product->ajust_stock_commande($this->qty, 0); $product->ajust_stock_commande($this->qty, 0);
} }
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('LINEORDER_INSERT',$this,$user,$langs,$conf); $result=$interface->run_triggers('LINEORDER_INSERT',$this,$user,$langs,$conf);
// Fin appel triggers // Fin appel triggers
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dolibarr_syslog("CommandeLigne.class.php::insert Error ".$this->error); dolibarr_syslog("CommandeLigne.class.php::insert Error ".$this->error);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
} }
/** /**
* \brief Mise a jour de l'objet ligne de commande en base * \brief Mise a jour de l'objet ligne de commande en base
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function update_total() function update_total()
{ {
$this->db->begin(); $this->db->begin();
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
$sql.= " total_ht='".price2num($this->total_ht)."'"; $sql.= " total_ht='".price2num($this->total_ht)."'";
$sql.= ",total_tva='".price2num($this->total_tva)."'"; $sql.= ",total_tva='".price2num($this->total_tva)."'";
$sql.= ",total_ttc='".price2num($this->total_ttc)."'"; $sql.= ",total_ttc='".price2num($this->total_ttc)."'";
$sql.= " WHERE rowid = ".$this->rowid; $sql.= " WHERE rowid = ".$this->rowid;
dolibarr_syslog("CommandeLigne.class.php::update_total sql=$sql"); dolibarr_syslog("CommandeLigne.class.php::update_total sql=$sql");
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dolibarr_syslog("CommandeLigne.class.php::update_total Error ".$this->error); dolibarr_syslog("CommandeLigne.class.php::update_total Error ".$this->error);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
} }
} }
?> ?>

View File

@ -30,7 +30,7 @@
\version $Revision$ \version $Revision$
*/ */
require_once(DOL_DOCUMENT_ROOT ."/fourn/commande/modules/modules_commandefournisseur.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/commande/modules/modules_commandefournisseur.php");
require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
@ -49,7 +49,10 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
*/ */
function pdf_muscadet($db) function pdf_muscadet($db)
{ {
global $conf,$langs; global $conf,$langs,$mysoc;
$langs->load("main");
$langs->load("bills");
$this->db = $db; $this->db = $db;
$this->name = "muscadet"; $this->name = "muscadet";
@ -70,24 +73,14 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$this->option_modereg = 1; // Affiche mode règlement $this->option_modereg = 1; // Affiche mode règlement
$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
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
$this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas $this->emetteur=$mysoc;
$sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini
$sql .= " WHERE rowid = '".$conf->global->MAIN_INFO_SOCIETE_PAYS."'";
$result=$this->db->query($sql);
if ($result) {
$obj = $this->db->fetch_object($result);
if ($obj->code) $this->emetteur->code_pays=$obj->code;
}
else {
dolibarr_print_error($this->db);
}
$this->db->free($result);
$this->tva=array();
// Defini position des colonnes // Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1; $this->posxdesc=$this->marge_gauche+1;
@ -97,6 +90,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=177; $this->postotalht=177;
$this->tva=array();
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
$this->atleastonediscount=0; $this->atleastonediscount=0;
} }
@ -129,24 +123,42 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
\remarks MAIN_INFO_TVAINTRA \remarks MAIN_INFO_TVAINTRA
\remarks MAIN_INFO_LOGO \remarks MAIN_INFO_LOGO
*/ */
function write_pdf_file($id) function write_pdf_file($com,$outputlangs='')
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$langs->load("main"); if (! is_object($outputlangs)) $outputlangs=$langs;
$langs->load("bills"); $outputlangs->load("main");
$langs->load("products"); $outputlangs->load("companies");
$langs->load("orders"); $outputlangs->load("bills");
$outputlangs->load("products");
$outputlangs->load("orders");
$outputlangs->setPhpLang();
if ($conf->fournisseur->commande->dir_output) if ($conf->fournisseur->commande->dir_output)
{ {
$com = new CommandeFournisseur($this->db); // Définition de l'objet $com (pour compatibilite ascendante)
$ret=$com->fetch($id); if (! is_object($com))
$nblignes = sizeof($com->lignes); {
$id = $com;
$com = new CommandeFournisseur($this->db);
$ret=$com->fetch($id);
}
$deja_regle = "";
$comref = sanitize_string($com->ref); // Définition de $dir et $file
$dir = $conf->fournisseur->commande->dir_output . "/" . $comref; if ($com->specimen)
$file = $dir . "/" . $comref . ".pdf"; {
$dir = $conf->fournisseur->commande->dir_output;
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$comref = sanitize_string($com->ref);
$dir = $conf->fournisseur->commande->dir_output . "/" . $comref;
$file = $dir . "/" . $comref . ".pdf";
}
if (! file_exists($dir)) if (! file_exists($dir))
{ {
@ -160,6 +172,8 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
if (file_exists($dir)) if (file_exists($dir))
{ {
$nblignes = sizeof($com->lignes);
// Initialisation document vierge // Initialisation document vierge
$pdf=new FPDF('P','mm',$this->format); $pdf=new FPDF('P','mm',$this->format);
$pdf->Open(); $pdf->Open();
@ -168,7 +182,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
$pdf->SetTitle($com->ref); $pdf->SetTitle($com->ref);
$pdf->SetSubject($langs->trans("Bill")); $pdf->SetSubject($outputlangs->transnoentities("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname); $pdf->SetAuthor($user->fullname);
@ -184,12 +198,13 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
} }
} }
$this->_pagehead($pdf, $com); $this->_pagehead($pdf, $com, 1, $outputlangs);
$pagenb = 1; $pagenb = 1;
$tab_top = 90; $tab_top = 90;
$tab_top_newpage = 50; $tab_top_newpage = 50;
$tab_height = 110; $tab_height = 110;
$tab_height_newpage = 180;
$iniY = $tab_top + 8; $iniY = $tab_top + 8;
$curY = $tab_top + 8; $curY = $tab_top + 8;
@ -215,7 +230,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$prodser->fetch($com->lignes[$i]->fk_product); $prodser->fetch($com->lignes[$i]->fk_product);
if ($prodser->ref) if ($prodser->ref)
{ {
$libelleproduitservice=$langs->trans("Product")." ".$prodser->ref." - ".$libelleproduitservice; $libelleproduitservice=$outputlangs->transnoentities("Product")." ".$prodser->ref." - ".$libelleproduitservice;
} }
// Ajoute description du produit // Ajoute description du produit
@ -231,7 +246,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end)
{ {
// Affichage durée si il y en a une // Affichage durée si il y en a une
$libelleproduitservice.="\n(".$langs->trans("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")"; $libelleproduitservice.="\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")";
} }
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page
@ -281,7 +296,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
// Nouvelle page // Nouvelle page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $com, 0); $this->_pagehead($pdf, $com, 0, $outputlangs);
$nexY = $tab_top_newpage + 8; $nexY = $tab_top_newpage + 8;
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -292,18 +307,18 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
// Affiche cadre tableau // Affiche cadre tableau
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$tab_top + $tab_height + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY); $this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY, $outputlangs);
$bottomlasttab=$tab_top_newpage + $tab_height + 1; $bottomlasttab=$tab_top_newpage + $tab_height + 1;
} }
$deja_regle = ""; $deja_regle = "";
$posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab); $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs);
if ($deja_regle) { if ($deja_regle) {
$this->_tableau_versements($pdf, $fac, $posy); $this->_tableau_versements($pdf, $fac, $posy);
@ -317,8 +332,8 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetXY ($this->marge_gauche, 228); $pdf->SetXY ($this->marge_gauche, 228);
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8); $pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans("ErrorNoPaiementModeConfigured"),0,'L',0); $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
$pdf->MultiCell(90, 3, $langs->trans("ErrorCreateBankAccount"),0,'L',0); $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorCreateBankAccount"),0,'L',0);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
} }
@ -414,7 +429,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
/* /*
* Pied de page * Pied de page
*/ */
$this->_pagefoot($pdf); $this->_pagefoot($pdf, $outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -445,12 +460,8 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
* \param deja_regle Montant deja regle * \param deja_regle Montant deja regle
* \return y Position pour suite * \return y Position pour suite
*/ */
function _tableau_tot(&$pdf, $com, $deja_regle, $posy) function _tableau_tot(&$pdf, $com, $deja_regle, $posy, $outputlangs)
{ {
global $langs;
$langs->load("main");
$langs->load("bills");
$tab2_top = $posy; $tab2_top = $posy;
$tab2_hl = 5; $tab2_hl = 5;
$tab2_height = $tab2_hl * 4; $tab2_height = $tab2_hl * 4;
@ -469,7 +480,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
// Total HT // Total HT
$pdf->SetFillColor(256,256,256); $pdf->SetFillColor(256,256,256);
$pdf->SetXY ($col1x, $tab2_top + 0); $pdf->SetXY ($col1x, $tab2_top + 0);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalHT"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + 0); $pdf->SetXY ($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($com->total_ht +$com->remise), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($com->total_ht +$com->remise), 0, 'R', 1);
@ -478,7 +489,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
if ($com->remise > 0) if ($com->remise > 0)
{ {
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("GlobalDiscount"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("GlobalDiscount"), 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl);
$pdf->MultiCell($largcol2, $tab2_hl, "-".$com->remise_percent."%", 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, "-".$com->remise_percent."%", 0, 'R', 1);
@ -506,8 +517,8 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$index++; $index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$tvacompl = ( (float)$tvakey < 0 ) ? " (".$langs->trans("NonPercuRecuperable").")" : '' ; $tvacompl = ( (float)$tvakey < 0 ) ? " (".$outputlangs->transnoentities("NonPercuRecuperable").")" : '' ;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * abs((float)$tvakey) / 100 ), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * abs((float)$tvakey) / 100 ), 0, 'R', 1);
@ -517,7 +528,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
{ {
$index++; $index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($com->total_tva), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($com->total_tva), 0, 'R', 1);
@ -529,7 +540,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(224,224,224); $pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalTTC"), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($com->total_ttc), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($com->total_ttc), $useborder, 'R', 1);
@ -541,7 +552,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$index++; $index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("AlreadyPayed"), 0, 'L', 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
@ -550,7 +561,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
//$pdf->SetFont('Arial','B', 9); //$pdf->SetFont('Arial','B', 9);
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("RemainderToPay"), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($com->total_ttc - $deja_regle), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($com->total_ttc - $deja_regle), $useborder, 'R', 1);
@ -566,16 +577,14 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
* \brief Affiche la grille des lignes de propales * \brief Affiche la grille des lignes de propales
* \param pdf objet PDF * \param pdf objet PDF
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs)
{ {
global $langs,$conf; global $conf;
$langs->load("main");
$langs->load("bills");
// Montants exprimés en (en tab_top - 1) // Montants exprimés en (en tab_top - 1)
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie)); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie));
$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre);
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
@ -588,25 +597,25 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetFont('Arial','',10); $pdf->SetFont('Arial','',10);
$pdf->SetXY ($this->posxdesc-1, $tab_top+2); $pdf->SetXY ($this->posxdesc-1, $tab_top+2);
$pdf->MultiCell(108,2, $langs->trans("Designation"),'','L'); $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxtva-1, $tab_top+2); $pdf->SetXY ($this->posxtva-1, $tab_top+2);
$pdf->MultiCell(12,2, $langs->trans("VAT"),'','C'); $pdf->MultiCell(12,2, $outputlangs->transnoentities("VAT"),'','C');
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxup-1, $tab_top+2); $pdf->SetXY ($this->posxup-1, $tab_top+2);
$pdf->MultiCell(18,2, $langs->trans("PriceUHT"),'','C'); $pdf->MultiCell(18,2, $outputlangs->transnoentities("PriceUHT"),'','C');
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxqty-1, $tab_top+2); $pdf->SetXY ($this->posxqty-1, $tab_top+2);
$pdf->MultiCell(11,2, $langs->trans("Qty"),'','C'); $pdf->MultiCell(11,2, $outputlangs->transnoentities("Qty"),'','C');
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
if ($this->atleastonediscount) if ($this->atleastonediscount)
{ {
$pdf->SetXY ($this->posxdiscount-1, $tab_top+2); $pdf->SetXY ($this->posxdiscount-1, $tab_top+2);
$pdf->MultiCell(16,2, $langs->trans("ReductionShort"),'','C'); $pdf->MultiCell(16,2, $outputlangs->transnoentities("ReductionShort"),'','C');
} }
if ($this->atleastonediscount) if ($this->atleastonediscount)
@ -614,7 +623,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
} }
$pdf->SetXY ($this->postotalht-1, $tab_top+2); $pdf->SetXY ($this->postotalht-1, $tab_top+2);
$pdf->MultiCell(23,2, $langs->trans("TotalHT"),'','C'); $pdf->MultiCell(23,2, $outputlangs->transnoentities("TotalHT"),'','C');
} }
@ -624,14 +633,14 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
* \param fac objet propale * \param fac objet propale
* \param showadress 0=non, 1=oui * \param showadress 0=non, 1=oui
*/ */
function _pagehead(&$pdf, $com, $showadress=1) function _pagehead(&$pdf, $com, $showadress=1, $outputlangs)
{ {
global $langs,$conf,$mysoc; global $langs,$conf,$mysoc;
$langs->load("main"); $outputlangs->load("main");
$langs->load("bills"); $outputlangs->load("bills");
$langs->load("orders"); $outputlangs->load("orders");
$langs->load("companies"); $outputlangs->load("companies");
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13); $pdf->SetFont('Arial','B',13);
@ -652,8 +661,8 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
{ {
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8); $pdf->SetFont('Arial','B',8);
$pdf->MultiCell(100, 3, $langs->trans("ErrorLogoFileNotFound",$logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
$pdf->MultiCell(100, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
} }
} }
else if(defined("MAIN_INFO_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) else if(defined("MAIN_INFO_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM)
@ -664,13 +673,13 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetFont('Arial','B',13); $pdf->SetFont('Arial','B',13);
$pdf->SetXY(100,$posy); $pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Order")." ".$com->ref, '' , 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$com->ref, '' , 'R');
$pdf->SetFont('Arial','',12); $pdf->SetFont('Arial','',12);
$posy+=6; $posy+=6;
$pdf->SetXY(100,$posy); $pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Date")." : " . dolibarr_print_date($com->date,"%d %b %Y"), '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dolibarr_print_date($com->date,"%d %b %Y"), '', 'R');
if ($showadress) if ($showadress)
{ {
@ -680,7 +689,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marge_gauche,$posy-5); $pdf->SetXY($this->marge_gauche,$posy-5);
$pdf->MultiCell(66,5, $langs->trans("BillTo").":"); $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillTo").":");
$pdf->SetXY($this->marge_gauche,$posy); $pdf->SetXY($this->marge_gauche,$posy);
@ -705,17 +714,17 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
} }
$carac_emetteur .= "\n"; $carac_emetteur .= "\n";
// Tel // Tel
if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".FAC_PDF_TEL; if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".FAC_PDF_TEL;
elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".$mysoc->tel; elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$mysoc->tel;
// Fax // Fax
if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".FAC_PDF_FAX; if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".FAC_PDF_FAX;
elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".$mysoc->fax; elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$mysoc->fax;
// EMail // EMail
if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".FAC_PDF_MEL; if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".FAC_PDF_MEL;
elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".$mysoc->email; elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$mysoc->email;
// Web // Web
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW; if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".FAC_PDF_WWW;
elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".$mysoc->url; elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$mysoc->url;
$pdf->SetFont('Arial','',9); $pdf->SetFont('Arial','',9);
$pdf->SetXY($this->marge_gauche+2,$posy+8); $pdf->SetXY($this->marge_gauche+2,$posy+8);
@ -726,7 +735,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$pdf->SetXY(102,$posy-5); $pdf->SetXY(102,$posy-5);
$pdf->MultiCell(80,5, $langs->trans("BillFrom").":"); $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillFrom").":");
// //
$client = new Societe($this->db); $client = new Societe($this->db);
$client->fetch($com->socid); $client->fetch($com->socid);
@ -744,7 +753,7 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
// Caractéristiques client // Caractéristiques client
$carac_client=$com->client->adresse; $carac_client=$com->client->adresse;
$carac_client.="\n".$com->client->cp . " " . $com->client->ville."\n"; $carac_client.="\n".$com->client->cp . " " . $com->client->ville."\n";
if ($com->client->tva_intra) $carac_client.="\n".$langs->trans("VATIntraShort").': '.$com->client->tva_intra; if ($com->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$com->client->tva_intra;
$pdf->SetFont('Arial','',9); $pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8); $pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client); $pdf->MultiCell(86,4, $carac_client);
@ -756,12 +765,9 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
* \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; global $conf;
$langs->load("main");
$langs->load("bills");
$langs->load("companies");
$html=new Form($this->db); $html=new Form($this->db);
@ -773,30 +779,30 @@ class pdf_muscadet extends ModelePDFCommandesSuppliers
} }
if ($conf->global->MAIN_INFO_CAPITAL) if ($conf->global->MAIN_INFO_CAPITAL)
{ {
$ligne1.=($ligne1?" - ":"").$langs->trans("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$langs->trans("Currency".$conf->monnaie); $ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$outputlangs->transnoentities("Currency".$conf->monnaie);
} }
if ($conf->global->MAIN_INFO_SIRET) if ($conf->global->MAIN_INFO_SIRET)
{ {
$ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId2",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIRET; $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId2",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIRET;
} }
if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->code_pays != 'FR')) if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->code_pays != 'FR'))
{ {
$ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId1",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIREN; $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId1",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIREN;
} }
if ($conf->global->MAIN_INFO_APE) if ($conf->global->MAIN_INFO_APE)
{ {
$ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId3",$this->emetteur->code_pays).": ".MAIN_INFO_APE; $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId3",$this->emetteur->code_pays).": ".MAIN_INFO_APE;
} }
// Deuxieme ligne d'info réglementaires // Deuxieme ligne d'info réglementaires
$ligne2=""; $ligne2="";
if ($conf->global->MAIN_INFO_RCS) if ($conf->global->MAIN_INFO_RCS)
{ {
$ligne2.=($ligne2?" - ":"").$langs->transcountry("ProfId4",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_RCS; $ligne2.=($ligne2?" - ":"").$outputlangs->transcountry("ProfId4",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_RCS;
} }
if ($conf->global->MAIN_INFO_TVAINTRA != '') if ($conf->global->MAIN_INFO_TVAINTRA != '')
{ {
$ligne2.=($ligne2?" - ":"").$langs->trans("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA; $ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA;
} }
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);

View File

@ -69,102 +69,103 @@ class CommandeFournisseur extends Commande
/** /**
* Lit une commande * Lit une commande
*/ */
function fetch($id) function fetch($id)
{ {
$sql = "SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,"; $sql = "SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,";
$sql .= " ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet, c.remise_percent, c.source, c.fk_methode_commande,"; $sql .= " ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet, c.remise_percent, c.source, c.fk_methode_commande,";
$sql .= " c.note, c.note_public,"; $sql .= " c.note, c.note_public,";
$sql .= " cm.libelle as methode_commande"; $sql .= " cm.libelle as methode_commande";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande";
$sql .= " WHERE c.rowid = ".$id; $sql .= " WHERE c.rowid = ".$id;
$resql = $this->db->query($sql) ; $resql = $this->db->query($sql) ;
if ($resql) if ($resql)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->fourn_id = $obj->fk_soc; $this->fourn_id = $obj->fk_soc;
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
$this->total_ht = $obj->total_ht; $this->total_ht = $obj->total_ht;
$this->total_tva = $obj->tva; $this->total_tva = $obj->tva;
$this->total_ttc = $obj->total_ttc; $this->total_ttc = $obj->total_ttc;
$this->date_commande = $obj->date_commande; // date à laquelle la commande a été transmise $this->date_commande = $obj->date_commande; // date à laquelle la commande a été transmise
$this->date = $obj->date_creation; $this->date = $obj->date_creation;
$this->remise_percent = $obj->remise_percent; $this->remise_percent = $obj->remise_percent;
$this->methode_commande_id = $obj->fk_methode_commande; $this->methode_commande_id = $obj->fk_methode_commande;
$this->methode_commande = $obj->methode_commande; $this->methode_commande = $obj->methode_commande;
$this->source = $obj->source; $this->source = $obj->source;
$this->facturee = $obj->facture; $this->facturee = $obj->facture;
$this->projet_id = $obj->fk_projet; $this->projet_id = $obj->fk_projet;
$this->note = $obj->note; $this->note = $obj->note;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->db->free(); $this->db->free();
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
// export pdf ----------- // export pdf -----------
$this->lignes = array(); $this->lignes = array();
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,'; $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
$sql.= ' p.label, p.description as product_desc, p.ref, p.rowid as prodid'; $sql.= ' p.label, p.description as product_desc, p.ref, p.rowid as prodid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
$sql.= ' WHERE l.fk_commande = '.$this->id; $sql.= ' WHERE l.fk_commande = '.$this->id;
$sql.= ' ORDER BY l.rowid'; $sql.= ' ORDER BY l.rowid';
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$ligne = new CommandeFournisseurLigne(); $ligne = new CommandeFournisseurLigne();
$ligne->desc = $objp->description; // Description ligne $ligne->desc = $objp->description; // Description ligne
$ligne->qty = $objp->qty; $ligne->qty = $objp->qty;
$ligne->tva_tx = $objp->tva_tx; $ligne->tva_tx = $objp->tva_tx;
$ligne->subprice = $objp->subprice; $ligne->subprice = $objp->subprice;
$ligne->remise_percent = $objp->remise_percent; $ligne->remise_percent = $objp->remise_percent;
$ligne->price = $objp->price; $ligne->price = $objp->price;
$ligne->fk_product = $objp->fk_product; $ligne->fk_product = $objp->fk_product;
$ligne->libelle = $objp->label; // Label produit $ligne->libelle = $objp->label; // Label produit
$ligne->product_desc = $objp->product_desc; // Description produit $ligne->product_desc = $objp->product_desc; // Description produit
$ligne->ref = $objp->ref; $ligne->ref = $objp->ref;
$this->lignes[$i] = $ligne; $this->lignes[$i] = $ligne;
//dolibarr_syslog("1 ".$ligne->desc); //dolibarr_syslog("1 ".$ligne->desc);
//dolibarr_syslog("2 ".$ligne->product_desc); //dolibarr_syslog("2 ".$ligne->product_desc);
$i++; $i++;
} }
$this->db->free($result); $this->db->free($result);
return 0;
}
else
{
$this->error=$this->db->error()." sql=".$sql;
dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error);
return -1;
}
}
else
{
$this->error=$this->db->error()." sql=".$sql;
dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error);
return -1;
}
}
return 0;
}
else
{
$this->error=$this->db->error()." sql=".$sql;
dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error);
return -1;
}
}
else
{
$this->error=$this->db->error()." sql=".$sql;
dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error);
return -1;
}
}
/** /**
* \brief Insère ligne de log * \brief Insère ligne de log
* \param user Utilisateur qui modifie la commande * \param user Utilisateur qui modifie la commande
@ -1278,8 +1279,89 @@ class CommandeFournisseur extends Commande
} }
} }
/**
* \brief Initialise la commande avec valeurs fictives aléatoire
* Sert à générer une commande pour l'aperu des modèles ou demo
*/
function initAsSpecimen()
{
global $user,$langs;
dolibarr_syslog("CommandeFournisseur::initAsSpecimen");
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE fournisseur=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs)
{
$i++;
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
}
// Charge tableau des produits prodids
$prodids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
$resql = $this->db->query($sql);
if ($resql)
{
$num_prods = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_prods)
{
$i++;
$row = $this->db->fetch_row($resql);
$prodids[$i] = $row[0];
}
}
// Initialise paramètres
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$socid = rand(1, $num_socs);
$this->socid = $socids[$socid];
$this->date = time();
$this->date_lim_reglement=$this->date+3600*24*30;
$this->cond_reglement_code = 'RECEP';
$this->mode_reglement_code = 'CHQ';
$this->note_public='SPECIMEN';
$nbp = rand(1, 9);
$xnbp = 0;
while ($xnbp < $nbp)
{
$ligne=new CommandeFournisseurLigne($this->db);
$ligne->desc=$langs->trans("Description")." ".$xnbp;
$ligne->qty=1;
$ligne->subprice=100;
$ligne->price=100;
$ligne->tva_tx=19.6;
$prodid = rand(1, $num_prods);
$ligne->produit_id=$prodids[$prodid];
$this->lignes[$xnbp]=$ligne;
$xnbp++;
}
$this->amount_ht = $xnbp*100;
$this->total_ht = $xnbp*100;
$this->total_tva = $xnbp*19.6;
$this->total_ttc = $xnbp*119.6;
}
} }
/**
* \class CommandeFournisseurLigne
* \brief Classe de gestion des lignes de commande
*/
class CommandeFournisseurLigne extends CommandeLigne class CommandeFournisseurLigne extends CommandeLigne
{ {
// From llx_propaldet // From llx_propaldet

View File

@ -638,5 +638,79 @@ class FactureFournisseur extends Facture
return $result; return $result;
} }
/**
* \brief Initialise la facture avec valeurs fictives aléatoire
* Sert à générer une facture pour l'aperu des modèles ou demo
*/
function initAsSpecimen()
{
global $user,$langs;
// Charge tableau des id de société socids
$socids = array();
$sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE fournisseur=1 LIMIT 10";
$resql = $this->db->query($sql);
if ($resql)
{
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs)
{
$i++;
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
}
// Charge tableau des produits prodids
$prodids = array();
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
$resql = $this->db->query($sql);
if ($resql)
{
$num_prods = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_prods)
{
$i++;
$row = $this->db->fetch_row($resql);
$prodids[$i] = $row[0];
}
}
// Initialise paramètres
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$socid = rand(1, $num_socs);
$this->socid = $socids[$socid];
$this->date = time();
$this->date_lim_reglement=$this->date+3600*24*30;
$this->cond_reglement_code = 'RECEP';
$this->mode_reglement_code = 'CHQ';
$this->note_public='SPECIMEN';
$nbp = 5;
$xnbp = 0;
while ($xnbp < $nbp)
{
$ligne=new FactureLigne($this->db);
$ligne->desc=$langs->trans("Description")." ".$xnbp;
$ligne->qty=1;
$ligne->subprice=100;
$ligne->price=100;
$ligne->tva_tx=19.6;
$prodid = rand(1, $num_prods);
$ligne->produit_id=$prodids[$prodid];
$this->lignes[$xnbp]=$ligne;
$xnbp++;
}
$this->amount_ht = $xnbp*100;
$this->total_ht = $xnbp*100;
$this->total_tva = $xnbp*19.6;
$this->total_ttc = $xnbp*119.6;
}
} }
?> ?>

View File

@ -52,6 +52,7 @@ class pdf_einstein extends ModelePDFCommandes
$langs->load("main"); $langs->load("main");
$langs->load("bills"); $langs->load("bills");
$this->db = $db; $this->db = $db;
$this->name = "einstein"; $this->name = "einstein";
$this->description = $langs->trans('PDFEinsteinDescription'); $this->description = $langs->trans('PDFEinsteinDescription');
@ -139,7 +140,7 @@ class pdf_einstein extends ModelePDFCommandes
{ {
if (create_exdir($dir) < 0) if (create_exdir($dir) < 0)
{ {
$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir); $this->error=$outputlangs->trans("ErrorCanNotCreateDir",$dir);
return 0; return 0;
} }
} }