Bug 3150: Move emails for sending cart and list contents to notices
authorAleisha Amohia <aleishaamohia@hotmail.com>
Mon, 21 Sep 2020 21:30:32 +0000 (09:30 +1200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 27 Mar 2023 10:49:38 +0000 (12:49 +0200)
This patch creates notices using Template Toolkit syntax for sending
emails containing cart and list contents.

To test:
1. Apply Bug 27266
2. Run update database and restart services
3. In the staff client, add multiple items to your cart and to a list
4. Go to your cart and click Send to email the contents
5. Add an email and a comment and click Send
6. Confirm the information shown in the success message is correct
7. In your terminal, log into the database. View the message queue ( i.e. select * from message_queue; ). Confirm that your email has been queued and the content is all correct. Confirm the cart contents has been included as an attachment.
8. Go to your list and click Send list to email the contents
9. Repeat steps 5-7
10. Log into the OPAC
11. Add multiple items to your cart and to a list
12. Repeat steps 4-9
13. By the end, you should have four emails in your message queue. All
of the data about the items should be correct, they should all have
attachments, and be addressed to the correct email address.

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
basket/sendbasket.pl
installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.pl [new file with mode: 0755]
installer/data/mysql/en/mandatory/sample_notices.yml
koha-tmpl/intranet-tmpl/prog/en/modules/basket/sendbasket.tt [deleted file]
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt [deleted file]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendbasket.tt [deleted file]
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelf.tt [deleted file]
opac/opac-sendbasket.pl
opac/opac-sendshelf.pl
virtualshelves/sendshelf.pl

index af47302..abd54de 100755 (executable)
@@ -54,109 +54,64 @@ if ( $email_add ) {
             session_id => scalar $query->cookie('CGISESSID'),
             token  => scalar $query->param('csrf_token'),
         });
-    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 $patron = Koha::Patrons->find( $borrowernumber );
+    my $user_email = $patron->first_valid_email_address;
+
+    my $comment = $query->param('comment');
 
     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 );
-    }
-
-    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 =~ /<SUBJECT>(?<subject>.*)<END_SUBJECT>/s ) {
-        $subject = $+{subject};
-        $subject =~ s|\n?(.*)\n?|$1|;
-    }
-    else {
-        $subject = "no subject";
-    }
 
-    my $email_header = "";
-    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
-        $email_header = $1;
-        $email_header =~ s|\n?(.*)\n?|$1|;
+    foreach my $bib ( @bibs ) {
+        my $biblio = Koha::Biblios->find( $bib ) or next;
+        $iso2709 .= $biblio->metadata->record->as_usmarc();
     }
 
