Merge pull request #19316 from vincentjdc/expensereport-option-to-require-file

NEW Adds `EXPENSEREPORT_FILE_IS_REQUIRED` global var to force user to join file for each line of an expense report
This commit is contained in:
Laurent Destailleur 2021-11-05 12:40:25 +01:00 committed by GitHub
commit 49e57c75fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,6 +118,7 @@ $permissiontoadd = $user->rights->expensereport->creer; // Used by the include o
$upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref);
$projectRequired = $conf->projet->enabled && ! empty($conf->global->EXPENSEREPORT_PROJECT_IS_REQUIRED);
$fileRequired = !empty($conf->global->EXPENSEREPORT_FILE_IS_REQUIRED);
if ($object->id > 0) {
// Check current user can read this expense report
@ -1157,6 +1158,12 @@ if (empty($reshook)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors');
}
// If no file associated
if ($fileRequired && $fk_ecm_files == 0) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
}
if (!$error) {
$type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees