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; 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 else
{ {

View File

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

View File

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

View File

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