-    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
-        $body = $1;
-        $body =~ s|\n?(.*)\n?|$1|;
-    }
-
-    my $THE_body = <<END_OF_BODY;
-$email_header
-$body
-END_OF_BODY
-
-    try {
+    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 $email = Koha::Email->create(
-            {
-                to      => $email_add,
-                subject => $subject,
-            }
+        my %substitute = (
+            comment => $comment,
         );
 
-        $email->text_body( $THE_body );
-        $email->attach(
-            Encode::encode( "UTF-8", $iso2709 ),
-            content_type => 'application/octet-stream',
-            name         => 'basket.iso2709',
-            disposition  => 'attachment',
+        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 $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 );
-    };
+        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 (executable)
index 0000000..bb74efe
--- /dev/null
@@ -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.
+    <hr/>[% comment | html %]<hr/>
+    <ol>[% FOREACH biblio IN biblios %]<li>
+        [% 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: <ul>[% FOREACH item IN biblio.items %]<li>[% 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 %]</li>[% END %]</ul>[% END %]
+    <hr/></li>[% END %]</ol>", '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.
+    <hr/>[% comment | html %]<hr/>
+    <ol>[% FOREACH biblio IN biblios %]<li>
+        [% 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: <ul>[% FOREACH item IN biblio.items %]<li>[% 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 %]</li>[% END %]</ul>[% END %]
+    <hr/></li>[% END %]</ol>",'email','default') });
+
+        say $out "Add LIST and CART notices";
+    },
+};
index a3c9c51..765875f 100644 (file)
@@ -2289,3 +2289,64 @@ tables:
             - "[% IF borrower.categorycode %]<li>Temporary patron category: [% borrower.categorycode %]</li>[% END %]"
             - "</ul>"
             - "</p>"
+
+        - 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."
+            - "<hr/>[% comment | html %]<hr/>"
+            - "<ol>[% FOREACH biblio IN biblios %]<li>"
+            - "[% 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: <ul>[% FOREACH item IN biblio.items %]<li>[% 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 %]</li>[% END %]</ul>[% END %]"
+            - "<hr/></li>[% END %]</ol>"
+
+        - 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."
+            - "<hr/>[% comment | html %]<hr/>"
+            - "<ol>[% FOREACH biblio IN biblios %]<li>"
+            - "[% 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: <ul>[% FOREACH item IN biblio.items %]<li>[% 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 %]</li>[% END %]</ul>[% END %]"
+            - "<hr/></li>[% END %]</ol>"
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 (file)
index 097090a..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-[% USE raw %]
-[% USE HtmlToText %]
-[% USE Koha %]
-[% USE Branches %]
-
-<SUBJECT>
-Your cart
-<END_SUBJECT>
-
-<HEADER>
-
-[% FILTER html2text %]
-    <p>Hi,</p>
-
-    <p>Here is your cart, sent from our online catalog.</p>
-
-    <p>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.</p>
-    <hr/>
-[% END %]
-<END_HEADER>
-
-<MESSAGE>
-[% FILTER html2text %]
-
-    [% IF comment %]
-        <p>[% comment | $raw %]</p>
-        <hr/>
-    [% END %]
-    <ol>
-    [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
-        <li>
-            <span>
-                [% BIBLIO_RESULT.title | $raw %]
-                [% IF ( BIBLIO_RESULT.subtitle ) %] [% BIBLIO_RESULT.subtitle | $raw %][% END %]
-                [% BIBLIO_RESULT.part_number | $raw %] [% BIBLIO_RESULT.part_name | $raw %]
-            </span>
-
-            <p>
-            [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
-            <span><span>Author(s):</span> [% 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 %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.ISBN ) %]
-            <span>
-                ISBN: [% BIBLIO_RESULT.ISBN | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.publishercode %]
-            <span>
-                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 %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.collection %]
-            <span>
-                Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.subject ) %]
-            <span>
-                Subject: [% BIBLIO_RESULT.subject | $raw %]
-            <span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-            <span>
-                Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.notes ) %]
-            <span>
-                Notes : [% BIBLIO_RESULT.notes | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.unititle ) %]
-            <span>
-                Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.serial ) %]
-            <span>
-                Serial: [% BIBLIO_RESULT.serial | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.dewey ) %]
-            <span>
-                Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.classification ) %]
-            <span>
-                Classification: [% BIBLIO_RESULT.classification | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.lccn ) %]
-            <span>
-                LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
-            <span>In:
-                [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
-                    [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
-                [% ELSE %]
-                    [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
-                [% END %]
-            </span>
-            <br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.url ) %]
-            <span>
-                URL: [% BIBLIO_RESULT.url | html %]
-            </span>
-            [% END %]
-            </p>
-
-            [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %]
-            [% IF ( OPACBaseURL ) %]
-            <p>
-                In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-            </p>
-            [% END %]
-            [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
-            <p>Items:
-            <ul>
-                [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]<li>
-                    [% Branches.GetName(ITEM_RESULT.holdingbranch) | $raw %]
-                    [% ITEM_RESULT.location | $raw %]
-                    [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber | $raw %])[% END %]
-                    [% ITEM_RESULT.barcode | $raw %]
-                </li>[% END %]
-            </ul>
-            </p>
-            [% END %]
-            <hr/>
-        </li>
-    [% END %]
-    </ol>
-
-[% END %]
-<END_MESSAGE>
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 (file)
index ed05c96..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-[% USE raw %]
-[% USE AuthorisedValues %]
-[% USE Branches %]
-<SUBJECT>
-Your list: [% shelfname | $raw %]
-<END_SUBJECT>
-
-[% USE HtmlToText %]
-
-<HEADER>
-[% FILTER html2text %]
-    <p>Hi,</p>
-
-    <p>Here is your list called [% shelfname | $raw %], sent from our online catalog.</p>
-
-    <p>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.</p>
-    <hr/>
-[% END %]
-
-<END_HEADER>
-
-<MESSAGE>
-[% FILTER html2text %]
-
-    [% IF comment %]
-        <p>[% comment | $raw %]</p>
-        <hr/>
-    [% END %]
-    <ol>
-    [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
-        <li>
-            <span>
-                [% 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 %]
-            </span>
-
-            <p>
-            [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
-            <span><span>Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author | $raw %][% END %]</span>
-
-            [% 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 %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.ISBN.size > 0 ) %]
-            <span>
-                ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %]
-                          [% isbn | $raw %]
-                          [% UNLESS ( loop.last ) %]; [% END %]
-                      [% END %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.publishercode %]
-            <span>
-                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 %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.collection %]
-            <span>
-                Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.subject ) %]
-            <span>
-                Subject: [% BIBLIO_RESULT.subject | $raw %]
-            <span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-            <span>
-                Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.notes ) %]
-            <span>
-                Notes : [% BIBLIO_RESULT.notes | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.unititle ) %]
-            <span>
-                Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.serial ) %]
-            <span>
-                Serial: [% BIBLIO_RESULT.serial | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.dewey ) %]
-            <span>
-                Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.classification ) %]
-            <span>
-                Classification: [% BIBLIO_RESULT.classification | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.lccn ) %]
-            <span>
-                LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
-            <span>In:
-                [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
-                    [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
-                [% ELSE %]
-                    [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
-                [% END %]
-            </span>
-            <br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.url ) %]
-            <span>
-                URL: [% BIBLIO_RESULT.url | html %]
-            </span>
-            [% END %]
-            </p>
-
-            [% IF ( OPACBaseURL ) %]
-            <p>
-                In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-            </p>
-            [% END %]
-            [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
-            <p>Items:
-            <ul>
-                [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]<li>
-                    [% 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 %]
-                </li>[% END %]
-            </ul>
-            </p>
-            [% END %]
-            <hr/>
-        </li>
-    [% END %]
-    </ol>
-
-[% END %]
-<END_MESSAGE>
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 (file)
index f676084..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-[% USE raw %]
-[% USE HtmlToText %]
-[% USE Koha %]
-[% USE AuthorisedValues %]
-[% USE Branches %]
-
-<SUBJECT>
-Your cart
-<END_SUBJECT>
-
-<HEADER>
-
-[% FILTER html2text %]
-    <p>Hi,</p>
-
-    <p>[% firstname | $raw %] [% surname | $raw %] sent you a cart from our online catalog.</p>
-
-    <p>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.</p>
-    <hr/>
-[% END %]
-<END_HEADER>
-
-<MESSAGE>
-[% FILTER html2text %]
-
-    [% IF comment %]
-        <p>[% comment | $raw %]</p>
-        <hr/>
-    [% END %]
-    <ol>
-    [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
-        <li>
-            <span>
-                [% 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 %]
-            </span>
-
-            <p>
-            [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
-            <span>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 %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.ISBN ) %]
-            <span>
-                ISBN: [% BIBLIO_RESULT.ISBN | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.publishercode %]
-            <span>
-                <span>Published by: [% BIBLIO_RESULT.publishercode | $raw %]
-                [% IF ( BIBLIO_RESULT.publicationyear ) %]
-                    in [% BIBLIO_RESULT.publicationyear | $raw %]
-                [% END %]</span>
-                [% IF ( BIBLIO_RESULT.pages ) %]
-                    , [% BIBLIO_RESULT.pages | $raw %]
-                [% END %]
-                [% IF BIBLIO_RESULT.item('size') %]
-                , [% BIBLIO_RESULT.item('size') | $raw %]
-                [% END %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.collection %]
-            <span>
-                Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.subject ) %]
-            <span>
-                Subject: [% BIBLIO_RESULT.subject | $raw %]
-            <span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-            <span>
-                Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.notes ) %]
-            <span>
-                Notes : [% BIBLIO_RESULT.notes | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.unititle ) %]
-            <span>
-                Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.serial ) %]
-            <span>
-                Serial: [% BIBLIO_RESULT.serial | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.dewey ) %]
-            <span>
-                Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.classification ) %]
-            <span>
-                Classification: [% BIBLIO_RESULT.classification | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.lccn ) %]
-            <span>
-                LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
-            <span>In:
-                [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
-                    [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
-                [% ELSE %]
-                    [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
-                [% END %]
-            </span>
-            <br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.url ) %]
-            <span>
-                URL: [% BIBLIO_RESULT.url | html %]
-            </span>
-            [% END %]
-            </p>
-
-            [% SET OPACBaseURL = Koha.Preference('OPACBaseURL') %]
-            [% IF ( OPACBaseURL ) %]
-            <p>
-                In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-            </p>
-            [% END %]
-            [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
-            <p>Items:
-            <ul>
-                [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]<li>
-                    [% 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 %]
-                </li>[% END %]
-            </ul>
-            </p>
-            [% END %]
-            <hr/>
-        </li>
-    [% END %]
-    </ol>
-
-[% END %]
-<END_MESSAGE>
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 (file)
index 4de4ab7..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-[% USE raw %]
-[% USE AuthorisedValues %]
-[% USE Branches %]
-<SUBJECT>
-Your list : [% shelfname | $raw %]
-<END_SUBJECT>
-
-[% USE HtmlToText %]
-
-<HEADER>
-[% FILTER html2text %]
-    <p>Hi,</p>
-
-    <p>[% firstname | $raw %] [% surname | $raw %] sent you from our online catalog, the
-    list called : [% shelfname | $raw %].</p>
-
-    <p>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.</p>
-    <hr/>
-[% END %]
-
-<END_HEADER>
-
-<MESSAGE>
-[% FILTER html2text %]
-
-    [% IF comment %]
-        <p>[% comment | $raw %]</p>
-        <hr/>
-    [% END %]
-    <ol>
-    [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]
-        <li>
-            <span>
-                [% 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 %]
-            </span>
-
-            <p>
-            [% IF ( BIBLIO_RESULT.HASAUTHORS ) %]
-            <span>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 %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.ISBN.size > 0 ) %]
-            <span>
-                ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %]
-                          [% isbn | $raw %]
-                          [% UNLESS ( loop.last ) %]; [% END %]
-                      [% END %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.publishercode %]
-            <span>
-                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 %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.collection %]
-            <span>
-                Collection: [% BIBLIO_RESULT.seriestitle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.subject ) %]
-            <span>
-                Subject: [% BIBLIO_RESULT.subject | $raw %]
-            <span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.copyrightdate ) %]
-            <span>
-                Copyright year: [% BIBLIO_RESULT.copyrightdate | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.notes ) %]
-            <span>
-                Notes : [% BIBLIO_RESULT.notes | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.unititle ) %]
-            <span>
-                Unified title: [% BIBLIO_RESULT.unititle | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.serial ) %]
-            <span>
-                Serial: [% BIBLIO_RESULT.serial | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.dewey ) %]
-            <span>
-                Dewey: [% BIBLIO_RESULT.dewey | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.classification ) %]
-            <span>
-                Classification: [% BIBLIO_RESULT.classification | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.lccn ) %]
-            <span>
-                LCCN: [% BIBLIO_RESULT.lccn | $raw %]
-            </span><br/>
-            [% END %]
-
-            [% IF BIBLIO_RESULT.HOSTITEMENTRIES %]
-                    <span>In:
-                        [% IF BIBLIO_RESULT.HOSTITEMENTRIES.biblionumber %]
-                            [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
-                        [% ELSE %]
-                            [% BIBLIO_RESULT.HOSTITEMENTRIES | html %]
-                        [% END %]
-                    </span>
-                    <br/>
-            [% END %]
-
-            [% IF ( BIBLIO_RESULT.url ) %]
-            <span>
-                URL: [% BIBLIO_RESULT.url | html %]
-            </span>
-            [% END %]
-            </p>
-
-            [% IF ( OPACBaseURL ) %]
-            <p>
-                In online catalog: [% OPACBaseURL | $raw %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber | html %]
-            </p>
-            [% END %]
-            [% IF ( BIBLIO_RESULT.ITEM_RESULTS.count ) %]
-            <p>Items:
-            <ul>
-                [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]<li>
-                    [% 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 %]
-                </li>[% END %]
-            </ul>
-            </p>
-            [% END %]
-            <hr/>
-        </li>
-    [% END %]
-    </ol>
-
-[% END %]
-
-<END_MESSAGE>
index 278cfd3..2461ccc 100755 (executable)
@@ -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 $user_email = $patron->first_valid_email_address;
 
-    my $email_replyto = $patron->firstname . " " . $patron->surname . " <$user_email>";
     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();
+    foreach my $bib ( @bibs ) {
+        my $biblio = Koha::Biblios->find( $bib ) or next;
+        $iso2709 .= $biblio->metadata->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;
+    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,
+        );
 
-    # Analysing information and getting mail properties
-    my $subject;
-    if ( $template_res =~ /\<SUBJECT\>(?<subject>.*)\<END_SUBJECT\>/s ) {
-        $subject = $+{subject};
-        $subject =~ s|\n?(.*)\n?|$1|;
-    }
-    else {
-        $subject = "no subject";
-    }
+        my %substitute = (
+            comment => $comment,
+        );
 
-    my $email_header = "";
-    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
-        $email_header = $1;
-        $email_header =~ s|\n?(.*)\n?|$1|;
-    }
+        my $letter = C4::Letters::GetPreparedLetter(
+            module => 'catalogue',
+            letter_code => 'CART',
+            lang => $patron->lang,
+            tables => {
+                borrowers => $borrowernumber,
+            },
+            message_transport_type => 'email',
+            loops => \%loops,
+            substitute => \%substitute,
+        );
 
