Browse Source

Fix Massactions : addmaindocfile : search by filename

Mathieu Moulin 2 years ago
parent
commit
675b8e0c48
1 changed files with 7 additions and 0 deletions
  1. 7 0
      htdocs/core/actions_massactions.inc.php

+ 7 - 0
htdocs/core/actions_massactions.inc.php

@@ -307,6 +307,13 @@ if (!$error && $massaction == 'confirm_presend') {
 					// $subdir = get_exdir($objectobj->id, 2, 0, 0, $objectobj, $objectobj->element)
 					$filedir = $uploaddir.'/'.$subdir.dol_sanitizeFileName($objectobj->ref);
 					$file = $filedir.'/'.$filename;
+					// Added By MMI Mathieu Moulin iProspective
+					// Fix search by filename
+					if (!file_exists($file)) {
+						$files = glob($filedir.'/'.dol_sanitizeFileName($objectobj->ref).'*.pdf');
+						if (!empty($files))
+							$file = $files[0];
+					}
 
 					// For supplier invoices, we use the file provided by supplier, not the one we generate
 					if ($objectobj->element == 'invoice_supplier') {