From 5b35435d35132cea0c0680145998fe7546b8e01f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Sun, 3 May 2015 23:26:11 +0200 Subject: [PATCH] Bug 14131 - Patroncard: Add possibility to print from patron lists This patch adds the possibility to print patron cards from patron lists. To test: - Go to Home > Tools > Patron card creator - Prepare a patron card and create some cards using the batch functionality - Apply patch - Prepare a patron list e.g. from patron search - Go to Home > Tools > Patron card creator > Manage batches - Below the list of batches you have a dropdown to select a patron list - Select your list and hit "Export from patron list" - Select template and layout as you would do with batches - Hit "Export" - Download PDF Modified patch to work with Bug 14676 changes. Functionality unchanged. Signed-off-by: Nick Clemens Signed-off-by: Liz (Amended to make it apply on current master) Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- .../prog/en/modules/patroncards/manage.tt | 36 ++++++++++++++++++- .../prog/en/modules/patroncards/print.tt | 7 ++++ patroncards/create-pdf.pl | 10 ++++++ patroncards/manage.pl | 3 ++ patroncards/print.pl | 11 ++++++ 5 files changed, 66 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt index 6f778880d3..331eede4bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/manage.tt @@ -88,7 +88,17 @@ } return GB_showCenter(_("Export patron cards"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 400, 800); }; - function selected_layouts(op) { + + function XportPatronlist() { + if ( patron_list_id.value.length < 1 ) { + alert(_("Please select a patron list.")); + return; // no patron list selected + } + getstr = 'patronlist_id='+patron_list_id.value; + return GB_showCenter(_("Export patron cards from list"), "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800); + }; + + function selected_layout(op) { if (document.layouts.action.length) { var selected = new Array(); for (i=0;i @@ -204,7 +218,27 @@
[% IF ( print ) %][% END %]
+ [% IF patron_lists %] +
+ Or use a patron list +
    +
  1. + + +
  2. +
+
+
+ +
+ [% END %] + [% ELSE %]

There are no [% PROCESS translate_card_element element=card_element_title %] currently available.

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt index c5a28571b2..3753b20c0d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt @@ -41,12 +41,18 @@ + [% ELSIF ( patronlist_id && template_id && layout_id ) %] +

Click on the link to download the patron cards from the patron list.

+

+ label_patronlist_[% patronlist_id %].pdf +

[% ELSE %]

[% IF ( label_ids ) %] [% IF ( card_count == 1 ) %]Exporting [% card_count %] patron card[% ELSE %]Exporting [% card_count %] patron cards[% END %] [% ELSIF ( borrower_numbers ) %] [% IF ( borrower_count == 1 ) %]Exporting [% borrower_count %] patron card[% ELSE %]Exporting [% borrower_count %] patron cards[% END %] + [% ELSIF ( patronlist_id ) %] Exporting from patron list [% ELSE %] [% IF ( multi_batch_count == 1 ) %][% multi_batch_count %] batch to export[% ELSE %][% multi_batch_count %] batches to export[% END %] [% END %] @@ -63,6 +69,7 @@ [% FOREACH borrower_number IN borrower_numbers %] [% END %] + [% IF (patronlist_id) %] [% END %]
  1. diff --git a/patroncards/create-pdf.pl b/patroncards/create-pdf.pl index 30440a44b6..d52c0375b5 100755 --- a/patroncards/create-pdf.pl +++ b/patroncards/create-pdf.pl @@ -32,6 +32,7 @@ use C4::Context; use autouse 'C4::Members' => qw(GetPatronImage GetMember); use C4::Creators; use C4::Patroncards; +use Koha::List::Patron; my $cgi = new CGI; @@ -51,6 +52,7 @@ my $layout_id = $cgi->param('layout_id') || undef; my $start_card = $cgi->param('start_card') || 1; my @label_ids = $cgi->param('label_id') if $cgi->param('label_id'); my @borrower_numbers = $cgi->param('borrower_number') if $cgi->param('borrower_number'); +my $patronlist_id = $cgi->param('patronlist_id'); my $items = undef; # items = cards my $new_page = 0; @@ -92,6 +94,14 @@ elsif (@borrower_numbers) { push(@{$items}, {borrower_number => $_}); } @borrower_numbers; } +elsif ( $patronlist_id ) { + my ($list) = GetPatronLists( { patron_list_id => $patronlist_id } ); + my @borrowerlist = $list->patron_list_patrons()->search_related('borrowernumber') + ->get_column('borrowernumber')->all(); + grep { + push(@{$items}, {borrower_number => $_}); + } @borrowerlist; +} else { $items = $batch->get_attr('items'); } diff --git a/patroncards/manage.pl b/patroncards/manage.pl index bd420b9642..da729b7a16 100755 --- a/patroncards/manage.pl +++ b/patroncards/manage.pl @@ -30,6 +30,7 @@ use C4::Output qw(output_html_with_http_headers); use C4::Creators; use C4::Patroncards; use C4::Labels; +use Koha::List::Patron; my $cgi = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -107,6 +108,8 @@ else { # trap unsupported operations here my $table = html_table($display_columns->{$card_element}, $db_rows); $template->param(print => 1) if ($card_element eq 'batch'); +$template->param( patron_lists => [ GetPatronLists() ] ) if ($card_element eq 'batch'); + $template->param( error => $errstr, ); diff --git a/patroncards/print.pl b/patroncards/print.pl index 6ba52263d8..2c674a4c5a 100755 --- a/patroncards/print.pl +++ b/patroncards/print.pl @@ -43,6 +43,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $op = $cgi->param('op') || 'none'; my @label_ids = $cgi->param('label_id') if $cgi->param('label_id'); # this will handle individual card printing; we use label_id to maintain consistency with the column names in the creator_batches table my @batch_ids = $cgi->param('batch_id') if $cgi->param('batch_id'); +my $patronlist_id = $cgi->param('patronlist_id') || undef; my $layout_id = $cgi->param('layout_id') || undef; my $template_id = $cgi->param('template_id') || undef; my $start_card = $cgi->param('start_card') || 1; @@ -104,6 +105,15 @@ if ($op eq 'export') { referer => $referer, ); } + elsif ($patronlist_id ) { + $template->param( + patronlist_id => $patronlist_id, + template_id => $template_id, + layout_id => $layout_id, + start_card => $start_card, + referer => $referer, + ); + } } elsif ($op eq 'none') { # setup select menus for selecting layout and template for this run... @@ -119,6 +129,7 @@ elsif ($op eq 'none') { batch_ids => \@batch_ids, label_ids => \@label_ids, borrower_numbers => \@borrower_numbers, + patronlist_id => $patronlist_id, templates => $templates, layouts => $layouts, output_formats => $output_formats, -- 2.39.5