Bugzilla – Attachment 125823 Details for
Bug 20119
Ability to print claims for late orders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20119 - Ability to print claims for late orders
Bug-20119---Ability-to-print-claims-for-late-order.patch (text/plain), 4.79 KB, created by
Alex Arnaud
on 2021-10-06 14:48:02 UTC
(
hide
)
Description:
Bug 20119 - Ability to print claims for late orders
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2021-10-06 14:48:02 UTC
Size:
4.79 KB
patch
obsolete
>From 5ff1475a6addb68f6d493631f0e8f7f336198a19 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Thu, 25 Jan 2018 10:14:03 +0000 >Subject: [PATCH] Bug 20119 - Ability to print claims for late orders >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan: > > - create a notice: module: claimacquisition, code: ACQCLAIM: transport: > print > - create at least a bookseller, basket and orders, > - close the basket and change the closedate to make orders late, > - go to cgi-bin/koha/acqui/lateorders.pl, > - select one or more order(s) to claim and click on "Print claim", > - check the pdf downloaded > >[2018-03-15] Rebased-by: Alex Arnaud <alex.arnaud@biblibre.com> > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > C4/Letters.pm | 66 ++++++++++++++++++++++ > acqui/lateorders.pl | 12 ++++ > .../prog/en/modules/acqui/lateorders.tt | 11 ++++ > 3 files changed, 89 insertions(+) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index a02c0d5..bb6c98d 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -583,6 +583,72 @@ sub SendAlerts { > return 1; > } > >+=head2 PrintClaimOrderNotice >+ >+Returns a 'claimorders' notice for given order ids and letter code as PDF >+ >+ my $pdf = PrintClaimOrderNotice(\@orderids, $letter_code); >+ >+ print $cgi->header('application/pdf'); >+ print $pdf; >+ >+=cut >+ >+sub PrintClaimOrderNotice { >+ my ($orderids, $letter_code) = @_; >+ >+ return unless ref $orderids eq 'ARRAY'; >+ return unless @$orderids > 0; >+ return unless $letter_code; >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $orderids_str = join(',', ('?') x @$orderids); >+ my $orders = $dbh->selectall_arrayref(qq{ >+ SELECT aqorders.*, aqbasket.*, biblio.* >+ FROM aqorders >+ LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber >+ LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno >+ WHERE aqorders.ordernumber IN ($orderids_str) >+ }, {Slice => {}}, @$orderids); >+ >+ return unless @$orders; >+ >+ my $booksellerid = $orders->[0]->{aqbooksellerid}; >+ >+ my $schema = Koha::Database->new->schema; >+ my $bookseller = >+ $schema->resultset('Aqbookseller')->find( { id => $booksellerid }, >+ { result_class => 'DBIx::Class::ResultClass::HashRefInflator' } ); >+ >+ my $userenv = C4::Context->userenv; >+ my $letter = GetPreparedLetter( >+ module => 'claimacquisition', >+ letter_code => $letter_code, >+ branchcode => $userenv->{branch}, >+ message_transport_type => 'print', >+ tables => { >+ 'branches' => $userenv->{branch}, >+ 'aqbooksellers' => $bookseller, >+ }, >+ want_librarian => 1, >+ repeat => $orders, >+ ) or return; >+ >+ my $content = $letter->{content}; >+ if ($letter->{is_html}) { >+ $content = _wrap_html($content, $letter->{title}); >+ } >+ >+ my $output = ''; >+ my $pdf = PDF::FromHTML->new(encoding => 'utf-8'); >+ $pdf->load_file(\$content); >+ $pdf->convert(); >+ $pdf->write_file(\$output); >+ >+ return $output; >+} >+ > =head2 GetPreparedLetter( %params ) > > %params hash: >diff --git a/acqui/lateorders.pl b/acqui/lateorders.pl >index 5999ab0..a5d0db1 100755 >--- a/acqui/lateorders.pl >+++ b/acqui/lateorders.pl >@@ -119,6 +119,18 @@ if ($op and $op eq "send_alert"){ > } > } > >+if ($op and $op eq "print_alert") { >+ my @orderids = $input->multi_param('ordernumber'); >+ >+ my $pdf = C4::Letters::PrintClaimOrderNotice(\@orderids, 'ACQCLAIM'); >+ print $input->header( >+ -type => 'application/pdf', >+ -attachment => 'claims.pdf', >+ ); >+ print $pdf; >+ exit; >+} >+ > my @lateorders = Koha::Acquisition::Orders->filter_by_lates( > { > delay => $delay, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >index c4847c1..186fd34 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt >@@ -213,6 +213,7 @@ > </div> > > <input type="submit" class="btn btn-default" value="Claim order" /> >+ <input type="button" value="Print claim" id="print-claim" /> > </fieldset> > </form> > [% ELSE %]<p>There are no late orders.</p> >@@ -369,6 +370,16 @@ > $("#ordernumber").val(""); > $("#type").val(""); > }); >+ >+ $('#print-claim').on('click', function(e) { >+ e.preventDefault(); >+ var form = $(this).parents('form') >+ var op = form.find('input[name="op"]'); >+ >+ op.val('print_alert'); >+ form.submit(); >+ op.val('send_alert'); >+ }); > }); > </script> > [% END %] >-- >2.7.4
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 20119
:
71106
|
71107
|
71150
|
71151
|
72928
|
72929
|
72944
|
72945
| 125823 |
125824
|
125825