On efface le reprtoire du pdf provisoire

This commit is contained in:
Regis Houssin 2006-05-31 11:34:05 +00:00
parent e5a1fed645
commit 45a0d11bb7
5 changed files with 81 additions and 24 deletions

View File

@ -348,6 +348,33 @@ class Expedition
return -2;
}
}
// On efface le répertoire de pdf provisoire
$expeditionref = sanitize_string($this->ref);
$expeditionref = str_replace("(","",$expeditionref);
$expeditionref = str_replace(")","",$expeditionref);
if ($conf->expedition->dir_output)
{
$dir = $conf->expedition->dir_output . "/" . $expeditionref ;
$file = $conf->expedition->dir_output . "/" . $expeditionref . "/" . $expeditionref . ".pdf";
if (file_exists($file))
{
if (!dol_delete_file($file))
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$dir);
return 0;
}
}
if (file_exists($dir))
{
if (!dol_delete_dir($dir))
{
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
return 0;
}
}
}
}
else
{

View File

@ -530,22 +530,20 @@ else
/*
* Documents générés
*/
//mis en commentaire pour test du patch
//$filename=sanitize_string($expedition->id);
//$filedir=$conf->expedition->dir_output . "/" .get_exdir($expedition->id);
$filename=sanitize_string($expedition->ref);
$filedir=$conf->expedition->dir_output . "/" .$expedition->ref;
$expeditionref = sanitize_string($expedition->ref);
$expeditionref = str_replace("(","",$expeditionref);
$expeditionref = str_replace(")","",$expeditionref);
$filedir = $conf->expedition->dir_output . "/" .$expeditionref;
$urlsource=$_SERVER["PHP_SELF"]."?id=".$expedition->id;
$urlsource = $_SERVER["PHP_SELF"]."?id=".$expedition->id;
//$genallowed=$user->rights->expedition->creer;
//$delallowed=$user->rights->expedition->supprimer;
$genallowed=1;
$delallowed=0;
$genallowed=$user->rights->expedition->creer;
$delallowed=$user->rights->expedition->supprimer;
//$genallowed=1;
//$delallowed=0;
$result=$html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
$result=$html->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf);
/*
* Déjà livre

View File

@ -124,6 +124,8 @@ function expedition_pdf_create($db, $id, $modele='', $outputlangs='')
$result=$expedition->fetch($id);
$expeditionref = sanitize_string($expedition->ref);
$expeditionref = str_replace("(","",$expeditionref);
$expeditionref = str_replace(")","",$expeditionref);
$dir = $conf->expedition->dir_output . "/" . $expeditionref;
$file = $dir . "/" . $expeditionref . ".pdf";
if ($obj->generate($expedition, $file))

View File

@ -82,18 +82,22 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Verification de la configuration
if ($conf->expedition->dir_output)
{
$forbidden_chars=array("/","\\",":","*","?","\"","<",">","|","[","]",",",";","=");
$expref = str_replace($forbidden_chars,"_",$this->expe->ref);
$dir = $conf->expedition->dir_output . "/" . $this->expe->ref . "/" ;
$file = $dir .$this->expe->ref . ".pdf";
//Si le dossier n existe pas
if (! file_exists($dir)){
umask(0);
//On tente de le creer
if (! mkdir($dir, 0755)){
$pdf->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
$expeditionref = sanitize_string($this->expe->ref);
$expeditionref = str_replace("(","",$expeditionref);
$expeditionref = str_replace(")","",$expeditionref);
$dir = $conf->expedition->dir_output . "/" . $expeditionref;
$file = $dir . "/" . $expeditionref . ".pdf";
//Si le dossier n existe pas
if (! file_exists($dir))
{
umask(0);
//On tente de le creer
if (! mkdir($dir, 0755))
{
$pdf->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
//Si le dossier existe
if (file_exists($dir))

View File

@ -339,6 +339,32 @@ class Livraison
}
}
// On efface le répertoire de pdf provisoire
$livraisonref = sanitize_string($this->ref);
$livraisonref = str_replace("(","",$livraisonref);
$livraisonref = str_replace(")","",$livraisonref);
if ($conf->expedition->dir_output)
{
$dir = $conf->livraison->dir_output . "/" . $livraisonref ;
$file = $conf->livraison->dir_output . "/" . $livraisonref . "/" . $livraisonref . ".pdf";
if (file_exists($file))
{
if (!dol_delete_file($file))
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$dir);
return 0;
}
}
if (file_exists($dir))
{
if (!dol_delete_dir($dir))
{
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
return 0;
}
}
}
dolibarr_syslog("livraison.class.php::valid ok");
}
else