From 0798f7b7193f37e4fcbd36c32194e3c9d7d65cfe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 20:53:03 +0100 Subject: [PATCH] NEW Can upload files from the edit page of expense report --- htdocs/core/actions_linkedfiles.inc.php | 2 +- htdocs/core/class/html.formfile.class.php | 52 +++++---- htdocs/expensereport/card.php | 103 +++++++++++++++--- .../class/expensereport.class.php | 4 +- htdocs/expensereport/document.php | 2 +- htdocs/langs/en_US/trips.lang | 8 +- 6 files changed, 120 insertions(+), 51 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 73cbd572e9d..272ac1532a6 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -29,7 +29,7 @@ // Submit file/link if (GETPOST('sendit', 'alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - if (! empty($_FILES)) + if (! empty($_FILES)) { if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; else $userfiles=array($_FILES['userfile']['tmp_name']); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2577d70e549..1ea48c90091 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -77,9 +77,10 @@ class FormFile * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM) * @param string $accept Specifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*') * @param string $sectiondir If upload must be done inside a particular directory (is sectiondir defined, sectionid must not be) + * @param int $usewithoutform 0=Default, 1=Disable
and style to use in existing area * @return int <0 if KO, >0 if OK */ - public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') + public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0) { // phpcs:enable global $conf,$langs, $hookmanager; @@ -114,10 +115,13 @@ class FormFile if (empty($title)) $title=$langs->trans("AttachANewFile"); if ($title != 'none') $out.=load_fiche_titre($title, null, null); - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + if (empty($usewithoutform)) + { + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + } $out .= ''; $out .= ''; @@ -176,13 +180,7 @@ class FormFile if ($savingdocmask) { //add a global variable for disable the auto renaming on upload - if (! empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)) - { - $rename=''; - } - else { - $rename='checked'; - } + $rename=(empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)?'checked':''); $out .= ''; if (! empty($options)) $out .= ''; @@ -194,8 +192,11 @@ class FormFile $out .= "
'.$options.'
"; - $out .= '
'; - if (empty($sectionid)) $out .= '
'; + if (empty($usewithoutform)) + { + $out .= ''; + if (empty($sectionid)) $out .= '
'; + } $out .= "\n\n"; @@ -205,12 +206,16 @@ class FormFile $langs->load('link'); $title = $langs->trans("LinkANewFile"); $out .= load_fiche_titre($title, null, null); - $out .= '