Bugzilla – Attachment 114545 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: WIP
Bug-3150-WIP.patch (text/plain), 20.06 KB, created by
Aleisha Amohia
on 2020-12-21 02:12:43 UTC
(
hide
)
Description:
Bug 3150: WIP
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2020-12-21 02:12:43 UTC
Size:
20.06 KB
patch
obsolete
>From ed092491a043b66c2aed9c66d28c297dca8935be 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: WIP > >--- > basket/sendbasket.pl | 2 + > .../bug_3150_-_add_LIST_and_CART_notices.perl | 358 +++++++++++++++++++++ > .../data/mysql/en/mandatory/sample_notices.yml | 7 + > opac/opac-sendshelf.pl | 86 ++--- > virtualshelves/sendshelf.pl | 2 + > 5 files changed, 404 insertions(+), 51 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 9e273b1f45..36e1adbac8 100755 >--- a/basket/sendbasket.pl >+++ b/basket/sendbasket.pl >@@ -66,6 +66,7 @@ if ( $email_add ) { > my $marcflavour = C4::Context->preference('marcflavour'); > foreach my $biblionumber (@bibs) { > $template2->param( biblionumber => $biblionumber ); >+ my $biblio = Koha::Biblios->find($biblionumber); > > my $dat = GetBiblioData($biblionumber); > next unless $dat; >@@ -88,6 +89,7 @@ if ( $email_add ) { > $dat->{HASAUTHORS} = $hasauthors; > $dat->{'biblionumber'} = $biblionumber; > $dat->{ITEM_RESULTS} = \@items; >+ $dat->{biblio} = $biblio; > > $iso2709 .= $record->as_usmarc(); > >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..db73989a0b >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_3150_-_add_LIST_and_CART_notices.perl >@@ -0,0 +1,358 @@ >+$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 >+ ('catalogue','LIST','','Send list',1,'Your list: [% listname %]'," >+<p>Hi,</p> >+ >+<p>[% borrower.firstname %] [% borrower.surname %] sent you a list from our online catalog called: [% listname %].</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>></p> >+<hr/> >+ >+<ol> >+[% FOREACH biblio IN biblios %] >+ <li> >+ <span> >+ [% biblio.title %] >+ [% IF ( biblio.subtitle ) %] >+ [% FOREACH subtitle IN biblio.subtitle.split(' | ') %] >+ [% subtitle %] >+ [% END %] >+ [% END %] >+ [% biblio.part_number %] [% biblio.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 %] >+ >+ [% SET record = biblio.metadata.record %] >+ <span>Author(s): [% IF ( biblio.author ) %][% biblio.author | $raw %][% END %] >+ [% FOREACH field IN record.fields('7..') %] >+ [% IF ( biblio.author ) %]; [% END %] >+ [% UNLESS ( field.tag < 700 || field.tag > 720 ) %] >+ [% SET separator = Koha.Preference('AuthoritySeparator') %] >+ [% IF ( separator ) %][% separator | $raw %][% ELSE %] [% END %][% field.as_string | $raw %] >+ [% END %] >+ [% UNLESS ( loop.last ) %];[% END %] >+ [% END %] >+ </span> >+ >+ [% 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 %] >+ [% IF BIBLIO_RESULT.item('size') %] >+ , [% BIBLIO_RESULT.item('size') | html %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( biblio.seriestitle ) %] >+ <span> >+ Collection: [% biblio.seriestitle | $raw %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( BIBLIO_RESULT.subject ) %] >+ <span> >+ Subject: [% BIBLIO_RESULT.subject | $raw %] >+ <span><br/> >+ [% END %] >+ >+ <span>Subject: >+ [% IF ( Koha.Preference('marcflavour') eq 'UNIMARC' ) %] >+ [% SET maxtag = 611 %] >+ [% ELSE %] >+ [% SET maxtag = 699 %] >+ [% END %] >+ [% FOREACH field IN record.fields('6..') %] >+ [% IF ( biblio.author ) %]; [% END %] >+ [% UNLESS ( field.tag < 600 || field.tag >= maxtag ) %] >+ [% SET separator = Koha.Preference('AuthoritySeparator') %] >+ [% IF ( separator ) %][% separator | $raw %][% ELSE %] [% END %][% field.as_string | $raw %] >+ [% END %] >+ [% UNLESS ( loop.last ) %];[% END %] >+ [% END %] >+ <span><br/> >+ >+ [% IF ( biblio.copyrightdate ) %] >+ <span> >+ Copyright year: [% biblio.copyrightdate | $raw %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( biblio.notes || biblioitem.notes ) %] >+ <span> >+ Notes: [% biblio.notes | $raw %]<br>[% biblioitem.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 ( record.field('082') ) %] >+ <span> >+ Dewey: [% record.field('082').as_string | $raw %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( biblioitem.cn_source ) %] >+ <span> >+ Classification: [% biblioitem.cn_source | $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.size ) %] >+ <p>Items: >+ <ul> >+ [% FOREACH item IN biblio.items %]<li> >+ [% item.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' ), >+ ('catalogue','CART','','Send cart',1,'Your cart',"<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>></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_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 %] >+ >+ [% SET record = biblio.metadata.record %] >+ <span>Author(s): [% IF ( biblio.author ) %][% biblio.author | $raw %][% END %] >+ [% FOREACH field IN record.fields('7..') %] >+ [% IF ( biblio.author ) %]; [% END %] >+ [% UNLESS ( field.tag < 700 || field.tag > 720 ) %] >+ [% SET separator = Koha.Preference('AuthoritySeparator') %] >+ [% IF ( separator ) %][% separator | $raw %][% ELSE %] [% END %][% field.as_string | $raw %] >+ [% END %] >+ [% UNLESS ( loop.last ) %];[% END %] >+ [% END %] >+ </span> >+ >+ [% 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 %] >+ [% IF BIBLIO_RESULT.item('size') %] >+ , [% BIBLIO_RESULT.item('size') | html %] >+ [% END %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( biblio.seriestitle ) %] >+ <span> >+ Collection: [% biblio.seriestitle | $raw %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( BIBLIO_RESULT.subject ) %] >+ <span> >+ Subject: [% BIBLIO_RESULT.subject | $raw %] >+ <span><br/> >+ [% END %] >+ >+ <span>Subject: >+ [% IF ( Koha.Preference('marcflavour') eq 'UNIMARC' ) %] >+ [% SET maxtag = 611 %] >+ [% ELSE %] >+ [% SET maxtag = 699 %] >+ [% END %] >+ [% FOREACH field IN record.fields('6..') %] >+ [% IF ( biblio.author ) %]; [% END %] >+ [% UNLESS ( field.tag < 600 || field.tag >= maxtag ) %] >+ [% SET separator = Koha.Preference('AuthoritySeparator') %] >+ [% IF ( separator ) %][% separator | $raw %][% ELSE %] [% END %][% field.as_string | $raw %] >+ [% END %] >+ [% UNLESS ( loop.last ) %];[% END %] >+ [% END %] >+ <span><br/> >+ >+ [% IF ( biblio.copyrightdate ) %] >+ <span> >+ Copyright year: [% biblio.copyrightdate | $raw %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( biblio.notes || biblioitem.notes ) %] >+ <span> >+ Notes: [% biblio.notes | $raw %]<br>[% biblioitem.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 ( record.field('082') ) %] >+ <span> >+ Dewey: [% record.field('082').as_string | $raw %] >+ </span><br/> >+ [% END %] >+ >+ [% IF ( biblioitem.cn_source ) %] >+ <span> >+ Classification: [% biblioitem.cn_source | $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.size ) %] >+ <p>Items: >+ <ul> >+ [% FOREACH item IN biblio.items %]<li> >+ [% item.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 22385cac31..6f2ff8b35a 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -1442,3 +1442,10 @@ tables: > - "[% ELSE %]" > - "The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %]" > - "[% END %]" >+ >+ - module: catalogue >+ code: LIST >+ branchcode: "" >+ name: "Send list" >+ is_html: 1 >+ title: "Your list: [% shelfname %]" >diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl >index c97aa450dc..015cc654e4 100755 >--- a/opac/opac-sendshelf.pl >+++ b/opac/opac-sendshelf.pl >@@ -71,7 +71,7 @@ if ( $email ) { > > my $patron = Koha::Patrons->find( $borrowernumber ); > my $borcat = $patron ? $patron->categorycode : q{}; >- >+=pod > my $shelf = Koha::Virtualshelves->find( $shelfid ); > my $contents = $shelf->get_contents; > my $marcflavour = C4::Context->preference('marcflavour'); >@@ -113,60 +113,44 @@ if ( $email ) { > firstname => $patron->firstname, > surname => $patron->surname, > ); >+=cut >+ my $shelf = Koha::Virtualshelves->find( $shelfid ); >+ my $contents = $shelf->get_contents; >+ my @biblionumbers; > >- # 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"; >- } >+ while ( my $content = $contents->next ) { >+ push @biblionumbers, $content->biblionumber; >+ }; > >- my $email_header = ""; >- if ( $template_res =~ /<HEADER>(.*)<END_HEADER>/s ) { >- $email_header = $1; >- $email_header =~ s|\n?(.*)\n?|$1|; >- } >+ my %loops = ( >+ biblio => \@biblionumbers, >+ ); > >- if ( $template_res =~ /<MESSAGE>(.*)<END_MESSAGE>/s ) { >- $body = $1; >- $body =~ s|\n?(.*)\n?|$1|; >- } >+ my %substitute = ( >+ comment => $comment, >+ ); > >- 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', >- ); >- my $library = Koha::Patrons->find( $borrowernumber )->library; >- $email->transport( $library->smtp_server->transport ); >- $email->send_or_die; >- $template->param( SENT => "1" ); >- } >- catch { >- carp "Error sending mail: $_"; >- $template->param( error => 1 ); >- }; >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'catalog', >+ letter_code => 'LIST', >+ branchcode => $branch, >+ lang => $patron->lang, >+ tables => { >+ biblio => $biblio->biblionumber, >+ borrowers => $borrowernumber, >+ }, >+ message_transport_type => 'email', >+ loops => \%loops, >+ substitute => \%substite, >+ ) >+ >+ C4::Letters::EnqueueLetter({ >+ letter => $letter, >+ message_transport_type => 'email', >+ borrowernumber => $patron->borrowernumber, >+ to_address => $email, >+ reply_address => $patron->first_valid_email_address, >+ }); > > $template->param( > shelfid => $shelfid, >diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl >index f15e2c9f64..cd1c506d8d 100755 >--- a/virtualshelves/sendshelf.pl >+++ b/virtualshelves/sendshelf.pl >@@ -67,6 +67,7 @@ if ($to_address) { > > while ( my $content = $contents->next ) { > my $biblionumber = $content->biblionumber; >+ my $biblio = Koha::Biblios->find($biblionumber); > my $dat = GetBiblioData($biblionumber); > my $record = GetMarcBiblio({ > biblionumber => $biblionumber, >@@ -82,6 +83,7 @@ if ($to_address) { > $dat->{'biblionumber'} = $biblionumber; > $dat->{ITEM_RESULTS} = \@items; > $dat->{HASAUTHORS} = $dat->{'author'} || @$marcauthorsarray; >+ $dat->{biblio} = $biblio; > > $iso2709 .= $record->as_usmarc(); > >-- >2.11.0
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