diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl
index af47302d5c..abd54deb64 100755
--- a/basket/sendbasket.pl
+++ b/basket/sendbasket.pl
@@ -54,109 +54,64 @@ if ( $email_add ) {
session_id => scalar $query->cookie('CGISESSID'),
token => scalar $query->param('csrf_token'),
});
+
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ my $user_email = $patron->first_valid_email_address;
+
my $comment = $query->param('comment');
- # Since we are already logged in, no need to check credentials again
- # when loading a second template.
- my $template2 = C4::Templates::gettemplate(
- 'basket/sendbasket.tt', 'intranet', $query,
- );
-
my @bibs = split( /\//, $bib_list );
- my @results;
my $iso2709;
- my $marcflavour = C4::Context->preference('marcflavour');
- foreach my $biblionumber (@bibs) {
- $template2->param( biblionumber => $biblionumber );
- my $biblio = Koha::Biblios->find( $biblionumber ) or next;
- my $dat = $biblio->unblessed;
- my $record = $biblio->metadata->record({ embed_items => 1 });
- my $marcauthorsarray = $biblio->get_marc_contributors;
- my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
-
- my $hasauthors = 0;
- if($dat->{'author'} || @$marcauthorsarray) {
- $hasauthors = 1;
- }
-
-
- $dat->{MARCSUBJCTS} = $marcsubjctsarray;
- $dat->{MARCAUTHORS} = $marcauthorsarray;
- $dat->{HASAUTHORS} = $hasauthors;
- $dat->{'biblionumber'} = $biblionumber;
- $dat->{ITEM_RESULTS} = $biblio->items->search_ordered;
- my ( $host, $relatedparts ) = $biblio->get_marc_host;
- $dat->{HOSTITEMENTRIES} = $host;
- $dat->{RELATEDPARTS} = $relatedparts;
-
- $iso2709 .= $record->as_usmarc();
-
- push( @results, $dat );
+ foreach my $bib ( @bibs ) {
+ my $biblio = Koha::Biblios->find( $bib ) or next;
+ $iso2709 .= $biblio->metadata->record->as_usmarc();
}
- my $resultsarray = \@results;
- $template2->param(
- BIBLIO_RESULTS => $resultsarray,
- comment => $comment
- );
-
- # Getting template result
- my $template_res = $template2->output();
- my $body;
-
- my $subject;
- # Analysing information and getting mail properties
- if ( $template_res =~ /(?.*)/s ) {
- $subject = $+{subject};
- $subject =~ s|\n?(.*)\n?|$1|;
- }
- else {
- $subject = "no subject";
- }
-
- my $email_header = "";
- if ( $template_res =~ /(.*)/s ) {
- $email_header = $1;
- $email_header =~ s|\n?(.*)\n?|$1|;
- }
-
- if ( $template_res =~ /(.*)/s ) {
- $body = $1;
- $body =~ s|\n?(.*)\n?|$1|;
- }
-
- my $THE_body = <create(
- {
- to => $email_add,
- subject => $subject,
- }
- );
-
- $email->text_body( $THE_body );
- $email->attach(
- Encode::encode( "UTF-8", $iso2709 ),
- content_type => 'application/octet-stream',
- name => 'basket.iso2709',
- disposition => 'attachment',
- );
-
- my $library = Koha::Patrons->find( $borrowernumber )->library;
- $email->send_or_die({ transport => $library->smtp_server->transport });
- $template->param( SENT => "1" );
- }
- catch {
- carp "Error sending mail: $_";
+ if ( !defined $iso2709 ) {
+ carp "Error sending mail: empty basket";
$template->param( error => 1 );
- };
+ } elsif ( !defined $user_email or $user_email eq '' ) {
+ carp "Error sending mail: sender's email address is invalid";
+ $template->param( error => 1 );
+ } else {
+ my %loops = (
+ biblio => \@bibs,
+ );
+ my %substitute = (
+ comment => $comment,
+ );
+
+ my $letter = C4::Letters::GetPreparedLetter(
+ module => 'catalogue',
+ letter_code => 'CART',
+ lang => $patron->lang,
+ tables => {
+ borrowers => $borrowernumber,
+ },
+ message_transport_type => 'email',
+ loops => \%loops,
+ substitute => \%substitute,
+ );
+
+ my $attachment = {
+ filename => 'basket.iso2709',
+ type => 'application/octet-stream',
+ content => Encode::encode("UTF-8", $iso2709),
+ };
+
+ C4::Letters::EnqueueLetter({
+ letter => $letter,
+ message_transport_type => 'email',
+ borrowernumber => $patron->borrowernumber,
+ to_address => $email_add,
+ reply_address => $user_email,
+ attachments => [$attachment],
+ });
+
+ $template->param( SENT => 1 );
+ }
$template->param( email_add => $email_add );
output_html_with_http_headers $query, $cookie, $template->output;
}
diff --git a/installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.pl b/installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.pl
new file mode 100755
index 0000000000..bb74efe2b8
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.pl
@@ -0,0 +1,62 @@
+use Modern::Perl;
+
+return {
+ bug_number => "3150",
+ description => "Add LIST and CART notices",
+ up => sub {
+ my ($args) = @_;
+ my ($dbh, $out) = @$args{qw(dbh out)};
+
+ $dbh->do(q{ INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES
+ ('catalogue','LIST','','Send list',1,'Your list: [% listname | html %]',"Hi,
+ [% borrower.firstname | html %] [% borrower.surname | html %] sent you a list from our online catalog called: [% listname | html %].
+ Please note that the attached file is a MARC bibliographic records file which can be imported into personal bibliographic software like EndNote, Reference Manager or ProCite.
+
[% comment | html %]
+ [% FOREACH biblio IN biblios %]-
+ [% biblio.title | html %]
+ [% IF ( biblio.subtitle ) %][% FOREACH subtitle IN biblio.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %]
+ [% biblio.part_number | html %] [% biblio.part_name | html %]
+ [% IF ( biblio.author || biblio.get_marc_contributors ) %]Author(s): [% IF ( biblio.author ) %][% biblio.author | html %][% END %][% IF ( biblio.get_marc_contributors ) %][% IF ( biblio.author ) %]; [% END %][% FOREACH author IN biblio.get_marc_contributors %][% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %][% subfield.separator | html %][% subfield.value | html %][% END %][% UNLESS ( loop.last ) %];[% END %][% END %][% END %][% END %]
+ [% SET biblioitem = biblio.biblioitem %][% IF ( biblioitem.isbn ) %]ISBN: [% FOREACH isbn IN biblioitem.isbn %][% isbn | html %][% UNLESS ( loop.last ) %]; [% END %][% END %][% END %]
+ [% IF ( biblioitem.publishercode ) %]Published by: [% biblioitem.publishercode | html %][% IF ( biblioitem.publicationyear ) %] in [% biblioitem.publicationyear | html %][% END %][% IF ( biblioitem.pages ) %], [% biblioitem.pages | html %][% END %][% END %]
+ [% IF ( biblio.seriestitle ) %]Collection: [% biblio.seriestitle | html %][% END %]
+ [% IF ( biblio.copyrightdate ) %]Copyright year: [% biblio.copyrightdate | html %][% END %]
+ [% IF ( biblio.notes ) %]Notes: [% biblio.notes | html %][% END %]
+ [% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %][% END %]
+ [% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %][% END %]
+ [% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %][% END %]
+ [% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %][% END %]
+ [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %][% IF ( OPACBaseURL ) %]In online catalog: [% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %][% END %]
+ [% IF ( biblio.items.count > 0 ) %]Items:
[% FOREACH item IN biblio.items %]- [% Branches.GetName( item.holdingbranch ) | html %]
+ [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %]
+ [% IF item.itemcallnumber %]([% item.itemcallnumber | html %])[% END %]
+ [% item.barcode | html %]
[% END %]
[% END %]
+
[% END %]
", 'email','default' ),
+ ('catalogue','CART','','Send cart',1,'Your cart',"Hi,
+ [% borrower.firstname | html %] [% borrower.surname | html %] sent you a cart from our online catalog.
+ Please note that the attached file is a MARC bibliographic records file which can be imported into personal bibliographic software like EndNote, Reference Manager or ProCite.
+
[% comment | html %]
+ [% FOREACH biblio IN biblios %]-
+ [% biblio.title | html %]
+ [% IF ( biblio.subtitle ) %][% FOREACH subtitle IN biblio.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %]
+ [% biblio.part_number | html %] [% biblio.part_name | html %]
+ [% IF ( biblio.author || biblio.get_marc_contributors ) %]Author(s): [% IF ( biblio.author ) %][% biblio.author | html %][% END %][% IF ( biblio.get_marc_contributors ) %][% IF ( biblio.author ) %]; [% END %][% FOREACH author IN biblio.get_marc_contributors %][% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %][% subfield.separator | html %][% subfield.value | html %][% END %][% UNLESS ( loop.last ) %];[% END %][% END %][% END %][% END %]
+ [% SET biblioitem = biblio.biblioitem %][% IF ( biblioitem.isbn ) %]ISBN: [% FOREACH isbn IN biblioitem.isbn %][% isbn | html %][% UNLESS ( loop.last ) %]; [% END %][% END %][% END %]
+ [% IF ( biblioitem.publishercode ) %]Published by: [% biblioitem.publishercode | html %][% IF ( biblioitem.publicationyear ) %] in [% biblioitem.publicationyear | html %][% END %][% IF ( biblioitem.pages ) %], [% biblioitem.pages | html %][% END %][% END %]
+ [% IF ( biblio.seriestitle ) %]Collection: [% biblio.seriestitle | html %][% END %]
+ [% IF ( biblio.copyrightdate ) %]Copyright year: [% biblio.copyrightdate | html %][% END %]
+ [% IF ( biblio.notes ) %]Notes: [% biblio.notes | html %][% END %]
+ [% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %][% END %]
+ [% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %][% END %]
+ [% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %][% END %]
+ [% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %][% END %]
+ [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %][% IF ( OPACBaseURL ) %]In online catalog: [% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %][% END %]
+ [% IF ( biblio.items.count > 0 ) %]Items:
[% FOREACH item IN biblio.items %]- [% Branches.GetName( item.holdingbranch ) | html %]
+ [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %]
+ [% IF item.itemcallnumber %]([% item.itemcallnumber | html %])[% END %]
+ [% item.barcode | html %]
[% END %]
[% END %]
+
[% END %]
",'email','default') });
+
+ say $out "Add LIST and CART notices";
+ },
+};
diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml
index a3c9c51a57..765875f151 100644
--- a/installer/data/mysql/en/mandatory/sample_notices.yml
+++ b/installer/data/mysql/en/mandatory/sample_notices.yml
@@ -2289,3 +2289,64 @@ tables:
- "[% IF borrower.categorycode %]Temporary patron category: [% borrower.categorycode %][% END %]"
- ""
- "
"
+
+ - module: catalogue
+ code: LIST
+ branchcode: ""
+ name: "Send list"
+ is_html: 1
+ title: "Your list: [% listname | html %]"
+ message_transport_type: email
+ lang: default
+ content:
+ - "Hi,"
+ - "[% borrower.firstname | html %] [% borrower.surname | html %] sent you a list from our online catalog called: [% listname | html %]."
+ - "Please note that the attached file is a MARC bibliographic records file which can be imported into personal bibliographic software like EndNote, Reference Manager or ProCite."
+ - "
[% comment | html %]
"
+ - "[% FOREACH biblio IN biblios %]- "
+ - "[% biblio.title | html %]"
+ - "[% IF ( biblio.subtitle ) %][% FOREACH subtitle IN biblio.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% biblio.part_number | html %] [% biblio.part_name | html %]"
+ - "[% IF ( biblio.author || biblio.get_marc_contributors ) %]Author(s): [% IF ( biblio.author ) %][% biblio.author | html %][% END %][% IF ( biblio.get_marc_contributors ) %][% IF ( biblio.author ) %]; [% END %][% FOREACH author IN biblio.get_marc_contributors %][% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %][% subfield.separator | html %][% subfield.value | html %][% END %][% UNLESS ( loop.last ) %];[% END %][% END %][% END %][% END %]"
+ - "[% SET biblioitem = biblio.biblioitem %][% IF ( biblioitem.isbn ) %]ISBN: [% FOREACH isbn IN biblioitem.isbn %][% isbn | html %][% UNLESS ( loop.last ) %]; [% END %][% END %][% END %]"
+ - "[% IF ( biblioitem.publishercode ) %]Published by: [% biblioitem.publishercode | html %][% IF ( biblioitem.publicationyear ) %] in [% biblioitem.publicationyear | html %][% END %][% IF ( biblioitem.pages ) %], [% biblioitem.pages | html %][% END %][% END %]"
+ - "[% IF ( biblio.seriestitle ) %]Collection: [% biblio.seriestitle | html %][% END %]"
+ - "[% IF ( biblio.copyrightdate ) %]Copyright year: [% biblio.copyrightdate | html %][% END %]"
+ - "[% IF ( biblio.notes ) %]Notes: [% biblio.notes | html %][% END %]"
+ - "[% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %][% END %]"
+ - "[% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %][% END %]"
+ - "[% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %][% END %]"
+ - "[% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %][% END %]"
+ - "[% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %][% IF ( OPACBaseURL ) %]In online catalog: [% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %][% END %]"
+ - "[% IF ( biblio.items.count > 0 ) %]Items:
[% FOREACH item IN biblio.items %]- [% Branches.GetName( item.holdingbranch ) | html %][% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %][% IF item.itemcallnumber %]([% item.itemcallnumber | html %])[% END %][% item.barcode | html %]
[% END %]
[% END %]"
+ - "
[% END %]
"
+
+ - module: catalogue
+ code: CART
+ branchcode: ""
+ name: "Send cart"
+ is_html: 1
+ title: "Your cart"
+ message_transport_type: email
+ lang: default
+ content:
+ - "Hi,"
+ - "[% borrower.firstname | html %] [% borrower.surname | html %] sent you a cart from our online catalog."
+ - "[% borrower.firstname | html %] [% borrower.surname | html %] sent you a list from our online catalog called: [% listname | html %]."
+ - "Please note that the attached file is a MARC bibliographic records file which can be imported into personal bibliographic software like EndNote, Reference Manager or ProCite."
+ - "
[% comment | html %]
"
+ - "[% FOREACH biblio IN biblios %]- "
+ - "[% biblio.title | html %]"
+ - "[% IF ( biblio.subtitle ) %][% FOREACH subtitle IN biblio.subtitle.split(' | ') %][% subtitle | html %][% END %][% END %][% biblio.part_number | html %] [% biblio.part_name | html %]"
+ - "[% IF ( biblio.author || biblio.get_marc_contributors ) %]Author(s): [% IF ( biblio.author ) %][% biblio.author | html %][% END %][% IF ( biblio.get_marc_contributors ) %][% IF ( biblio.author ) %]; [% END %][% FOREACH author IN biblio.get_marc_contributors %][% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %][% subfield.separator | html %][% subfield.value | html %][% END %][% UNLESS ( loop.last ) %];[% END %][% END %][% END %][% END %]"
+ - "[% SET biblioitem = biblio.biblioitem %][% IF ( biblioitem.isbn ) %]ISBN: [% FOREACH isbn IN biblioitem.isbn %][% isbn | html %][% UNLESS ( loop.last ) %]; [% END %][% END %][% END %]"
+ - "[% IF ( biblioitem.publishercode ) %]Published by: [% biblioitem.publishercode | html %][% IF ( biblioitem.publicationyear ) %] in [% biblioitem.publicationyear | html %][% END %][% IF ( biblioitem.pages ) %], [% biblioitem.pages | html %][% END %][% END %]"
+ - "[% IF ( biblio.seriestitle ) %]Collection: [% biblio.seriestitle | html %][% END %]"
+ - "[% IF ( biblio.copyrightdate ) %]Copyright year: [% biblio.copyrightdate | html %][% END %]"
+ - "[% IF ( biblio.notes ) %]Notes: [% biblio.notes | html %][% END %]"
+ - "[% IF ( biblio.unititle ) %]Unified title: [% biblio.unititle | html %][% END %]"
+ - "[% IF ( biblio.serial ) %]Serial: [% biblio.serial | html %][% END %]"
+ - "[% IF ( biblioitem.lccn ) %]LCCN: [% biblioitem.lccn | html %][% END %]"
+ - "[% IF ( biblioitem.url ) %]URL: [% biblioitem.url | html %][% END %]"
+ - "[% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %][% IF ( OPACBaseURL ) %]In online catalog: [% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | html %][% END %]"
+ - "[% IF ( biblio.items.count > 0 ) %]Items:
[% FOREACH item IN biblio.items %]- [% Branches.GetName( item.holdingbranch ) | html %][% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %][% IF item.itemcallnumber %]([% item.itemcallnumber | html %])[% END %][% item.barcode | html %]
[% END %]
[% END %]"
+ - "
[% END %]
"
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt
deleted file mode 100644
index 097090a5d2..0000000000
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt
+++ /dev/null
@@ -1,173 +0,0 @@
-[% USE raw %]
-[% USE HtmlToText %]
-[% USE Koha %]
-[% USE Branches %]
-
-
-Your cart
-
-
-
-
-[% FILTER html2text %]
- Hi,
-
- Here is your cart, sent from our online catalog.
-
- Please note that the attached file is a MARC bibliographic records file
- which can be imported into personal bibliographic software like EndNote,
- Reference Manager or ProCite.
-
-[% END %]
-
-
-
-[% FILTER html2text %]
-
- [% IF comment %]
- [% comment | $raw %]
-
- [% END %]
-
- [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
- -
-
- [% BIBLIO_RESULT.title | $raw %]
- [% IF ( BIBLIO_RESULT.subtitle ) %] [% BIBLIO_RESULT.subtitle | $raw %][% END %]
- [% BIBLIO_RESULT.part_number | $raw %] [% BIBLIO_RESULT.part_name | $raw %]
-
-
-
- [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
- Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author | $raw %][% END %]
-
- [% IF ( BIBLIO_RESULT.MARCAUTHORS ) %]
- [% IF ( BIBLIO_RESULT.author ) %]; [% END %]
- [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %]
- [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %]
- [% MARCAUTHOR_SUBFIELDS_LOO.separator | $raw %][% MARCAUTHOR_SUBFIELDS_LOO.value | $raw %]
- [% END %]
- [% UNLESS ( loop.last ) %];[% END %]
- [% END %]
- [% END %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.ISBN ) %]
-
- ISBN: [% BIBLIO_RESULT.ISBN | $raw %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.publishercode %]
-
- Published by: [% BIBLIO_RESULT.publishercode | $raw %]
- [% IF ( BIBLIO_RESULT.publicationyear ) %]
- in [% BIBLIO_RESULT.publicationyear | $raw %]
- [% END %]
- [% IF ( BIBLIO_RESULT.pages ) %]
- , [% BIBLIO_RESULT.pages | $raw %]
- [% END %]
- [% IF BIBLIO_RESULT.item('size') %]
- , [% BIBLIO_RESULT.item('size') | html %]
- [% END %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.collection %]
-
- Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.subject ) %]
-
- Subject: [% BIBLIO_RESULT.subject | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-
- Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.notes ) %]
-
- Notes : [% BIBLIO_RESULT.notes | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.unititle ) %]
-
- Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.serial ) %]
-
- Serial: [% BIBLIO_RESULT.serial | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.dewey ) %]
-
- Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.classification ) %]
-
- Classification: [% BIBLIO_RESULT.classification | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.lccn ) %]
-
- LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
- In:
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
- [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
- [% ELSE %]
- [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
- [% END %]
-
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.url ) %]
-
- URL: [% BIBLIO_RESULT.url | html %]
-
- [% END %]
-
-
- [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %]
- [% IF ( OPACBaseURL ) %]
-
- In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-
- [% END %]
- [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
- Items:
-
- [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]-
- [% Branches.GetName(ITEM_RESULT.holdingbranch) | $raw %]
- [% ITEM_RESULT.location | $raw %]
- [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber | $raw %])[% END %]
- [% ITEM_RESULT.barcode | $raw %]
-
[% END %]
-
-
- [% END %]
-
-
- [% END %]
-
-
-[% END %]
-
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt
deleted file mode 100644
index ed05c96b7f..0000000000
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt
+++ /dev/null
@@ -1,179 +0,0 @@
-[% USE raw %]
-[% USE AuthorisedValues %]
-[% USE Branches %]
-
-Your list: [% shelfname | $raw %]
-
-
-[% USE HtmlToText %]
-
-
-[% FILTER html2text %]
- Hi,
-
- Here is your list called [% shelfname | $raw %], sent from our online catalog.
-
- Please note that the attached file is a MARC bibliographic records file
- which can be imported into personal bibliographic software like EndNote,
- Reference Manager or ProCite.
-
-[% END %]
-
-
-
-
-[% FILTER html2text %]
-
- [% IF comment %]
- [% comment | $raw %]
-
- [% END %]
-
- [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
- -
-
- [% BIBLIO_RESULT.title | $raw %]
- [% IF ( BIBLIO_RESULT.subtitle ) %]
- [% FOREACH subtitle IN BIBLIO_RESULT.subtitle.split(' | ') %]
- [% subtitle | $raw %]
- [% END %]
- [% END %]
- [% BIBLIO_RESULT.part_number | $raw %] [% BIBLIO_RESULT.part_name | $raw %]
-
-
-
- [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
- Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author | $raw %][% END %]
-
- [% IF ( BIBLIO_RESULT.MARCAUTHORS ) %]
- [% IF ( BIBLIO_RESULT.author ) %]; [% END %]
- [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %]
- [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %]
- [% MARCAUTHOR_SUBFIELDS_LOO.separator | $raw %][% MARCAUTHOR_SUBFIELDS_LOO.value | $raw %]
- [% END %]
- [% UNLESS ( loop.last ) %];[% END %]
- [% END %]
- [% END %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.ISBN.size > 0 ) %]
-
- ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %]
- [% isbn | $raw %]
- [% UNLESS ( loop.last ) %]; [% END %]
- [% END %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.publishercode %]
-
- Published by: [% BIBLIO_RESULT.publishercode | $raw %]
- [% IF ( BIBLIO_RESULT.publicationyear ) %]
- in [% BIBLIO_RESULT.publicationyear | $raw %]
- [% END %]
- [% IF ( BIBLIO_RESULT.pages ) %]
- , [% BIBLIO_RESULT.pages | $raw %]
- [% END %]
- [% IF BIBLIO_RESULT.item('size') %]
- , [% BIBLIO_RESULT.item('size') | html %]
- [% END %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.collection %]
-
- Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.subject ) %]
-
- Subject: [% BIBLIO_RESULT.subject | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-
- Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.notes ) %]
-
- Notes : [% BIBLIO_RESULT.notes | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.unititle ) %]
-
- Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.serial ) %]
-
- Serial: [% BIBLIO_RESULT.serial | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.dewey ) %]
-
- Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.classification ) %]
-
- Classification: [% BIBLIO_RESULT.classification | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.lccn ) %]
-
- LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
- In:
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
- [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
- [% ELSE %]
- [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
- [% END %]
-
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.url ) %]
-
- URL: [% BIBLIO_RESULT.url | html %]
-
- [% END %]
-
-
- [% IF ( OPACBaseURL ) %]
-
- In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-
- [% END %]
- [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
- Items:
-
- [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]-
- [% Branches.GetName(ITEM_RESULT.holdingbranch) | $raw %]
- [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_RESULT.location ) | html %]
- [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber | $raw %])[% END %]
- [% ITEM_RESULT.barcode | $raw %]
-
[% END %]
-
-
- [% END %]
-
-
- [% END %]
-
-
-[% END %]
-
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasket.tt
deleted file mode 100644
index f676084f90..0000000000
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasket.tt
+++ /dev/null
@@ -1,178 +0,0 @@
-[% USE raw %]
-[% USE HtmlToText %]
-[% USE Koha %]
-[% USE AuthorisedValues %]
-[% USE Branches %]
-
-
-Your cart
-
-
-
-
-[% FILTER html2text %]
- Hi,
-
- [% firstname | $raw %] [% surname | $raw %] sent you a cart from our online catalog.
-
- Please note that the attached file is a MARC bibliographic records file
- which can be imported into personal bibliographic software like EndNote,
- Reference Manager or ProCite.
-
-[% END %]
-
-
-
-[% FILTER html2text %]
-
- [% IF comment %]
- [% comment | $raw %]
-
- [% END %]
-
- [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
- -
-
- [% BIBLIO_RESULT.title | $raw %]
- [% IF ( BIBLIO_RESULT.subtitle ) %]
- [% FOREACH subtitle IN BIBLIO_RESULT.subtitle.split(' | ') %]
- [% subtitle | $raw %]
- [% END %]
- [% END %]
- [% BIBLIO_RESULT.part_number | $raw %] [% BIBLIO_RESULT.part_name | $raw %]
-
-
-
- [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
- Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author | $raw %][% END %]
-
- [% IF ( BIBLIO_RESULT.MARCAUTHORS ) %]
- [% IF ( BIBLIO_RESULT.author ) %]; [% END %]
- [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %]
- [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %]
- [% MARCAUTHOR_SUBFIELDS_LOO.separator | $raw %][% MARCAUTHOR_SUBFIELDS_LOO.value | $raw %]
- [% END %]
- [% UNLESS ( loop.last ) %];[% END %]
- [% END %]
- [% END %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.ISBN ) %]
-
- ISBN: [% BIBLIO_RESULT.ISBN | $raw %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.publishercode %]
-
- Published by: [% BIBLIO_RESULT.publishercode | $raw %]
- [% IF ( BIBLIO_RESULT.publicationyear ) %]
- in [% BIBLIO_RESULT.publicationyear | $raw %]
- [% END %]
- [% IF ( BIBLIO_RESULT.pages ) %]
- , [% BIBLIO_RESULT.pages | $raw %]
- [% END %]
- [% IF BIBLIO_RESULT.item('size') %]
- , [% BIBLIO_RESULT.item('size') | $raw %]
- [% END %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.collection %]
-
- Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.subject ) %]
-
- Subject: [% BIBLIO_RESULT.subject | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-
- Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.notes ) %]
-
- Notes : [% BIBLIO_RESULT.notes | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.unititle ) %]
-
- Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.serial ) %]
-
- Serial: [% BIBLIO_RESULT.serial | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.dewey ) %]
-
- Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.classification ) %]
-
- Classification: [% BIBLIO_RESULT.classification | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.lccn ) %]
-
- LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
- In:
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
- [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
- [% ELSE %]
- [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
- [% END %]
-
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.url ) %]
-
- URL: [% BIBLIO_RESULT.url | html %]
-
- [% END %]
-
-
- [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %]
- [% IF ( OPACBaseURL ) %]
-
- In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-
- [% END %]
- [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
- Items:
-
- [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]-
- [% Branches.GetName(ITEM_RESULT.holdingbranch) | $raw %]
- [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_RESULT.location ) | html %]
- [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber | $raw %])[% END %]
- [% ITEM_RESULT.barcode | $raw %]
-
[% END %]
-
-
- [% END %]
-
-
- [% END %]
-
-
-[% END %]
-
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt
deleted file mode 100644
index 4de4ab7f35..0000000000
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt
+++ /dev/null
@@ -1,181 +0,0 @@
-[% USE raw %]
-[% USE AuthorisedValues %]
-[% USE Branches %]
-
-Your list : [% shelfname | $raw %]
-
-
-[% USE HtmlToText %]
-
-
-[% FILTER html2text %]
- Hi,
-
- [% firstname | $raw %] [% surname | $raw %] sent you from our online catalog, the
- list called : [% shelfname | $raw %].
-
- Please note that the attached file is a MARC bibliographic records file
- which can be imported into personal bibliographic software like EndNote,
- Reference Manager or ProCite.
-
-[% END %]
-
-
-
-
-[% FILTER html2text %]
-
- [% IF comment %]
- [% comment | $raw %]
-
- [% END %]
-
- [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
- -
-
- [% BIBLIO_RESULT.title | $raw %]
- [% IF ( BIBLIO_RESULT.subtitle ) %]
- [% FOREACH subtitle IN BIBLIO_RESULT.subtitle.split(' | ') %]
- [% subtitle | $raw %]
- [% END %]
- [% END %]
- [% BIBLIO_RESULT.part_number | $raw %] [% BIBLIO_RESULT.part_name | $raw %]
-
-
-
- [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
- Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author | $raw %][% END %]
-
- [% IF ( BIBLIO_RESULT.MARCAUTHORS ) %]
- [% IF ( BIBLIO_RESULT.author ) %]; [% END %]
- [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %]
- [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %]
- [% MARCAUTHOR_SUBFIELDS_LOO.separator | $raw %][% MARCAUTHOR_SUBFIELDS_LOO.value | $raw %]
- [% END %]
- [% UNLESS ( loop.last ) %];[% END %]
- [% END %]
- [% END %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.ISBN.size > 0 ) %]
-
- ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %]
- [% isbn | $raw %]
- [% UNLESS ( loop.last ) %]; [% END %]
- [% END %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.publishercode %]
-
- Published by: [% BIBLIO_RESULT.publishercode | $raw %]
- [% IF ( BIBLIO_RESULT.publicationyear ) %]
- in [% BIBLIO_RESULT.publicationyear | $raw %]
- [% END %]
- [% IF ( BIBLIO_RESULT.pages ) %]
- , [% BIBLIO_RESULT.pages | $raw %]
- [% END %]
- [% IF BIBLIO_RESULT.item('size') %]
- , [% BIBLIO_RESULT.item('size') | html %]
- [% END %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.collection %]
-
- Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.subject ) %]
-
- Subject: [% BIBLIO_RESULT.subject | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-
- Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.notes ) %]
-
- Notes : [% BIBLIO_RESULT.notes | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.unititle ) %]
-
- Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.serial ) %]
-
- Serial: [% BIBLIO_RESULT.serial | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.dewey ) %]
-
- Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.classification ) %]
-
- Classification: [% BIBLIO_RESULT.classification | $raw %]
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.lccn ) %]
-
- LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-
- [% END %]
-
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
- In:
- [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
- [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
- [% ELSE %]
- [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
- [% END %]
-
-
- [% END %]
-
- [% IF ( BIBLIO_RESULT.url ) %]
-
- URL: [% BIBLIO_RESULT.url | html %]
-
- [% END %]
-
-
- [% IF ( OPACBaseURL ) %]
-
- In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-
- [% END %]
- [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
- Items:
-
- [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]-
- [% Branches.GetName(ITEM_RESULT.holdingbranch) | $raw %]
- [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_RESULT.location ) | html %]
- [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber | $raw %])[% END %]
- [% ITEM_RESULT.barcode | $raw %]
-
[% END %]
-
-
- [% END %]
-
-
- [% END %]
-
-
-[% END %]
-
-
diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl
index 278cfd34a6..2461cccbeb 100755
--- a/opac/opac-sendbasket.pl
+++ b/opac/opac-sendbasket.pl
@@ -53,127 +53,62 @@ if ( $email_add ) {
session_id => scalar $query->cookie('CGISESSID'),
token => scalar $query->param('csrf_token'),
});
- my $patron = Koha::Patrons->find( $borrowernumber );
- my $user_email = $patron->first_valid_email_address
- || C4::Context->preference('KohaAdminEmailAddress');
- my $email_replyto = $patron->firstname . " " . $patron->surname . " <$user_email>";
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ my $user_email = $patron->first_valid_email_address;
+
my $comment = $query->param('comment');
- # Since we are already logged in, no need to check credentials again
- # when loading a second template.
- my $template2 = C4::Templates::gettemplate(
- 'opac-sendbasket.tt', 'opac', $query,
- );
-
my @bibs = split( /\//, $bib_list );
- my @results;
my $iso2709;
- my $marcflavour = C4::Context->preference('marcflavour');
- foreach my $biblionumber (@bibs) {
- $template2->param( biblionumber => $biblionumber );
-
- my $biblio = Koha::Biblios->find( $biblionumber ) or next;
- my $dat = $biblio->unblessed;
- my $record = $biblio->metadata->record(
- {
- embed_items => 1,
- opac => 1,
- patron => $patron,
- }
- );
- my $marcauthorsarray = $biblio->get_marc_contributors;
- my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
-
- my $items = $biblio->items->search_ordered->filter_by_visible_in_opac({ patron => $patron });
-
- my $hasauthors = 0;
- if($dat->{'author'} || @$marcauthorsarray) {
- $hasauthors = 1;
- }
-
- $dat->{MARCSUBJCTS} = $marcsubjctsarray;
- $dat->{MARCAUTHORS} = $marcauthorsarray;
- $dat->{HASAUTHORS} = $hasauthors;
- $dat->{'biblionumber'} = $biblionumber;
- $dat->{ITEM_RESULTS} = $items;
- my ( $host, $relatedparts ) = $biblio->get_marc_host;
- $dat->{HOSTITEMENTRIES} = $host;
- $dat->{RELATEDPARTS} = $relatedparts;
-
- $iso2709 .= $record->as_usmarc();
-
- push( @results, $dat );
- }
-
- my $resultsarray = \@results;
-
- $template2->param(
- BIBLIO_RESULTS => $resultsarray,
- comment => $comment,
- firstname => $patron->firstname,
- surname => $patron->surname,
- );
-
- # Getting template result
- my $template_res = $template2->output();
- my $body;
-
- # Analysing information and getting mail properties
- my $subject;
- if ( $template_res =~ /\(?.*)\/s ) {
- $subject = $+{subject};
- $subject =~ s|\n?(.*)\n?|$1|;
- }
- else {
- $subject = "no subject";
- }
-
- my $email_header = "";
- if ( $template_res =~ /(.*)/s ) {
- $email_header = $1;
- $email_header =~ s|\n?(.*)\n?|$1|;
- }
-
- if ( $template_res =~ /(.*)/s ) {
- $body = $1;
- $body =~ s|\n?(.*)\n?|$1|;
- }
-
- my $THE_body = <find( $bib ) or next;
+ $iso2709 .= $biblio->metadata->record->as_usmarc();
+ };
if ( !defined $iso2709 ) {
carp "Error sending mail: empty basket";
$template->param( error => 1 );
- }
- else {
- try {
- # if you want to use the KohaAdmin address as from, that is the default no need to set it
- my $email = Koha::Email->create({
- to => $email_add,
- reply_to => $email_replyto,
- subject => $subject,
- });
- $email->header( 'X-Abuse-Report' => C4::Context->preference('KohaAdminEmailAddress') );
- $email->text_body( $THE_body );
- $email->attach(
- Encode::encode( "UTF-8", $iso2709 ),
- content_type => 'application/octet-stream',
- name => 'basket.iso2709',
- disposition => 'attachment',
- );
- my $library = $patron->library;
- $email->transport( $library->smtp_server->transport );
- $email->send_or_die;
- $template->param( SENT => "1" );
- }
- catch {
- carp "Error sending mail: $_";
- $template->param( error => 1 );
+ } elsif ( !defined $user_email or $user_email eq '' ) {
+ carp "Error sending mail: sender's email address is invalid";
+ $template->param( error => 1 );
+ } else {
+ my %loops = (
+ biblio => \@bibs,
+ );
+
+ my %substitute = (
+ comment => $comment,
+ );
+
+ my $letter = C4::Letters::GetPreparedLetter(
+ module => 'catalogue',
+ letter_code => 'CART',
+ lang => $patron->lang,
+ tables => {
+ borrowers => $borrowernumber,
+ },
+ message_transport_type => 'email',
+ loops => \%loops,
+ substitute => \%substitute,
+ );
+
+ my $attachment = {
+ filename => 'basket.iso2709',
+ type => 'application/octet-stream',
+ content => Encode::encode("UTF-8", $iso2709),
};
+
+ C4::Letters::EnqueueLetter({
+ letter => $letter,
+ message_transport_type => 'email',
+ borrowernumber => $patron->borrowernumber,
+ to_address => $email_add,
+ reply_address => $user_email,
+ attachments => [$attachment],
+ });
+
+ $template->param( SENT => 1 );
}
$template->param( email_add => $email_add );
diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl
index 3d3d9232ed..ddfc164910 100755
--- a/opac/opac-sendshelf.pl
+++ b/opac/opac-sendshelf.pl
@@ -70,109 +70,64 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) {
);
my $patron = Koha::Patrons->find( $borrowernumber );
-
+ my $user_email = $patron->first_valid_email_address;
my $shelf = Koha::Virtualshelves->find( $shelfid );
my $contents = $shelf->get_contents;
- my $marcflavour = C4::Context->preference('marcflavour');
my $iso2709;
- my @results;
+ my @biblionumbers;
while ( my $content = $contents->next ) {
- my $biblionumber = $content->biblionumber;
- my $biblio = Koha::Biblios->find( $biblionumber ) or next;
- my $dat = $biblio->unblessed;
- my $record = $biblio->metadata->record(
- {
- embed_items => 1,
- opac => 1,
- patron => $patron,
- }
- );
- next unless $record;
- my $fw = GetFrameworkCode($biblionumber);
-
- my $marcauthorsarray = $biblio->get_marc_contributors;
- my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
-
- my $items = $biblio->items->search_ordered->filter_by_visible_in_opac({ patron => $patron });
-
- $dat->{ISBN} = GetMarcISBN($record, $marcflavour);
- $dat->{MARCSUBJCTS} = $marcsubjctsarray;
- $dat->{MARCAUTHORS} = $marcauthorsarray;
- $dat->{'biblionumber'} = $biblionumber;
- $dat->{ITEM_RESULTS} = $items;
- $dat->{HASAUTHORS} = $dat->{'author'} || @$marcauthorsarray;
- my ( $host, $relatedparts ) = $biblio->get_marc_host;
- $dat->{HOSTITEMENTRIES} = $host;
- $dat->{RELATEDPARTS} = $relatedparts;
-
- $iso2709 .= $record->as_usmarc();
-
- push( @results, $dat );
- }
-
- $template2->param(
- BIBLIO_RESULTS => \@results,
- comment => $comment,
- shelfname => $shelf->shelfname,
- firstname => $patron->firstname,
- surname => $patron->surname,
- );
-
- # Getting template result
- my $template_res = $template2->output();
- my $body;
-
- my $subject;
- # Analysing information and getting mail properties
- if ( $template_res =~ /(?.*)/s ) {
- $subject = $+{subject};
- $subject =~ s|\n?(.*)\n?|$1|;
- }
- else {
- $subject = "no subject";
- }
-
- my $email_header = "";
- if ( $template_res =~ /(.*)/s ) {
- $email_header = $1;
- $email_header =~ s|\n?(.*)\n?|$1|;
- }
-
- if ( $template_res =~ /(.*)/s ) {
- $body = $1;
- $body =~ s|\n?(.*)\n?|$1|;
- }
-
- my $THE_body = <create(
- {
- to => $email,
- subject => $subject,
- }
- );
- $email->text_body( $THE_body );
- $email->attach(
- Encode::encode( "UTF-8", $iso2709 ),
- content_type => 'application/octet-stream',
- name => 'list.iso2709',
- disposition => 'attachment',
- );
- my $library = Koha::Patrons->find( $borrowernumber )->library;
- $email->transport( $library->smtp_server->transport );
- $email->send_or_die;
- $template->param( SENT => "1" );
- }
- catch {
- carp "Error sending mail: $_";
- $template->param( error => 1 );
+ push @biblionumbers, $content->biblionumber;
+ my $biblio = Koha::Biblios->find($content->biblionumber);
+ $iso2709 .= $biblio->metadata->record->as_usmarc();
};
+ if ( !defined $iso2709 ) {
+ carp "Error sending mail: empty list";
+ $template->param( error => 1 );
+ } elsif ( !defined $user_email or $user_email eq '' ) {
+ carp "Error sending mail: sender's email address is invalid";
+ $template->param( error => 1 );
+ } else {
+ my %loops = (
+ biblio => \@biblionumbers,
+ );
+
+ my %substitute = (
+ comment => $comment,
+ listname => $shelf->shelfname,
+ );
+
+ my $letter = C4::Letters::GetPreparedLetter(
+ module => 'catalogue',
+ letter_code => 'LIST',
+ lang => $patron->lang,
+ tables => {
+ borrowers => $borrowernumber,
+ },
+ message_transport_type => 'email',
+ loops => \%loops,
+ substitute => \%substitute,
+ );
+
+ my $attachment = {
+ filename => 'list.iso2709',
+ type => 'application/octet-stream',
+ content => Encode::encode("UTF-8", $iso2709),
+ };
+
+ C4::Letters::EnqueueLetter({
+ letter => $letter,
+ message_transport_type => 'email',
+ borrowernumber => $patron->borrowernumber,
+ to_address => $email,
+ reply_address => $user_email,
+ attachments => [$attachment],
+ });
+
+ $template->param( SENT => 1 );
+ }
+
$template->param(
shelfid => $shelfid,
email => $email,
diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl
index d3514159a6..5079568e39 100755
--- a/virtualshelves/sendshelf.pl
+++ b/virtualshelves/sendshelf.pl
@@ -69,96 +69,64 @@ if ($to_address) {
}
);
+ my $patron = Koha::Patrons->find( $borrowernumber );
+ my $user_email = $patron->first_valid_email_address;
my $contents = $shelf->get_contents;
- my $marcflavour = C4::Context->preference('marcflavour');
+ my @biblionumbers;
my $iso2709;
- my @results;
while ( my $content = $contents->next ) {
- my $biblionumber = $content->biblionumber;
- my $biblio = Koha::Biblios->find( $biblionumber ) or next;
- my $dat = $biblio->unblessed;
- my $record = $biblio->metadata->record({ embed_items => 1 });
- my $marcauthorsarray = $biblio->get_marc_contributors;
- my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
-
- my $items = $biblio->items->search_ordered;
-
- $dat->{ISBN} = GetMarcISBN($record, $marcflavour);
- $dat->{MARCSUBJCTS} = $marcsubjctsarray;
- $dat->{MARCAUTHORS} = $marcauthorsarray;
- $dat->{'biblionumber'} = $biblionumber;
- $dat->{ITEM_RESULTS} = $items;
- $dat->{HASAUTHORS} = $dat->{'author'} || @$marcauthorsarray;
- my ( $host, $relatedparts ) = $biblio->get_marc_host;
- $dat->{HOSTITEMENTRIES} = $host;
- $dat->{RELATEDPARTS} = $relatedparts;
-
- $iso2709 .= $record->as_usmarc();
-
- push( @results, $dat );
- }
-
- $template2->param(
- BIBLIO_RESULTS => \@results,
- comment => $comment,
- shelfname => $shelf->shelfname,
- );
-
- # Getting template result
- my $template_res = $template2->output();
- my $body;
-
- my $subject;
- # Analysing information and getting mail properties
- if ( $template_res =~ /(?.*)/s ) {
- $subject = $+{subject};
- $subject =~ s|\n?(.*)\n?|$1|;
- }
- else {
- $subject = "no subject";
- }
-
- my $email_header = "";
- if ( $template_res =~ /(.*)/s ) {
- $email_header = $1;
- $email_header =~ s|\n?(.*)\n?|$1|;
- }
-
- if ( $template_res =~ /(.*)/s ) {
- $body = $1;
- $body =~ s|\n?(.*)\n?|$1|;
- }
-
- my $THE_body = <create(
- {
- to => $to_address,
- subject => $subject,
- }
- );
- $email->text_body( $THE_body );
- $email->attach(
- Encode::encode("UTF-8", $iso2709),
- content_type => 'application/octet-stream',
- name => 'shelf.iso2709',
- disposition => 'attachment',
- );
-
- my $library = Koha::Patrons->find( $borrowernumber )->library;
- $email->send_or_die({ transport => $library->smtp_server->transport });
- $template->param( SENT => "1" );
- }
- catch {
- carp "Error sending mail: $_";
- $template->param( error => 1 );
+ push @biblionumbers, $content->biblionumber;
+ my $biblio = Koha::Biblios->find($content->biblionumber);
+ $iso2709 .= $biblio->metadata->record->as_usmarc();
};
+ if ( !defined $iso2709 ) {
+ carp "Error sending mail: empty basket";
+ $template->param( error => 1 );
+ } elsif ( !defined $user_email or $user_email eq '' ) {
+ carp "Error sending mail: sender's email address is invalid";
+ $template->param( error => 1 );
+ } else {
+ my %loops = (
+ biblio => \@biblionumbers,
+ );
+
+ my %substitute = (
+ comment => $comment,
+ listname => $shelf->shelfname,
+ );
+
+ my $letter = C4::Letters::GetPreparedLetter(
+ module => 'catalogue',
+ letter_code => 'LIST',
+ lang => $patron->lang,
+ tables => {
+ borrowers => $borrowernumber,
+ },
+ message_transport_type => 'email',
+ loops => \%loops,
+ substitute => \%substitute,
+ );
+
+ my $attachment = {
+ filename => 'shelf.iso2709',
+ type => 'application/octet-stream',
+ content => Encode::encode("UTF-8", $iso2709),
+ };
+
+ C4::Letters::EnqueueLetter({
+ letter => $letter,
+ message_transport_type => 'email',
+ borrowernumber => $patron->borrowernumber,
+ to_address => $to_address,
+ reply_address => $user_email,
+ attachments => [$attachment],
+ });
+
+ $template->param( SENT => 1 );
+ }
+
$template->param( email => $to_address );
output_html_with_http_headers $query, $cookie, $template->output;