Merge pull request #22082 from Radarjr2002/patch-3

Update card_presend.tpl.php
This commit is contained in:
Laurent Destailleur 2022-09-07 13:25:38 +02:00 committed by GitHub
commit 32e18735f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,14 +43,18 @@ if ($action == 'presend') {
$ref = dol_sanitizeFileName($object->ref);
if (!in_array($object->element, array('user', 'member'))) {
// TODO get also the main_lastdoc field of $object. If not found, try to guess with following code
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Special case
if ($object->element == 'invoice_supplier') {
$fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
//$fileparams['fullname'] can be filled from the card
//Get also the main_lastdoc field of $object. If not found, try to guess with following code
if (!empty($object->last_main_doc) && is_readable(DOL_DATA_ROOT.'/'.$object->last_main_doc) && is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
$fileparams['fullname'] = DOL_DATA_ROOT.'/'.$object->last_main_doc;
} else {
$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+');
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Special case
if ($object->element == 'invoice_supplier') {
$fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
} else {
$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+');
}
}
$file = $fileparams['fullname'];