Update card_presend.tpl.php

TODO Get also the main_lastdoc field of $object
This commit is contained in:
Radarjr2002 2022-09-05 13:40:39 +02:00 committed by GitHub
parent 33ad0de37e
commit 7344b1946a
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, '/').'([^\-])+');
} else {
$fileparams = dol_most_recent_file($diroutput.'/'.$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 {
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'];