diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index efe2a43834a..e755a58f2fb 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -22,7 +22,7 @@
* $Source$
*/
-/**
+/**
\file htdocs/admin/facture.php
\ingroup facture
\brief Page d'administration/configuration du module Facture
@@ -96,7 +96,7 @@ if ($_GET["action"] == 'del')
if ($_GET["action"] == 'setdoc')
{
$db->begin();
-
+
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$_GET["value"]))
{
// La constante qui a été lue en avant du nouveau set
@@ -111,7 +111,7 @@ if ($_GET["action"] == 'setdoc')
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);
- if ($result1 && $result2)
+ if ($result1 && $result2)
{
$db->commit();
}
@@ -214,18 +214,18 @@ while (($file = readdir($handle))!==false)
print '
';
echo "$file";
print " \n";
-
+
// Chargement de la classe de numérotation
require_once($dir.$filebis);
$classname = "mod_facture_".$file;
$module = new $classname($db);
print $module->info();
-
+
print ' ';
-
+
// Affiche example
print ''.$module->getExample().' ';
-
+
print '';
if ($conf->global->FACTURE_ADDON == "$file")
{
@@ -236,7 +236,7 @@ while (($file = readdir($handle))!==false)
print ''.$langs->trans("Default").' ';
}
print ' ';
-
+
// Info
$htmltooltip='';
$nextval=$module->getNextValue();
@@ -247,7 +247,7 @@ while (($file = readdir($handle))!==false)
print 'tooltip_properties($htmltooltip).'>';
print ($htmltooltip?img_help(0):'');
print ' ';
-
+
print " \n";
}
}
@@ -306,7 +306,7 @@ while (($file = readdir($handle))!==false)
$var = !$var;
$name = substr($file, 4, strlen($file) -16);
$classname = substr($file, 0, strlen($file) -12);
-
+
print '';
echo "$name";
print " \n";
@@ -315,12 +315,12 @@ while (($file = readdir($handle))!==false)
$module = new $classname($db);
print $module->description;
print ' ';
-
+
// Activé
if (in_array($name, $def))
{
print "\n";
- if ($conf->global->FACTURE_ADDON_PDF != "$name")
+ if ($conf->global->FACTURE_ADDON_PDF != "$name")
{
print '';
print img_tick($langs->trans("Disable"));
@@ -350,7 +350,7 @@ while (($file = readdir($handle))!==false)
print ' '.$langs->trans("Default").' ';
}
print ' ';
-
+
// Info
$htmltooltip = ''.$langs->trans("Type").' : '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip.=''.$langs->trans("Width").' : '.$module->page_largeur;
@@ -410,11 +410,11 @@ if ($conf->banque->enabled)
{
$var=!$var;
$row = $db->fetch_row($resql);
-
+
print 'global->FACTURE_RIB_NUMBER == $row[0] ? ' selected="true"':'';
print '>'.$row[1].' ';
-
+
$i++;
}
print "";
@@ -450,7 +450,7 @@ if ($resql)
{
$var=!$var;
$row = $db->fetch_row($resql);
-
+
print 'global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected="true"':'';
print '>'.$langs->trans("OwnerOfBankAccount",$row[1]).' ';
diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php
index 47e8b29cee4..46a37ed02a4 100644
--- a/htdocs/admin/propale.php
+++ b/htdocs/admin/propale.php
@@ -31,6 +31,7 @@
*/
require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
$langs->load("admin");
$langs->load("bills");
@@ -44,7 +45,32 @@ if (!$user->admin)
/*
* Actions
*/
-
+
+if ($_GET["action"] == 'specimen')
+{
+ $modele=$_GET["module"];
+
+ $propal = new Propal($db);
+ $propal->initAsSpecimen();
+
+ // Charge le modele
+ $dir = DOL_DOCUMENT_ROOT . "/includes/modules/propale/";
+ $file = "pdf_propale_".$modele.".modules.php";
+ if (file_exists($dir.$file))
+ {
+ $classname = "pdf_propale_".$modele;
+ require_once($dir.$file);
+
+ $obj = new $classname($db);
+
+ if ($obj->write_pdf_file($propal) > 0)
+ {
+ header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf");
+ return;
+ }
+ }
+}
+
if ($_POST["action"] == 'nbprod')
{
dolibarr_set_const($db, "PROPALE_NEW_FORM_NB_PRODUCT",$_POST["value"]);
@@ -88,7 +114,7 @@ if ($_GET["action"] == 'del')
if ($_GET["action"] == 'setdoc')
{
$db->begin();
-
+
if (dolibarr_set_const($db, "PROPALE_ADDON_PDF",$_GET["value"]))
{
// La constante qui a été lue en avant du nouveau set
@@ -103,7 +129,7 @@ if ($_GET["action"] == 'setdoc')
$result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES ('".$_GET["value"]."','".$type."')";
$result2=$db->query($sql);
- if ($result1 && $result2)
+ if ($result1 && $result2)
{
$db->commit();
}
@@ -175,7 +201,7 @@ if ($handle)
print ''.$module->nom." \n";
print $module->info();
print ' ';
-
+
// Examples
print ''.$module->getExample()." \n";
@@ -273,7 +299,7 @@ while (($file = readdir($handle))!==false)
if (in_array($name, $def))
{
print "\n";
- if ($conf->global->PROPALE_ADDON_PDF != "$name")
+ if ($conf->global->PROPALE_ADDON_PDF != "$name")
{
print '';
print img_tick($langs->trans("Disable"));
@@ -303,7 +329,7 @@ while (($file = readdir($handle))!==false)
print ' '.$langs->trans("Default").' ';
}
print ' ';
-
+
// Info
$htmltooltip = ''.$langs->trans("Type").' : '.($obj->type?$obj->type:$langs->trans("Unknown"));
$htmltooltip.=''.$langs->trans("Width").' : '.$obj->page_largeur;
@@ -312,7 +338,9 @@ while (($file = readdir($handle))!==false)
$htmltooltip.=''.$langs->trans("Logo").' : '.yn($obj->option_logo);
$htmltooltip.=''.$langs->trans("PaymentMode").' : '.yn($obj->option_modereg);
$htmltooltip.=''.$langs->trans("PaymentConditions").' : '.yn($obj->option_condreg);
- print 'tooltip_properties($htmltooltip).'>'.img_help(0).' ';
+ print 'tooltip_properties($htmltooltip).'>';
+ print ''.img_help(0,0).' ';
+ print ' ';
print " \n";
}
@@ -397,7 +425,7 @@ if ($conf->commande->enabled)
print '';
print '';
print '';
-
+
print ' ';
}
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index a7511458a04..b7892fe7705 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -59,7 +59,7 @@ $month=isset($_GET["month"])?$_GET["month"]:"";
// Sécurité accés client
$socidp='';
if ($_GET["socidp"]) { $socidp=$_GET["socidp"]; }
-if ($user->societe_id > 0)
+if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
@@ -139,10 +139,10 @@ if ($_POST['action'] == 'setdeliveryadress' && $user->rights->propale->creer)
if ($result < 0) dolibarr_print_error($db,$propal->error);
}
-if ($_POST['action'] == 'add')
+if ($_POST['action'] == 'add')
{
$propal = new Propal($db, $_POST['socidp']);
-
+
/*
* Si on seléctionné une propal à copier, on réalise la copie
*/
@@ -180,15 +180,15 @@ if ($_POST['action'] == 'add')
$propal->duree_validite = $_POST['duree_validite'];
$propal->cond_reglement_id = $_POST['cond_reglement_id'];
$propal->mode_reglement_id = $_POST['mode_reglement_id'];
-
+
$propal->contactid = $_POST['contactidp'];
$propal->projetidp = $_POST['projetidp'];
$propal->modelpdf = $_POST['model'];
$propal->author = $user->id;
$propal->note = $_POST['note'];
-
+
$propal->ref = $_POST['ref'];
-
+
for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
{
if ($_POST['idprod'.$i])
@@ -199,7 +199,7 @@ if ($_POST['action'] == 'add')
$propal->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]);
}
}
-
+
$id = $propal->create();
}
/*
@@ -208,7 +208,7 @@ if ($_POST['action'] == 'add')
if ($id > 0)
{
propale_pdf_create($db, $id, $_POST['model']);
-
+
Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$id);
exit;
}
@@ -222,7 +222,7 @@ if ($_POST['action'] == 'add')
/*
* Cloture de la propale
*/
-if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer)
+if ($_POST['action'] == 'setstatut' && $user->rights->propale->cloturer)
{
if (! $_POST['cancel'])
{
@@ -265,25 +265,25 @@ if ($_POST['action'] == 'send')
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message'];
$sendtocc = $_POST['sendtocc'];
-
+
if ($_POST['action'] == 'send')
{
$subject = $_POST['subject'];
-
+
if($subject == '')
{
$subject = $langs->trans('Propal').' '.$propal->ref;
}
-
+
$actiontypeid=3;
$actionmsg ='Mail envoyé par '.$from.' à '.$sendto.'. ';
-
+
if ($message)
{
$actionmsg.='Texte utilisé dans le corps du message: ';
$actionmsg.=$message;
}
-
+
$actionmsg2='Envoi Propal par mail';
}
@@ -357,7 +357,7 @@ if ($_GET['action'] == 'commande')
$propal->create_commande($user);
}
-if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
+if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
{
/*
* Repasse la propale en mode brouillon
@@ -372,7 +372,7 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
{
$propal = new Propal($db);
$ret=$propal->fetch($_POST['propalid']);
-
+
if ($_POST["remise_id"])
{
$propal->insert_discount($_POST["remise_id"]);
@@ -382,23 +382,23 @@ if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
/*
* Ajout d'une ligne produit dans la propale
*/
-if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
+if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
{
if ($_POST['qty'] && (($_POST['np_price']!=0 && $_POST['np_desc']) || $_POST['idprod']))
{
$propal = new Propal($db);
$ret=$propal->fetch($_POST['propalid']);
-
+
if (isset($_POST['np_tva_tx']))
{
$propal->insert_product_generic(
- $_POST['np_desc'],
- $_POST['np_price'],
+ $_POST['np_desc'],
+ $_POST['np_price'],
$_POST['qty'],
$_POST['np_tva_tx'],
$_POST['np_remise']);
}
- else
+ else
{
$propal->insert_product(
$_POST['idprod'],
@@ -410,7 +410,7 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
}
}
-if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save"))
+if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save"))
{
/*
* Mise à jour d'une ligne dans la propale
@@ -433,7 +433,7 @@ if ($_REQUEST['action'] == 'builddoc' && $user->rights->propale->creer)
}
-if ($_GET['action'] == 'del_ligne' && $user->rights->propale->creer && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE)
+if ($_GET['action'] == 'del_ligne' && $user->rights->propale->creer && !$conf->global->PRODUIT_CONFIRM_DELETE_LINE)
{
/*
* Supprime une ligne produit dans la propale
@@ -460,7 +460,7 @@ if ($_POST['action'] == 'set_contact')
// Conditions de règlement
if ($_POST["action"] == 'setconditions')
-{
+{
$propal = new Propal($db, $_GET["propalid"]);
$propal->cond_reglement_id = $_POST['cond_reglement_id'];
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
@@ -546,7 +546,7 @@ if ($_GET['propalid'] > 0)
$html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete');
print ' ';
}
-
+
/*
* Confirmation de la suppression d'une ligne produit
*/
@@ -1490,7 +1490,7 @@ else
if (!$user->rights->commercial->client->voir && !$socidp) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal';
$sql.= ' WHERE p.fk_soc = s.idp';
-
+
if (!$user->rights->commercial->client->voir && !$socidp) //restriction
{
$sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id;
@@ -1508,10 +1508,10 @@ else
$sql .= " AND p.price='".addslashes($_GET['search_montant_ht'])."'";
}
if ($sall) $sql.= " AND (s.nom like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%' OR pd.description like '%".addslashes($sall)."%')";
- if ($socidp) $sql .= ' AND s.idp = '.$socidp;
+ if ($socidp) $sql .= ' AND s.idp = '.$socidp;
if ($_GET['viewstatut'] <> '')
{
- $sql .= ' AND p.fk_statut in ('.$_GET['viewstatut'].')';
+ $sql .= ' AND p.fk_statut in ('.$_GET['viewstatut'].')';
}
if ($month > 0)
{
@@ -1571,7 +1571,7 @@ else
$var=!$var;
print '';
print 'propalid.'">'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref." \n";
-
+
if ($objp->client == 1)
{
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objp->idp;
@@ -1583,18 +1583,18 @@ else
// Société
print ''.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.' ';
-
+
// Date propale
print '';
$y = strftime('%Y',$objp->dp);
$m = strftime('%m',$objp->dp);
-
+
print strftime('%d',$objp->dp)."\n";
print ' ';
print dolibarr_print_date($objp->dp,'%b')." \n";
print ' ';
print strftime('%Y',$objp->dp)." \n";
-
+
// Date fin validite
if ($objp->dfv)
{
@@ -1606,15 +1606,15 @@ else
{
print ' ';
}
-
+
print ''.price($objp->price)." \n";
$propal=New Propal($db);
print ''.$propal->LibStatut($objp->fk_statut,5)." \n";
print " \n";
-
+
$total = $total + $objp->price;
$subtotal = $subtotal + $objp->price;
-
+
$i++;
}
print '';
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index e34bee9c04e..a5a791fad4c 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -48,7 +48,7 @@ class Facture
var $socidp; // Id client
var $client; // Objet societe client (à charger par fetch_client)
-
+
var $number;
var $author;
var $date;
@@ -68,6 +68,14 @@ class Facture
var $mode_reglement_id;
var $mode_reglement_code;
+ // Pour board
+ var $nbtodo;
+ var $nbtodolate;
+
+ var $specimen;
+ var $error;
+
+
/**
* \brief Constructeur de la classe
* \param DB handler accès base de données
@@ -260,7 +268,7 @@ class Facture
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_CREATE',$this,$user,$langs,$conf);
// Fin appel triggers
-
+
$this->db->commit();
return $this->id;
}
@@ -350,15 +358,15 @@ class Facture
$this->commande_id = $obj->fk_commande;
$this->lignes = array();
-
+
if ($this->user_author)
{
$sql = "SELECT name, firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."user";
$sql.= " WHERE rowid = ".$this->user_author;
-
+
$resqluser = $this->db->query($sql);
-
+
if ($resqluser)
{
$obju = $this->db->fetch_object($resqluser);
@@ -366,22 +374,22 @@ class Facture
$this->user_author_firstname = $obju->firstname;
}
}
-
+
if ($this->commande_id)
{
$sql = "SELECT ref";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE rowid = ".$this->commande_id;
-
+
$resqlcomm = $this->db->query($sql);
-
+
if ($resqlcomm)
{
$objc = $this->db->fetch_object($resqlcomm);
$this->commande_ref = $objc->ref;
}
}
-
+
if ($this->statut == 0)
{
$this->brouillon = 1;
@@ -457,12 +465,12 @@ class Facture
$client->fetch($this->socidp);
$this->client = $client;
}
-
+
/**
*
*
*/
-
+
function fetch_contact_facture($id)
{
$idcontact = $id;
@@ -520,7 +528,7 @@ class Facture
function delete($rowid)
{
global $user,$langs,$conf;
-
+
$this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$rowid;
@@ -550,7 +558,7 @@ class Facture
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf);
// Fin appel triggers
-
+
$this->db->commit();
return 1;
}
@@ -622,12 +630,12 @@ class Facture
return -1;
}
$this->db->free($resqltemp);
-
+
/* Definition de la date limite */
-
+
// 1 : ajout du nombre de jours
$datelim = $this->date + ( $cdr_nbjour * 3600 * 24 );
-
+
// 2 : application de la règle "fin de mois"
if ($cdr_fdm)
{
@@ -646,22 +654,22 @@ class Facture
$datelim=mktime(12,0,0,$mois,1,$annee);
$datelim -= (3600 * 24);
}
-
+
// 3 : application du décalage
$datelim += ( $cdr_decalage * 3600 * 24);
-
+
return $datelim;
}
/**
* \brief Tag la facture comme payée complètement + appel trigger BILL_PAYED
- * \param user Objet utilisateur qui modifie
+ * \param user Objet utilisateur qui modifie
* \return int <0 si ok, >0 si ok
*/
function set_payed($user)
{
global $conf,$langs;
-
+
dolibarr_syslog("Facture.class.php::set_payed rowid=".$this->id);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET paye=1 WHERE rowid = '.$this->id ;
@@ -670,20 +678,20 @@ class Facture
if ($resql)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
-
+
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_PAYED',$this,$user,$langs,$conf);
// Fin appel triggers
}
-
+
return 1;
}
-
+
/**
* \brief Tag la facture comme non payée complètement + appel trigger BILL_UNPAYED
- * \param user Objet utilisateur qui modifie
+ * \param user Objet utilisateur qui modifie
* \return int <0 si ok, >0 si ok
*/
function set_unpayed($user)
@@ -698,17 +706,17 @@ class Facture
if ($resql)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
-
+
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_UNPAYED',$this,$user,$langs,$conf);
// Fin appel triggers
}
-
+
return 1;
}
-
+
/**
* \brief Tag la facture comme payer partiellement
* \param rowid id de la facture à modifier
@@ -721,7 +729,7 @@ class Facture
/**
* \brief Tag la facture comme abandonnée + appel trigger BILL_CANCEL
- * \param user Objet utilisateur qui modifie
+ * \param user Objet utilisateur qui modifie
* \return int <0 si ok, >0 si ok
*/
function set_canceled($user)
@@ -758,7 +766,7 @@ class Facture
function set_valid($rowid, $user, $soc, $force_number='')
{
global $conf,$langs;
-
+
$error = 0;
if ($this->brouillon)
{
@@ -829,7 +837,7 @@ class Facture
{
$obj = $this->db->fetch_object($resql);
$avoir=$obj->amount;
-
+
// On met à jour avoir comme affecté à facture
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql.= ' SET fk_facture = '.$this->id.',';
@@ -864,8 +872,8 @@ class Facture
$i++;
}
*/
-
-
+
+
/*
* Pour chaque produit, on met a jour indicateur nbvente
* On crée ici une dénormalisation des données pas forcément utilisée.
@@ -896,7 +904,7 @@ class Facture
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
$this->ref = $numfa;
-
+
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
@@ -926,13 +934,13 @@ class Facture
}
}
}
-
+
/*
*
*
*
*/
-
+
function set_pdf_model($user, $modelpdf)
{
if ($user->rights->facture->creer)
@@ -940,7 +948,7 @@ class Facture
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET model_pdf = '$modelpdf'";
$sql .= " WHERE rowid = $this->id AND fk_statut < 2 ;";
-
+
if ($this->db->query($sql) )
{
return 1;
@@ -1056,7 +1064,7 @@ class Facture
$row = $this->db->fetch_row($resql);
$rangmax = $row[0];
}
-
+
if ($conf->global->PRODUIT_CHANGE_PROD_DESC)
{
if (!$product_desc)
@@ -1071,7 +1079,7 @@ class Facture
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet ';
$sql.= ' (fk_facture, description, price, qty, tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang)';
-
+
if ($conf->global->PRODUIT_CHANGE_PROD_DESC)
{
$sql.= " VALUES ($facid, '".addslashes($product_desc)."','$price','$qty','$txtva',";
@@ -1080,7 +1088,7 @@ class Facture
{
$sql.= " VALUES ($facid, '".addslashes($desc)."','$price','$qty','$txtva',";
}
-
+
if ($fk_product) { $sql.= "'$fk_product',"; }
else { $sql.='0,'; }
$sql.= " '$remise_percent','$subprice','$remise',";
@@ -1322,11 +1330,11 @@ class Facture
function set_remise_absolue($user, $remise)
{
$remise=trim($remise)?trim($remise):0;
-
+
if ($user->rights->facture->creer)
{
$remise=price2num($remise);
-
+
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
$sql.= ' SET remise_absolue = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
@@ -1354,7 +1362,7 @@ class Facture
function getSumTva()
{
$tvs=array();
-
+
$sql = 'SELECT amount, tva_tx FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$this->id;
if ($this->db->query($sql))
{
@@ -1518,22 +1526,22 @@ class Facture
{
global $db, $langs;
$langs->load("bills");
-
+
$dir = DOL_DOCUMENT_ROOT . "/includes/modules/facture/";
-
+
if (defined("FACTURE_ADDON") && FACTURE_ADDON)
{
$file = FACTURE_ADDON."/".FACTURE_ADDON.".modules.php";
-
+
// Chargement de la classe de numérotation
$classname = "mod_facture_".FACTURE_ADDON;
require_once($dir.$file);
-
+
$obj = new $classname();
-
+
$numref = "";
$numref = $obj->getNumRef($soc,$this);
-
+
if ( $numref != "")
{
return $numref;
@@ -1550,7 +1558,7 @@ class Facture
return "";
}
}
-
+
/**
* \brief Mets à jour les commentaires privés
* \param note Commentaire
@@ -1596,7 +1604,7 @@ class Facture
return -1;
}
}
-
+
/**
* \brief Charge les informations de l'onglet info dans l'objet facture
* \param id Id de la facture a charger
@@ -1712,7 +1720,7 @@ class Facture
/**
* \brief Créé une demande de prélèvement
* \param user Utilisateur créant la demande
- * \return int <0 si ko, >0 si ok
+ * \return int <0 si ko, >0 si ok
*/
function demande_prelevement($user)
{
@@ -1967,14 +1975,14 @@ class Facture
if ($fk_socpeople <= 0) return -1;
// Verifie type_contact
- if (! $type_contact || ! is_numeric($type_contact))
+ if (! $type_contact || ! is_numeric($type_contact))
{
$this->error="Valeur pour type_contact incorrect";
- return -3;
+ return -3;
}
-
+
$datecreate = time();
-
+
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
@@ -1982,7 +1990,7 @@ class Facture
$sql.= $this->db->idate($datecreate);
$sql.= ", 4, '". $type_contact . "' ";
$sql.= ")";
-
+
// Retour
if ( $this->db->query($sql) )
{
@@ -1993,7 +2001,7 @@ class Facture
$this->error=$this->db->error()." - $sql";
return -1;
}
- }
+ }
/**
* \brief Mise a jour du contact associé une facture
@@ -2019,16 +2027,16 @@ class Facture
dolibarr_print_error($this->db);
return -1;
}
- }
+ }
- /**
+ /**
* \brief Supprime une ligne de contact
* \param rowid La reference du contact
* \return statur >0 si ok, <0 si ko
*/
function delete_contact($rowid)
{
-
+
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql.= " WHERE rowid =".$rowid;
if ($this->db->query($sql))
@@ -2041,7 +2049,7 @@ class Facture
}
}
- /**
+ /**
* \brief Récupère les lignes de contact de l'objet
* \param statut Statut des lignes detail à récupérer
* \param source Source du contact external (llx_socpeople) ou internal (llx_user)
@@ -2050,11 +2058,11 @@ class Facture
function liste_contact($statut=-1,$source='external')
{
global $langs;
-
+
$element='facture';
$tab=array();
-
+
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
if ($source == 'internal') $sql.=" '-1' as socid,";
if ($source == 'external') $sql.=" t.fk_soc as socid,";
@@ -2075,7 +2083,7 @@ class Facture
if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp";
if ($statut >= 0) $sql.= " AND statut = '$statut'";
$sql.=" ORDER BY t.name ASC";
-
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -2084,7 +2092,7 @@ class Facture
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
-
+
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,
@@ -2101,7 +2109,7 @@ class Facture
}
}
- /**
+ /**
* \brief Le détail d'un contact
* \param rowid L'identifiant du contact
* \return object L'objet construit par DoliDb.fetch_object
@@ -2131,9 +2139,9 @@ class Facture
dolibarr_print_error($this->db);
return null;
}
- }
+ }
- /**
+ /**
* \brief Liste les valeurs possibles de type de contacts pour les factures
* \param source 'internal' ou 'external'
* \return array Tableau des types de contacts
@@ -2141,11 +2149,11 @@ class Facture
function liste_type_contact($source)
{
global $langs;
-
+
$element='facture';
-
+
$tab = array();
-
+
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE element='".$element."'";
@@ -2173,7 +2181,7 @@ class Facture
$this->error=$this->db->error();
return null;
}
- }
+ }
/**
* \brief Retourne id des contacts d'une source et d'un type donné
@@ -2181,14 +2189,14 @@ class Facture
* Exemple: contact client de livraison ('external', 'SHIPPING')
* Exemple: contact interne suivi paiement ('internal', 'SALESREPFOLL')
* \return array Liste des id contacts
- */
+ */
function getIdContact($source,$code)
{
$element='facture'; // Contact sur la facture
-
+
$result=array();
$i=0;
-
+
$sql = "SELECT ec.fk_socpeople";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE ec.element_id = ".$this->id;
@@ -2211,14 +2219,14 @@ class Facture
$this->error=$this->db->error();
return null;
}
-
+
return $result;
- }
+ }
/**
* \brief Retourne id des contacts clients de facturation
* \return array Liste des id contacts facturation
- */
+ */
function getIdBillingContact()
{
return $this->getIdContact('external','BILLING');
@@ -2227,7 +2235,7 @@ class Facture
/**
* \brief Retourne id des contacts clients de livraison
* \return array Liste des id contacts livraison
- */
+ */
function getIdShippingContact()
{
return $this->getIdContact('external','SHIPPING');
@@ -2253,12 +2261,12 @@ class Facture
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";
@@ -2274,7 +2282,7 @@ class Facture
$prodids[$i] = $row[0];
}
}
-
+
// Initialise paramètres
$this->id=0;
$this->ref = 'SPECIMEN';
@@ -2301,7 +2309,7 @@ class Facture
$this->lignes[$xnbp]=$ligne;
$xnbp++;
}
-
+
$this->amount_ht = $xnbp*100;
$this->total_ht = $xnbp*100;
$this->total_tva = $xnbp*19.6;
diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php
index d007da17140..0ce11cd22cb 100644
--- a/htdocs/includes/modules/facture/modules_facture.php
+++ b/htdocs/includes/modules/facture/modules_facture.php
@@ -64,7 +64,7 @@ class ModelePDFFactures extends FPDF
$sql ="SELECT nom as id, nom as lib";
$sql.=" FROM ".MAIN_DB_PREFIX."document_model";
$sql.=" WHERE type = '".$type."'";
-
+
$resql = $db->query($sql);
if ($resql)
{
@@ -189,7 +189,7 @@ function facture_pdf_create($db, $id, $message='', $modele='', $outputlangs='')
else
{
dolibarr_print_error('',"facture_pdf_create Error: ".$obj->error);
- $this->error=$langs->trans("Error")." ".$obj->error;
+ $this->error=$langs->trans("Error")." ".$obj->error;
return -1;
}
@@ -210,17 +210,17 @@ function facture_pdf_create($db, $id, $message='', $modele='', $outputlangs='')
function facture_meta_create($db, $facid, $message="")
{
global $langs,$conf;
-
+
$fac = new Facture($db,"",$facid);
- $fac->fetch($facid);
+ $fac->fetch($facid);
$fac->fetch_client();
-
+
if ($conf->facture->dir_output)
{
- $facref = sanitize_string($fac->ref);
- $dir = $conf->facture->dir_output . "/" . $facref ;
+ $facref = sanitize_string($fac->ref);
+ $dir = $conf->facture->dir_output . "/" . $facref ;
$file = $dir . "/" . $facref . ".meta";
-
+
if (! file_exists($dir))
{
umask(0);
@@ -230,7 +230,7 @@ function facture_meta_create($db, $facid, $message="")
return 0;
}
}
-
+
if (file_exists($dir))
{
$nblignes = sizeof($fac->lignes);
@@ -241,7 +241,7 @@ NB_ITEMS=\"" . $nblignes . "\"
CLIENT=\"" . $client . "\"
TOTAL_HT=\"" . $fac->total_ht . "\"
TOTAL_TTC=\"" . $fac->total_ttc . "\"\n";
-
+
for ($i = 0 ; $i < $nblignes ; $i++) {
//Pour les articles
$meta .= "ITEM_" . $i . "_QUANTITY=\"" . $fac->lignes[$i]->qty . "\"
@@ -268,13 +268,13 @@ function facture_delete_preview($db, $facid)
global $langs,$conf;
$fac = new Facture($db,"",$facid);
- $fac->fetch($facid);
+ $fac->fetch($facid);
$fac->fetch_client();
if ($conf->facture->dir_output)
{
- $facref = sanitize_string($fac->ref);
- $dir = $conf->facture->dir_output . "/" . $facref ;
+ $facref = sanitize_string($fac->ref);
+ $dir = $conf->facture->dir_output . "/" . $facref ;
$file = $dir . "/" . $facref . ".pdf.png";
if ( file_exists( $file ) && is_writable( $file ) )
diff --git a/htdocs/includes/modules/facture/pdf_bernique.modules.php b/htdocs/includes/modules/facture/pdf_bernique.modules.php
index 110a82a964b..f1e9a0eadf8 100644
--- a/htdocs/includes/modules/facture/pdf_bernique.modules.php
+++ b/htdocs/includes/modules/facture/pdf_bernique.modules.php
@@ -32,7 +32,7 @@
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
-/**
+/**
\class pdf_bernique
\brief Classe permettant de générer les factures au modèle Bernique
*/
@@ -40,13 +40,13 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php")
class pdf_bernique extends ModelePDFFactures {
function pdf_bernique($db=0)
- {
+ {
global $langs;
-
+
$langs->load("main");
$langs->load("bills");
$langs->load("products");
-
+
$this->db = $db;
$this->description = $langs->trans('PDFBerniqueDescription');
@@ -65,7 +65,7 @@ class pdf_bernique extends ModelePDFFactures {
function write_pdf_file($fac,$outputlangs='')
{
global $user,$langs,$conf,$mysoc;
-
+
if ($conf->facture->dir_output)
{
// Définition de l'objet $fac (pour compatibilite ascendante)
@@ -88,7 +88,7 @@ class pdf_bernique extends ModelePDFFactures {
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -97,61 +97,61 @@ class pdf_bernique extends ModelePDFFactures {
return 0;
}
}
-
+
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
-
+
$this->_pagehead($pdf, $fac);
-
+
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$tab_top = 100;
$tab_height = 110;
-
+
/*
*
*/
-
+
$pdf->SetFillColor(220,220,220);
-
+
$pdf->SetFont('Arial','', 9);
-
+
$pdf->SetXY (10, $tab_top + 10 );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
-
+
$pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J');
-
+
$nexY = $pdf->GetY();
-
+
$pdf->SetXY (133, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
-
+
$pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C');
-
+
$pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
-
+
$pdf->SetXY (174, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
-
+
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@@ -161,14 +161,14 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
-
+
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$this->_tableau_tot($pdf, $fac, $tab_top, $tab_height);
-
+
$this->_tableau_compl($pdf, $fac);
-
+
/*
*
*/
@@ -178,7 +178,7 @@ class pdf_bernique extends ModelePDFFactures {
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
-
+
$pdf->SetXY (10, 40);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
@@ -192,21 +192,21 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
-
+
/*
*
*
*/
-
+
$pdf->SetFont('Arial','',9);
$pdf->SetXY(10, 260);
$pdf->MultiCell(190, 5, $langs->trans("IntracommunityVATNumber").' : '.MAIN_INFO_TVAINTRA, 0, 'J');
$pdf->MultiCell(190, 5, $langs->trans("PrettyLittleSentence"), 0, 'J');
-
+
$pdf->Close();
-
+
$pdf->Output($file);
-
+
return 1;
}
else
@@ -221,7 +221,7 @@ class pdf_bernique extends ModelePDFFactures {
return 0;
}
}
-
+
/*
*
*
@@ -232,18 +232,18 @@ class pdf_bernique extends ModelePDFFactures {
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$tab3_top = 240;
$tab3_height = 18;
$tab3_width = 60;
-
+
$pdf->Rect(10, $tab3_top, $tab3_width, $tab3_height);
-
+
$pdf->line(10, $tab3_top + 6, $tab3_width+10, $tab3_top + 6 );
$pdf->line(10, $tab3_top + 12, $tab3_width+10, $tab3_top + 12 );
-
+
$pdf->line(30, $tab3_top, 30, $tab3_top + $tab3_height );
-
+
$pdf->SetFont('Arial','',8);
$pdf->SetXY (10, $tab3_top - 6);
$pdf->MultiCell(60, 6, $langs->trans("ExtraInfos"), 0, 'L', 0);
@@ -253,7 +253,7 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->MultiCell(20, 6, $langs->trans("ChequeNumber"), 0, 'L', 0);
$pdf->SetXY (10, $tab3_top + 12);
$pdf->MultiCell(20, 6, $langs->trans("Bank"), 0, 'L', 0);
-
+
/*
* Conditions de règlements
*/
@@ -267,25 +267,25 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->MultiCell(120, 5, $titre.$lib_condition_paiement, 0, 'J');
}
}
-
+
function _tableau_tot(&$pdf, $fac, $top, $height)
{
global $langs;
$langs->load("main");
$langs->load("bills");
-
-
+
+
$tab2_top = $top + $height;
$tab2_hl = 5;
$tab2_height = $tab2_hl * 4;
$pdf->SetFont('Arial','', 9);
-
+
$tvas = $fac->getSumTva();
-
+
$i = 0;
-
+
$tab4_top = $tab2_top + 2 + ($tab2_hl * 2);
-
+
foreach ($tvas as $key => $value)
{
$pdf->SetXY (10, $tab4_top + ( $i * $tab2_hl));
@@ -299,43 +299,43 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->line(10, $tab4_top, 10, $tab4_top + ($tab2_hl * $i));
$pdf->line(35, $tab4_top, 35, $tab4_top + ($tab2_hl * $i));
$pdf->line(55, $tab4_top, 55, $tab4_top + ($tab2_hl * $i));
-
-
+
+
$pdf->Rect(10, $tab2_top, 190, $tab2_hl * 2);
$pdf->line(10, $tab2_top + $tab2_hl, 200, $tab2_top + $tab2_hl);
-
-
+
+
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalHT"), 0, 'R', 0);
-
+
$pdf->SetXY (11, $tab2_top + $tab2_hl);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("Discount")." ". $fac->remise_percent . " %", 0, 'L', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * 2);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("WithDiscountTotalHT"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * 3);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalVAT"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * 4);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalTTC"), 0, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl);
$pdf->MultiCell(26, $tab2_hl, price($fac->remise), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * 2);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ht), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * 3);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * 4);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 1);
}
-
+
/*
*
*/
@@ -344,23 +344,23 @@ class pdf_bernique extends ModelePDFFactures {
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$pdf->SetFont('Arial','',10);
-
+
$pdf->Text(11,$tab_top + 5,$langs->trans("Designation"));
-
+
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->Text(134,$tab_top + 5,$langs->trans("VAT"));
-
+
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->Text(147,$tab_top + 5,$langs->trans("Qty"));
-
+
$pdf->line(156, $tab_top, 156, $tab_top + $tab_height);
$pdf->Text(160,$tab_top + 5,$langs->trans("PriceU"));
-
+
$pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
$pdf->Text(187,$tab_top + 5,$langs->trans("Total"));
-
+
$pdf->Rect(10, $tab_top, 190, $tab_height);
$pdf->line(10, $tab_top + 10, 200, $tab_top + 10 );
}
@@ -375,7 +375,7 @@ class pdf_bernique extends ModelePDFFactures {
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
-
+
$pdf->SetXY(10,5);
if (defined("FAC_PDF_INTITULE"))
{
@@ -383,7 +383,7 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->SetFont('Arial','B',14);
$pdf->MultiCell(60, 8, FAC_PDF_INTITULE, 0, 'L');
}
-
+
$pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE"))
{
@@ -400,7 +400,7 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(40, 5, "SIREN : ".MAIN_INFO_SIREN);
}
-
+
if (defined("FAC_PDF_INTITULE2"))
{
$pdf->SetXY(100,5);
@@ -420,13 +420,13 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->SetXY(102,$pdf->GetY());
$pdf->MultiCell(66,5, $fac->client->adresse . "\n" . $fac->client->cp . " " . $fac->client->ville);
$pdf->rect(100, 40, 100, 40);
-
-
+
+
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',14);
$pdf->Text(11, 88, $langs->trans('Date').' : ' . strftime("%d %b %Y", $fac->date));
$pdf->Text(11, 94, $langs->trans('Invoice').' : '.$fac->ref);
-
+
/*
*/
$pdf->SetTextColor(0,0,0);
@@ -435,7 +435,7 @@ class pdf_bernique extends ModelePDFFactures {
$pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre);
/*
*/
-
+
}
}
diff --git a/htdocs/includes/modules/facture/pdf_bulot.modules.php b/htdocs/includes/modules/facture/pdf_bulot.modules.php
index a66df8d8787..9a1fa86ceef 100644
--- a/htdocs/includes/modules/facture/pdf_bulot.modules.php
+++ b/htdocs/includes/modules/facture/pdf_bulot.modules.php
@@ -41,13 +41,13 @@ class pdf_bulot extends ModelePDFFactures {
\param db handler accès base de donnée
*/
function pdf_bulot($db)
- {
+ {
global $langs;
-
+
$langs->load("main");
$langs->load("bills");
$langs->load("products");
-
+
$this->db = $db;
$this->description = $langs->trans('PDFBulotDescription');
@@ -66,7 +66,7 @@ class pdf_bulot extends ModelePDFFactures {
function write_pdf_file($fac,$outputlangs='')
{
global $user,$langs,$conf,$mysoc;
-
+
if ($conf->facture->dir_output)
{
// Définition de l'objet $fac (pour compatibilite ascendante)
@@ -89,7 +89,7 @@ class pdf_bulot extends ModelePDFFactures {
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -98,61 +98,61 @@ class pdf_bulot extends ModelePDFFactures {
return 0;
}
}
-
+
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
-
+
$this->_pagehead($pdf, $fac);
-
+
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$tab_top = 100;
$tab_height = 110;
-
+
/*
*
*/
-
+
$pdf->SetFillColor(220,220,220);
-
+
$pdf->SetFont('Arial','', 9);
-
+
$pdf->SetXY (10, $tab_top + 10 );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
-
+
$pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J');
-
+
$nexY = $pdf->GetY();
-
+
$pdf->SetXY (133, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
-
+
$pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C');
-
+
$pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
-
+
$pdf->SetXY (174, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
-
+
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@@ -162,14 +162,14 @@ class pdf_bulot extends ModelePDFFactures {
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
-
+
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
-
+
$this->_tableau_tot($pdf, $fac, $tab_top, $tab_height);
-
+
$this->_tableau_compl($pdf, $fac);
-
+
/*
*
*/
@@ -179,7 +179,7 @@ class pdf_bulot extends ModelePDFFactures {
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
-
+
$pdf->SetXY (10, 40);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
@@ -193,25 +193,25 @@ class pdf_bulot extends ModelePDFFactures {
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
-
+
/*
*
*
*/
-
+
$pdf->SetFont('Arial','U',12);
$pdf->SetXY(10, 220);
$titre = $langs->trans("PaymentConditions").' : '.$fac->cond_reglement_facture;
$pdf->MultiCell(190, 5, $titre, 0, 'J');
-
+
$pdf->SetFont('Arial','',9);
$pdf->SetXY(10, 265);
$pdf->MultiCell(190, 5, $langs->trans("PrettyLittleSentence"), 0, 'J');
-
+
$pdf->Close();
-
+
$pdf->Output($file);
-
+
return 1;
}
else
@@ -237,18 +237,18 @@ class pdf_bulot extends ModelePDFFactures {
function _tableau_compl(&$pdf, $fac)
{
global $langs;
-
+
$tab3_top = 240;
$tab3_height = 18;
$tab3_width = 60;
-
+
$pdf->Rect(10, $tab3_top, $tab3_width, $tab3_height);
-
+
$pdf->line(10, $tab3_top + 6, $tab3_width+10, $tab3_top + 6 );
$pdf->line(10, $tab3_top + 12, $tab3_width+10, $tab3_top + 12 );
-
+
$pdf->line(30, $tab3_top, 30, $tab3_top + $tab3_height );
-
+
$pdf->SetFont('Arial','',8);
$pdf->SetXY (10, $tab3_top - 6);
$pdf->MultiCell(60, 6, $langs->trans("ExtraInfos"), 0, 'L', 0);
@@ -271,78 +271,78 @@ class pdf_bulot extends ModelePDFFactures {
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$tab2_top = $top + $height;
$tab2_hl = 5;
$tab2_height = $tab2_hl * 4;
$pdf->SetFont('Arial','', 9);
$pdf->SetFont('Arial','', 9);
-
+
// $pdf->Rect(132, $tab2_top, 68, $tab2_height);
// $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
-
+
// $pdf->line(132, $tab2_top + $tab2_height - 21, 200, $tab2_top + $tab2_height - 21 );
// $pdf->line(132, $tab2_top + $tab2_height - 14, 200, $tab2_top + $tab2_height - 14 );
// $pdf->line(132, $tab2_top + $tab2_height - 7, 200, $tab2_top + $tab2_height - 7 );
-
+
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalHT"), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0);
-
+
if ($fac->remise > 0)
{
$pdf->SetXY (132, $tab2_top + $tab2_hl);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("GlobalDiscount"), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl);
$pdf->MultiCell(26, $tab2_hl, price($fac->remise), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * 2);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("WithDiscountTotalHT"), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * 2);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ht), 0, 'R', 0);
-
+
$index = 3;
}
else
{
$index = 1;
}
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalVAT"), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+1));
$pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalTTC"), 0, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+1));
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 1);
-
+
$deja_regle = $fac->getSommePaiement();
-
+
if ($deja_regle > 0)
{
$pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+2));
$pdf->MultiCell(42, $tab2_hl, $langs->trans("AlreadyPayed"), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+2));
$pdf->MultiCell(26, $tab2_hl, price($deja_regle), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+3));
$pdf->MultiCell(42, $tab2_hl, $langs->trans("RemainderToPay"), 0, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+3));
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc - $deja_regle), 0, 'R', 1);
}
}
-
-
+
+
/*
* \brief Affiche la grille des lignes de factures
* \param pdf objet PDF
@@ -352,23 +352,23 @@ class pdf_bulot extends ModelePDFFactures {
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$pdf->SetFont('Arial','',10);
-
+
$pdf->Text(11,$tab_top + 5,$langs->trans("Designation"));
-
+
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->Text(134,$tab_top + 5,$langs->trans("VAT"));
-
+
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->Text(147,$tab_top + 5,$langs->trans("Qty"));
-
+
$pdf->line(156, $tab_top, 156, $tab_top + $tab_height);
$pdf->Text(160,$tab_top + 5,$langs->trans("PriceU"));
-
+
$pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
$pdf->Text(187,$tab_top + 5,$langs->trans("Total"));
-
+
$pdf->Rect(10, $tab_top, 190, $tab_height);
$pdf->line(10, $tab_top + 10, 200, $tab_top + 10 );
}
@@ -384,7 +384,7 @@ class pdf_bulot extends ModelePDFFactures {
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
-
+
$pdf->SetXY(10,5);
if (defined("FAC_PDF_INTITULE"))
{
@@ -392,7 +392,7 @@ class pdf_bulot extends ModelePDFFactures {
$pdf->SetFont('Arial','B',14);
$pdf->MultiCell(60, 8, FAC_PDF_INTITULE, 0, 'L');
}
-
+
$pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE"))
{
@@ -409,7 +409,7 @@ class pdf_bulot extends ModelePDFFactures {
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(40, 5, "SIREN : ".MAIN_INFO_SIREN);
}
-
+
if (defined("FAC_PDF_INTITULE2"))
{
$pdf->SetXY(100,5);
@@ -429,13 +429,13 @@ class pdf_bulot extends ModelePDFFactures {
$pdf->SetXY(102,$pdf->GetY());
$pdf->MultiCell(66,5, $fac->client->adresse . "\n" . $fac->client->cp . " " . $fac->client->ville);
$pdf->rect(100, 40, 100, 40);
-
-
+
+
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',14);
$pdf->Text(11, 88, $langs->trans('Date').' : ' . strftime("%d %b %Y", $fac->date));
$pdf->Text(11, 94, $langs->trans('Invoice').' : '.$fac->ref);
-
+
/*
*/
$pdf->SetTextColor(0,0,0);
@@ -444,9 +444,9 @@ class pdf_bulot extends ModelePDFFactures {
$pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre);
/*
*/
-
+
}
-
+
}
?>
diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php
index f907a45841d..00093fe704b 100644
--- a/htdocs/includes/modules/facture/pdf_crabe.modules.php
+++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php
@@ -39,7 +39,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
class pdf_crabe extends ModelePDFFactures
{
-
+
/**
\brief Constructeur
\param db Handler accès base de donnée
@@ -47,11 +47,11 @@ class pdf_crabe extends ModelePDFFactures
function pdf_crabe($db)
{
global $conf,$langs;
-
+
$langs->load("main");
$langs->load("bills");
$langs->load("products");
-
+
$this->db = $db;
$this->name = "crabe";
$this->description = $langs->trans('PDFCrabeDescription');
@@ -71,7 +71,7 @@ class pdf_crabe extends ModelePDFFactures
$this->option_modereg = 1; // Affiche mode règlement
$this->option_condreg = 1; // Affiche conditions règlement
$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;
// Recupere code pays de l'emmetteur
@@ -87,9 +87,9 @@ class pdf_crabe extends ModelePDFFactures
dolibarr_print_error($this->db);
}
$this->db->free($result);
-
+
$this->tva=array();
-
+
// Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1;
$this->posxtva=121;
@@ -189,7 +189,7 @@ class pdf_crabe extends ModelePDFFactures
}
$this->_pagehead($pdf, $fac);
-
+
// Affiches lignes
$pagenb = 1;
$tab_top = 90;
@@ -247,7 +247,7 @@ class pdf_crabe extends ModelePDFFactures
$prefix_prodserv = $langs->trans("Product")." ";
if($prodser->type == 1)
$prefix_prodserv = $langs->trans("Service")." ";
-
+
$libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice;
}
@@ -259,7 +259,7 @@ class pdf_crabe extends ModelePDFFactures
if ($libelleproduitservice) $libelleproduitservice.="\n";
$libelleproduitservice.=$fac->lignes[$i]->product_desc;
}
- }
+ }
}
if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) {
@@ -310,7 +310,7 @@ class pdf_crabe extends ModelePDFFactures
{
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY);
$this->_pagefoot($pdf);
-
+
// Nouvelle page
$pdf->AddPage();
$pagenb++;
@@ -328,17 +328,17 @@ class pdf_crabe extends ModelePDFFactures
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$bottomlasttab=$tab_top + $tab_height + 1;
}
- else
+ else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY);
$bottomlasttab=$tab_top_newpage + $tab_height + 1;
}
-
+
$deja_regle = $fac->getSommePaiement();
$posy=$this->_tableau_tot($pdf, $fac, $deja_regle, $bottomlasttab);
- if ($deja_regle) {
+ if ($deja_regle) {
$this->_tableau_versements($pdf, $fac, $posy);
}
@@ -393,7 +393,7 @@ class pdf_crabe extends ModelePDFFactures
$account->fetch($conf->global->FACTURE_RIB_NUMBER);
$this->marges['g']=$this->marge_gauche;
-
+
$cury=242;
$pdf->SetXY ($this->marges['g'], $cury);
$pdf->SetFont('Arial','B',8);
@@ -413,7 +413,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY ($this->marges['g']+60, $cury);
$pdf->MultiCell(13, 3, $langs->trans("BankAccountNumberKey"), 0, 'C', 0);
$pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 );
-
+
$pdf->SetFont('Arial','',8);
$pdf->SetXY ($this->marges['g'], $cury+5);
$pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0);
@@ -423,7 +423,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(24, 3, $account->number, 0, 'C', 0);
$pdf->SetXY ($this->marges['g']+60, $cury+5);
$pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0);
-
+
$pdf->SetXY ($this->marges['g'], $cury+12);
$pdf->MultiCell(90, 3, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+22);
@@ -454,7 +454,7 @@ class pdf_crabe extends ModelePDFFactures
*/
$this->_pagefoot($pdf);
$pdf->AliasNbPages();
-
+
$pdf->Close();
$pdf->Output($file);
@@ -487,7 +487,7 @@ class pdf_crabe extends ModelePDFFactures
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$tab3_posx = 120;
$tab3_top = $posy + 8;
$tab3_width = 80;
@@ -520,7 +520,7 @@ class pdf_crabe extends ModelePDFFactures
while ($i < $num) {
$y+=3;
$row = $this->db->fetch_row();
-
+
$pdf->SetXY ($tab3_posx, $tab3_top+$y );
$pdf->MultiCell(20, 4, strftime("%d/%m/%y",$row[0]), 0, 'L', 0);
$pdf->SetXY ($tab3_posx+21, $tab3_top+$y);
@@ -553,7 +553,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(20, 4, $oper, 0, 'L', 0);
$pdf->SetXY ($tab3_posx+60, $tab3_top+$y);
$pdf->MultiCell(20, 4, $row[3], 0, 'L', 0);
-
+
$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 );
$i++;
@@ -632,12 +632,12 @@ class pdf_crabe extends ModelePDFFactures
if ($tvakey) // On affiche pas taux 0
{
$this->atleastoneratenotnull++;
-
+
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl = ( (float)$tvakey < 0 ) ? " (".$langs->trans("NonPercuRecuperable").")" : '' ;
+ $tvacompl = ( (float)$tvakey < 0 ) ? " (".$langs->trans("NonPercuRecuperable").")" : '' ;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * (float)$tvakey / 100 ), 0, 'R', 1);
}
@@ -653,7 +653,7 @@ class pdf_crabe extends ModelePDFFactures
}
$useborder=0;
-
+
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60);
@@ -668,7 +668,7 @@ class pdf_crabe extends ModelePDFFactures
if ($deja_regle > 0)
{
$index++;
-
+
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("AlreadyPayed"), 0, 'L', 0);
@@ -686,7 +686,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('Arial','', 9);
$pdf->SetTextColor(0,0,0);
}
-
+
/* Ne semble pas requis par la réglementation
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
@@ -705,7 +705,7 @@ class pdf_crabe extends ModelePDFFactures
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
-
+
// Montants exprimés en (en tab_top - 1)
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
@@ -742,7 +742,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY ($this->posxdiscount-1, $tab_top+2);
$pdf->MultiCell(16,2, $langs->trans("ReductionShort"),'','C');
}
-
+
if ($this->atleastonediscount)
{
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
@@ -761,12 +761,12 @@ class pdf_crabe extends ModelePDFFactures
function _pagehead(&$pdf, $fac, $showadress=1)
{
global $langs,$conf,$mysoc;
-
+
$langs->load("main");
$langs->load("bills");
$langs->load("propal");
$langs->load("companies");
-
+
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13);
@@ -800,7 +800,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Invoice")." ".$fac->ref, '' , 'R');
$pdf->SetFont('Arial','',12);
-
+
$posy+=6;
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60);
@@ -820,21 +820,21 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marge_gauche,$posy-5);
$pdf->MultiCell(66,5, $langs->trans("BillFrom").":");
-
-
+
+
$pdf->SetXY($this->marge_gauche,$posy);
$pdf->SetFillColor(230,230,230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
-
-
+
+
$pdf->SetXY($this->marge_gauche+2,$posy+3);
-
+
// Nom emetteur
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',11);
if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L');
else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L');
-
+
// Caractéristiques emetteur
$carac_emetteur = '';
if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE;
@@ -855,11 +855,11 @@ class pdf_crabe extends ModelePDFFactures
// Web
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW;
elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".$mysoc->url;
-
+
$pdf->SetFont('Arial','',9);
$pdf->SetXY($this->marge_gauche+2,$posy+8);
$pdf->MultiCell(80,4, $carac_emetteur);
-
+
// Client destinataire
$posy=42;
$pdf->SetTextColor(0,0,0);
@@ -869,12 +869,12 @@ class pdf_crabe extends ModelePDFFactures
$fac->fetch_client();
// Cadre client destinataire
$pdf->rect(100, $posy, 100, $hautcadre);
-
+
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $fac->client->nom, 0, 'L');
-
+
// Caractéristiques client
$carac_client=$fac->client->adresse;
$carac_client.="\n".$fac->client->cp . " " . $fac->client->ville."\n";
@@ -883,7 +883,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
}
-
+
}
/*
@@ -896,9 +896,9 @@ class pdf_crabe extends ModelePDFFactures
$langs->load("main");
$langs->load("bills");
$langs->load("companies");
-
+
$html=new Form($this->db);
-
+
// Premiere ligne d'info réglementaires
$ligne1="";
if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)
@@ -942,7 +942,7 @@ class pdf_crabe extends ModelePDFFactures
$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);
@@ -955,7 +955,7 @@ class pdf_crabe extends ModelePDFFactures
$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);
}
diff --git a/htdocs/includes/modules/facture/pdf_huitre.modules.php b/htdocs/includes/modules/facture/pdf_huitre.modules.php
index 1e6fbbc0253..93b014416b0 100644
--- a/htdocs/includes/modules/facture/pdf_huitre.modules.php
+++ b/htdocs/includes/modules/facture/pdf_huitre.modules.php
@@ -50,7 +50,7 @@ class pdf_huitre extends ModelePDFFactures {
$langs->load("bills");
$langs->load("products");
-
+
$this->db = $db;
$this->name = "huitre";
$this->description = $langs->trans('PDFHuitreDescription');
@@ -71,7 +71,7 @@ class pdf_huitre extends ModelePDFFactures {
function write_pdf_file($fac,$outputlangs='')
{
global $user,$langs,$conf,$mysoc;
-
+
if ($conf->facture->dir_output)
{
// Définition de l'objet $fac (pour compatibilite ascendante)
@@ -94,7 +94,7 @@ class pdf_huitre extends ModelePDFFactures {
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -103,16 +103,16 @@ class pdf_huitre extends ModelePDFFactures {
return 0;
}
}
-
+
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
-
+
$this->_pagehead($pdf, $fac);
-
+
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr (By ADYTEK)".DOL_VERSION);
@@ -121,41 +121,41 @@ class pdf_huitre extends ModelePDFFactures {
$pdf->SetAutoPageBreak(1,0);
$tab_top = 100;
$tab_height = 110;
-
+
$pdf->SetFillColor(242,239,119);
-
+
$pdf->SetFont('Arial','', 9);
-
+
$pdf->SetXY (10, $tab_top + 10 );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
-
+
// Boucle sur les lignes de factures
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
-
+
$pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J');
-
+
$nexY = $pdf->GetY();
-
+
$pdf->SetXY (133, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
-
+
$pdf->SetXY (145, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C');
-
+
$pdf->SetXY (156, $curY);
$pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
-
+
$pdf->SetXY (174, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
-
+
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@@ -165,14 +165,14 @@ class pdf_huitre extends ModelePDFFactures {
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
-
+
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
-
+
$this->_tableau_tot($pdf, $fac);
-
+
$this->_tableau_compl($pdf, $fac);
-
+
/*
*
*/
@@ -182,7 +182,7 @@ class pdf_huitre extends ModelePDFFactures {
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
-
+
$pdf->SetXY (10, 40);
$pdf->SetFont('Arial','U',8);
$pdf->MultiCell(40, 4, $langs->trans("BankDetails"), 0, 'L', 0);
@@ -196,12 +196,12 @@ class pdf_huitre extends ModelePDFFactures {
$pdf->MultiCell(40, 4, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
-
+
/*
*
*
*/
-
+
if ( $fac->note_public)
{
$pdf->SetFont('Arial','',7);
@@ -209,12 +209,12 @@ class pdf_huitre extends ModelePDFFactures {
$note = $langs->trans("Note").' : '.$fac->note_public;
$pdf->MultiCell(110, 3, $note, 0, 'J');
}
-
+
$pdf->SetFont('Arial','U',11);
$pdf->SetXY(10, 225);
$titre = $langs->trans("PaymentConditions").' : '.$fac->cond_reglement_facture;
$pdf->MultiCell(190, 5, $titre, 0, 'J');
-
+
$pdf->SetFont('Arial','',6);
$pdf->SetXY(10, 265);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart1'), 0, 'J');
@@ -224,27 +224,27 @@ class pdf_huitre extends ModelePDFFactures {
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart3'), 0, 'J');
$pdf->SetXY(10, 271);
$pdf->MultiCell(90, 2, $langs->trans('LawApplicationPart4'), 0, 'J');
-
+
$pdf->SetFont('Arial','',7);
$pdf->SetXY(85, 271);
$pdf->MultiCell(90, 3, $langs->trans('VATDischarged'), 0, 'J');
-
+
$this->_pagefoot($pdf, $fac);
$pdf->AliasNbPages();
//----
$pdf->SetTextColor(0,0,0);
$pdf->SetFillColor(242,239,119);
-
+
$pdf->SetLineWidth(0.5);
-
-
-
-
-
+
+
+
+
+
$pdf->Close();
-
+
$pdf->Output($file);
-
+
return 1; // Pas d'erreur
}
else
@@ -261,8 +261,8 @@ class pdf_huitre extends ModelePDFFactures {
$this->error=$langs->trans("ErrorUnknown");
return 0; // Erreur par defaut
}
-
-
+
+
/*
*
*
@@ -312,18 +312,18 @@ class pdf_huitre extends ModelePDFFactures {
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$tab3_top = 240;
$tab3_height = 18;
$tab3_width = 60;
-
+
$pdf->Rect(10, $tab3_top, $tab3_width, $tab3_height);
$pdf->line(10, $tab3_top + 6, $tab3_width+10, $tab3_top + 6 );
$pdf->line(10, $tab3_top + 12, $tab3_width+10, $tab3_top + 12 );
-
+
$pdf->line(40, $tab3_top, 40, $tab3_top + $tab3_height );
-
+
$pdf->SetFont('Arial','',8);
$pdf->SetXY (10, $tab3_top - 6);
$pdf->MultiCell(60, 6, $langs->trans("ExtraInfos"), 0, 'L', 0);
@@ -345,15 +345,15 @@ class pdf_huitre extends ModelePDFFactures {
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$tab2_top = 212;
$tab2_hl = 5;
$tab2_height = $tab2_hl * 4;
$pdf->SetFont('Arial','', 9);
-
+
// $pdf->Rect(132, $tab2_top, 68, $tab2_height);
// $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
-
+
// $pdf->line(132, $tab2_top + $tab2_height - 21, 200, $tab2_top + $tab2_height - 21 );
// $pdf->line(132, $tab2_top + $tab2_height - 14, 200, $tab2_top + $tab2_height - 14 );
// $pdf->line(132, $tab2_top + $tab2_height - 7, 200, $tab2_top + $tab2_height - 7 );
@@ -390,10 +390,10 @@ class pdf_huitre extends ModelePDFFactures {
$pdf->SetXY (174, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+1));
$pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalTTC"), 0, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+1));
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 1);
@@ -423,14 +423,14 @@ class pdf_huitre extends ModelePDFFactures {
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$pdf->SetFont('Arial','',10);
-
+
$pdf->Text(11,$tab_top + 5,$langs->trans("Designation"));
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->Text(134,$tab_top + 5,$langs->trans("VAT"));
-
+
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->Text(147,$tab_top + 5,$langs->trans("Qty"));
@@ -439,7 +439,7 @@ class pdf_huitre extends ModelePDFFactures {
$pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
$pdf->Text(187,$tab_top + 5,$langs->trans("Total"));
-
+
$pdf->Rect(10, $tab_top, 190, $tab_height);
$pdf->line(10, $tab_top + 10, 200, $tab_top + 10 );
}
@@ -531,7 +531,7 @@ class pdf_huitre extends ModelePDFFactures {
*/
$pdf->SetTextColor(0,0,0);
$pdf->SetFillColor(242,239,119);
-
+
// $this->RoundedRect(100, 40, 100, 40, 3, 'F');
$pdf->rect(100, 40, 100, 40, 'F');
$pdf->SetFont('Arial','B',12);
diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php
index fd0a5853126..df1afc90e89 100644
--- a/htdocs/includes/modules/facture/pdf_oursin.modules.php
+++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php
@@ -41,8 +41,8 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php")
class pdf_oursin extends ModelePDFFactures
{
var $marges=array("g"=>10,"h"=>5,"d"=>10,"b"=>15);
-
-
+
+
/**
\brief Constructeur
\param db handler accès base de donnée
@@ -50,7 +50,7 @@ class pdf_oursin extends ModelePDFFactures
function pdf_oursin($db)
{
global $conf,$langs;
-
+
$langs->load("main");
$langs->load("bills");
$langs->load("products");
@@ -71,7 +71,7 @@ class pdf_oursin extends ModelePDFFactures
$this->option_codeproduitservice = 1; // Affiche code produit-service FACTURE_CODEPRODUITSERVICE
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
$this->franchise=1;
-
+
// Recupere code pays de l'emmetteur
$this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas
$sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays";
@@ -111,11 +111,11 @@ class pdf_oursin extends ModelePDFFactures
function write_pdf_file($fac,$outputlangs='')
{
global $user,$langs,$conf,$mysoc;
-
+
$langs->load("main");
$langs->load("bills");
$langs->load("products");
-
+
if ($conf->facture->dir_output)
{
// Définition de l'objet $fac (pour compatibilite ascendante)
@@ -138,7 +138,7 @@ class pdf_oursin extends ModelePDFFactures
$dir = $conf->facture->dir_output . "/" . $facref;
$file = $dir . "/" . $facref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -147,49 +147,49 @@ class pdf_oursin extends ModelePDFFactures
return 0;
}
}
-
+
if (file_exists($dir))
{
// Initialisation facture vierge
$pdf=new FPDF('P','mm',$this->format);
$pdf->Open();
$pdf->AddPage();
-
+
$this->_pagehead($pdf, $fac);
-
+
$pdf->SetTitle($fac->ref);
$pdf->SetSubject($langs->trans("Invoice"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$pdf->SetMargins(10, 10, 10);
$pdf->SetAutoPageBreak(1,0);
-
+
$tab_top = $this->marges['h']+90;
$tab_height = 110;
-
+
$pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9);
$pdf->SetXY ($this->marges['g'], $tab_top + $this->marges['g'] );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes);
-
+
// Boucle sur les lignes de factures
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
-
+
// Description produit
$codeproduitservice="";
$pdf->SetXY ($this->marges['g']+ 1, $curY );
if (defined("FACTURE_CODEPRODUITSERVICE") && FACTURE_CODEPRODUITSERVICE) {
// Affiche code produit si ligne associée à un code produit
-
+
$prodser = new Product($this->db);
-
+
$prodser->fetch($fac->lignes[$i]->produit_id);
if ($prodser->ref) {
$codeproduitservice=" - ".$langs->trans("ProductCode")." ".$prodser->ref;
@@ -200,9 +200,9 @@ class pdf_oursin extends ModelePDFFactures
$codeproduitservice.=" (".$langs->trans("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")";
}
$pdf->MultiCell(108, 5, $fac->lignes[$i]->desc."$codeproduitservice", 0, 'J');
-
+
$nexY = $pdf->GetY();
-
+
// TVA
if ($this->franchise!=1)
{
@@ -212,23 +212,23 @@ class pdf_oursin extends ModelePDFFactures
// Prix unitaire HT avant remise
$pdf->SetXY ($this->marges['g']+132, $curY);
$pdf->MultiCell(16, 5, price($fac->lignes[$i]->subprice), 0, 'R', 0);
-
+
// Quantit
$pdf->SetXY ($this->marges['g']+150, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'R');
-
+
// Remise sur ligne
$pdf->SetXY ($this->marges['g']+160, $curY);
if ($fac->lignes[$i]->remise_percent) {
$pdf->MultiCell(14, 5, $fac->lignes[$i]->remise_percent."%", 0, 'R');
}
-
+
// Total HT
$pdf->SetXY ($this->marges['g']+168, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(21, 5, $total, 0, 'R', 0);
-
-
+
+
if ($nexY > 200 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac);
@@ -238,18 +238,18 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
-
+
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac);
-
+
$deja_regle = $fac->getSommePaiement();
-
+
$this->_tableau_tot($pdf, $fac, $deja_regle);
-
+
if ($deja_regle) {
$this->_tableau_versements($pdf, $fac);
}
-
+
/*
* Mode de règlement
*/
@@ -261,7 +261,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->MultiCell(90, 3, $langs->trans("ErrorCreateBankAccount"),0,'L',0);
$pdf->SetTextColor(0,0,0);
}
-
+
/*
* Propose mode règlement par CHQ
*/
@@ -271,7 +271,7 @@ class pdf_oursin extends ModelePDFFactures
{
$account = new Account($this->db);
$account->fetch(FACTURE_CHQ_NUMBER);
-
+
$pdf->SetXY ($this->marges['g'], 225);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, $langs->trans('PaymentByChequeOrderedTo').' '.$account->proprio.' '.$langs->trans('SendTo').':',0,'L',0);
@@ -280,7 +280,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0);
}
}
-
+
/*
* Propose mode règlement par RIB
*/
@@ -290,7 +290,7 @@ class pdf_oursin extends ModelePDFFactures
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
-
+
$cury=240;
$pdf->SetXY ($this->marges['g'], $cury);
$pdf->SetFont('Arial','B',8);
@@ -310,7 +310,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY ($this->marges['g']+60, $cury);
$pdf->MultiCell(13, 3, $langs->trans("BankAccountNumberKey"), 0, 'C', 0);
$pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 );
-
+
$pdf->SetFont('Arial','',8);
$pdf->SetXY ($this->marges['g'], $cury+5);
$pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0);
@@ -320,7 +320,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->MultiCell(24, 3, $account->number, 0, 'C', 0);
$pdf->SetXY ($this->marges['g']+60, $cury+5);
$pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0);
-
+
$pdf->SetXY ($this->marges['g'], $cury+15);
$pdf->MultiCell(90, 3, $langs->trans("Residence").' : ' . $account->domiciliation, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+25);
@@ -329,7 +329,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->MultiCell(90, 3, $langs->trans("BIC").' : ' . $account->bic, 0, 'L', 0);
}
}
-
+
/*
* Conditions de règlements
*/
@@ -343,17 +343,17 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetXY($this->marges['g']+44, 217);
$pdf->MultiCell(80, 5, $fac->cond_reglement_facture,0,'L');
}
-
+
/*
* Pied de page
*/
$this->_pagefoot($pdf, $fac);
$pdf->AliasNbPages();
-
+
$pdf->Close();
-
+
$pdf->Output($file);
-
+
return 1; // Pas d'erreur
}
else
@@ -382,7 +382,7 @@ class pdf_oursin extends ModelePDFFactures
global $langs;
$langs->load("main");
$langs->load("bills");
-
+
$tab3_posx = $this->marges['g']+110;
$tab3_top = $this->marges['h']+235;
$tab3_width = 80;
@@ -415,7 +415,7 @@ class pdf_oursin extends ModelePDFFactures
while ($i < $num) {
$y+=3;
$row = $this->db->fetch_row();
-
+
$pdf->SetXY ($tab3_posx, $tab3_top+$y );
$pdf->MultiCell(20, 4, strftime("%d/%m/%y",$row[0]), 0, 'L', 0);
$pdf->SetXY ($tab3_posx+21, $tab3_top+$y);
@@ -448,7 +448,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->MultiCell(20, 4, $oper, 0, 'L', 0);
$pdf->SetXY ($tab3_posx+60, $tab3_top+$y);
$pdf->MultiCell(20, 4, $row[3], 0, 'L', 0);
-
+
$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 );
$i++;
@@ -558,7 +558,7 @@ class pdf_oursin extends ModelePDFFactures
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 );
@@ -572,8 +572,8 @@ class pdf_oursin extends ModelePDFFactures
$nblignes = sizeof($fac->lignes);
$rem=0;
for ($i = 0 ; $i < $nblignes ; $i++)
- if ($fac->lignes[$i]->remise_percent)
- {
+ if ($fac->lignes[$i]->remise_percent)
+ {
$rem=1;
}
if ($rem==1)
@@ -595,7 +595,7 @@ class pdf_oursin extends ModelePDFFactures
$langs->load("bills");
$langs->load("propal");
$langs->load("companies");
-
+
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13);
@@ -603,15 +603,15 @@ class pdf_oursin extends ModelePDFFactures
// Logo
$logo=$conf->societe->dir_logos.'/'.$mysoc->logo;
- if ($mysoc->logo)
+ if ($mysoc->logo)
{
- if (is_readable($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
+ else
{
$pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8);
@@ -632,7 +632,7 @@ class pdf_oursin extends ModelePDFFactures
$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);
@@ -652,7 +652,7 @@ class pdf_oursin extends ModelePDFFactures
{
$pdf->MultiCell(80, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L');
}
-
+
// Caractéristiques emetteur
$pdf->SetFont('Arial','',9);
if (defined("FAC_PDF_ADRESSE"))
@@ -722,7 +722,7 @@ class pdf_oursin extends ModelePDFFactures
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(60, 4, $langs->trans("Project")." : ".$projet->title);
}
-
+
/*
* ref propal
*/
@@ -734,8 +734,8 @@ class pdf_oursin extends ModelePDFFactures
$objp = $fac->db->fetch_object();
$pdf->SetFont('Arial','',9);
$pdf->MultiCell(60, 4, $langs->trans("RefProposal")." : ".$objp->ref);
- }
-
+ }
+
/*
* monnaie
*/
@@ -759,7 +759,7 @@ class pdf_oursin extends ModelePDFFactures
$langs->load("main");
$langs->load("bills");
$langs->load("companies");
-
+
$footy=13;
$pdf->SetFont('Arial','',8);
diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php
index 740a7a95bf1..a6f07caa15a 100644
--- a/htdocs/includes/modules/propale/modules_propale.php
+++ b/htdocs/includes/modules/propale/modules_propale.php
@@ -21,7 +21,7 @@
* $Source$
*/
-/**
+/**
\file htdocs/includes/modules/propale/modules_propale.php
\ingroup propale
\brief Fichier contenant la classe mère de generation des propales en PDF
@@ -40,16 +40,16 @@ require_once(FPDF_PATH.'fpdf.php');
class ModelePDFPropales extends FPDF
{
var $error='';
-
- /**
+
+ /**
* \brief Renvoi le dernier message d'erreur de création de propale
*/
function pdferror()
{
return $this->error;
}
-
- /**
+
+ /**
* \brief Renvoi la liste des modèles actifs
*/
function liste_modeles($db)
@@ -59,7 +59,7 @@ class ModelePDFPropales extends FPDF
$sql ="SELECT nom as id, nom as lib";
$sql.=" FROM ".MAIN_DB_PREFIX."document_model";
$sql.=" WHERE type = '".$type."'";
-
+
$resql = $db->query($sql);
if ($resql)
{
@@ -128,7 +128,7 @@ class ModeleNumRefPropales
global $langs;
return $langs->trans("NotAvailable");
}
-
+
}
@@ -206,14 +206,14 @@ function propale_delete_preview($db, $propalid, $propalref='')
$propal->fetch($propalid);
$propalref = $propal->ref;
}
-
+
if ($conf->propal->dir_output)
{
$propref = sanitize_string($propalref);
$dir = $conf->propal->dir_output . "/" . $propalref ;
$file = $dir . "/" . $propalref . ".pdf.png";
$multiple = $file . ".";
-
+
if ( file_exists( $file ) && is_writable( $file ) )
{
if ( ! unlink($file) )
@@ -227,7 +227,7 @@ function propale_delete_preview($db, $propalid, $propalref='')
for ($i = 0; $i < 20; $i++)
{
$preview = $multiple.$i;
-
+
if ( file_exists( $preview ) && is_writable( $preview ) )
{
if ( ! unlink($preview) )
diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
index 705c0b110da..5e95fc93cb5 100644
--- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php
@@ -40,7 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
class pdf_propale_azur extends ModelePDFPropales
{
-
+
/**
\brief Constructeur
\param db Handler accès base de donnée
@@ -49,6 +49,10 @@ class pdf_propale_azur extends ModelePDFPropales
{
global $conf,$langs;
+ $langs->load("main");
+ $langs->load("bills");
+ $langs->load("products");
+
$this->db = $db;
$this->name = "azur";
$this->description = "Modèle de propositions commerciales complet (logo...)";
@@ -62,13 +66,13 @@ class pdf_propale_azur extends ModelePDFPropales
$this->marge_droite=10;
$this->marge_haute=10;
$this->marge_basse=10;
-
+
$this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode règlement
$this->option_condreg = 1; // Affiche conditions règlement
$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;
// Recupere code pays de l'emmetteur
@@ -94,7 +98,7 @@ class pdf_propale_azur extends ModelePDFPropales
$this->posxqty=151;
$this->posxdiscount=162;
$this->postotalht=177;
-
+
$this->atleastoneratenotnull=0;
$this->atleastonediscount=0;
}
@@ -103,7 +107,7 @@ class pdf_propale_azur extends ModelePDFPropales
\brief Renvoi dernière erreur
\return string Dernière erreur
*/
- function pdferror()
+ function pdferror()
{
return $this->error;
}
@@ -127,10 +131,10 @@ class pdf_propale_azur extends ModelePDFPropales
\remarks MAIN_INFO_CAPITAL
\remarks MAIN_INFO_TVAINTRA
*/
- function write_pdf_file($propale)
+ function write_pdf_file($propale,$outputlangs='')
{
- global $user,$conf,$langs;
-
+ global $user,$conf,$langs,$mysoc;
+
if ($conf->propal->dir_output)
{
// Définition de l'objet $propale (pour compatibilite ascendante)
@@ -140,7 +144,7 @@ class pdf_propale_azur extends ModelePDFPropales
$propale = new Propal($this->db,"",$id);
$ret=$propale->fetch($id);
}
-
+
// Définition de $dir et $file
if ($propale->specimen)
{
@@ -153,7 +157,7 @@ class pdf_propale_azur extends ModelePDFPropales
$dir = $conf->propal->dir_output . "/" . $propref;
$file = $dir . "/" . $propref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -162,24 +166,26 @@ class pdf_propale_azur extends ModelePDFPropales
return 0;
}
}
-
+
if (file_exists($dir))
{
+ $nblignes = sizeof($propale->lignes);
+
// Initialisation document vierge
$pdf=new FPDF('P','mm',$this->format);
$pdf->Open();
$pdf->AddPage();
-
+
$pdf->SetDrawColor(128,128,128);
-
+
$pdf->SetTitle($propale->ref);
$pdf->SetSubject($langs->trans("Bill"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
-
+
// Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++)
{
@@ -188,30 +194,30 @@ class pdf_propale_azur extends ModelePDFPropales
$this->atleastonediscount++;
}
}
-
+
$this->_pagehead($pdf, $propale);
-
+
// Affiches lignes
$pagenb = 1;
$tab_top = 90;
$tab_top_newpage = 50;
$tab_height = 110;
-
+
// Affiche notes
if ($propale->note_public)
{
$tab_top = 88;
-
+
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page
$pdf->SetXY ($this->posxdesc-1, $tab_top);
$pdf->MultiCell(190, 3, $propale->note_public, 0, 'J');
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
-
+
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
-
+
$tab_height = $tab_height - $height_note;
$tab_top = $nexY+6;
}
@@ -219,16 +225,16 @@ class pdf_propale_azur extends ModelePDFPropales
{
$height_note=0;
}
-
+
$iniY = $tab_top + 8;
$curY = $tab_top + 8;
$nexY = $tab_top + 8;
-
+
// Boucle sur les lignes
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
-
+
// Description de la ligne produit
$libelleproduitservice=$propale->lignes[$i]->libelle;
if ($propale->lignes[$i]->desc&&$propale->lignes[$i]->desc!=$propale->lignes[$i]->libelle)
@@ -240,7 +246,7 @@ class pdf_propale_azur extends ModelePDFPropales
if ($propale->lignes[$i]->product_id)
{
$prodser = new Product($this->db);
-
+
$prodser->fetch($propale->lignes[$i]->product_id);
if ($prodser->ref)
{
@@ -249,10 +255,10 @@ class pdf_propale_azur extends ModelePDFPropales
$prefix_prodserv = $langs->trans("Product")." ";
if($prodser->type == 1)
$prefix_prodserv = $langs->trans("Service")." ";
-
+
$libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice;
}
-
+
// Ajoute description du produit
if ($conf->global->PROP_ADD_PROD_DESC && !$conf->global->PRODUIT_CHANGE_PROD_DESC)
{
@@ -268,46 +274,46 @@ class pdf_propale_azur extends ModelePDFPropales
// Affichage durée si il y en a une
$libelleproduitservice.="\n(".$langs->trans("From")." ".dolibarr_print_date($propale->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($propale->lignes[$i]->date_end).")";
}
-
+
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page
-
+
$pdf->SetXY ($this->posxdesc-1, $curY);
$pdf->MultiCell(108, 4, $libelleproduitservice, 0, 'J');
-
+
$nexY = $pdf->GetY();
-
+
// TVA
$pdf->SetXY ($this->posxtva, $curY);
$pdf->MultiCell(10, 4, ($propale->lignes[$i]->tva_tx < 0 ? '*':'').abs($propale->lignes[$i]->tva_tx), 0, 'R');
-
+
// Prix unitaire HT avant remise
$pdf->SetXY ($this->posxup, $curY);
$pdf->MultiCell(18, 4, price($propale->lignes[$i]->subprice), 0, 'R', 0);
-
+
// Quantit
$pdf->SetXY ($this->posxqty, $curY);
$pdf->MultiCell(10, 4, $propale->lignes[$i]->qty, 0, 'R');
-
+
// Remise sur ligne
$pdf->SetXY ($this->posxdiscount, $curY);
if ($propale->lignes[$i]->remise_percent)
{
$pdf->MultiCell(14, 4, $propale->lignes[$i]->remise_percent."%", 0, 'R');
}
-
+
// Total HT ligne
$pdf->SetXY ($this->postotalht, $curY);
$total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty);
$pdf->MultiCell(23, 4, $total, 0, 'R', 0);
-
+
// Collecte des totaux par valeur de tva
// dans le tableau tva["taux"]=total_tva
$tvaligne=$propale->lignes[$i]->price * $propale->lignes[$i]->qty;
if ($propale->remise_percent) $tvaligne-=($tvaligne*$propale->remise_percent)/100;
$this->tva[ (string)$propale->lignes[$i]->tva_tx ] += $tvaligne;
-
+
$nexY+=2; // Passe espace entre les lignes
-
+
if ($nexY > 200 && $i < ($nblignes - 1))
{
//$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY);
@@ -316,24 +322,24 @@ class pdf_propale_azur extends ModelePDFPropales
else
$this->_tableau($pdf, $tab_top_newpage, $nexY - $tab_top_newpage + 20, $nexY);
$this->_pagefoot($pdf);
-
+
// Nouvelle page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $propale, 0);
-
+
$nexY = $tab_top_newpage + 8;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
-
+
}
// Affiche cadre tableau
if ($pagenb == 1)
{
//$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
//$bottomlasttab=$tab_top + $tab_height + 1;
-
+
$this->_tableau($pdf, $tab_top, $nexY - $tab_top + 20, $nexY);
$bottomlasttab=$tab_top + $nexY - $tab_top + 20 + 1;
}
@@ -344,15 +350,15 @@ class pdf_propale_azur extends ModelePDFPropales
$this->_tableau($pdf, $tab_top_newpage, $nexY - $tab_top_newpage + 20, $nexY);
$bottomlasttab=$tab_top_newpage + $nexY - $tab_top_newpage + 20 + 1;
}
-
+
$deja_regle = "";
-
+
$posy=$this->_tableau_tot($pdf, $propale, $deja_regle, $bottomlasttab);
-
+
if ($deja_regle) {
$this->_tableau_versements($pdf, $fac, $posy);
}
-
+
/*
* Mode de règlement
*/
@@ -366,7 +372,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetTextColor(0,0,0);
}
*/
-
+
/*
* Propose mode règlement par CHQ
*/
@@ -377,7 +383,7 @@ class pdf_propale_azur extends ModelePDFPropales
{
$account = new Account($this->db);
$account->fetch(FACTURE_CHQ_NUMBER);
-
+
$pdf->SetXY ($this->marge_gauche, 227);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(90, 3, "Règlement par chèque à l'ordre de ".$account->proprio." envoyé à:",0,'L',0);
@@ -387,7 +393,7 @@ class pdf_propale_azur extends ModelePDFPropales
}
}
*/
-
+
/*
* Propose mode règlement par RIB
*/
@@ -398,9 +404,9 @@ class pdf_propale_azur extends ModelePDFPropales
{
$account = new Account($this->db);
$account->fetch(FACTURE_RIB_NUMBER);
-
+
$this->marges['g']=$this->marge_gauche;
-
+
$cury=242;
$pdf->SetXY ($this->marges['g'], $cury);
$pdf->SetFont('Arial','B',8);
@@ -420,7 +426,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetXY ($this->marges['g']+60, $cury);
$pdf->MultiCell(13, 3, "Clé RIB", 0, 'C', 0);
$pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 );
-
+
$pdf->SetFont('Arial','',8);
$pdf->SetXY ($this->marges['g'], $cury+5);
$pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0);
@@ -430,18 +436,18 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->MultiCell(24, 3, $account->number, 0, 'C', 0);
$pdf->SetXY ($this->marges['g']+60, $cury+5);
$pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0);
-
+
$pdf->SetXY ($this->marges['g'], $cury+12);
$pdf->MultiCell(90, 3, "Domiciliation : " . $account->domiciliation, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+22);
$pdf->MultiCell(90, 3, "Prefix IBAN : " . $account->iban_prefix, 0, 'L', 0);
$pdf->SetXY ($this->marges['g'], $cury+25);
$pdf->MultiCell(90, 3, "BIC : " . $account->bic, 0, 'L', 0);
-
+
}
}
*/
-
+
/*
* Conditions de règlements
*/
@@ -456,17 +462,17 @@ class pdf_propale_azur extends ModelePDFPropales
$lib_condition_paiement=$langs->trans("PaymentCondition".$propale->cond_reglement_code)?$langs->trans("PaymentCondition".$propale->cond_reglement_code):$propale->cond_reglement;
$pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L');
}
-
+
/*
* Pied de page
*/
$this->_pagefoot($pdf);
$pdf->AliasNbPages();
-
+
$pdf->Close();
-
+
$pdf->Output($file);
-
+
return 1; // Pas d'erreur
}
else
@@ -550,12 +556,12 @@ class pdf_propale_azur extends ModelePDFPropales
if ($tvakey) // On affiche pas taux 0
{
$this->atleastoneratenotnull++;
-
+
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl = ( (float)$tvakey < 0 ) ? " (".$langs->trans("NonPercuRecuperable").")" : '' ;
+ $tvacompl = ( (float)$tvakey < 0 ) ? " (".$langs->trans("NonPercuRecuperable").")" : '' ;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * abs((float)$tvakey) / 100 ), 0, 'R', 1);
}
@@ -565,13 +571,13 @@ class pdf_propale_azur extends ModelePDFPropales
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT"), 0, 'L', 1);
-
+
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($propale->total_tva), 0, 'R', 1);
}
-
+
$useborder=0;
-
+
$index++;
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60);
@@ -586,7 +592,7 @@ class pdf_propale_azur extends ModelePDFPropales
if ($deja_regle > 0)
{
$index++;
-
+
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("AlreadyPayed"), 0, 'L', 0);
@@ -604,7 +610,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetFont('Arial','', 9);
$pdf->SetTextColor(0,0,0);
}
-
+
$index++;
return ($tab2_top + ($tab2_hl * $index));
}
@@ -618,7 +624,7 @@ class pdf_propale_azur extends ModelePDFPropales
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
-
+
// Montants exprimés en (en tab_top - 1)
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
@@ -679,12 +685,12 @@ class pdf_propale_azur extends ModelePDFPropales
$langs->load("bills");
$langs->load("propal");
$langs->load("companies");
-
+
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13);
$posy=$this->marge_haute;
-
+
$pdf->SetXY($this->marge_gauche,$posy);
// Logo
@@ -713,7 +719,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Proposal")." ".$propale->ref, '' , 'R');
$pdf->SetFont('Arial','',12);
-
+
$posy+=6;
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60);
@@ -733,21 +739,21 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marge_gauche,$posy-5);
$pdf->MultiCell(66,5, $langs->trans("BillFrom").":");
-
-
+
+
$pdf->SetXY($this->marge_gauche,$posy);
$pdf->SetFillColor(230,230,230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
-
-
+
+
$pdf->SetXY($this->marge_gauche+2,$posy+3);
-
+
// Nom emetteur
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',11);
if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L');
else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L');
-
+
// Caractéristiques emetteur
$carac_emetteur = '';
if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE;
@@ -768,11 +774,11 @@ class pdf_propale_azur extends ModelePDFPropales
// Web
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW;
elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".$mysoc->url;
-
+
$pdf->SetFont('Arial','',9);
$pdf->SetXY($this->marge_gauche+2,$posy+8);
$pdf->MultiCell(80,4, $carac_emetteur);
-
+
// Client destinataire
$posy=42;
$pdf->SetTextColor(0,0,0);
@@ -780,15 +786,15 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetXY(102,$posy-5);
$pdf->MultiCell(80,5, $langs->trans("BillTo").":");
$propale->fetch_client();
-
+
// Cadre client destinataire
$pdf->rect(100, $posy, 100, $hautcadre);
-
+
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $propale->client->nom, 0, 'L');
-
+
// Caractéristiques client
$carac_client=$propale->client->adresse;
$carac_client.="\n".$propale->client->cp . " " . $propale->client->ville."\n";
@@ -810,9 +816,9 @@ class pdf_propale_azur extends ModelePDFPropales
$langs->load("main");
$langs->load("bills");
$langs->load("companies");
-
+
$html=new Form($this->db);
-
+
// Premiere ligne d'info réglementaires
$ligne1="";
if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)
@@ -856,7 +862,7 @@ class pdf_propale_azur extends ModelePDFPropales
$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);
@@ -869,7 +875,7 @@ class pdf_propale_azur extends ModelePDFPropales
$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);
}
diff --git a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php
index a791d7fe8e4..c0f730ad9c4 100644
--- a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php
@@ -41,7 +41,7 @@ class pdf_propale_bleu extends ModelePDFPropales
\param db handler accès base de donnée
*/
function pdf_propale_bleu($db=0)
- {
+ {
$this->db = $db;
$this->name = "bleu";
$this->description = "Modèle de propale sans remise.";
@@ -60,12 +60,12 @@ class pdf_propale_bleu extends ModelePDFPropales
\brief Renvoi dernière erreur
\return string Dernière erreur
*/
- function pdferror()
+ function pdferror()
{
return $this->error;
}
-
+
/**
\brief Fonction générant la propale sur le disque
\param propale Objet propal
@@ -85,10 +85,10 @@ class pdf_propale_bleu extends ModelePDFPropales
\remarks MAIN_INFO_CAPITAL
\remarks MAIN_INFO_TVAINTRA
*/
- function write_pdf_file($propale)
+ function write_pdf_file($propale,$outputlangs='')
{
- global $user,$conf,$langs;
-
+ global $user,$conf,$langs,$mysoc;
+
if ($conf->propal->dir_output)
{
// Définition de l'objet $propal (pour compatibilite ascendante)
@@ -98,7 +98,7 @@ class pdf_propale_bleu extends ModelePDFPropales
$propale = new Propal($this->db,"",$id);
$ret=$propale->fetch($id);
}
-
+
// Définition de $dir et $file
if ($propale->specimen)
{
@@ -111,7 +111,7 @@ class pdf_propale_bleu extends ModelePDFPropales
$dir = $conf->propal->dir_output . "/" . $propref;
$file = $dir . "/" . $propref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -120,21 +120,21 @@ class pdf_propale_bleu extends ModelePDFPropales
return 0;
}
}
-
+
if (file_exists($dir))
{
-
+
$pdf=new FPDF('P','mm',$this->format);
$pdf->Open();
$pdf->AddPage();
-
+
$pdf->SetTitle($propale->ref);
$pdf->SetSubject("Proposition commerciale");
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$this->_pagehead($pdf, $propale);
-
+
/*
*/
$tab_top = 100;
@@ -142,49 +142,49 @@ class pdf_propale_bleu extends ModelePDFPropales
/*
*
*/
-
+
$pdf->SetFillColor(220,220,220);
-
+
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
-
+
$pdf->SetXY (10, $tab_top + 10 );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($propale->lignes);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
-
+
$curY = $nexY;
-
+
$pdf->SetXY (30, $curY );
-
+
$pdf->MultiCell(100, 5, $propale->lignes[$i]->desc, 0, 'J', 0);
-
+
$nexY = $pdf->GetY();
-
+
$pdf->SetXY (10, $curY );
-
+
$pdf->MultiCell(20, 5, $propale->lignes[$i]->ref, 0, 'C');
-
+
$pdf->SetXY (133, $curY );
$pdf->MultiCell(10, 5, $propale->lignes[$i]->tva_tx, 0, 'C');
-
+
$pdf->SetXY (145, $curY );
$pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C');
-
+
$pdf->SetXY (156, $curY );
$pdf->MultiCell(18, 5, price($propale->lignes[$i]->price), 0, 'R', 0);
-
+
$pdf->SetXY (174, $curY );
$total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
-
+
$pdf->line(10, $curY, 200, $curY );
-
+
if ($nexY > 240 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@@ -195,7 +195,7 @@ class pdf_propale_bleu extends ModelePDFPropales
$pdf->SetFont('Arial','', 10);
}
}
-
+
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
/*
*
@@ -203,39 +203,39 @@ class pdf_propale_bleu extends ModelePDFPropales
$tab2_top = 254;
$tab2_lh = 7;
$tab2_height = $tab2_lh * 3;
-
+
$pdf->SetFont('Arial','', 11);
-
+
$pdf->Rect(132, $tab2_top, 68, $tab2_height);
-
+
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) );
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) );
$pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh );
-
+
$pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
-
+
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh);
$pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + ($tab2_lh*2));
$pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + ($tab2_lh*2));
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1);
-
+
/*
*
*/
-
+
$pdf->Output($file);
return 1;
}
@@ -249,21 +249,21 @@ class pdf_propale_bleu extends ModelePDFPropales
$langs->load("bills");
$pdf->SetFont('Arial','',11);
-
+
$pdf->Text(30,$tab_top + 5,$langs->trans("Designation"));
-
+
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->Text(134,$tab_top + 5,$langs->trans("VAT"));
-
+
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->Text(147,$tab_top + 5,$langs->trans("Qty"));
-
+
$pdf->line(156, $tab_top, 156, $tab_top + $tab_height);
$pdf->Text(160,$tab_top + 5,$langs->trans("PriceU"));
-
+
$pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
$pdf->Text(187,$tab_top + 5,$langs->trans("Total"));
-
+
// $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top);
$pdf->Rect(10, $tab_top, 190, $tab_height);
@@ -285,7 +285,7 @@ class pdf_propale_bleu extends ModelePDFPropales
$pdf->SetFont('Times','B',14);
$pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L');
}
-
+
$pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE"))
{
@@ -296,13 +296,13 @@ class pdf_propale_bleu extends ModelePDFPropales
{
$pdf->SetFont('Times','',10);
$pdf->MultiCell(76, 5, $langs->trans("Phone")." : ".FAC_PDF_TEL);
- }
+ }
if (defined("MAIN_INFO_SIREN"))
{
$pdf->SetFont('Times','',10);
$pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN);
- }
-
+ }
+
if (defined("FAC_PDF_INTITULE2"))
{
$pdf->SetXY(100,5);
@@ -322,14 +322,14 @@ class pdf_propale_bleu extends ModelePDFPropales
$pdf->SetXY(102,47);
$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('Courier','B',12);
$pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $propale->date));
$pdf->Text(11, 94, "Proposition commerciale : ".$propale->ref);
-
-
+
+
}
}
diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
index eb63ba6fe3c..a1614897c3a 100644
--- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php
@@ -41,7 +41,7 @@ class pdf_propale_jaune extends ModelePDFPropales
\param db handler accès base de donnée
*/
function pdf_propale_jaune($db=0)
- {
+ {
$this->db = $db;
$this->name = "jaune";
$this->description = "Modèle de proposition Jaune";
@@ -51,7 +51,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$this->page_largeur = 210;
$this->page_hauteur = 297;
$this->format = array($this->page_largeur,$this->page_hauteur);
-
+
$this->error = "";
}
@@ -59,21 +59,21 @@ class pdf_propale_jaune extends ModelePDFPropales
/** \brief Renvoi dernière erreur
\return string Dernière erreur
*/
- function pdferror()
+ function pdferror()
{
return $this->error;
}
-
-
+
+
/**
\brief Fonction générant la propale sur le disque
\param propale Objet propal
\return int 1=ok, 0=ko
*/
- function write_pdf_file($propale)
+ function write_pdf_file($propale,$outputlangs='')
{
- global $user,$conf,$langs;
-
+ global $user,$conf,$langs,$mysoc;
+
if ($conf->propal->dir_output)
{
// Définition de l'objet $propal (pour compatibilite ascendante)
@@ -83,7 +83,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$propale = new Propal($this->db,"",$id);
$ret=$propale->fetch($id);
}
-
+
// Définition de $dir et $file
if ($propale->specimen)
{
@@ -96,7 +96,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$dir = $conf->propal->dir_output . "/" . $propref;
$file = $dir . "/" . $propref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -105,22 +105,22 @@ class pdf_propale_jaune extends ModelePDFPropales
return 0;
}
}
-
+
if (file_exists($dir))
{
-
+
$pdf=new FPDF('P','mm',$this->format);
$pdf->Open();
-
+
$pdf->SetTitle($propale->ref);
$pdf->SetSubject("Proposition commerciale");
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$pdf->AddPage();
-
+
$this->_pagehead($pdf, $propale);
-
+
/*
*/
$tab_top = 100;
@@ -128,46 +128,46 @@ class pdf_propale_jaune extends ModelePDFPropales
/*
*
*/
-
+
$pdf->SetFillColor(242,239,119);
-
+
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
-
+
$pdf->SetXY (10, $tab_top + 10 );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($propale->lignes);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
$total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty);
-
+
$pdf->SetXY (30, $curY );
$pdf->MultiCell(102, 5, $propale->lignes[$i]->desc, 0, 'J', 0);
-
+
$nexY = $pdf->GetY();
-
+
$pdf->SetXY (10, $curY );
$pdf->MultiCell(20, 5, $propale->lignes[$i]->ref, 0, 'C', 0);
-
+
$pdf->SetXY (132, $curY );
$pdf->MultiCell(12, 5, $propale->lignes[$i]->tva_tx, 0, 'C', 0);
-
+
$pdf->SetXY (144, $curY );
$pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C', 0);
-
+
$pdf->SetXY (154, $curY );
$pdf->MultiCell(22, 5, price($propale->lignes[$i]->price), 0, 'R', 0);
-
+
$pdf->SetXY (176, $curY );
$pdf->MultiCell(24, 5, $total, 0, 'R', 0);
-
+
$pdf->line(10, $curY, 200, $curY );
-
+
if ($nexY > 240 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@@ -178,7 +178,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetFont('Arial','', 10);
}
}
-
+
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
/*
*
@@ -186,39 +186,39 @@ class pdf_propale_jaune extends ModelePDFPropales
$tab2_top = 254;
$tab2_lh = 7;
$tab2_height = $tab2_lh * 3;
-
+
$pdf->SetFont('Arial','', 11);
-
+
$pdf->Rect(132, $tab2_top, 68, $tab2_height);
-
+
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) );
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) );
$pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh );
-
+
$pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
-
+
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh);
$pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + ($tab2_lh*2));
$pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + ($tab2_lh*2));
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1);
-
+
/*
*
*/
-
+
$pdf->Output($file);
return 1;
}
@@ -238,23 +238,23 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetXY(30,$tab_top);
$pdf->MultiCell(102,10,$langs->trans("Designation"),0,'L',1);
-
+
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->SetXY(132,$tab_top);
$pdf->MultiCell(12, 10,$langs->trans("VAT"),0,'C',1);
-
+
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->SetXY(144,$tab_top);
$pdf->MultiCell(10,10,$langs->trans("Qty"),0,'C',1);
-
+
$pdf->line(154, $tab_top, 154, $tab_top + $tab_height);
$pdf->SetXY(154,$tab_top);
$pdf->MultiCell(22,10,$langs->trans("PriceU"),0,'R',1);
-
+
$pdf->line(176, $tab_top, 176, $tab_top + $tab_height);
$pdf->SetXY(176,$tab_top);
$pdf->MultiCell(24,10,$langs->trans("Total"),0,'R',1);
-
+
$pdf->Rect(10, $tab_top, 190, $tab_height);
$pdf->SetTextColor(0,0,0);
@@ -272,7 +272,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetFont('Arial','B',14);
$pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L');
}
-
+
$pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE"))
{
@@ -285,14 +285,14 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetX(12);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL);
- }
+ }
if (defined("MAIN_INFO_SIREN"))
{
$pdf->SetX(12);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN);
- }
- $pdf->rect(10, 40, 80, 40);
+ }
+ $pdf->rect(10, 40, 80, 40);
$pdf->SetXY(10,5);
$pdf->SetFont('Arial','B',16);
@@ -311,7 +311,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetXY(102,47);
$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);
@@ -321,7 +321,7 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->SetXY(10,90);
$pdf->MultiCell(110, 10, "Numéro : ".$propale->ref);
$pdf->SetXY(110,90);
- $pdf->MultiCell(100, 10, "Date : " . strftime("%d %B %Y", $propale->date));
+ $pdf->MultiCell(100, 10, "Date : " . strftime("%d %B %Y", $propale->date));
}
}
?>
diff --git a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php
index 3c56ef3c908..f9c26f04161 100644
--- a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php
@@ -21,7 +21,7 @@
* $Source$
*/
-/**
+/**
\file htdocs/includes/modules/propale/pdf_propale_rouge.modules.php
\ingroup propale
\brief Fichier de la classe permettant de générer les propales au modèle Rouge
@@ -44,7 +44,7 @@ class pdf_propale_rouge extends ModelePDFPropales
\param db handler accès base de donnée
*/
function pdf_propale_rouge($db=0)
- {
+ {
$this->db = $db;
$this->name = "rouge";
$this->description = "Modèle de propale simple";
@@ -57,26 +57,26 @@ class pdf_propale_rouge extends ModelePDFPropales
$this->error = "";
}
-
+
/** \brief Renvoi dernière erreur
\return string Dernière erreur
*/
- function pdferror()
+ function pdferror()
{
return $this->error;
}
-
-
+
+
/**
\brief Fonction générant la propale sur le disque
\param propale Objet propal
\return int 1=ok, 0=ko
*/
- function write_pdf_file($propale)
+ function write_pdf_file($propale,$outputlangs='')
{
- global $user,$conf,$langs;
-
+ global $user,$conf,$langs,$mysoc;
+
if ($conf->propal->dir_output)
{
// Définition de l'objet $propal (pour compatibilite ascendante)
@@ -114,58 +114,58 @@ class pdf_propale_rouge extends ModelePDFPropales
$pdf=new FPDF('P','mm',$this->format);
$pdf->Open();
$pdf->AddPage();
-
+
$pdf->SetTitle($propale->ref);
$pdf->SetSubject($langs->trans("CommercialProposal"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$this->_pagehead($pdf, $propale);
-
+
$tab_top = 100;
$tab_height = 140;
$pdf->SetFillColor(220,220,220);
-
+
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
-
+
$pdf->SetXY (10, $tab_top + 10 );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($propale->lignes);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
$curY = $nexY;
-
+
$pdf->SetXY (30, $curY );
-
+
$pdf->MultiCell(100, 5, $propale->lignes[$i]->desc, 0, 'J', 0);
-
+
$nexY = $pdf->GetY();
-
+
$pdf->SetXY (10, $curY );
-
+
$pdf->MultiCell(20, 5, $propale->lignes[$i]->ref, 0, 'C');
-
+
$pdf->SetXY (133, $curY );
$pdf->MultiCell(10, 5, $propale->lignes[$i]->tva_tx, 0, 'C');
-
+
$pdf->SetXY (145, $curY );
$pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C');
-
+
$pdf->SetXY (156, $curY );
$pdf->MultiCell(18, 5, price($propale->lignes[$i]->price), 0, 'R', 0);
-
+
$pdf->SetXY (174, $curY );
$total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0);
-
+
$pdf->line(10, $curY, 200, $curY );
-
+
if ($nexY > 240 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@@ -176,7 +176,7 @@ class pdf_propale_rouge extends ModelePDFPropales
$pdf->SetFont('Arial','', 10);
}
}
-
+
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
/*
*
@@ -184,55 +184,55 @@ class pdf_propale_rouge extends ModelePDFPropales
$tab2_top = 241;
$tab2_lh = 7;
$tab2_height = $tab2_lh * 4;
-
+
$pdf->SetFont('Arial','', 11);
-
+
$pdf->Rect(132, $tab2_top, 68, $tab2_height);
-
+
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) );
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) );
$pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh );
-
+
$pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
-
+
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalHT"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh);
$pdf->MultiCell(42, $tab2_lh, $langs->trans("Discount"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh*2);
$pdf->MultiCell(42, $tab2_lh, "Total HT après remise", 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh*3);
$pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalVAT"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + ($tab2_lh*4));
$pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalTTC"), 1, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ht + $propale->remise), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh);
$pdf->MultiCell(26, $tab2_lh, price($propale->remise), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh*2);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh*3);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + ($tab2_lh*4));
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1);
-
-
+
+
if (defined("PROP_PDF_MESSAGE") && PROP_PDF_MESSAGE)
{
$pdf->SetXY (10, $tab2_top + 2);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(120, 5, PROP_PDF_MESSAGE);
}
-
+
$pdf->Output($file);
return 1;
}
@@ -242,8 +242,8 @@ class pdf_propale_rouge extends ModelePDFPropales
$this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR");
return 0;
}
-
- }
+
+ }
function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
@@ -253,21 +253,21 @@ class pdf_propale_rouge extends ModelePDFPropales
$langs->load("bills");
$pdf->SetFont('Arial','',11);
-
+
$pdf->Text(30,$tab_top + 5,$langs->trans("Designation"));
-
+
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->Text(134,$tab_top + 5,$langs->trans("VAT"));
-
+
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height);
$pdf->Text(147,$tab_top + 5,$langs->trans("Qty"));
-
+
$pdf->line(156, $tab_top, 156, $tab_top + $tab_height);
$pdf->Text(160,$tab_top + 5,$langs->trans("PriceU"));
-
+
$pdf->line(174, $tab_top, 174, $tab_top + $tab_height);
$pdf->Text(187,$tab_top + 5,$langs->trans("Total"));
-
+
// $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top);
$pdf->Rect(10, $tab_top, 190, $tab_height);
@@ -288,7 +288,7 @@ class pdf_propale_rouge extends ModelePDFPropales
$pdf->SetFont('Arial','B',14);
$pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L');
}
-
+
$pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE"))
{
@@ -299,13 +299,13 @@ class pdf_propale_rouge extends ModelePDFPropales
{
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL);
- }
+ }
if (defined("MAIN_INFO_SIREN"))
{
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN);
- }
-
+ }
+
if (defined("FAC_PDF_INTITULE2"))
{
$pdf->SetXY(100,5);
@@ -325,14 +325,14 @@ class pdf_propale_rouge extends ModelePDFPropales
$pdf->SetXY(102,47);
$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->Text(11, 88, "Date : " . strftime("%d %b %Y", $propale->date));
$pdf->Text(11, 94, "Proposition commerciale : ".$propale->ref);
-
-
+
+
}
}
diff --git a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php
index 75bf5c32f60..2f358d15ed0 100644
--- a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php
+++ b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php
@@ -42,7 +42,7 @@ class pdf_propale_vert extends ModelePDFPropales
\param db handler accès base de donnée
*/
function pdf_propale_vert($db=0)
- {
+ {
$this->db = $db;
$this->name = "vert";
$this->description = "Affichage de la remise par produit";
@@ -52,7 +52,7 @@ class pdf_propale_vert extends ModelePDFPropales
$this->page_largeur = 210;
$this->page_hauteur = 297;
$this->format = array($this->page_largeur,$this->page_hauteur);
-
+
$this->error = "";
}
@@ -60,21 +60,21 @@ class pdf_propale_vert extends ModelePDFPropales
/** \brief Renvoi dernière erreur
\return string Dernière erreur
*/
- function pdferror()
+ function pdferror()
{
return $this->error;
}
-
-
+
+
/**
\brief Fonction générant la propale sur le disque
\param propale Objet propal
\return int 1=ok, 0=ko
*/
- function write_pdf_file($propale)
+ function write_pdf_file($propale,$outputlangs='')
{
- global $user,$conf,$langs;
-
+ global $user,$conf,$langs,$mysoc;
+
if ($conf->propal->dir_output)
{
// Définition de l'objet $propal (pour compatibilite ascendante)
@@ -84,7 +84,7 @@ class pdf_propale_vert extends ModelePDFPropales
$propale = new Propal($this->db,"",$id);
$ret=$propale->fetch($id);
}
-
+
// Définition de $dir et $file
if ($propale->specimen)
{
@@ -97,7 +97,7 @@ class pdf_propale_vert extends ModelePDFPropales
$dir = $conf->propal->dir_output . "/" . $propref;
$file = $dir . "/" . $propref . ".pdf";
}
-
+
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
@@ -106,21 +106,21 @@ class pdf_propale_vert extends ModelePDFPropales
return 0;
}
}
-
+
if (file_exists($dir))
{
-
+
$pdf=new FPDF('P','mm',$this->format);
$pdf->Open();
$pdf->AddPage();
-
+
$pdf->SetTitle($propale->ref);
$pdf->SetSubject("Proposition commerciale");
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($user->fullname);
-
+
$this->_pagehead($pdf, $propale);
-
+
/*
*/
$tab_top = 100;
@@ -128,53 +128,53 @@ class pdf_propale_vert extends ModelePDFPropales
/*
*
*/
-
+
$pdf->SetFillColor(220,220,220);
-
+
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
-
+
$pdf->SetXY (10, $tab_top + 10 );
-
+
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
$nblignes = sizeof($propale->lignes);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
-
+
$curY = $nexY;
-
+
$pdf->SetXY (40, $curY );
-
+
$pdf->MultiCell(90, 5, $propale->lignes[$i]->desc, 0, 'J', 0);
-
+
$nexY = $pdf->GetY();
-
+
$pdf->SetXY (10, $curY );
$pdf->SetFont('Arial','', 8);
$pdf->MultiCell(30, 5, $propale->lignes[$i]->ref, 0, 'L', 0);
-
+
$pdf->SetFont('Arial','', 10);
$pdf->SetXY (132, $curY );
$pdf->MultiCell(10, 5, $propale->lignes[$i]->tva_tx, 0, 'C', 0);
-
+
$pdf->SetXY (142, $curY );
$pdf->MultiCell(8, 5, $propale->lignes[$i]->qty, 0, 'C');
-
+
$pdf->SetXY (150, $curY );
$pdf->MultiCell(16, 5, price($propale->lignes[$i]->subprice), 0, 'R', 0);
-
+
$pdf->SetXY (166, $curY );
$pdf->MultiCell(14, 5, $propale->lignes[$i]->remise_percent."%", 0, 'R', 0);
-
+
$pdf->SetXY (180, $curY );
$total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty);
$pdf->MultiCell(20, 5, $total, 0, 'R', 0);
-
+
$pdf->line(10, $curY, 200, $curY );
-
+
if ($nexY > 240 && $i < $nblignes - 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@@ -185,7 +185,7 @@ class pdf_propale_vert extends ModelePDFPropales
$pdf->SetFont('Arial','', 10);
}
}
-
+
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
/*
*
@@ -193,51 +193,51 @@ class pdf_propale_vert extends ModelePDFPropales
$tab2_top = 241;
$tab2_lh = 7;
$tab2_height = $tab2_lh * 4;
-
+
$pdf->SetFont('Arial','', 11);
-
+
$pdf->Rect(132, $tab2_top, 68, $tab2_height);
-
+
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) );
$pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) );
$pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh );
-
+
$pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
-
+
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalHT"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh);
$pdf->MultiCell(42, $tab2_lh, $langs->trans("GlobalDiscount"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh*2);
$pdf->MultiCell(42, $tab2_lh, "Total HT après remise", 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + $tab2_lh*3);
$pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalVAT"), 0, 'R', 0);
-
+
$pdf->SetXY (132, $tab2_top + ($tab2_lh*4));
$pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalTTC"), 1, 'R', 1);
-
+
$pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ht + $propale->remise), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh);
$pdf->MultiCell(26, $tab2_lh, price($propale->remise), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh*2);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + $tab2_lh*3);
$pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0);
-
+
$pdf->SetXY (174, $tab2_top + ($tab2_lh*4));
$pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1);
-
+
/*
*
*/
-
+
$pdf->Output($file);
return 1;
}
@@ -249,10 +249,10 @@ class pdf_propale_vert extends ModelePDFPropales
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
-
+
$yt = 100;
$pdf->SetFont('Arial','',10);
-
+
$pdf->SetXY(10, $yt);
$pdf->MultiCell(30,5,$langs->trans("Ref"),0,'L');
@@ -262,15 +262,15 @@ class pdf_propale_vert extends ModelePDFPropales
$pdf->SetXY(132, $yt);
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->MultiCell(10,5,$langs->trans("VAT"),0,'C');
-
+
$pdf->line(142, $tab_top, 142, $tab_top + $tab_height);
$pdf->SetXY(142, $yt);
$pdf->MultiCell(8,5,$langs->trans("Qty"),0,'C');
-
+
$pdf->line(150, $tab_top, 150, $tab_top + $tab_height);
$pdf->SetXY(150, $yt);
$pdf->MultiCell(16,5,$langs->trans("PriceU"),0,'C');
-
+
$pdf->line(166, $tab_top, 166, $tab_top + $tab_height);
$pdf->SetXY(166, $yt);
$pdf->MultiCell(14,5,$langs->trans("ReductionShort"),0,'C');
@@ -278,7 +278,7 @@ class pdf_propale_vert extends ModelePDFPropales
$pdf->line(180, $tab_top, 180, $tab_top + $tab_height);
$pdf->SetXY(180, $yt);
$pdf->MultiCell(20,5,$langs->trans("Total"),0,'R');
-
+
// $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top);
$pdf->Rect(10, $tab_top, 190, $tab_height);
@@ -303,7 +303,7 @@ class pdf_propale_vert extends ModelePDFPropales
$pdf->SetFont('Arial','B',14);
$pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L');
}
-
+
$pdf->SetTextColor(70,70,170);
if (defined("FAC_PDF_ADRESSE"))
{
@@ -314,13 +314,13 @@ class pdf_propale_vert extends ModelePDFPropales
{
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL);
- }
+ }
if (defined("MAIN_INFO_SIREN"))
{
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN);
- }
-
+ }
+
if (defined("FAC_PDF_INTITULE2"))
{
$pdf->SetXY(100,5);
@@ -340,14 +340,14 @@ class pdf_propale_vert extends ModelePDFPropales
$pdf->SetXY(102,47);
$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->Text(11, 88, "Date : " . strftime("%d %b %Y", $propale->date));
$pdf->Text(11, 94, "Proposition commerciale : ".$propale->ref);
-
-
+
+
}
}
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index 56ecaabdb57..b74aae8dc3e 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -51,12 +51,13 @@ class Propal
var $projetidp;
var $author;
var $ref;
+ var $status;
var $datep;
+ var $fin_validite;
+
var $products;
var $products_qty;
var $price;
- var $status;
- var $fin_validite;
var $cond_reglement_id;
var $cond_reglement_code;
var $mode_reglement_id;
@@ -69,20 +70,21 @@ class Propal
var $date_livraison;
var $adresse_livraison_id;
-
+
var $labelstatut=array();
var $labelstatut_short=array();
-
+
var $product=array();
// Pour board
var $nbtodo;
var $nbtodolate;
-
+
+ var $specimen;
var $error;
- /**
+ /**
* \brief Constructeur
* \param DB Handler d'accès base
* \param soc_idp Id de la société
@@ -91,7 +93,7 @@ class Propal
function Propal($DB, $soc_idp="", $propalid=0)
{
global $langs;
-
+
$this->db = $DB ;
$this->socidp = $soc_idp;
$this->id = $propalid;
@@ -99,7 +101,7 @@ class Propal
$this->remise = 0;
$this->remise_percent = 0;
$this->remise_absolue = 0;
-
+
$langs->load("propals");
$this->labelstatut[0]=$langs->trans("PropalStatusDraft");
$this->labelstatut[1]=$langs->trans("PropalStatusValidated");
@@ -122,7 +124,7 @@ class Propal
* \return void
* \see insert_product
*/
-
+
function add_product($idproduct, $qty, $remise_percent=0)
{
if ($idproduct > 0)
@@ -152,7 +154,7 @@ class Propal
}
-
+
/**
* \brief Ajout d'un produit dans la proposition, en base
* \param idproduct Id du produit à ajouter
@@ -171,7 +173,7 @@ class Propal
// Nettoyage parametres
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
-
+
if ($idproduct)
{
$prod = new Product($this->db, $idproduct);
@@ -195,9 +197,9 @@ class Propal
$subprice = price2num($prod->price);
}
/*
-
+
*/
-
+
// Calcul remise et nouveau prix
$remise = 0;
if ($remise_percent > 0)
@@ -263,19 +265,19 @@ class Propal
$price = $p_price;
$subprice = $p_price;
-
+
if ($remise_percent > 0)
{
$remise = round(($p_price * $remise_percent / 100), 2);
$price = $p_price - $remise;
}
-
+
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
$sql .= " (".$this->id.", 0,'". $p_qty."','". price2num($price)."','".$p_tva_tx."','".addslashes($p_desc)."','$remise_percent', '".price2num($subprice)."') ; ";
-
+
if ($this->db->query($sql) )
{
-
+
if ($this->update_price() > 0)
{
return 1;
@@ -291,8 +293,8 @@ class Propal
}
}
}
-
-
+
+
/**
* \brief Mise à jour d'une ligne de produit
* \param id Id de la ligne
@@ -303,7 +305,7 @@ class Propal
* \param desc Description
* \return int 0 en cas de succès
*/
-
+
function UpdateLigne($id, $subprice, $qty, $remise_percent=0, $tva_tx, $desc='')
{
if ($this->statut == 0)
@@ -313,13 +315,13 @@ class Propal
$price = $subprice;
$remise_percent=price2num($remise_percent);
$tva_tx=price2num($tva_tx);
-
+
if ($remise_percent > 0)
{
$remise = round(($subprice * $remise_percent / 100), 2);
$price = $subprice - $remise;
}
-
+
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet ";
$sql.= " SET qty='".$qty."'";
$sql.= " , price='". price2num($price)."'";
@@ -328,7 +330,7 @@ class Propal
$sql.= " , tva_tx='".$tva_tx."'";
$sql.= " , description='".addslashes($desc)."'";
$sql.= " WHERE rowid = '".$id."';";
-
+
if ($this->db->query($sql))
{
$this->update_price();
@@ -347,8 +349,8 @@ class Propal
return -2;
}
}
-
-
+
+
/**
* \brief Liste les valeurs possibles de type de contacts pour les factures
* \param source 'internal' ou 'external'
@@ -359,20 +361,20 @@ class Propal
global $langs;
$element='propal';
$tab = array();
-
+
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE element='".$element."'";
$sql.= " AND source='".$source."'";
$sql.= " ORDER by tc.code";
-
+
$resql=$this->db->query($sql);
-
+
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
-
+
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
@@ -381,7 +383,7 @@ class Propal
$tab[$obj->rowid]=$libelle_type;
$i++;
}
-
+
return $tab;
}
else
@@ -390,8 +392,8 @@ class Propal
return null;
}
}
-
-
+
+
/**
* \brief Récupère les lignes de contact de l'objet
* \param statut Statut des lignes detail à récupérer
@@ -403,7 +405,7 @@ class Propal
global $langs;
$element='propal';
$tab=array();
-
+
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
if ($source == 'internal') $sql.=" '-1' as socid,";
if ($source == 'external') $sql.=" t.fk_soc as socid,";
@@ -424,14 +426,14 @@ class Propal
if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp";
if ($statut >= 0) $sql.= " AND statut = '$statut'";
$sql.=" ORDER BY t.name ASC";
-
+
$resql=$this->db->query($sql);
-
+
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
-
+
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
@@ -440,7 +442,7 @@ class Propal
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut);
$i++;
}
-
+
return $tab;
}
else
@@ -450,8 +452,8 @@ class Propal
return -1;
}
}
-
-
+
+
/**
* \brief Ajoute un contact associé une commande
* \param fk_socpeople Id du contact a ajouter.
@@ -462,18 +464,18 @@ class Propal
function add_contact($fk_socpeople, $type_contact, $source='extern')
{
dolibarr_syslog("Commande::add_contact $fk_socpeople, $type_contact, $source");
-
+
if ($fk_socpeople <= 0) return -1;
-
+
// Verifie type_contact
if (! $type_contact || ! is_numeric($type_contact))
{
$this->error="Valeur pour type_contact incorrect";
return -3;
}
-
+
$datecreate = time();
-
+
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
@@ -481,7 +483,7 @@ class Propal
$sql.= $this->db->idate($datecreate);
$sql.= ", 4, '". $type_contact . "' ";
$sql.= ")";
-
+
// Retour
if ( $this->db->query($sql) )
{
@@ -493,8 +495,8 @@ class Propal
return -1;
}
}
-
-
+
+
/**
* \brief Supprime une ligne de contact
* \param rowid La reference du contact
@@ -504,7 +506,7 @@ class Propal
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql.= " WHERE rowid =".$rowid;
-
+
if ($this->db->query($sql))
{
return 1;
@@ -514,7 +516,7 @@ class Propal
return -1;
}
}
-
+
/**
* \brief Le détail d'un contact
* \param rowid L'identifiant du contact
@@ -523,7 +525,7 @@ class Propal
function detail_contact($rowid)
{
$element='propal';
-
+
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql.= " tc.code, tc.libelle, s.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc, ";
@@ -532,7 +534,7 @@ class Propal
$sql.= " AND ec.fk_socpeople=s.idp";
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = '".$element."'";
-
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -546,7 +548,7 @@ class Propal
return null;
}
}
-
+
/**
* \brief Mise a jour du contact associé à une commande
* \param rowid La reference du lien commande-contact
@@ -572,7 +574,7 @@ class Propal
return -1;
}
}
-
+
/**
* \brief Renvoi tableau des id des contacts d'un type donné
* \param source 'internel' ou 'external'
@@ -584,7 +586,7 @@ class Propal
$element='propal'; // Contact sur propal
$result=array();
$i=0;
-
+
$sql = "SELECT ec.fk_socpeople";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE ec.element_id = ".$this->id;
@@ -592,9 +594,9 @@ class Propal
$sql.= " AND tc.element = '".$element."'";
$sql.= " AND tc.source = '".$source."'";
$sql.= " AND tc.code = '".$code."'";
-
+
$resql=$this->db->query($sql);
-
+
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
@@ -608,29 +610,29 @@ class Propal
$this->error=$this->db->error();
return null;
}
-
+
return $result;
- }
+ }
/**
*
*
*/
-
+
function fetch_client()
{
$client = new Societe($this->db);
$client->fetch($this->socidp);
$this->client = $client;
}
-
-
+
+
/**
*
*
*/
-
+
function fetch_adresse_livraison($id)
{
$idadresse = $id;
@@ -638,12 +640,12 @@ class Propal
$adresse->fetch_adresse_livraison($idadresse);
$this->adresse = $adresse;
}
-
+
/**
*
*
*/
-
+
function fetch_contact_propal($id)
{
$idcontact = $id;
@@ -651,9 +653,9 @@ class Propal
$contact->fetch($idcontact);
$this->contact = $contact;
}
-
-
-
+
+
+
/**
* \brief Supprime une ligne de detail
* \param idligne Id de la ligne detail à supprimer
@@ -664,11 +666,11 @@ class Propal
if ($this->statut == 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$idligne;
-
+
if ($this->db->query($sql) )
{
$this->update_price();
-
+
return 1;
}
else
@@ -682,7 +684,7 @@ class Propal
}
}
-
+
/**
* \brief Crée une propal
* \return int <0 si ko, >=0 si ok
@@ -692,7 +694,7 @@ class Propal
global $langs,$conf;
// Définition paramètres
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
-
+
$this->db->begin();
// Insertion dans la base
@@ -710,7 +712,7 @@ class Propal
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal");
-
+
if ($this->id)
{
/*
@@ -732,7 +734,7 @@ class Propal
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_projet=$this->projetidp WHERE ref='$this->ref'";
$result=$this->db->query($sql);
}
-
+
// Affectation de l'adresse de livraison
if ($this->adresse_livraison_id)
{
@@ -748,7 +750,7 @@ class Propal
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf);
// Fin appel triggers
-
+
$this->db->commit();
return $this->id;
}
@@ -768,10 +770,10 @@ class Propal
$this->db->rollback();
return -1;
}
-
+
return $this->id;
}
-
+
/**
* \brief Mets à jour le prix total de la proposition
* \return int <0 si ko, >0 si ok
@@ -779,7 +781,7 @@ class Propal
function update_price()
{
include_once DOL_DOCUMENT_ROOT . "/lib/price.lib.php";
-
+
/*
* Liste des produits a ajouter
*/
@@ -789,7 +791,7 @@ class Propal
{
$num = $this->db->num_rows();
$i = 0;
-
+
while ($i < $num)
{
$obj = $this->db->fetch_object();
@@ -800,7 +802,7 @@ class Propal
}
}
$calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
-
+
$this->total_remise = $calculs[3];
$this->amount_ht = $calculs[4];
$this->total_ht = $calculs[0];
@@ -815,7 +817,7 @@ class Propal
$sql .= ", total='". price2num($this->total_ttc)."'";
$sql .= ", remise='".price2num($this->total_remise)."'";
$sql .=" WHERE rowid = ".$this->id;
-
+
if ( $this->db->query($sql) )
{
return 1;
@@ -827,7 +829,7 @@ class Propal
}
}
-
+
/**
* \brief Stocke un numéro de rang pour toutes les lignes de
* detail d'une propale qui n'en ont pas.
@@ -951,7 +953,7 @@ class Propal
}
}
}
-
+
/**
* \brief Recupère de la base les caractéristiques d'une propale
* \param rowid id de la propal à récupérer
@@ -973,15 +975,15 @@ class Propal
$sql.= " AND rowid='".$rowid."';";
$resql=$this->db->query($sql);
-
+
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
-
+
$this->id = $rowid;
-
+
$this->datep = $obj->dp;
$this->fin_validite = $obj->dfv;
$this->date = $obj->dp;
@@ -1007,17 +1009,17 @@ class Propal
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->date_livraison = $obj->date_livraison;
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
-
+
$this->user_author_id = $obj->fk_user_author;
-
+
if ($this->cond_reglement_id)
{
$sql = "SELECT rowid, libelle, code";
$sql.= " FROM ".MAIN_DB_PREFIX."cond_reglement";
$sql.= " WHERE rowid = ".$this->cond_reglement_id;
-
+
$resqlcond = $this->db->query($sql);
-
+
if ($resqlcond)
{
$objc = $this->db->fetch_object($resqlcond);
@@ -1025,15 +1027,15 @@ class Propal
$this->cond_reglement_code = $objc->code;
}
}
-
+
if ($this->user_author_id)
{
$sql = "SELECT name, firstname";
$sql.= " FROM ".MAIN_DB_PREFIX."user";
$sql.= " WHERE rowid = ".$this->user_author_id;
-
+
$resqluser = $this->db->query($sql);
-
+
if ($resqluser)
{
$obju = $this->db->fetch_object($resqluser);
@@ -1041,37 +1043,37 @@ class Propal
$this->user_author_firstname = $obju->firstname;
}
}
-
+
if ($obj->fk_statut == 0)
{
$this->brouillon = 1;
}
-
+
$this->lignes = array();
$this->db->free($resql);
-
+
$this->ref_url = ''.$this->ref.' ';
-
+
/*
- * Lignes propales liées à un produit
- */
- $sql = "SELECT d.description, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice,";
- $sql.= " d.fk_product, p.label, p.description as product_desc, p.ref";
+ * Lignes propales liées à un produit ou non
+ */
+ $sql = "SELECT d.description, d.price, d.tva_tx, d.qty, d.remise_percent, d.subprice, d.fk_product,";
+ $sql.= " p.label, p.description as product_desc, p.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
$sql.= " WHERE d.fk_propal = ".$this->id;
$sql.= " ORDER by d.rang";
-
+
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
$i = 0;
-
+
while ($i < $num)
{
$objp = $this->db->fetch_object($result);
-
+
$ligne = new PropaleLigne();
$ligne->desc = $objp->description; // Description ligne
@@ -1086,10 +1088,10 @@ class Propal
$ligne->libelle = $objp->label; // Label produit
$ligne->product_desc = $objp->product_desc; // Description produit
$ligne->ref = $objp->ref;
-
+
$this->lignes[$i] = $ligne;
//dolibarr_syslog("1 ".$ligne->desc);
- //dolibarr_syslog("2 ".$ligne->product_desc);
+ //print "xx $i ".$this->lignes[$i]->product_desc;
$i++;
}
$this->db->free($result);
@@ -1099,55 +1101,7 @@ class Propal
dolibarr_syslog("Propal::Fetch Erreur lecture des produits");
return -1;
}
-
- /*
- * Lignes propales liées à aucun produit
- */
-/* // requête en double, du coup les "Lignes propales liées à aucun produit" n'était plus classé dans l'ordre
-
- $sql = "SELECT d.qty, d.description, d.price, d.subprice, d.tva_tx, d.rowid, d.remise_percent";
- $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d";
- $sql .= " WHERE d.fk_propal = ".$this->id ." AND d.fk_product = 0";
-
- $result = $this->db->query($sql);
- if ($result)
- {
- $num = $this->db->num_rows($result);
- $j = 0;
-
- while ($j < $num)
- {
- $objp = $this->db->fetch_object($result);
-
- $ligne = new PropaleLigne();
-
- $ligne->desc = $objp->description;
- $ligne->qty = $objp->qty;
- $ligne->tva_tx = $objp->tva_tx;
- $ligne->subprice = $objp->subprice;
- $ligne->remise_percent = $objp->remise_percent;
- $ligne->price = $objp->price;
- $ligne->product_id = 0;
-
- $ligne->libelle = $objp->description;
- $ligne->product_desc = '';
- $ligne->ref = '';
-
- $this->lignes[$i] = $ligne;
- $i++;
- $j++;
- }
-
- $this->db->free($result);
- }
- else
- {
- dolibarr_syslog("Propal::Fetch Erreur lecture des lignes de propale");
-
- return -1;
- }
-*/
}
return 1;
}
@@ -1157,7 +1111,7 @@ class Propal
return -1;
}
}
-
+
/**
* \brief Passe au statut valider une propale
* \param user Objet utilisateur qui valide
@@ -1166,7 +1120,7 @@ class Propal
function valid($user)
{
global $conf,$langs;
-
+
if ($user->rights->propale->valider)
{
$this->db->begin();
@@ -1174,7 +1128,7 @@ class Propal
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
-
+
if ($this->db->query($sql))
{
@@ -1194,7 +1148,7 @@ class Propal
}
}
}
-
+
/**
* \brief Définit la date de fin de validité
@@ -1221,11 +1175,11 @@ class Propal
}
}
}
-
+
/**
* \brief Définit une date de livraison
* \param user Objet utilisateur qui modifie
- * \param date_livraison date de livraison
+ * \param date_livraison date de livraison
* \return int <0 si ko, >0 si ok
*/
function set_date_livraison($user, $date_livraison)
@@ -1235,7 +1189,7 @@ class Propal
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET date_livraison = ".$this->db->idate($date_livraison);
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
-
+
if ($this->db->query($sql))
{
$this->date_livraison = $date_livraison;
@@ -1253,7 +1207,7 @@ class Propal
/**
* \brief Définit une adresse de livraison
* \param user Objet utilisateur qui modifie
- * \param adresse_livraison Adresse de livraison
+ * \param adresse_livraison Adresse de livraison
* \return int <0 si ko, >0 si ok
*/
function set_adresse_livraison($user, $adresse_livraison)
@@ -1262,7 +1216,7 @@ class Propal
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_adresse_livraison = '".$adresse_livraison."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
-
+
if ($this->db->query($sql) )
{
$this->adresse_livraison_id = $adresse_livraison;
@@ -1280,7 +1234,7 @@ class Propal
/**
* \brief Définit une remise globale relative sur la proposition
* \param user Objet utilisateur qui modifie
- * \param remise Montant remise
+ * \param remise Montant remise
* \return int <0 si ko, >0 si ok
*/
function set_remise_percent($user, $remise)
@@ -1290,10 +1244,10 @@ class Propal
if ($user->rights->propale->creer)
{
$remise = price2num($remise);
-
+
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
-
+
if ($this->db->query($sql) )
{
$this->remise_percent = $remise;
@@ -1309,11 +1263,11 @@ class Propal
}
}
-
+
/**
* \brief Définit une remise globale absolue sur la proposition
* \param user Objet utilisateur qui modifie
- * \param remise Montant remise
+ * \param remise Montant remise
* \return int <0 si ko, >0 si ok
*/
function set_remise_absolue($user, $remise)
@@ -1323,11 +1277,11 @@ class Propal
if ($user->rights->propale->creer)
{
$remise = price2num($remise);
-
+
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET remise_absolue = ".$remise;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
-
+
if ($this->db->query($sql) )
{
$this->remise_absolue = $remise;
@@ -1342,7 +1296,7 @@ class Propal
}
}
}
-
+
/*
*
*
@@ -1368,7 +1322,7 @@ class Propal
}
else
{
-
+
dolibarr_syslog("Propal::set_project Erreur SQL");
}
}
@@ -1379,7 +1333,7 @@ class Propal
*
*
*/
-
+
function set_contact($user, $contact_id)
{
if ($user->rights->propale->creer)
@@ -1404,7 +1358,7 @@ class Propal
}
}
}
-
+
/**
* \brief Positionne modele derniere generation
* \param user Objet use qui modifie
@@ -1417,7 +1371,7 @@ class Propal
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET model_pdf = '".$modelpdf."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
-
+
if ($this->db->query($sql))
{
$this->modelpdf=$modelpdf;
@@ -1430,7 +1384,7 @@ class Propal
}
}
}
-
+
/**
* \brief Cloture de la proposition commerciale
* \param user Utilisateur qui cloture
@@ -1441,13 +1395,13 @@ class Propal
function cloture($user, $statut, $note)
{
$this->statut = $statut;
-
+
$this->db->begin();
-
+
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_statut = $statut, note = '".addslashes($note)."', date_cloture=now(), fk_user_cloture=".$user->id;
$sql.= " WHERE rowid = ".$this->id;
-
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -1465,14 +1419,14 @@ class Propal
$soc->id = $this->socidp;
$result=$soc->set_as_client();
}
-
+
if ($result < 0)
{
$this->error=$this->db->error();
$this->db->rollback();
return -2;
}
-
+
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
@@ -1487,7 +1441,7 @@ class Propal
$result=$interface->run_triggers('PROPAL_CLOSE_REFUSED',$this,$user,$langs,$conf);
// Fin appel triggers
}
-
+
$this->db->commit();
return 1;
}
@@ -1498,7 +1452,7 @@ class Propal
return -1;
}
}
-
+
/**
* \brief Classe la propale comme facturée
* \return int <0 si ko, >0 si ok
@@ -1526,7 +1480,7 @@ class Propal
function create_commande($user)
{
global $conf;
-
+
if ($conf->commande->enabled)
{
if ($this->statut == 2)
@@ -1535,7 +1489,7 @@ class Propal
include_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
$commande = new Commande($this->db);
$result=$commande->create_from_propale($user, $this->id);
-
+
return $result;
}
else return 0;
@@ -1551,9 +1505,9 @@ class Propal
function reopen($userid)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
-
+
$sql .= " WHERE rowid = $this->id;";
-
+
if ($this->db->query($sql) )
{
return 1;
@@ -1563,21 +1517,21 @@ class Propal
dolibarr_print_error($this->db);
}
}
-
-
+
+
/**
* \brief Renvoi la liste des propal (éventuellement filtrée sur un user) dans un tableau
* \param brouillon 0=non brouillon, 1=brouillon
* \param user Objet user de filtre
* \return int -1 si erreur, tableau résultat si ok
*/
-
+
function liste_array ($brouillon=0, $user='')
{
$ga = array();
-
+
$sql = "SELECT rowid, ref FROM ".MAIN_DB_PREFIX."propal";
-
+
if ($brouillon)
{
$sql .= " WHERE fk_statut = 0";
@@ -1593,21 +1547,21 @@ class Propal
$sql .= " WHERE fk_user_author".$user;
}
}
-
+
$sql .= " ORDER BY datep DESC";
$result=$this->db->query($sql);
if ($result)
{
$nump = $this->db->num_rows($result);
-
+
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($result);
-
+
$ga[$obj->rowid] = $obj->ref;
$i++;
}
@@ -1619,7 +1573,7 @@ class Propal
return -1;
}
}
-
+
/**
* \brief Renvoie un tableau contenant les numéros de commandes associées
* \remarks Fonction plus light que associated_orders
@@ -1628,20 +1582,20 @@ class Propal
function commande_liste_array ()
{
$ga = array();
-
+
$sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr";
$sql .= " WHERE fk_propale = " . $this->id;
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
-
+
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
-
+
$ga[$i] = $obj->fk_commande;
$i++;
}
@@ -1653,7 +1607,7 @@ class Propal
dolibarr_print_error($this->db);
}
}
-
+
/**
* \brief Renvoie un tableau contenant les commandes associées
* \remarks Fonction plus lourde que commande_liste_array
@@ -1662,13 +1616,13 @@ class Propal
function associated_orders()
{
$ga = array();
-
+
$sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr";
$sql.= " WHERE fk_propale = " . $this->id;
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
-
+
if ($nump)
{
$i = 0;
@@ -1692,7 +1646,7 @@ class Propal
print $this->db->error();
}
}
-
+
/**
* \brief Renvoie un tableau contenant les numéros de factures associées
* \return array Tableau des id de factures
@@ -1710,20 +1664,20 @@ class Propal
function FactureListeArray($id)
{
$ga = array();
-
+
$sql = "SELECT fk_facture FROM ".MAIN_DB_PREFIX."fa_pr as fp";
$sql .= " WHERE fk_propal = " . $id;
if ($this->db->query($sql))
{
$nump = $this->db->num_rows();
-
+
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object();
-
+
$ga[$i] = $obj->fk_facture;
$i++;
}
@@ -1743,14 +1697,14 @@ class Propal
function delete($user)
{
global $conf;
-
+
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
- if ( $this->db->query($sql) )
+ if ( $this->db->query($sql) )
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
- if ( $this->db->query($sql) )
+ if ( $this->db->query($sql) )
{
-
+
// On efface le répertoire du pdf
$propalref = sanitize_string($this->ref);
if ($conf->propal->dir_output)
@@ -1760,7 +1714,7 @@ class Propal
if (file_exists($file))
{
propale_delete_preview($this->db, $this->id, $this->ref);
-
+
if (!dol_delete_file($file))
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
@@ -1776,7 +1730,7 @@ class Propal
}
}
}
-
+
dolibarr_syslog("Suppression de la proposition $this->id par $user->fullname ($user->id)");
return 1;
}
@@ -1790,7 +1744,7 @@ class Propal
return -1;
}
}
-
+
/**
* \brief Mets à jour les commentaires privés
* \param note Commentaire
@@ -1840,7 +1794,7 @@ class Propal
return -1;
}
}
-
+
/**
* \brief Change les conditions de réglement de la facture
* \param cond_reglement_id Id de la nouvelle condition de réglement
@@ -1908,7 +1862,7 @@ class Propal
}
}
-
+
/**
* \brief Information sur l'objet propal
* \param id id de la propale
@@ -1920,49 +1874,49 @@ class Propal
$sql.= ", fk_user_author, fk_user_valid, fk_user_cloture";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql.= " WHERE c.rowid = $id";
-
+
if ($this->db->query($sql))
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object();
-
+
$this->id = $obj->rowid;
-
+
$this->date_creation = $obj->datec;
$this->date_validation = $obj->datev;
$this->date_cloture = $obj->dateo;
-
+
$cuser = new User($this->db, $obj->fk_user_author);
$cuser->fetch();
$this->user_creation = $cuser;
-
+
if ($obj->fk_user_valid)
{
$vuser = new User($this->db, $obj->fk_user_valid);
$vuser->fetch();
$this->user_validation = $vuser;
}
-
+
if ($obj->fk_user_cloture)
{
$cluser = new User($this->db, $obj->fk_user_cloture);
$cluser->fetch();
$this->user_cloture = $cluser;
}
-
-
+
+
}
$this->db->free();
-
+
}
else
{
dolibarr_print_error($this->db);
}
}
-
-
+
+
/**
* \brief Retourne le libellé du statut d'une propale (brouillon, validée, ...)
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
@@ -1972,7 +1926,7 @@ class Propal
{
return $this->LibStatut($this->statut,$mode);
}
-
+
/**
* \brief Renvoi le libellé d'un statut donné
* \param statut id statut
@@ -2036,7 +1990,7 @@ class Propal
function load_board($user,$mode)
{
global $conf, $user;
-
+
$this->nbtodo=$this->nbtodolate=0;
$sql ="SELECT p.rowid, p.ref, ".$this->db->pdate("p.datec")." as datec,".$this->db->pdate("p.fin_validite")." as datefin";
if (!$user->rights->commercial->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
@@ -2052,7 +2006,7 @@ class Propal
while ($obj=$this->db->fetch_object($resql))
{
$this->nbtodo++;
- if ($obj->datefin < (time() - $conf->propal->cloture->warning_delay))
+ if ($obj->datefin < (time() - $conf->propal->cloture->warning_delay))
{
if ($mode == 'opened') $this->nbtodolate++;
if ($mode == 'signed') $this->nbtodolate++;
@@ -2062,13 +2016,13 @@ class Propal
}
return 1;
}
- else
+ else
{
$this->error=$this->db->error();
return -1;
}
}
-
+
/**
* \brief Charge l'objet propal en mémoire avec propal dont l'id est passé en argument
* \param $src_propal_id Id de la propal source
@@ -2109,14 +2063,14 @@ class Propal
$this->date_livraison = $src_propal->date_livraison;
$this->adresse_livraison_id = $src_propal->adresse_livraison_id;
$this->user_author_id = $src_propal->user_author_id;
-
+
$this->cond_reglement = $src_propal->cond_reglement;
$this->cond_reglement_code=$src_propal->cond_reglement_code;
$this->ref_url = $src_propal->ref_url;
$this->lignes = $src_propal->lignes;
return 1;
}
-
+
/**
* \brief Insert en base un objet propal complétement définie par ses données membres (resultant d'une copie par exemple).
* \return int l'id du nouvel objet propal en base si ok, <0 si ko
@@ -2124,9 +2078,9 @@ class Propal
*/
function create_from()
{
-
+
$this->db->begin();
-
+
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
// Insertion dans la base
@@ -2142,7 +2096,7 @@ class Propal
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal");
-
+
if ($this->id)
{
/*
@@ -2158,7 +2112,7 @@ class Propal
}
else
{
- $this->insert_product_generic($ligne->desc, $ligne->price,
+ $this->insert_product_generic($ligne->desc, $ligne->price,
$ligne->qty, $ligne->tva_tx, $ligne->remise_percent);
}
}
@@ -2178,7 +2132,7 @@ class Propal
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf);
// Fin appel triggers
-
+
$this->db->commit();
return $this->id;
}
@@ -2198,9 +2152,85 @@ class Propal
$this->db->rollback();
return -1;
}
-
+
return $this->id;
}
+
+
+ /**
+ * \brief Initialise la propale avec valeurs fictives aléatoire
+ * Sert à générer une facture pour l'aperu des modèles ou demo
+ */
+ function initAsSpecimen()
+ {
+ global $user,$langs;
+
+ // Charge tableau des id de société socids
+ $socids = array();
+ $sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num_socs = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_socs)
+ {
+ $i++;
+
+ $row = $this->db->fetch_row($resql);
+ $socids[$i] = $row[0];
+ }
+ }
+
+ // Charge tableau des produits prodids
+ $prodids = array();
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num_prods = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_prods)
+ {
+ $i++;
+ $row = $this->db->fetch_row($resql);
+ $prodids[$i] = $row[0];
+ }
+ }
+
+ // Initialise paramètres
+ $this->id=0;
+ $this->ref = 'SPECIMEN';
+ $this->specimen=1;
+ $socid = rand(1, $num_socs);
+ $this->socidp = $socids[$socid];
+ $this->date = time();
+ $this->date_lim_reglement=$this->date+3600*24*30;
+ $this->cond_reglement_code = 'RECEP';
+ $this->mode_reglement_code = 'CHQ';
+ $this->note_public='SPECIMEN';
+ $nbp = rand(1, 9);
+ $xnbp = 0;
+ while ($xnbp < $nbp)
+ {
+ $ligne=new PropaleLigne($this->db);
+ $ligne->desc=$langs->trans("Description")." ".$xnbp;
+ $ligne->qty=1;
+ $ligne->subprice=100;
+ $ligne->price=100;
+ $ligne->tva_taux=19.6;
+ $prodid = rand(1, $num_prods);
+ $ligne->produit_id=$prodids[$prodid];
+ $this->lignes[$xnbp]=$ligne;
+ $xnbp++;
+ }
+
+ $this->amount_ht = $xnbp*100;
+ $this->total_ht = $xnbp*100;
+ $this->total_tva = $xnbp*19.6;
+ $this->total_ttc = $xnbp*119.6;
+ }
+
}
@@ -2209,7 +2239,7 @@ class Propal
\brief Classe permettant la gestion des lignes de propales
*/
-class PropaleLigne
+class PropaleLigne
{
// From llx_propaldet
var $qty;