From 058d0b1b08b3de93c8139a7024e56421271d640e Mon Sep 17 00:00:00 2001 From: Regis Houssin <regis@dolibarr.fr> Date: Sat, 18 Aug 2012 08:51:52 +0200 Subject: [PATCH] Fix: [ bug #503 ] Unable to delete linked file to a deposit --- htdocs/compta/paiement/cheque/fiche.php | 28 +++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/paiement/cheque/fiche.php b/htdocs/compta/paiement/cheque/fiche.php index 94ef6ce5414..981d2d97b66 100644 --- a/htdocs/compta/paiement/cheque/fiche.php +++ b/htdocs/compta/paiement/cheque/fiche.php @@ -158,7 +158,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->c if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->cheque) { - $result = $object->fetch($_GET["id"]); + $result = $object->fetch($id); $result = $object->validate($user); if ($result >= 0) { @@ -185,7 +185,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->c if ($action == 'builddoc' && $user->rights->banque->cheque) { - $result = $object->fetch($_GET["id"]); + $result = $object->fetch($id); /*if ($_REQUEST['model']) { @@ -214,6 +214,22 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) } } +// Remove file in doc form +else if ($action == 'remove_file' && $user->rights->banque->cheque) +{ + if ($object->fetch($id) > 0) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $langs->load("other"); + + $file=$dir.get_exdir($object->number,2,1) . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + } +} + /* * View @@ -608,8 +624,12 @@ if ($action != 'new') { if ($object->statut == 1) { - $dirchequereceipts = $dir.get_exdir($object->number,2,1).$object->ref; - $formfile->show_documents("remisecheque",$object->ref,$dirchequereceipts,$_SERVER["PHP_SELF"].'?id='.$object->id,1,1); + $filename=dol_sanitizeFileName($object->ref); + $filedir=$dir.get_exdir($object->number,2,1) . dol_sanitizeFileName($object->ref); + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + + $formfile->show_documents('remisecheque', $filename, $filedir, $urlsource, 1, 1); + print '<br>'; } } -- GitLab