Fix documents are lost if we rename contrat ref
This commit is contained in:
parent
faef7a2e0c
commit
cad7bdc74b
@ -872,12 +872,26 @@ if (empty($reshook))
|
|||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$old_ref = $object->ref;
|
||||||
$result = $object->setValueFrom('ref', GETPOST('ref','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY');
|
$result = $object->setValueFrom('ref', GETPOST('ref','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY');
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$action = 'editref';
|
$action = 'editref';
|
||||||
} else {
|
} else {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
$old_filedir = $conf->contrat->dir_output . '/' . dol_sanitizeFileName($old_ref);
|
||||||
|
$new_filedir = $conf->contrat->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
||||||
|
|
||||||
|
$files = dol_dir_list($old_filedir);
|
||||||
|
if (!empty($files))
|
||||||
|
{
|
||||||
|
foreach ($files as $file)
|
||||||
|
{
|
||||||
|
dol_move($file['fullname'], $new_filedir.'/'.$file['name']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
|
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user