NEW add attached file in presend email form of thirdparty card
This commit is contained in:
parent
2033b75c33
commit
65d20bdc61
@ -41,14 +41,16 @@ if ($action == 'presend') {
|
||||
|
||||
$object->fetch_projet();
|
||||
|
||||
if (!in_array($object->element, array('societe', 'user', 'member'))) {
|
||||
$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
|
||||
|
||||
$ref = dol_sanitizeFileName($object->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, '/').'([^\-])+');
|
||||
} elseif ($object->element == 'societe') {
|
||||
$fileparams = dol_most_recent_file($diroutput.'/'.$ref);
|
||||
} else {
|
||||
$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+');
|
||||
}
|
||||
@ -82,12 +84,15 @@ if ($action == 'presend') {
|
||||
|
||||
// Build document if it not exists
|
||||
$forcebuilddoc = true;
|
||||
if (in_array($object->element, array('societe', 'user', 'member'))) {
|
||||
if (in_array($object->element, array('user', 'member'))) {
|
||||
$forcebuilddoc = false;
|
||||
}
|
||||
if ($object->element == 'invoice_supplier' && empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) {
|
||||
$forcebuilddoc = false;
|
||||
}
|
||||
if ($object->element == 'societe' && empty($conf->global->COMPANY_ADDON_PDF)) {
|
||||
$forcebuilddoc = false;
|
||||
}
|
||||
if ($forcebuilddoc) { // If there is no default value for supplier invoice, we do not generate file, even if modelpdf was set by a manual generation
|
||||
if ((!$file || !is_readable($file)) && method_exists($object, 'generateDocument')) {
|
||||
$result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
@ -97,6 +102,8 @@ if ($action == 'presend') {
|
||||
}
|
||||
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, '/').'([^\-])+');
|
||||
} elseif ($object->element == 'societe') {
|
||||
$fileparams = dol_most_recent_file($diroutput.'/'.$ref);
|
||||
} else {
|
||||
$fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user