Fix: [ bug #1062 ] Documents lost in propals and contracts validating
This commit is contained in:
parent
899c209468
commit
817569d487
@ -24,6 +24,7 @@ Fix: Compatiblity with multicompany module
|
||||
Fix: Edit propal line was losing product supplier price id
|
||||
Fix: Delete linked element to supplier invoice when deleted
|
||||
Fix: [ bug #1061 ] Bad info shipped products
|
||||
Fix: [ bug #1062 ] Documents lost in propals and contracts validating
|
||||
Qual: Add travis-ci integration
|
||||
|
||||
|
||||
|
||||
@ -1259,6 +1259,7 @@ class Propal extends CommonObject
|
||||
*/
|
||||
function valid($user, $notrigger=0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
global $conf,$langs;
|
||||
|
||||
$error=0;
|
||||
@ -1305,8 +1306,31 @@ class Propal extends CommonObject
|
||||
// Fin appel triggers
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $error)
|
||||
{
|
||||
// Rename directory if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||
{
|
||||
// Rename of propal directory ($this->ref = old ref, $num = new ref)
|
||||
// to not lose the linked files
|
||||
$facref = dol_sanitizeFileName($this->ref);
|
||||
$snumfa = dol_sanitizeFileName($num);
|
||||
$dirsource = $conf->propal->dir_output.'/'.$facref;
|
||||
$dirdest = $conf->propal->dir_output.'/'.$snumfa;
|
||||
if (file_exists($dirsource))
|
||||
{
|
||||
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
|
||||
dol_syslog("Rename ok");
|
||||
// Deleting old PDF in new rep
|
||||
dol_delete_file($conf->propal->dir_output.'/'.$snumfa.'/'.$facref.'*.*');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->brouillon=0;
|
||||
$this->statut = 1;
|
||||
$this->user_valid_id=$user->id;
|
||||
@ -1315,13 +1339,13 @@ class Propal extends CommonObject
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
@ -281,6 +281,7 @@ class Contrat extends CommonObject
|
||||
*/
|
||||
function validate($user)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
global $langs, $conf;
|
||||
|
||||
$error=0;
|
||||
@ -315,7 +316,36 @@ class Contrat extends CommonObject
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
|
||||
return 1;
|
||||
if (! $error)
|
||||
{
|
||||
// Rename directory if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||
{
|
||||
// Rename of propal directory ($this->ref = old ref, $num = new ref)
|
||||
// to not lose the linked files
|
||||
$facref = dol_sanitizeFileName($this->ref);
|
||||
$snumfa = dol_sanitizeFileName($num);
|
||||
$dirsource = $conf->contract->dir_output.'/'.$facref;
|
||||
$dirdest = $conf->contract->dir_output.'/'.$snumfa;
|
||||
if (file_exists($dirsource))
|
||||
{
|
||||
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
dol_syslog("Rename ok");
|
||||
// Deleting old PDF in new rep
|
||||
dol_delete_file($conf->contract->dir_output.'/'.$snumfa.'/'.$facref.'*.*');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user