-    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
-        $body = $1;
-        $body =~ s|\n?(.*)\n?|$1|;
-    }
+        my $attachment = {
+            filename => 'basket.iso2709',
+            type => 'application/octet-stream',
+            content => Encode::encode("UTF-8", $iso2709),
+        };
 
-    my $THE_body = <<END_OF_BODY;
-$email_header
-$body
-END_OF_BODY
+        C4::Letters::EnqueueLetter({
+            letter => $letter,
+            message_transport_type => 'email',
+            borrowernumber => $patron->borrowernumber,
+            to_address => $email_add,
+            reply_address => $user_email,
+            attachments => [$attachment],
+        });
 
-    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 );
-        };
+        $template->param( SENT => 1 );
     }
 
     $template->param( email_add => $email_add );
index 3d3d923..ddfc164 100755 (executable)
@@ -70,108 +70,63 @@ 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 =~ /<SUBJECT>(?<subject>.*)<END_SUBJECT>/s ) {
-        $subject = $+{subject};
-        $subject =~ s|\n?(.*)\n?|$1|;
-    }
-    else {
-        $subject = "no subject";
-    }
-
-    my $email_header = "";
-    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
-        $email_header = $1;
-        $email_header =~ s|\n?(.*)\n?|$1|;
-    }
-
-    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
-        $body = $1;
-        $body =~ s|\n?(.*)\n?|$1|;
-    }
+        push @biblionumbers, $content->biblionumber;
+        my $biblio = Koha::Biblios->find($content->biblionumber);
+        $iso2709 .= $biblio->metadata->record->as_usmarc();
+    };
 
