Fix link attachment on bank document page
This commit is contained in:
parent
ddbb7ee1f4
commit
d48f2507b5
@ -182,6 +182,7 @@ if ($id > 0 || ! empty($ref))
|
||||
else
|
||||
{
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -81,59 +81,13 @@ if ($id)
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// Envoi fichier
|
||||
if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) {
|
||||
if ($object->fetch($id)) {
|
||||
|
||||
$upload_dir = $conf->bank->dir_output . "/" . $object->ref;
|
||||
|
||||
if (dol_mkdir($upload_dir) >= 0) {
|
||||
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'],
|
||||
$upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),
|
||||
0, 0, $_FILES['userfile']['error']);
|
||||
if (is_numeric($resupload) && $resupload > 0) {
|
||||
if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
|
||||
{
|
||||
// Create thumbs
|
||||
$object->addThumbs($upload_dir . "/" . $_FILES['userfile']['name']);
|
||||
}
|
||||
$mesg = '<div class="ok">' . $langs->trans("FileTransferComplete") . '</div>';
|
||||
}
|
||||
else {
|
||||
$langs->load("errors");
|
||||
if ($resupload < 0) { // Unknown error
|
||||
$mesg = '<div class="error">' . $langs->trans("ErrorFileNotUploaded") . '</div>';
|
||||
}
|
||||
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',
|
||||
$resupload)) { // Files infected by a virus
|
||||
$mesg = '<div class="error">' . $langs->trans("ErrorFileIsInfectedWithAVirus") . '</div>';
|
||||
}
|
||||
else { // Known error
|
||||
$mesg = '<div class="error">' . $langs->trans($resupload) . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
$upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
}
|
||||
|
||||
// Delete
|
||||
else if ($action == 'confirm_deletefile' && $confirm == 'yes') {
|
||||
if ($object->fetch($id)) {
|
||||
|
||||
$upload_dir = $conf->bank->dir_output;
|
||||
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
|
||||
$ret = dol_delete_file($file, 0, 0, 0, $object);
|
||||
if ($ret) {
|
||||
setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
|
||||
}
|
||||
|
||||
Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
@ -182,30 +136,12 @@ if ($id > 0 || !empty($ref)) {
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
dol_htmloutput_mesg($mesg, $mesgs);
|
||||
|
||||
|
||||
/*
|
||||
* Confirmation suppression fichier
|
||||
*/
|
||||
if ($action == 'delete') {
|
||||
$ret = $form->form_confirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode($_GET["urlfile"]),
|
||||
$langs->trans('DeleteFile'),
|
||||
$langs->trans('ConfirmDeleteFile'), 'confirm_deletefile',
|
||||
'', 0, 1);
|
||||
if ($ret == 'html')
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
// Affiche formulaire upload
|
||||
$formfile = new FormFile($db);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT . '/compta/bank/document.php?id=' . $object->id,
|
||||
'', 0, 0, $user->rights->banque, 50, $object);
|
||||
|
||||
|
||||
// List of document
|
||||
$modulepart = 'bank';
|
||||
$permission = $user->rights->banque->modifier;
|
||||
$permtoedit = $user->rights->banque->modifier;
|
||||
$param = '&id=' . $object->id;
|
||||
$formfile->list_of_documents($filearray, $object, 'bank', $param);
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
}
|
||||
else {
|
||||
dol_print_error($db);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user