diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php
index 3db650d7232..2342cca9703 100644
--- a/htdocs/expedition/expedition.class.php
+++ b/htdocs/expedition/expedition.class.php
@@ -183,41 +183,42 @@ class Expedition
* Lit une commande
*
*/
- function fetch ($id)
+ function fetch ($id)
{
- $sql = "SELECT e.rowid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut, e.fk_commande, e.fk_entrepot";
- $sql .= ", ".$this->db->pdate("e.date_expedition")." as date_expedition ";
- $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
- $sql .= " WHERE e.rowid = $id";
-
- $result = $this->db->query($sql) ;
-
- if ( $result )
- {
- $obj = $this->db->fetch_object();
-
- $this->id = $obj->rowid;
- $this->ref = $obj->ref;
- $this->statut = $obj->fk_statut;
- $this->commande_id = $obj->fk_commande;
- $this->user_author_id = $obj->fk_user_author;
- $this->date = $obj->date_expedition;
- $this->entrepot_id = $obj->fk_entrepot;
- $this->db->free();
-
- if ($this->statut == 0)
- $this->brouillon = 1;
-
- $file = $this->_dir() . $this->id.".pdf";
- $this->pdf_filename = $file;
-
- return 1;
- }
- else
- {
- print $this->db->error();
- return -1;
- }
+ global $conf;
+
+ $sql = "SELECT e.rowid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut, e.fk_commande, e.fk_entrepot";
+ $sql .= ", ".$this->db->pdate("e.date_expedition")." as date_expedition ";
+ $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
+ $sql .= " WHERE e.rowid = $id";
+
+ $result = $this->db->query($sql) ;
+
+ if ( $result )
+ {
+ $obj = $this->db->fetch_object($result);
+
+ $this->id = $obj->rowid;
+ $this->ref = $obj->ref;
+ $this->statut = $obj->fk_statut;
+ $this->commande_id = $obj->fk_commande;
+ $this->user_author_id = $obj->fk_user_author;
+ $this->date = $obj->date_expedition;
+ $this->entrepot_id = $obj->fk_entrepot;
+ $this->db->free();
+
+ if ($this->statut == 0) $this->brouillon = 1;
+
+ $file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id) . "/" . $this->id.".pdf";
+ $this->pdf_filename = $file;
+
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
}
/**
@@ -407,50 +408,42 @@ class Expedition
print $this->db->error() . ' in ' . $sql;
}
}
- /*
- * Renvoie le répertoire ou est/sera stocké le document
- */
- function _dir()
- {
- $dir = DOL_DATA_ROOT . "/expedition/" . get_exdir($this->id) ;
- return $dir;
- }
- /**
- * Genere le pdf
- *
- *
- */
- function PdfWrite()
+ /**
+ * Genere le pdf
+ */
+ function PdfWrite()
{
- //EXPEDITION_ADDON_PDF
-
- if (defined("EXPEDITION_ADDON_PDF") && strlen(EXPEDITION_ADDON_PDF) > 0)
- {
- $module_file_name = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition_".EXPEDITION_ADDON_PDF.".modules.php";
-
- $mod = "pdf_expedition_".EXPEDITION_ADDON_PDF;
- $this->fetch_commande();
-
- require_once $module_file_name;
-
- $pdf = new $mod($this->db);
-
- $dir = $this->_dir();
-
- if (! file_exists($dir))
- {
- create_exdir($dir);
- }
-
- $file = $dir . $this->id . ".pdf";
-
- if (file_exists($dir))
- {
- $pdf->generate($this, $file);
- }
- }
+ global $conf;
+
+ //EXPEDITION_ADDON_PDF
+ if (defined("EXPEDITION_ADDON_PDF") && strlen(EXPEDITION_ADDON_PDF) > 0)
+ {
+ $module_file_name = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition_".EXPEDITION_ADDON_PDF.".modules.php";
+
+ $mod = "pdf_expedition_".EXPEDITION_ADDON_PDF;
+ $this->fetch_commande();
+
+ require_once($module_file_name);
+
+ $pdf = new $mod($this->db);
+
+ $dir = $conf->expedition->dir_output . "/" .get_exdir($this->id);
+
+ if (! file_exists($dir))
+ {
+ create_exdir($dir);
+ }
+
+ $file = $dir . $this->id . ".pdf";
+
+ if (file_exists($dir))
+ {
+ $pdf->generate($this, $file);
+ }
+ }
}
+
/*
* Lit la commande associée
*
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 433ee56d432..a6c56283537 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -19,7 +19,6 @@
*
* $Id$
* $Source$
- *
*/
// Code identique a /expedition/commande.php
@@ -490,7 +489,8 @@ else
$var=true;
print "
\n";
- $html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
+
+ $html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
/*
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index c1110a22938..6992daec9c8 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -1572,12 +1572,14 @@ class Form
*/
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='')
{
+ // filedir = conf->...dir_ouput."/".get_exdir(id)
+
global $langs,$bc;
$var=true;
$filename = sanitize_string($filename);
- $relativepath = "${filename}/${filename}.pdf";
- $fullpathfile = $filedir . "/" . $filename . ".pdf";
+ if ($modulepart != 'expedition') $relativepath = "${filename}/${filename}.pdf";
+ else $relativepath = get_exdir("${filename}")."${filename}.pdf";
$i=0;
if (is_dir($filedir))
@@ -1632,9 +1634,7 @@ class Form
if (eregi('\-detail\.pdf',$file)) print '