Fix: Lien invalide sur PDF expedition
This commit is contained in:
parent
17fd57841c
commit
2f0816b4a7
@ -183,41 +183,42 @@ class Expedition
|
|||||||
* Lit une commande
|
* 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";
|
global $conf;
|
||||||
$sql .= ", ".$this->db->pdate("e.date_expedition")." as date_expedition ";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql = "SELECT e.rowid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut, e.fk_commande, e.fk_entrepot";
|
||||||
$sql .= " WHERE e.rowid = $id";
|
$sql .= ", ".$this->db->pdate("e.date_expedition")." as date_expedition ";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||||
$result = $this->db->query($sql) ;
|
$sql .= " WHERE e.rowid = $id";
|
||||||
|
|
||||||
if ( $result )
|
$result = $this->db->query($sql) ;
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object();
|
if ( $result )
|
||||||
|
{
|
||||||
$this->id = $obj->rowid;
|
$obj = $this->db->fetch_object($result);
|
||||||
$this->ref = $obj->ref;
|
|
||||||
$this->statut = $obj->fk_statut;
|
$this->id = $obj->rowid;
|
||||||
$this->commande_id = $obj->fk_commande;
|
$this->ref = $obj->ref;
|
||||||
$this->user_author_id = $obj->fk_user_author;
|
$this->statut = $obj->fk_statut;
|
||||||
$this->date = $obj->date_expedition;
|
$this->commande_id = $obj->fk_commande;
|
||||||
$this->entrepot_id = $obj->fk_entrepot;
|
$this->user_author_id = $obj->fk_user_author;
|
||||||
$this->db->free();
|
$this->date = $obj->date_expedition;
|
||||||
|
$this->entrepot_id = $obj->fk_entrepot;
|
||||||
if ($this->statut == 0)
|
$this->db->free();
|
||||||
$this->brouillon = 1;
|
|
||||||
|
if ($this->statut == 0) $this->brouillon = 1;
|
||||||
$file = $this->_dir() . $this->id.".pdf";
|
|
||||||
$this->pdf_filename = $file;
|
$file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id) . "/" . $this->id.".pdf";
|
||||||
|
$this->pdf_filename = $file;
|
||||||
return 1;
|
|
||||||
}
|
return 1;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
print $this->db->error();
|
{
|
||||||
return -1;
|
$this->error=$this->db->error();
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -407,50 +408,42 @@ 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;
|
||||||
|
|
||||||
if (defined("EXPEDITION_ADDON_PDF") && strlen(EXPEDITION_ADDON_PDF) > 0)
|
//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";
|
{
|
||||||
|
$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();
|
$mod = "pdf_expedition_".EXPEDITION_ADDON_PDF;
|
||||||
|
$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))
|
||||||
create_exdir($dir);
|
{
|
||||||
}
|
create_exdir($dir);
|
||||||
|
}
|
||||||
$file = $dir . $this->id . ".pdf";
|
|
||||||
|
$file = $dir . $this->id . ".pdf";
|
||||||
if (file_exists($dir))
|
|
||||||
{
|
if (file_exists($dir))
|
||||||
$pdf->generate($this, $file);
|
{
|
||||||
}
|
$pdf->generate($this, $file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lit la commande associée
|
* Lit la commande associée
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -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>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user