From 8de4753b2d91f701e682ca70cacf7730a5c1b13e Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Wed, 19 Oct 2022 11:42:19 +0000 Subject: [PATCH] Bug 31858: add TT syntax for ACQORDER notices Test Plan: 1) Set your ACQORDER notice content to: [%- USE Price -%] [% bookseller.name %] [% FOREACH order IN orders %] Ordernumber [% order.ordernumber %] ([% order.biblio.title %] - [% order.biblio.biblioitem.publicationyear %]) (quantity: [% order.quantity %]) ($[% order.listprice | $Price %] each). [% END %] Thank you, [% branch.branchname %] 2) Set up a vendor with an email, set contact for email so the "E-mail order" button shows on a basket for that vendor 3) E-mail the basket 4) Check the content is correct Signed-off-by: Kyle M Hall --- C4/Letters.pm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/C4/Letters.pm b/C4/Letters.pm index 3bddc69ecb..fc948c05cc 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -365,6 +365,7 @@ sub SendAlerts { my $dataorders; my $action; my $basketno; + my %loops; if ( $type eq 'claimacquisition') { $strsth = qq{ SELECT aqorders.*,aqbasket.*,biblio.*,biblioitems.* @@ -430,25 +431,24 @@ sub SendAlerts { $sthorders = $dbh->prepare($strsth); $sthorders->execute($basketno); $dataorders = $sthorders->fetchall_arrayref( {} ); + %loops = ( + aqorders => [ map { $_->{ordernumber} } @$dataorders ] + ); } - my $sthbookseller = - $dbh->prepare("select * from aqbooksellers where id=?"); - $sthbookseller->execute( $dataorders->[0]->{booksellerid} ); - my $databookseller = $sthbookseller->fetchrow_hashref; - + my $booksellerid = $dataorders->[0]->{booksellerid}; my $addressee = $type eq 'claimacquisition' || $type eq 'orderacquisition' ? 'acqprimary' : 'serialsprimary'; my $sthcontact = $dbh->prepare("SELECT * FROM aqcontacts WHERE booksellerid=? AND $type=1 ORDER BY $addressee DESC"); - $sthcontact->execute( $dataorders->[0]->{booksellerid} ); + $sthcontact->execute( $booksellerid ); my $datacontact = $sthcontact->fetchrow_hashref; my @email; my @cc; push @email, $datacontact->{email} if ( $datacontact && $datacontact->{email} ); unless (@email) { - warn "Bookseller $dataorders->[0]->{booksellerid} without emails"; + warn "Bookseller $booksellerid without emails"; return { error => "no_email" }; } my $addlcontact; @@ -463,11 +463,12 @@ sub SendAlerts { branchcode => $userenv->{branch}, tables => { 'branches' => $userenv->{branch}, - 'aqbooksellers' => $databookseller, + 'aqbooksellers' => $booksellerid, 'aqcontacts' => $datacontact, 'aqbasket' => $basketno, }, repeat => $dataorders, + loops => \%loops, want_librarian => 1, ) or return { error => "no_letter" }; @@ -1650,6 +1651,12 @@ sub _get_tt_params { plural => 'baskets', pk => 'basketno', }, + aqbooksellers => { + module => 'Koha::Acquisition::Booksellers', + singular => 'bookseller', + plural => 'booksellers', + pk => 'id', + }, biblio => { module => 'Koha::Biblios', singular => 'biblio', -- 2.30.2