* EPL Invoices: allow to select a mail template and directly mail invoice to buyer

This commit is contained in:
ralf 2025-01-03 16:07:03 +01:00
parent fbcedf0adf
commit ac06db6c5c
4 changed files with 33 additions and 5 deletions

View File

@ -751,9 +751,9 @@ class Country
{
if (!self::$countries_translated) self::_translate_countries();
return self::$countries_translated[strtoupper($code)];
return self::$countries_translated[strtoupper($code)] ?? null;
}
return self::$country_array[strtoupper($code)];
return self::$country_array[strtoupper($code)] ?? null;
}
/**
@ -856,4 +856,4 @@ class Country
natcasesort(self::$countries_translated);
}
}
}
}

View File

@ -7204,7 +7204,8 @@ class Mail
$header = $mailObject->getHeader(Mailer::$type2header[$type]);
if(is_array($header)) $header = implode(', ',$header);
$mailObject->clearAddresses($type);
$merged = $bo_merge->merge_string($header,$val,$e,'text/plain',array(),self::$displayCharset);
$merged = empty($header) || strpos($header, '{{') === false ? $header :
$bo_merge->merge_string($header,$val,$e,'text/plain',array(),self::$displayCharset);
//error_log($type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$merged);
$mailObject->addAddress(trim($merged,'"'),'',$type);
}
@ -7232,6 +7233,11 @@ class Mail
{
$_folder = $this->getDraftFolder();
}
// add attachments from app-specific merge-class
foreach($bo_merge->getAttachments($val) as $file)
{
$mailObject->addAttachment($file);
}
}
if ($sendOK || $openAsDraft)
{

View File

@ -328,7 +328,7 @@ class Mailer extends Horde_Mime_Mail
*
* "text/calendar; method=..." get automatic detected and added as highest priority alternative
*
* @param string|resource $data Path to the attachment or open file-descriptor
* @param string|resource|array $data Path to the attachment or open file-descriptor or array with values for keys "data", "name" and "type"
* @param string $name =null file name to use for the attachment
* @param string $type =null content type of the file, incl. parameters eg. "text/plain; charset=utf-8"
* @param string $old_type =null used to support phpMailer signature (deprecated)
@ -343,6 +343,12 @@ class Mailer extends Horde_Mime_Mail
$type = $old_type;
}
if (is_array($data))
{
$name = $data['name'] ?? null;
$type = $data['type'] ?? null;
$data = $data['data'] ?? null;
}
// pass file as resource to Horde_Mime_Part::setContent()
if (is_resource($data))
{

View File

@ -3431,4 +3431,20 @@ abstract class Merge
protected function show_replacements_hook(&$template_name, &$content, &$sel_options, &$readonlys)
{
}
/**
* Allow to attach files to merged mails
*
* Called from mail.mail_compose.compose
*
* @param int|string $id
* @return array[] array of array with values for keys
* - "data": path or open file resource,
* - "name": filename to be used for attachment
* - "type": mime-type of attachment
*/
public function getAttachments($id)
{
return [];
}
}