|
Lines 1556-1562
sub _send_duplicate_order_email_notice {
Link Here
|
| 1556 |
my $logger = Koha::Logger->get( { interface => 'edi' } ); |
1556 |
my $logger = Koha::Logger->get( { interface => 'edi' } ); |
| 1557 |
|
1557 |
|
| 1558 |
# Check if email notifications enabled |
1558 |
# Check if email notifications enabled |
| 1559 |
return unless C4::Context->preference('EdiDuplicateOrderEmailNotice'); |
1559 |
my $email_pref = C4::Context->preference('EdifactOrderSendBlockDuplicatesEmailNotice'); |
|
|
1560 |
return unless $email_pref; |
| 1560 |
|
1561 |
|
| 1561 |
my $vendor_id = $vendor->vendor_id; |
1562 |
my $vendor_id = $vendor->vendor_id; |
| 1562 |
my $po_number = $basket->basketname; |
1563 |
my $po_number = $basket->basketname; |
|
Lines 1571-1615
sub _send_duplicate_order_email_notice {
Link Here
|
| 1571 |
vendor_san => $vendor->san || '', |
1572 |
vendor_san => $vendor->san || '', |
| 1572 |
}; |
1573 |
}; |
| 1573 |
|
1574 |
|
|
|
1575 |
# Use acquisitions from/reply addresses, consistent with other acquisitions notices |
| 1576 |
my $from_address = C4::Context->preference('AcquisitionsDefaultEmailAddress') |
| 1577 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
| 1578 |
my $reply_address = C4::Context->preference('AcquisitionsDefaultReplyTo') || undef; |
| 1579 |
|
| 1574 |
# 1. Send notification to library staff |
1580 |
# 1. Send notification to library staff |
| 1575 |
my $library_email_addresses = C4::Context->preference('EdiDuplicateOrderEmailAddresses'); |
1581 |
my @library_addresses; |
| 1576 |
if ($library_email_addresses) { |
1582 |
if ( $email_pref eq 'AcquisitionsDefaultEmailAddress' ) { |
| 1577 |
my @library_addresses = split /\s*,\s*/, $library_email_addresses; |
1583 |
my $addr = C4::Context->preference('AcquisitionsDefaultEmailAddress') |
| 1578 |
|
1584 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
| 1579 |
foreach my $to_address (@library_addresses) { |
1585 |
push @library_addresses, $addr if $addr; |
| 1580 |
$to_address =~ s/^\s+|\s+$//g; # trim whitespace |
1586 |
} elsif ( $email_pref eq 'KohaAdminEmailAddress' ) { |
| 1581 |
next unless $to_address; |
1587 |
my $addr = C4::Context->preference('ReplytoDefault') |
| 1582 |
next unless Koha::Email->is_valid($to_address); |
1588 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
| 1583 |
|
1589 |
push @library_addresses, $addr if $addr; |
| 1584 |
my $letter = C4::Letters::GetPreparedLetter( |
1590 |
} elsif ( $email_pref eq 'EdifactOrderSendBlockDuplicatesEmailAddresses' ) { |
| 1585 |
module => 'acquisition', |
1591 |
my $addresses = C4::Context->preference('EdifactOrderSendBlockDuplicatesEmailAddresses'); |
| 1586 |
letter_code => 'EDI_DUP_ORD_LIBRARY', |
1592 |
push @library_addresses, split /\s*,\s*/, $addresses if $addresses; |
| 1587 |
message_transport_type => 'email', |
1593 |
} |
| 1588 |
tables => { |
|
|
| 1589 |
aqbooksellers => $vendor_id, |
| 1590 |
}, |
| 1591 |
substitute => $substitute, |
| 1592 |
); |
| 1593 |
|
1594 |
|
| 1594 |
if ($letter) { |
1595 |
foreach my $to_address (@library_addresses) { |
| 1595 |
my $message_id = C4::Letters::EnqueueLetter( |
1596 |
$to_address =~ s/^\s+|\s+$//g; # trim whitespace |
| 1596 |
{ |
1597 |
next unless $to_address; |
| 1597 |
letter => $letter, |
1598 |
next unless Koha::Email->is_valid($to_address); |
| 1598 |
to_address => $to_address, |
|
|
| 1599 |
message_transport_type => 'email', |
| 1600 |
} |
| 1601 |
); |
| 1602 |
|
1599 |
|
| 1603 |
if ($message_id) { |
1600 |
my $letter = C4::Letters::GetPreparedLetter( |
| 1604 |
$logger->info( |
1601 |
module => 'acquisition', |
| 1605 |
"Library duplicate order notification queued (message_id: $message_id) for $to_address, PO number $po_number. Message will be sent by message_queue cronjob." |
1602 |
letter_code => 'EDI_DUP_ORD_LIBRARY', |
| 1606 |
); |
1603 |
message_transport_type => 'email', |
| 1607 |
} else { |
1604 |
tables => { |
| 1608 |
$logger->warn("Failed to enqueue library notification to $to_address for PO number $po_number"); |
1605 |
aqbooksellers => $vendor_id, |
|
|
1606 |
}, |
| 1607 |
substitute => $substitute, |
| 1608 |
); |
| 1609 |
|
| 1610 |
if ($letter) { |
| 1611 |
my $message_id = C4::Letters::EnqueueLetter( |
| 1612 |
{ |
| 1613 |
letter => $letter, |
| 1614 |
to_address => $to_address, |
| 1615 |
from_address => $from_address, |
| 1616 |
( $reply_address ? ( reply_address => $reply_address ) : () ), |
| 1617 |
message_transport_type => 'email', |
| 1609 |
} |
1618 |
} |
|
|
1619 |
); |
| 1620 |
|
| 1621 |
if ($message_id) { |
| 1622 |
$logger->info( |
| 1623 |
"Library duplicate order notification queued (message_id: $message_id) for $to_address, PO number $po_number. Message will be sent by message_queue cronjob." |
| 1624 |
); |
| 1610 |
} else { |
1625 |
} else { |
| 1611 |
$logger->warn("Could not generate library notification letter for PO number $po_number"); |
1626 |
$logger->warn("Failed to enqueue library notification to $to_address for PO number $po_number"); |
| 1612 |
} |
1627 |
} |
|
|
1628 |
} else { |
| 1629 |
$logger->warn("Could not generate library notification letter for PO number $po_number"); |
| 1613 |
} |
1630 |
} |
| 1614 |
} |
1631 |
} |
| 1615 |
|
1632 |
|
|
Lines 1641-1648
sub _send_duplicate_order_email_notice {
Link Here
|
| 1641 |
if ($letter) { |
1658 |
if ($letter) { |
| 1642 |
my $message_id = C4::Letters::EnqueueLetter( |
1659 |
my $message_id = C4::Letters::EnqueueLetter( |
| 1643 |
{ |
1660 |
{ |
| 1644 |
letter => $letter, |
1661 |
letter => $letter, |
| 1645 |
to_address => $vendor_email, |
1662 |
to_address => $vendor_email, |
|
|
1663 |
from_address => $from_address, |
| 1664 |
( $reply_address ? ( reply_address => $reply_address ) : () ), |
| 1646 |
message_transport_type => 'email', |
1665 |
message_transport_type => 'email', |
| 1647 |
} |
1666 |
} |
| 1648 |
); |
1667 |
); |
|
Lines 1929-1938
Koha::EDI
Link Here
|
| 1929 |
are detected (i.e. a basket with the same PO number already exists for the vendor). |
1948 |
are detected (i.e. a basket with the same PO number already exists for the vendor). |
| 1930 |
|
1949 |
|
| 1931 |
Queues two types of notifications using letter templates: |
1950 |
Queues two types of notifications using letter templates: |
| 1932 |
1. EDI_DUP_ORD_LIBRARY - to library staff (addresses from EdiDuplicateOrderEmailAddresses) |
1951 |
1. EDI_DUP_ORD_LIBRARY - to library staff (addresses from EdifactOrderSendBlockDuplicatesEmailAddresses) |
| 1933 |
2. EDI_DUP_ORD_VENDOR - to vendor contacts with edi_error_notification set |
1952 |
2. EDI_DUP_ORD_VENDOR - to vendor contacts with edi_error_notification set |
| 1934 |
|
1953 |
|
| 1935 |
Only runs if EdiDuplicateOrderEmailNotice preference is enabled. |
1954 |
Only runs if EdifactOrderSendBlockDuplicatesEmailNotice preference is enabled. |
| 1936 |
|
1955 |
|
| 1937 |
Parameters: |
1956 |
Parameters: |
| 1938 |
- $basket: The Aqbasket DBIC row for the basket being blocked |
1957 |
- $basket: The Aqbasket DBIC row for the basket being blocked |