-    my $THE_body = <<END_OF_BODY;
-$email_header
-$body
-END_OF_BODY
-
-    try {
-        my $email = Koha::Email->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',
+    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 $library = Koha::Patrons->find( $borrowernumber )->library;
-        $email->transport( $library->smtp_server->transport );
-        $email->send_or_die;
-        $template->param( SENT => "1" );
+
+        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 );
     }
-    catch {
-        carp "Error sending mail: $_";
-        $template->param( error => 1 );
-    };
 
     $template->param(
         shelfid => $shelfid,
index d351415..5079568 100755 (executable)
@@ -69,95 +69,63 @@ 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 =~ /<SUBJECT>(?<subject>.*)<END_SUBJECT>/s ) {
-        $subject = $+{subject};
-        $subject =~ s|\n?(.*)\n?|$1|;
-    }
-    else {
-        $subject = "no subject";
-    }
-
-    my $email_header = "";
-    if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) {
-        $email_header = $1;
-        $email_header =~ s|\n?(.*)\n?|$1|;
-    }
+        push @biblionumbers, $content->biblionumber;
+        my $biblio = Koha::Biblios->find($content->biblionumber);
+        $iso2709 .= $biblio->metadata->record->as_usmarc();
+    };
 
-    if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) {
-        $body = $1;
-        $body =~ s|\n?(.*)\n?|$1|;
-    }
+    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 $THE_body = <<END_OF_BODY;
-$email_header
-$body
-END_OF_BODY
-
-    try {
-        my $email = Koha::Email->create(
-            {
-                to      => $to_address,
-                subject => $subject,
-            }
+        my %substitute = (
+            comment => $comment,
+            listname => $shelf->shelfname,
         );
-        $email->text_body( $THE_body );
-        $email->attach(
-            Encode::encode("UTF-8", $iso2709),
-            content_type => 'application/octet-stream',
-            name         => 'shelf.iso2709',
-            disposition  => 'attachment',
+
+        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 $library = Koha::Patrons->find( $borrowernumber )->library;
-        $email->send_or_die({ transport => $library->smtp_server->transport });
-        $template->param( SENT => "1" );
+        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 );
     }
-    catch {
-        carp "Error sending mail: $_";
-        $template->param( error => 1 );
-    };
 
     $template->param( email => $to_address );
     output_html_with_http_headers $query, $cookie, $template->output;