View | Details | Raw Unified | Return to bug 32742
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/print.tt (-15 / +14 lines)
Lines 23-39 Link Here
23
                        [% IF ( batche.label_ids ) %]
23
                        [% IF ( batche.label_ids ) %]
24
                        <legend>[% batche.card_count | html %] Single patron cards</legend>
24
                        <legend>[% batche.card_count | html %] Single patron cards</legend>
25
                        <p>
25
                        <p>
26
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.label_ids | html %]">label_single_[% batche.card_count | html %].pdf</a>
26
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.label_ids | html %]&amp;order_by=[% order_by | html %]">label_single_[% batche.card_count | html %].pdf</a>
27
                        </p>
27
                        </p>
28
                        [% ELSIF ( batche.borrower_numbers ) %]
28
                        [% ELSIF ( batche.borrower_numbers ) %]
29
                        <legend>[% batche.card_count | html %] Single patron cards</legend>
29
                        <legend>[% batche.card_count | html %] Single patron cards</legend>
30
                        <p>
30
                        <p>
31
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.borrower_numbers | html %]">label_single_[% batche.card_count | html %].pdf</a>
31
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/[% batche.create_script | html %]?template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %][% batche.borrower_numbers | html %]&amp;order_by=[% order_by | html %]">label_single_[% batche.card_count | html %].pdf</a>
32
                        </p>
32
                        </p>
33
                        [% ELSE %]
33
                        [% ELSE %]
34
                        <legend>Card batch number [% batche.batch_id | html %]</legend>
34
                        <legend>Card batch number [% batche.batch_id | html %]</legend>
35
                        <p>
35
                        <p>
36
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %]">label_batch_[% batche.batch_id | html %].pdf</a>
36
                                <a class="document pdf" href="/cgi-bin/koha/patroncards/create-pdf.pl?batch_id=[% batche.batch_id | html %]&amp;template_id=[% batche.template_id | html %]&amp;layout_id=[% batche.layout_id | html %]&amp;layout_back_id=[% batche.layout_back_id | html %]&amp;start_card=[% batche.start_card | html %]&amp;order_by=[% order_by | html %]">label_batch_[% batche.batch_id | html %].pdf</a>
37
                        </p>
37
                        </p>
38
                        [% END %]
38
                        [% END %]
39
                    [% END %]
39
                    [% END %]
Lines 77-93 Link Here
77
                [% IF (patronlist_id) %] <input type="hidden" name="patronlist_id" value="[% patronlist_id | html %]" /> [% END %]
77
                [% IF (patronlist_id) %] <input type="hidden" name="patronlist_id" value="[% patronlist_id | html %]" /> [% END %]
78
                <fieldset class="rows">
78
                <fieldset class="rows">
79
                    <ol>
79
                    <ol>
80
                    [% IF (patronlist_id) %]
81
                        <li>
82
                            <label style="width:9em" for="order_by">Order by: </label>
83
                            <select name="order_by" id="order_by">
84
                                <option value=""></option>
85
                                <option value="cardnumber">Card number</option>
86
                                <option value="firstname">First name</option>
87
                                <option value="surname">Surname</option>
88
                            </select>
89
                        </li>
90
                    [% END %]
91
                        <li>
80
                        <li>
92
                            <label style="width:9em" for="template_id">Select a template to be applied: </label>
81
                            <label style="width:9em" for="template_id">Select a template to be applied: </label>
93
                            <select name="template_id" id="template_id">
82
                            <select name="template_id" id="template_id">
Lines 114-120 Link Here
114
                            </select>
103
                            </select>
115
                            <span class="hint">Used for duplex printers (needs a '1 up template')</span>
104
                            <span class="hint">Used for duplex printers (needs a '1 up template')</span>
116
                        </li>
105
                        </li>
117
106
                        [% IF ( card_count != 1 ) %]
107
                        <li>
108
                            <label style="width:9em" for="order_by">Order by: </label>
109
                            <select name="order_by" id="order_by">
110
                                <option value=""></option>
111
                                <option value="cardnumber">Card number</option>
112
                                <option value="firstname">First name</option>
113
                                <option value="surname">Surname</option>
114
                            </select>
115
                        </li>
116
                        [% END %]
118
                        <li>
117
                        <li>
119
                            <label style="width:9em" for="start_card">Enter starting card position: </label>
118
                            <label style="width:9em" for="start_card">Enter starting card position: </label>
120
                            <input type="text" size="5" id="start_card" name="start_card" class="focus" title="Starting card number" value="1" />
119
                            <input type="text" size="5" id="start_card" name="start_card" class="focus" title="Starting card number" value="1" />
