Bugzilla – Attachment 147868 Details for
Bug 3150
Move emails for sending cart and list contents into notices tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 3150: Move emails for sending cart and list contents to notices
Bug-3150-Move-emails-for-sending-cart-and-list-con.patch (text/plain), 42.38 KB, created by
Katrin Fischer
on 2023-03-07 18:04:15 UTC
(
hide
)
Description:
Bug 3150: Move emails for sending cart and list contents to notices
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-03-07 18:04:15 UTC
Size:
42.38 KB
patch
obsolete
>From 4517d86a30f5d21f305442fc87ca3c3c51a2bc29 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 22 Sep 2020 09:30:32 +1200 >Subject: [PATCH] Bug 3150: Move emails for sending cart and list contents to > notices >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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> >--- > basket/sendbasket.pl | 132 ++++------ > .../bug_3150_-_add_LIST_and_CART_notices.perl | 224 +++++++++++++++++ > .../mysql/en/mandatory/sample_notices.yml | 238 ++++++++++++++++++ > opac/opac-sendbasket.pl | 153 ++++------- > opac/opac-sendshelf.pl | 137 ++++------ > virtualshelves/sendshelf.pl | 122 ++++----- > 6 files changed, 633 insertions(+), 373 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.perl > >diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl >index af47302d5c..7220544c35 100755 >--- a/basket/sendbasket.pl >+++ b/basket/sendbasket.pl >@@ -54,109 +54,61 @@ 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 $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|; >- } > >- if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) { >- $body = $1; >- $body =~ s|\n?(.*)\n?|$1|; >+ foreach my $bib ( @bibs ) { >+ my $biblio = Koha::Biblios->find( $biblionumber ) or next; >+ $iso2709 .= $biblio->metadata->record->as_usmarc(); > } > >- 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 ); >+ } 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 => 'catalog', >+ 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), >+ }; >+ >+ my $user_email = $patron->first_valid_email_address || C4::Context->preference('KohaAdminEmailAddress'); >+ 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.perl b/installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.perl >new file mode 100644 >index 0000000000..610a58ac12 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.perl >@@ -0,0 +1,224 @@ >+$DBversion = 'XXX'; >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES >+ ('catalog','LIST','','Send list',1,'Your list: [% listname | html %]',"[%- USE raw -%] >+<p>Hi,</p> >+<p>[% borrower.firstname | $raw %] [% borrower.surname | $raw %] sent you a list from our online catalog called: [% listname | $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/> >+<p>[% comment | $raw %]</p> >+<hr/> >+<ol> >+[% FOREACH biblio IN biblios %] >+ <li> >+ <span> >+ [% biblio.title | $raw %] >+ [% IF ( biblio.subtitle ) %] >+ [% FOREACH subtitle IN biblio.subtitle.split(' | ') %] >+ [% subtitle | $raw %] >+ [% END %] >+ [% END %] >+ [% biblio.part_number | $raw %] [% biblio.part_name | $raw %] >+ </span> >+ <p> >+ [% IF ( biblio.author || biblio.get_authors_from_MARC ) %] >+ <span>Author(s): [% IF ( biblio.author ) %][% biblio.author | $raw %][% END %] >+ [% IF ( biblio.get_authors_from_MARC ) %] >+ [% IF ( biblio.author ) %]; [% END %] >+ [% FOREACH author IN biblio.get_authors_from_MARC %] >+ [% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %] >+ [% subfield.separator | $raw %][% subfield.value | $raw %] >+ [% END %] >+ [% UNLESS ( loop.last ) %];[% END %] >+ [% END %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ [% SET biblioitem = biblio.biblioitem %] >+ [% IF ( biblioitem.isbn ) %] >+ <span> >+ ISBN: [% FOREACH isbn IN biblioitem.isbn %] >+ [% isbn | $raw %] >+ [% UNLESS ( loop.last ) %]; [% END %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblioitem.publishercode ) %] >+ <span> >+ Published by: [% biblioitem.publishercode | $raw %] >+ [% IF ( biblioitem.publicationyear ) %] >+ in [% biblioitem.publicationyear | $raw %] >+ [% END %] >+ [% IF ( biblioitem.pages ) %] >+ , [% biblioitem.pages | $raw %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.seriestitle ) %] >+ <span> >+ Collection: [% biblio.seriestitle | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.copyrightdate ) %] >+ <span> >+ Copyright year: [% biblio.copyrightdate | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.notes ) %] >+ <span> >+ Notes: [% biblio.notes | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.unititle ) %] >+ <span> >+ Unified title: [% biblio.unititle | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.serial ) %] >+ <span> >+ Serial: [% biblio.serial | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblioitem.lccn ) %] >+ <span> >+ LCCN: [% biblioitem.lccn | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblioitem.url ) %] >+ <span> >+ URL: [% biblioitem.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.biblionumber | html %]</p> >+ [% END %] >+ [% IF ( biblio.items.count > 0 ) %] >+ <p>Items: >+ <ul> >+ [% FOREACH item IN biblio.items %]<li> >+ [% item.holding_branch.branchname | $raw %] >+ [% item.location | $raw %] >+ [% IF item.itemcallnumber %]([% item.itemcallnumber | $raw %])[% END %] >+ [% item.barcode | $raw %] >+ </li>[% END %] >+ </ul> >+ </p> >+ [% END %] >+ <hr/> >+ </li> >+[% END %] >+</ol>", 'email','default' ), >+ ('catalog','CART','','Send cart',1,'Your cart',"[%- USE raw -%] >+<p>Hi,</p> >+<p>[% borrower.firstname | $raw %] [% borrower.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/> >+<p>[% comment | $raw %]</p> >+<hr/> >+<ol> >+[% FOREACH biblio IN biblios %] >+ <li> >+ <span> >+ [% biblio.title | $raw %] >+ [% IF ( biblio.subtitle ) %] >+ [% FOREACH subtitle IN biblio.subtitle.split(' | ') %] >+ [% subtitle | $raw %] >+ [% END %] >+ [% END %] >+ [% biblio.part_number | $raw %] [% biblio.part_name | $raw %] >+ </span> >+ <p> >+ [% IF ( biblio.author || biblio.get_authors_from_MARC ) %] >+ <span>Author(s): [% IF ( biblio.author ) %][% biblio.author | $raw %][% END %] >+ [% IF ( biblio.get_authors_from_MARC ) %] >+ [% IF ( biblio.author ) %]; [% END %] >+ [% FOREACH author IN biblio.get_authors_from_MARC %] >+ [% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %] >+ [% subfield.separator | $raw %][% subfield.value | $raw %] >+ [% END %] >+ [% UNLESS ( loop.last ) %];[% END %] >+ [% END %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ [% SET biblioitem = biblio.biblioitem %] >+ [% IF ( biblioitem.isbn ) %] >+ <span> >+ ISBN: [% FOREACH isbn IN biblioitem.isbn %] >+ [% isbn | $raw %] >+ [% UNLESS ( loop.last ) %]; [% END %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblioitem.publishercode ) %] >+ <span> >+ Published by: [% biblioitem.publishercode | $raw %] >+ [% IF ( biblioitem.publicationyear ) %] >+ in [% biblioitem.publicationyear | $raw %] >+ [% END %] >+ [% IF ( biblioitem.pages ) %] >+ , [% biblioitem.pages | $raw %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.seriestitle ) %] >+ <span> >+ Collection: [% biblio.seriestitle | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.copyrightdate ) %] >+ <span> >+ Copyright year: [% biblio.copyrightdate | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.notes ) %] >+ <span> >+ Notes: [% biblio.notes | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.unititle ) %] >+ <span> >+ Unified title: [% biblio.unititle | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblio.serial ) %] >+ <span> >+ Serial: [% biblio.serial | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblioitem.lccn ) %] >+ <span> >+ LCCN: [% biblioitem.lccn | $raw %] >+ </span><br/> >+ [% END %] >+ [% IF ( biblioitem.url ) %] >+ <span> >+ URL: [% biblioitem.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.biblionumber | html %]</p> >+ [% END %] >+ [% IF ( biblio.items.count > 0 ) %] >+ <p>Items: >+ <ul> >+ [% FOREACH item IN biblio.items %]<li> >+ [% item.holding_branch.branchname | $raw %] >+ [% item.location | $raw %] >+ [% IF item.itemcallnumber %]([% item.itemcallnumber | $raw %])[% END %] >+ [% item.barcode | $raw %] >+ </li>[% END %] >+ </ul> >+ </p> >+ [% END %] >+ <hr/> >+ </li> >+[% END %] >+</ol>",'email','default') }); >+ >+ NewVersion( $DBversion, 3150, '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 b18824ae20..8f41704aa0 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -2186,3 +2186,241 @@ tables: > - "[% IF borrower.categorycode %]<li>Temporary patron category: [% borrower.categorycode %]</li>[% END %]" > - "</ul>" > - "</p>" >+ >+ - module: catalog >+ code: LIST >+ branchcode: "" >+ name: "Send list" >+ is_html: 1 >+ title: "Your list: [% listname | html %]" >+ message_transport_type: email >+ lang: default >+ content: >+ - "[%- USE raw -%]" >+ - "<p>Hi,</p>" >+ - "<p>[% borrower.firstname | $raw %] [% borrower.surname | $raw %] sent you a list from our online catalog called: [% listname | $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/>" >+ - "<p>[% comment | $raw %]</p>" >+ - "<hr/>" >+ - "<ol>" >+ - "[% FOREACH biblio IN biblios %]" >+ - "<li>" >+ - "<span>" >+ - "[% biblio.title | $raw %]" >+ - "[% IF ( biblio.subtitle ) %]" >+ - "[% FOREACH subtitle IN biblio.subtitle.split(' | ') %]" >+ - "[% subtitle | $raw %]" >+ - "[% END %]" >+ - "[% END %]" >+ - "[% biblio.part_number | $raw %] [% biblio.part_name | $raw %]" >+ - "</span>" >+ - "<p>" >+ - "[% IF ( biblio.author || biblio.get_authors_from_MARC ) %]" >+ - "<span>Author(s): [% IF ( biblio.author ) %][% biblio.author | $raw %][% END %]" >+ - "[% IF ( biblio.get_authors_from_MARC ) %]" >+ - "[% IF ( biblio.author ) %]; [% END %]" >+ - "[% FOREACH author IN biblio.get_authors_from_MARC %]" >+ - "[% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %]" >+ - "[% subfield.separator | $raw %][% subfield.value | $raw %]" >+ - "[% END %]" >+ - "[% UNLESS ( loop.last ) %];[% END %]" >+ - "[% END %]" >+ - "[% END %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% SET biblioitem = biblio.biblioitem %]" >+ - "[% IF ( biblioitem.isbn ) %]" >+ - "<span>" >+ - "ISBN: [% FOREACH isbn IN biblioitem.isbn %]" >+ - "[% isbn | $raw %]" >+ - "[% UNLESS ( loop.last ) %]; [% END %]" >+ - "[% END %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblioitem.publishercode ) %]" >+ - "<span>" >+ - "Published by: [% biblioitem.publishercode | $raw %]" >+ - "[% IF ( biblioitem.publicationyear ) %]" >+ - "in [% biblioitem.publicationyear | $raw %]" >+ - "[% END %]" >+ - "[% IF ( biblioitem.pages ) %]" >+ - ", [% biblioitem.pages | $raw %]" >+ - "[% END %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.seriestitle ) %]" >+ - "<span>" >+ - "Collection: [% biblio.seriestitle | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.copyrightdate ) %]" >+ - "<span>" >+ - "Copyright year: [% biblio.copyrightdate | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.notes ) %]" >+ - "<span>" >+ - "Notes: [% biblio.notes | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.unititle ) %]" >+ - "<span>" >+ - "Unified title: [% biblio.unititle | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.serial ) %]" >+ - "<span>" >+ - "Serial: [% biblio.serial | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblioitem.lccn ) %]" >+ - "<span>" >+ - "LCCN: [% biblioitem.lccn | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblioitem.url ) %]" >+ - "<span>" >+ - "URL: [% biblioitem.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.biblionumber | html %]</p>" >+ - "[% END %]" >+ - "[% IF ( biblio.items.count > 0 ) %]" >+ - "<p>Items:" >+ - "<ul>" >+ - "[% FOREACH item IN biblio.items %]<li>" >+ - "[% item.holding_branch.branchname | $raw %]" >+ - "[% item.location | $raw %]" >+ - "[% IF item.itemcallnumber %]([% item.itemcallnumber | $raw %])[% END %]" >+ - "[% item.barcode | $raw %]" >+ - "</li>[% END %]" >+ - "</ul>" >+ - "</p>" >+ - "[% END %]" >+ - "<hr/>" >+ - "</li>" >+ - "[% END %]" >+ - "</ol>" >+ >+ - module: catalog >+ code: CART >+ branchcode: "" >+ name: "Send cart" >+ is_html: 1 >+ title: "Your cart" >+ message_transport_type: email >+ lang: default >+ content: >+ - "[%- USE raw -%]" >+ - "<p>Hi,</p>" >+ - "<p>[% borrower.firstname | $raw %] [% borrower.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/>" >+ - "<p>[% comment | $raw %]</p>" >+ - "<hr/>" >+ - "<ol>" >+ - "[% FOREACH biblio IN biblios %]" >+ - "<li>" >+ - "<span>" >+ - "[% biblio.title | $raw %]" >+ - "[% IF ( biblio.subtitle ) %]" >+ - "[% FOREACH subtitle IN biblio.subtitle.split(' | ') %]" >+ - "[% subtitle | $raw %]" >+ - "[% END %]" >+ - "[% END %]" >+ - "[% biblio.part_number | $raw %] [% biblio.part_name | $raw %]" >+ - "</span>" >+ - "<p>" >+ - "[% IF ( biblio.author || biblio.get_authors_from_MARC ) %]" >+ - "<span>Author(s): [% IF ( biblio.author ) %][% biblio.author | $raw %][% END %]" >+ - "[% IF ( biblio.get_authors_from_MARC ) %]" >+ - "[% IF ( biblio.author ) %]; [% END %]" >+ - "[% FOREACH author IN biblio.get_authors_from_MARC %]" >+ - "[% FOREACH subfield IN author.MARCAUTHOR_SUBFIELDS_LOOP %]" >+ - "[% subfield.separator | $raw %][% subfield.value | $raw %]" >+ - "[% END %]" >+ - "[% UNLESS ( loop.last ) %];[% END %]" >+ - "[% END %]" >+ - "[% END %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% SET biblioitem = biblio.biblioitem %]" >+ - "[% IF ( biblioitem.isbn ) %]" >+ - "<span>" >+ - "ISBN: [% FOREACH isbn IN biblioitem.isbn %]" >+ - "[% isbn | $raw %]" >+ - "[% UNLESS ( loop.last ) %]; [% END %]" >+ - "[% END %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblioitem.publishercode ) %]" >+ - "<span>" >+ - "Published by: [% biblioitem.publishercode | $raw %]" >+ - "[% IF ( biblioitem.publicationyear ) %]" >+ - "in [% biblioitem.publicationyear | $raw %]" >+ - "[% END %]" >+ - "[% IF ( biblioitem.pages ) %]" >+ - ", [% biblioitem.pages | $raw %]" >+ - "[% END %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.seriestitle ) %]" >+ - "<span>" >+ - "Collection: [% biblio.seriestitle | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.copyrightdate ) %]" >+ - "<span>" >+ - "Copyright year: [% biblio.copyrightdate | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.notes ) %]" >+ - "<span>" >+ - "Notes: [% biblio.notes | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.unititle ) %]" >+ - "<span>" >+ - "Unified title: [% biblio.unititle | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblio.serial ) %]" >+ - "<span>" >+ - "Serial: [% biblio.serial | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblioitem.lccn ) %]" >+ - "<span>" >+ - "LCCN: [% biblioitem.lccn | $raw %]" >+ - "</span><br/>" >+ - "[% END %]" >+ - "[% IF ( biblioitem.url ) %]" >+ - "<span>" >+ - "URL: [% biblioitem.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.biblionumber | html %]</p>" >+ - "[% END %]" >+ - "[% IF ( biblio.items.count > 0 ) %]" >+ - "<p>Items:" >+ - "<ul>" >+ - "[% FOREACH item IN biblio.items %]<li>" >+ - "[% item.holding_branch.branchname | $raw %]" >+ - "[% item.location | $raw %]" >+ - "[% IF item.itemcallnumber %]([% item.itemcallnumber | $raw %])[% END %]" >+ - "[% item.barcode | $raw %]" >+ - "</li>[% END %]" >+ - "</ul>" >+ - "</p>" >+ - "[% END %]" >+ - "<hr/>" >+ - "</li>" >+ - "[% END %]" >+ - "</ol>" >diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl >index 278cfd34a6..99ca57ef1b 100755 >--- a/opac/opac-sendbasket.pl >+++ b/opac/opac-sendbasket.pl >@@ -53,128 +53,59 @@ 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 $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 =~ /\<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|; >- } >- >- my $THE_body = <<END_OF_BODY; >-$email_header >-$body >-END_OF_BODY >+ foreach my $bib ( @bibs ) { >+ my $biblio = Koha::Biblios->find( $biblionumber ) 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 ); >+ } else { >+ my %loops = ( >+ biblio => \@bibs, >+ ); >+ >+ my %substitute = ( >+ comment => $comment, >+ ); >+ >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'catalog', >+ 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), > }; >- } >+ >+ my $user_email = $patron->first_valid_email_address || C4::Context->preference('KohaAdminEmailAddress'); >+ 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, undef, { force_no_caching => 1 }; >diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl >index 3d3d9232ed..a0b485c846 100755 >--- a/opac/opac-sendshelf.pl >+++ b/opac/opac-sendshelf.pl >@@ -73,105 +73,56 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { > > my $shelf = Koha::Virtualshelves->find( $shelfid ); > my $contents = $shelf->get_contents; >- my $marcflavour = C4::Context->preference('marcflavour'); > 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, >- 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 ); >+ } else { >+ my %loops = ( >+ biblio => \@biblionumbers, >+ ); >+ >+ my %substitute = ( >+ comment => $comment, >+ listname => $shelf->shelfname, >+ ); >+ >+ my $letter = C4::Letters::GetPreparedLetter( >+ module => 'catalog', >+ 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 => $patron->first_valid_email_address, >+ attachments => [$attachment], >+ }); >+ >+ $template->param( SENT => 1 ); > } >- catch { >- carp "Error sending mail: $_"; >- $template->param( error => 1 ); >- }; > > $template->param( > shelfid => $shelfid, >diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl >index d3514159a6..25e5ac72f9 100755 >--- a/virtualshelves/sendshelf.pl >+++ b/virtualshelves/sendshelf.pl >@@ -69,95 +69,59 @@ if ($to_address) { > } > ); > >+ my $patron = Koha:::Patrons->find( $borrowernumber ); > 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 ); >+ } 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 => 'catalog', >+ 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 => $patron->first_valid_email_address, >+ 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; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3150
:
114127
|
114545
|
114579
|
114582
|
117237
|
118313
|
120477
|
120478
|
121026
|
121027
|
121037
|
121038
|
123020
|
123021
|
123022
|
125225
|
125226
|
125227
|
125379
|
126544
|
126545
|
126546
|
126547
|
130150
|
130151
|
130152
|
130153
|
134304
|
134305
|
134306
|
134307
|
134308
|
134477
|
137690
|
137691
|
137692
|
137693
|
137694
|
137716
|
137717
|
137718
|
137719
|
137720
|
137878
|
140246
|
140247
|
140248
|
140249
|
140250
|
140251
|
140252
|
140253
|
140254
|
140255
|
140256
|
140257
|
140258
|
140259
|
145229
|
145230
|
145231
|
145232
|
145233
|
145234
|
145676
|
145677
|
145678
|
145679
|
145680
|
145681
|
146560
|
146561
|
146562
|
146563
|
146564
|
146565
|
146566
|
146858
|
146859
|
146860
|
146861
|
146862
|
146863
|
146864
|
146865
|
146866
|
146867
|
146987
|
147423
|
147868
|
147869
|
147870
|
147871
|
147872
|
147873
|
147874
|
147875
|
147876
|
147877
|
147878
|
147879
|
147880
|
148045
|
148170
|
148171
|
148172
|
148173
|
148174
|
148175
|
148176
|
148177
|
148178
|
148179
|
148180
|
148181
|
148182
|
148183
|
148184
|
148185