From d48f2507b50edac397fe2e4b4f8bcc21b2ca241d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 18 Jan 2017 15:37:45 +0100 Subject: [PATCH] Fix link attachment on bank document page --- htdocs/commande/document.php | 1 + htdocs/compta/bank/document.php | 82 ++++----------------------------- 2 files changed, 10 insertions(+), 73 deletions(-) diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 5175c4c85c5..5ce456fe8e0 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -182,6 +182,7 @@ if ($id > 0 || ! empty($ref)) else { header('Location: index.php'); + exit; } diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 0878474dcb5..db70acc7373 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -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); -- GitLab