(-)a/patroncards/create-pdf.pl (-6 / +26 lines)
Lines 91-114 eval { Link Here
91
    my ( $llx, $lly ) = 0, 0;
91
    my ( $llx, $lly ) = 0, 0;
92
    ( undef, undef, $llx, $lly ) = $pc_template->get_label_position($start_card);
92
    ( undef, undef, $llx, $lly ) = $pc_template->get_label_position($start_card);
93
93
94
    # sort the borrower list by the order_by field
95
    sub sort_borrowerlist {
96
        my ( $list, $order_by ) = @_;    # $list is a reference to an array of borrower numbers
97
        my @borrower_list = @$list;
98
        if ($order_by) {
99
            @borrower_list =
100
                map { $_->borrowernumber }
101
                Koha::Patrons->search( { borrowernumber => { -in => \@borrower_list } }, { order_by => [$order_by] } )
102
                ->as_list;
103
        }
104
        return @borrower_list;
105
    }
106
94
    if (@label_ids) {
107
    if (@label_ids) {
95
        my $batch_items = $batch->get_attr('items');
108
        my $batch_items = $batch->get_attr('items');
109
        my @selected_borrower;
96
        grep {
110
        grep {
97
            my $label_id = $_;
111
            my $label_id = $_;
98
            push( @{$items}, grep { $_->{'label_id'} == $label_id; } @{$batch_items} );
112
            push( @selected_borrower, grep { $_->{'label_id'} == $label_id; } @{$batch_items} );
99
        } @label_ids;
113
        } @label_ids;
114
        @selected_borrower = map { $_->{borrower_number} } @selected_borrower;
115
        @selected_borrower = sort_borrowerlist( \@selected_borrower, $order_by ) if ($order_by);
116
        grep { push( @{$items}, { borrower_number => $_ } ); } @selected_borrower;
100
    } elsif (@borrower_numbers) {
117
    } elsif (@borrower_numbers) {
118
        @borrower_numbers = sort_borrowerlist( \@borrower_numbers, $order_by ) if ($order_by);
101
        grep { push( @{$items}, { borrower_number => $_ } ); } @borrower_numbers;
119
        grep { push( @{$items}, { borrower_number => $_ } ); } @borrower_numbers;
102
    } elsif ($patronlist_id) {
120
    } elsif ($patronlist_id) {
103
        my ($list) = GetPatronLists( { patron_list_id => $patronlist_id } );
121
        my ($list) = GetPatronLists( { patron_list_id => $patronlist_id } );
104
        my @borrowerlist =
122
        my @borrowerlist =
105
            $list->patron_list_patrons()->search_related('borrowernumber')->get_column('borrowernumber')->all();
123
            $list->patron_list_patrons()->search_related('borrowernumber')->get_column('borrowernumber')->all();
106
        @borrowerlist =
124
        @borrowerlist = sort_borrowerlist( \@borrowerlist, $order_by ) if ($order_by);
107
            map { $_->borrowernumber }
108
            Koha::Patrons->search( { borrowernumber => { -in => \@borrowerlist } }, { order_by => [$order_by] } )
109
            ->as_list
110
            if ($order_by);
111
        grep { push( @{$items}, { borrower_number => $_ } ); } @borrowerlist;
125
        grep { push( @{$items}, { borrower_number => $_ } ); } @borrowerlist;
126
    } elsif ($batch_id) {
127
        $items = $batch->get_attr('items');
128
        my @borrowerlist = map { $_->{'borrower_number'} } @{$items};
129
        @borrowerlist = sort_borrowerlist( \@borrowerlist, $order_by ) if ($order_by);
130
        @{$items} = map { { borrower_number => $_ } } @borrowerlist;
131
112
    } else {
132
    } else {
113
        $items = $batch->get_attr('items');
133
        $items = $batch->get_attr('items');
114
    }
134
    }
(-)a/patroncards/print.pl (-7 / +9 lines)
Lines 77-84 if ( $op eq 'cud-export' ) { #FIXME Seems like a GET operation? Link Here
77
            }
77
            }
78
        );
78
        );
79
        $template->param(
79
        $template->param(
80
            batches => \@batches,
80
            batches  => \@batches,
81
            referer => $referer,
81
            referer  => $referer,
82
            order_by => $order_by,
82
        );
83
        );
83
    } elsif (@borrower_numbers) {
84
    } elsif (@borrower_numbers) {
84
        my $borrower_number_param = '&amp;borrower_number=';
85
        my $borrower_number_param = '&amp;borrower_number=';
Lines 96-103 if ( $op eq 'cud-export' ) { #FIXME Seems like a GET operation? Link Here
96
            }
97
            }
97
        );
98
        );
98
        $template->param(
99
        $template->param(
99
            batches => \@batches,
100
            batches  => \@batches,
100
            referer => $referer,
101
            referer  => $referer,
102
            order_by => $order_by,
101
        );
103
        );
102
    } elsif (@batch_ids) {
104
    } elsif (@batch_ids) {
103
        foreach my $batch_id (@batch_ids) {
105
        foreach my $batch_id (@batch_ids) {
Lines 114-121 if ( $op eq 'cud-export' ) { #FIXME Seems like a GET operation? Link Here
114
            );
116
            );
115
        }
117
        }
116
        $template->param(
118
        $template->param(
117
            batches => \@batches,
119
            batches  => \@batches,
118
            referer => $referer,
120
            referer  => $referer,
121
            order_by => $order_by,
119
        );
122
        );
120
    } elsif ($patronlist_id) {
123
    } elsif ($patronlist_id) {
121
        $template->param(
124
        $template->param(
122
- 

Return to bug 32742