diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index c8adde476da..a1e908491ce 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -32,6 +32,7 @@
*/
require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT.'/expedition/expedition.class.php');
$langs->load("admin");
$langs->load("bills");
@@ -45,6 +46,35 @@ if (!$user->admin) accessforbidden();
/*
* Actions
*/
+if ($_GET["action"] == 'specimen')
+{
+ $modele=$_GET["module"];
+
+ $exp = new Expedition($db);
+ $exp->initAsSpecimen();
+ $exp->fetch_commande();
+
+ // Charge le modele
+ $dir = DOL_DOCUMENT_ROOT . "/expedition/mods/pdf/";
+ $file = "pdf_expedition_".$modele.".modules.php";
+ if (file_exists($dir.$file))
+ {
+ $classname = "pdf_expedition_".$modele;
+ require_once($dir.$file);
+
+ $obj = new $classname($db);
+
+ if ($obj->write_file($exp,$langs) > 0)
+ {
+ header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf");
+ return;
+ }
+ }
+ else
+ {
+ $mesg='
'.$langs->trans("ErrorModuleNotFound").'
';
+ }
+}
if ($_GET["action"] == 'set')
{
@@ -128,6 +158,9 @@ if ($_GET["action"] == 'setmod')
llxHeader("","");
+if ($mesg) print $mesg.'
';
+
+
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
$html=new Form($db);
@@ -345,9 +378,9 @@ if(is_dir($dir))
print '';
// Info
- $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
- $htmltooltip.='
'.$langs->trans("Width").': '.$module->page_largeur;
- $htmltooltip.='
'.$langs->trans("Height").': '.$module->page_hauteur;
+ $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+ $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+ $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip.='
'.$langs->trans("FeaturesSupported").':';
$htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo);
print '';
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index 9b2d61bab85..f02b33c5dc7 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -64,12 +64,16 @@ if ($_GET["action"] == 'specimen')
$obj = new $classname($db);
- if ($obj->write_pdf_file($facture) > 0)
+ if ($obj->write_pdf_file($facture,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
return;
}
}
+ else
+ {
+ $mesg=' '.$langs->trans("ErrorModuleNotFound").' ';
+ }
}
if ($_GET["action"] == 'set')
diff --git a/htdocs/document.php b/htdocs/document.php
index f446494dad3..66bf2240b09 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -41,15 +41,16 @@ $original_file = urldecode($_GET["file"]);
$modulepart = urldecode($_GET["modulepart"]);
$urlsource = urldecode($_GET["urlsource"]);
// Défini type (attachment=1 pour forcer popup 'enregistrer sous')
-$type = urldecode($_GET["type"]); $attachment = true;
-if (eregi('\.sql',$original_file)) { $type='text/plain'; $attachment = true; }
-if (eregi('\.html',$original_file)) { $type='text/html'; $attachment = false; }
-if (eregi('\.csv',$original_file)) { $type='text/csv'; $attachment = true; }
-if (eregi('\.pdf',$original_file)) { $type='application/pdf'; $attachment = true; }
-if (eregi('\.xls',$original_file)) { $type='application/x-msexcel'; $attachment = true; }
-if (eregi('\.jpg',$original_file)) { $type='image/jpeg'; $attachment = true; }
-if (eregi('\.png',$original_file)) { $type='image/jpeg'; $attachment = true; }
-if (eregi('\.tiff',$original_file)) { $type='image/tiff'; $attachment = true; }
+$type = urldecode($_GET["type"]);
+$attachment = true;
+if (eregi('\.sql$',$original_file)) { $type='text/plain'; $attachment = true; }
+if (eregi('\.html$',$original_file)) { $type='text/html'; $attachment = false; }
+if (eregi('\.csv$',$original_file)) { $type='text/csv'; $attachment = true; }
+if (eregi('\.pdf$',$original_file)) { $type='application/pdf'; $attachment = true; }
+if (eregi('\.xls$',$original_file)) { $type='application/x-msexcel'; $attachment = true; }
+if (eregi('\.jpg$',$original_file)) { $type='image/jpeg'; $attachment = true; }
+if (eregi('\.png$',$original_file)) { $type='image/jpeg'; $attachment = true; }
+if (eregi('\.tiff$',$original_file)) { $type='image/tiff'; $attachment = true; }
//Suppression de la chaine de caractère ../ dans $original_file
$original_file = str_replace("../","/", "$original_file");
diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php
index 817cde8c680..dc4f02afeaa 100644
--- a/htdocs/expedition/expedition.class.php
+++ b/htdocs/expedition/expedition.class.php
@@ -28,6 +28,7 @@
*/
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
+require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
/**
@@ -571,15 +572,15 @@ class Expedition extends CommonObject
}
- /*
- * Lit la commande associée
- *
- */
- function fetch_commande()
- {
- $this->commande =& new Commande($this->db);
- $this->commande->fetch($this->commande_id);
- }
+ /*
+ * Lit la commande associée
+ *
+ */
+ function fetch_commande()
+ {
+ $this->commande =& new Commande($this->db);
+ $this->commande->fetch($this->commande_id);
+ }
function fetch_lignes()
@@ -653,7 +654,78 @@ class Expedition extends CommonObject
if ($statut==1) return img_picto($langs->trans('StatusSendingValidated'),'statut4').' '.$langs->trans('StatusSendingValidated');
}
}
-
+
+ /**
+ * \brief Initialise la facture avec valeurs fictives aléatoire
+ * Sert à générer une facture pour l'aperu des modèles ou demo
+ */
+ function initAsSpecimen()
+ {
+ global $user,$langs;
+
+ // Charge tableau des id de société socids
+ $socids = array();
+ $sql = "SELECT idp FROM ".MAIN_DB_PREFIX."societe WHERE client=1 LIMIT 10";
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num_socs = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_socs)
+ {
+ $i++;
+
+ $row = $this->db->fetch_row($resql);
+ $socids[$i] = $row[0];
+ }
+ }
+
+ // Charge tableau des produits prodids
+ $prodids = array();
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE envente=1";
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num_prods = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_prods)
+ {
+ $i++;
+ $row = $this->db->fetch_row($resql);
+ $prodids[$i] = $row[0];
+ }
+ }
+
+ // Initialise paramètres
+ $this->id=0;
+ $this->ref = 'SPECIMEN';
+ $this->specimen=1;
+ $socid = rand(1, $num_socs);
+ $this->statut = 1;
+ $this->commande_id = 0;
+ if ($conf->livraison->enabled)
+ {
+ $this->livraison_id = 0;
+ }
+ $this->date = time();
+ $this->entrepot_id = 0;
+ $this->adresse_livraison_id = 0;
+ $this->socidp = $socids[$socid];
+
+ $nbp = 5;
+ $xnbp = 0;
+ while ($xnbp < $nbp)
+ {
+ $ligne=new ExpeditionLigne($this->db);
+ $ligne->desc=$langs->trans("Description")." ".$xnbp;
+ $ligne->libelle=$langs->trans("Description")." ".$xnbp;
+ $ligne->qty=10;
+ $ligne->qty_expedition=5;
+ $prodid = rand(1, $num_prods);
+ $ligne->fk_product=$prodids[$prodid];
+ $xnbp++;
+ }
+ }
}
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index cc988453fae..68a23a36583 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -142,6 +142,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
// Sauvegarde le dernier modèle choisi pour générer un document
$expedition = new Expedition($db, 0, $_REQUEST['id']);
$expedition->fetch($_REQUEST['id']);
+ $expedition->fetch_commande();
if ($_REQUEST['model'])
{
$expedition->set_pdf_model($user, $_REQUEST['model']);
@@ -152,7 +153,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
- $result=expedition_pdf_create($db, $expedition->id,$expedition->modelpdf,$outputlangs);
+ $result=expedition_pdf_create($db,$expedition->id,$expedition->modelpdf,$outputlangs);
if ($result <= 0)
{
dolibarr_print_error($db,$result);
diff --git a/htdocs/expedition/mods/pdf/ModelePdfExpedition.class.php b/htdocs/expedition/mods/pdf/ModelePdfExpedition.class.php
index a0375eac305..b684ecb333c 100644
--- a/htdocs/expedition/mods/pdf/ModelePdfExpedition.class.php
+++ b/htdocs/expedition/mods/pdf/ModelePdfExpedition.class.php
@@ -77,7 +77,7 @@ Class ModelePdfExpedition extends DolibarrPdfBarCode
/*
\brief Crée un bon d'expedition sur disque
\param db objet base de donnée
- \param id id de la propale à créer
+ \param id id de la expedition à créer
\param modele force le modele à utiliser ('' par defaut)
\param outputlangs objet lang a utiliser pour traduction
*/
@@ -123,12 +123,7 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='')
$expedition = new Expedition($db);
$result=$expedition->fetch($id);
- $expeditionref = sanitize_string($expedition->ref);
- $dir = $conf->expedition->dir_output . "/" . $expeditionref;
- $file = $dir . "/" . $expeditionref . ".pdf";
-
- if ($obj->generate($expedition, $file) > 0)
-// if ( $obj->write_pdf_file($id, $outputlangs) > 0)
+ if ($obj->write_file($expedition, $langs) > 0)
{
// on supprime l'image correspondant au preview
// expedition_delete_preview($db, $id);
diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php
index b6f921cf225..02ecd64f656 100644
--- a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php
+++ b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php
@@ -73,11 +73,12 @@ Class pdf_expedition_merou extends ModelePdfExpedition
}
- //*****************************
- //Creation du Document
- //Initialisation des données
- //*****************************
- function generate(&$objExpe, $file, $outputlangs='')
+ /**
+ * \brief Fonction générant le document sur le disque
+ * \param obj Objet expedition à générer (ou id si ancienne methode)
+ * \return int 1=ok, 0=ko
+ */
+ function write_file(&$obj, $outputlangs='')
{
global $user,$conf,$langs;
@@ -92,8 +93,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$outputlangs->setPhpLang();
//Generation de la fiche
- $this->expe = $objExpe;
- $this->expe->fetch_commande();
+ $this->expe = $obj;
//Verification de la configuration
if ($conf->expedition->dir_output)
@@ -210,10 +210,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition
}
//Insertion du pied de page
$this->_pagefoot($pdf);
+
$pdf->AliasNbPages();
- //Cloture du pdf
+
$pdf->Close();
- //Ecriture du pdf
+
$pdf->Output($file);
$langs->setPhpLang(); // On restaure langue session
diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php
index 45dcc48e6ba..27072ad1a8d 100644
--- a/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php
+++ b/htdocs/expedition/mods/pdf/pdf_expedition_rouget.modules.php
@@ -114,7 +114,13 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->Text($posx, 60, $outputlangs->trans("Date")." : ".dolibarr_print_date($this->expe->commande->date,"%d %b %Y"));
}
- function generate(&$objExpe, $filename, $outputlangs='')
+
+ /**
+ * \brief Fonction générant le document sur le disque
+ * \param obj Objet expedition à générer (ou id si ancienne methode)
+ * \return int 1=ok, 0=ko
+ */
+ function write_file(&$obj, $outputlangs='')
{
global $user,$conf,$langs;
@@ -129,8 +135,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if ($conf->expedition->dir_output)
{
- $this->expe = $objExpe;
- $this->expe->fetch_commande();
+ $this->expe = $obj;
// Définition de $dir et $file
if ($this->expe->specimen)
@@ -253,8 +258,11 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->Text(194, $curY, $this->expe->lignes[$i]->qty_expedition);
}
+ $pdf->AliasNbPages();
+
+ $pdf->Close();
- $pdf->Output($filename);
+ $pdf->Output($file);
$langs->setPhpLang(); // On restaure langue session
return 1;
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 8dc6294e5bf..d378be036b8 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -2233,7 +2233,7 @@ class Facture extends CommonObject
$this->cond_reglement_code = 'RECEP';
$this->mode_reglement_code = 'CHQ';
$this->note_public='SPECIMEN';
- $nbp = rand(1, 9);
+ $nbp = 5;
$xnbp = 0;
while ($xnbp < $nbp)
{
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index f699c0a7c7b..ea24bb62586 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -573,5 +573,5 @@ DeliveriesOrderAbility=Prise en charge des bons de r
ActivateFCKeditor=Activer FCKeditor pour :
FCKeditorForCompany=Création/édition WYSIWIG des descriptions et notes des tiers
FCKeditorForProductDescription=Création/édition WYSIWIG des notes des produits/services
-FCKeditorForDetails=Création/édition WYSIWIG des lignes details des entités (commandes, propales, factures, etc...)
+FCKeditorForDetails=Création/édition WYSIWIG des lignes details des produits (sur commandes, propales, factures, etc...)
FCKeditorForMailing=Création/édition WYSIWIG des mailings
|