Fix: Lien invalide sur PDF expedition

This commit is contained in:
Laurent Destailleur 2005-09-14 03:47:27 +00:00
parent 17fd57841c
commit 2f0816b4a7
3 changed files with 75 additions and 82 deletions

View File

@ -185,6 +185,8 @@ class Expedition
*/ */
function fetch ($id) function fetch ($id)
{ {
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 = "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 .= ", ".$this->db->pdate("e.date_expedition")." as date_expedition ";
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
@ -194,7 +196,7 @@ class Expedition
if ( $result ) if ( $result )
{ {
$obj = $this->db->fetch_object(); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref; $this->ref = $obj->ref;
@ -205,17 +207,16 @@ class Expedition
$this->entrepot_id = $obj->fk_entrepot; $this->entrepot_id = $obj->fk_entrepot;
$this->db->free(); $this->db->free();
if ($this->statut == 0) if ($this->statut == 0) $this->brouillon = 1;
$this->brouillon = 1;
$file = $this->_dir() . $this->id.".pdf"; $file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id) . "/" . $this->id.".pdf";
$this->pdf_filename = $file; $this->pdf_filename = $file;
return 1; return 1;
} }
else else
{ {
print $this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }
} }
@ -407,24 +408,15 @@ class Expedition
print $this->db->error() . ' in ' . $sql; 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 * Genere le pdf
*
*
*/ */
function PdfWrite() function PdfWrite()
{ {
//EXPEDITION_ADDON_PDF global $conf;
//EXPEDITION_ADDON_PDF
if (defined("EXPEDITION_ADDON_PDF") && strlen(EXPEDITION_ADDON_PDF) > 0) 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"; $module_file_name = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition_".EXPEDITION_ADDON_PDF.".modules.php";
@ -432,11 +424,11 @@ class Expedition
$mod = "pdf_expedition_".EXPEDITION_ADDON_PDF; $mod = "pdf_expedition_".EXPEDITION_ADDON_PDF;
$this->fetch_commande(); $this->fetch_commande();
require_once $module_file_name; require_once($module_file_name);
$pdf = new $mod($this->db); $pdf = new $mod($this->db);
$dir = $this->_dir(); $dir = $conf->expedition->dir_output . "/" .get_exdir($this->id);
if (! file_exists($dir)) if (! file_exists($dir))
{ {
@ -451,6 +443,7 @@ class Expedition
} }
} }
} }
/* /*
* Lit la commande associée * Lit la commande associée
* *

View File

@ -19,7 +19,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
// Code identique a /expedition/commande.php // Code identique a /expedition/commande.php
@ -490,7 +489,8 @@ else
$var=true; $var=true;
print "<br>\n"; print "<br>\n";
$html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
$html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
/* /*

View File

@ -1572,12 +1572,14 @@ class Form
*/ */
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='') function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='')
{ {
// filedir = conf->...dir_ouput."/".get_exdir(id)
global $langs,$bc; global $langs,$bc;
$var=true; $var=true;
$filename = sanitize_string($filename); $filename = sanitize_string($filename);
$relativepath = "${filename}/${filename}.pdf"; if ($modulepart != 'expedition') $relativepath = "${filename}/${filename}.pdf";
$fullpathfile = $filedir . "/" . $filename . ".pdf"; else $relativepath = get_exdir("${filename}")."${filename}.pdf";
$i=0; $i=0;
if (is_dir($filedir)) if (is_dir($filedir))
@ -1632,9 +1634,7 @@ class Form
if (eregi('\-detail\.pdf',$file)) print '<td nowrap>PDF Détaillé</td>'; if (eregi('\-detail\.pdf',$file)) print '<td nowrap>PDF Détaillé</td>';
else print '<td nowrap>PDF</td>'; else print '<td nowrap>PDF</td>';
$relativepathdetail = "${filename}/$file"; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&file='.urlencode($relativepath).'">'.$file.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&file='.urlencode($relativepathdetail).'">'.$file.'</a></td>';
print '<td align="right">'.filesize($filedir."/".$file). ' bytes</td>'; print '<td align="right">'.filesize($filedir."/".$file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedir."/".$file)).'</td>'; print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($filedir."/".$file)).'</td>';
print '</tr>'; print '</tr>';