From 91483fd560e58285ca535bfd4fe740c580608b78 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Wed, 8 Apr 2020 10:24:32 +0200 Subject: [PATCH 1/5] Add optional remove action for showDocuments --- htdocs/core/class/html.formfile.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index f688880b789..bc8aa3a9b39 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -331,9 +331,10 @@ class FormFile * @param string $morepicto Add more HTML content into cell with picto * @param Object $object Object when method is called from an object card. * @param int $hideifempty Hide section of generated files if there is no file + * @param string $removeaction (optional) The action to remove a file * @return string Output string with HTML array of documents (might be empty string) */ - public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) + public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0, $removeaction = 'remove_file') { // Deprecation warning if (!empty($iconPDF)) { @@ -859,7 +860,7 @@ class FormFile if ($delallowed) { $tmpurlsource = preg_replace('/#[a-zA-Z0-9_]*$/', '', $urlsource); - $out .= ' Date: Wed, 8 Apr 2020 10:30:51 +0200 Subject: [PATCH 2/5] Add confirm for delte file in facture --- htdocs/compta/facture/card.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 19a4022a9a4..3ac39041e45 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3983,6 +3983,20 @@ elseif ($id > 0 || !empty($ref)) $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250); } + if ($action == "remove_file_comfirm") + { + $file = GETPOST('file', 'alpha'); + + $formconfirm = $form->formconfirm( + $_SERVER["PHP_SELF"].'?facid='.$object->id.'&file='.$file, + $langs->trans('DeleteFileHeader'), + $langs->trans('DeleteFileText')."

".$file, + 'remove_file', + '', + 'no', + 2); + } + // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid, 'remainingtopay' => &$resteapayer); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -5359,7 +5373,11 @@ elseif ($id > 0 || !empty($ref)) $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); + print $formfile->showdocuments( + 'facture', $filename, $filedir, $urlsource, $genallowed, + $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', + $soc->default_lang, '', $object, 0, 'remove_file_comfirm'); + $somethingshown = $formfile->numoffiles; // Show links to link elements From bbd7134a0f3e8458e9340ec0a589f863a1fc6d22 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Wed, 8 Apr 2020 10:31:54 +0200 Subject: [PATCH 3/5] Update german lang --- htdocs/langs/de_DE/main.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/de_DE/main.lang b/htdocs/langs/de_DE/main.lang index a3c7af845ec..aed761fb08e 100644 --- a/htdocs/langs/de_DE/main.lang +++ b/htdocs/langs/de_DE/main.lang @@ -1022,3 +1022,5 @@ SelectYourGraphOptionsFirst=Wählen Sie Ihre Diagrammoptionen aus, um ein Diagra Measures=Maße XAxis=X-Achse YAxis=Y-Achse +DeleteFileHeader=Dateilöschung bestätigen +DeleteFileText=Möchten sie diese Datei wirklich löschen? From a506050fee04b0334adcda9d633aac0d5f370feb Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Wed, 8 Apr 2020 10:33:24 +0200 Subject: [PATCH 4/5] Update English lang --- htdocs/langs/en_US/main.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index cbe3c3e46bf..2082506c405 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1026,3 +1026,5 @@ Measures=Measures XAxis=X-Axis YAxis=Y-Axis StatusOfRefMustBe=Status of %s must be %s +DeleteFileHeader=Confirm file delete +DeleteFileText=Do you really want delete this file? From 0ce44251f73ad595bba4ebd17314f2cc941b9980 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 8 Apr 2020 08:50:16 +0000 Subject: [PATCH 5/5] Fixing style errors. --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3ac39041e45..bc8b59671f8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3996,7 +3996,7 @@ elseif ($id > 0 || !empty($ref)) 'no', 2); } - + // Call Hook formConfirm $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid, 'remainingtopay' => &$resteapayer); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -5377,7 +5377,7 @@ elseif ($id > 0 || !empty($ref)) 'facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object, 0, 'remove_file_comfirm'); - + $somethingshown = $formfile->numoffiles; // Show links to link elements