Fix: Validation of order if a file was attached
This commit is contained in:
parent
4a794016fb
commit
af1cede0ed
@ -29,6 +29,7 @@ For users:
|
||||
- Fix: Clicktodial plugin works correctly now
|
||||
- Fix: Multiprices features works correctly.
|
||||
- Fix: Project module and task creation.
|
||||
- Fix: Validation of order if a file was attached.
|
||||
|
||||
For translators:
|
||||
- Added ca_ES language files
|
||||
|
||||
@ -251,34 +251,26 @@ class Commande extends CommonObject
|
||||
// On efface le repertoire de pdf provisoire
|
||||
if (eregi('^\(PROV', $this->ref))
|
||||
{
|
||||
// On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref)
|
||||
// afin de ne pas perdre les fichiers attachés
|
||||
$comref = sanitizeFileName($this->ref);
|
||||
if ($conf->commande->dir_output)
|
||||
$snum = sanitizeFileName($num);
|
||||
$dirsource = $conf->commande->dir_output.'/'.$comref;
|
||||
$dirdest = $conf->commande->dir_output.'/'.$snum;
|
||||
if (file_exists($dirsource))
|
||||
{
|
||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
||||
if (file_exists($file))
|
||||
{
|
||||
commande_delete_preview($this->db, $this->id, $this->ref);
|
||||
dol_syslog("Commande::valid() rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (!dol_delete_file($file))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (file_exists($dir))
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
if (!dol_delete_dir($dir))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||
$this->db->rollback();
|
||||
return 0;
|
||||
}
|
||||
dol_syslog("Rename ok");
|
||||
// Suppression ancien fichier PDF dans nouveau rep
|
||||
dol_delete_file($conf->commande->dir_output.'/'.$snum.'/'.$comref.'.*');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If stock is incremented on validate order, we must increment it
|
||||
if ($result >= 0 && $conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
|
||||
{
|
||||
|
||||
@ -1310,11 +1310,11 @@ class Facture extends CommonObject
|
||||
$dirdest = $conf->facture->dir_output.'/'.$snumfa;
|
||||
if (file_exists($dirsource))
|
||||
{
|
||||
dol_syslog("Facture::set_valid() renommage rep ".$dirsource." en ".$dirdest);
|
||||
dol_syslog("Facture::set_valid() rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
dol_syslog("Renommage ok");
|
||||
dol_syslog("Rename ok");
|
||||
// Suppression ancien fichier PDF dans nouveau rep
|
||||
dol_delete_file($conf->facture->dir_output.'/'.$snumfa.'/'.$facref.'.*');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user