Skip to content

Commit

Permalink
LIMS-1500: Set the dispatch request email recipients based on the dew…
Browse files Browse the repository at this point in the history
…ar barcode
  • Loading branch information
Mark Williams committed Oct 15, 2024
1 parent 087beda commit e08dd79
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ function _dispatch_dewar()
global $facility_country;
global $facility_courier_countries;
global $dispatch_email;
global $dispatch_email_regex;
global $dispatch_email_intl;
global $use_shipping_service;
global $shipping_service_links_in_emails;
Expand Down Expand Up @@ -1315,6 +1316,14 @@ function _dispatch_dewar()
$local_contact_email = $this->has_arg('LCEMAIL') ? $this->args['LCEMAIL'] : '';
if ($local_contact_email) $recpts .= ', ' . $local_contact_email;

if (!is_null($dispatch_email_regex)) {
foreach ($dispatch_email_regex as $address => $pattern) {
if (preg_match($pattern, $data['BARCODE'])) {
$recpts .= ', ' . $address;
}
}
}

$email->send($recpts);

// Update the dewar status and storage location
Expand Down Expand Up @@ -1343,6 +1352,7 @@ function _dispatch_dewar()
function _dispatch_dewar_confirmation()
{
global $dispatch_email;
global $dispatch_email_regex;
global $shipping_service_app_url;

if (!$this->has_arg('did'))
Expand Down Expand Up @@ -1405,6 +1415,14 @@ function _dispatch_dewar_confirmation()
$local_contact_email = $this->has_arg('LCEMAIL') ? $this->args['LCEMAIL'] : '';
if ($local_contact_email) $recpts .= ', ' . $local_contact_email;

if (!is_null($dispatch_email_regex)) {
foreach ($dispatch_email_regex as $address => $pattern) {
if (preg_match($pattern, $data['BARCODE'])) {
$recpts .= ', ' . $address;
}
}
}

$email->send($recpts);

// Also update the dewar status and storage location to keep it in sync with history...
Expand Down

0 comments on commit e08dd79

Please sign in to comment.