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 (-27 / +44 lines)
Lines 81-113 my $upper_right_y = $pc_template->get_attr('page_height'); Link Here
81
$pdf->Compress(1); # comment this out to debug pdf files, but be sure to uncomment it in production or you may be very sorry...
81
$pdf->Compress(1); # comment this out to debug pdf files, but be sure to uncomment it in production or you may be very sorry...
82
$pdf->Mbox($lower_left_x, $lower_left_y, $upper_right_x, $upper_right_y);
82
$pdf->Mbox($lower_left_x, $lower_left_y, $upper_right_x, $upper_right_y);
83
83
84
my ($llx, $lly) = 0,0;
84
    my ( $llx, $lly ) = 0, 0;
85
(undef, undef, $llx, $lly) = $pc_template->get_label_position($start_card);
85
    ( undef, undef, $llx, $lly ) = $pc_template->get_label_position($start_card);
86
86
87
if (@label_ids) {
87
    # sort the borrower list by the order_by field
88
    my $batch_items = $batch->get_attr('items');
88
    sub sort_borrowerlist {
89
    grep {
89
        my ( $list, $order_by ) = @_;    # $list is a reference to an array of borrower numbers
90
        my $label_id = $_;
90
        my @borrower_list = @$list;
91
        push(@{$items}, grep{$_->{'label_id'} == $label_id;} @{$batch_items});
91
        if ($order_by) {
92
    } @label_ids;
92
            @borrower_list =
93
}
93
                map { $_->borrowernumber }
94
elsif (@borrower_numbers) {
94
                Koha::Patrons->search( { borrowernumber => { -in => \@borrower_list } }, { order_by => [$order_by] } )
95
    grep {
95
                ->as_list;
96
        push(@{$items}, {borrower_number => $_});
96
        }
97
    } @borrower_numbers;
97
        return @borrower_list;
98
}
98
    }
99
elsif ( $patronlist_id  ) {
99
100
    my ($list) = GetPatronLists( { patron_list_id => $patronlist_id } );
100
    if (@label_ids) {
101
    my @borrowerlist = $list->patron_list_patrons()->search_related('borrowernumber')
101
        my $batch_items = $batch->get_attr('items');
102
    ->get_column('borrowernumber')->all();
102
        my @selected_borrower;
103
    @borrowerlist =  map { $_->borrowernumber } Koha::Patrons->search( {borrowernumber => { -in => \@borrowerlist }}, { order_by => [$order_by]} )->as_list if($order_by);
103
        grep {
104
    grep {
104
            my $label_id = $_;
105
        push(@{$items}, {borrower_number => $_});
105
            push( @selected_borrower, grep { $_->{'label_id'} == $label_id; } @{$batch_items} );
106
    } @borrowerlist;
106
        } @label_ids;
107
}
107
        @selected_borrower = map { $_->{borrower_number} } @selected_borrower;
108
else {
108
        @selected_borrower = sort_borrowerlist( \@selected_borrower, $order_by ) if ($order_by);
109
    $items = $batch->get_attr('items');
109
        grep { push( @{$items}, { borrower_number => $_ } ); } @selected_borrower;
110
}
110
    } elsif (@borrower_numbers) {
111
        @borrower_numbers = sort_borrowerlist( \@borrower_numbers, $order_by ) if ($order_by);
112
        grep { push( @{$items}, { borrower_number => $_ } ); } @borrower_numbers;
113
    } elsif ($patronlist_id) {
114
        my ($list) = GetPatronLists( { patron_list_id => $patronlist_id } );
115
        my @borrowerlist =
116
            $list->patron_list_patrons()->search_related('borrowernumber')->get_column('borrowernumber')->all();
117
        @borrowerlist = sort_borrowerlist( \@borrowerlist, $order_by ) if ($order_by);
118
        grep { push( @{$items}, { borrower_number => $_ } ); } @borrowerlist;
119
    } elsif ($batch_id) {
120
        $items = $batch->get_attr('items');
121
        my @borrowerlist = map { $_->{'borrower_number'} } @{$items};
122
        @borrowerlist = sort_borrowerlist( \@borrowerlist, $order_by ) if ($order_by);
123
        @{$items} = map { { borrower_number => $_ } } @borrowerlist;
124
125
    } else {
126
        $items = $batch->get_attr('items');
127
    }
111
128
112
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1);
129
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1);
113
my $layout_back_xml = defined $layout_back ? XMLin($layout_back->get_attr('layout_xml'), ForceArray => 1) : undef;
130
my $layout_back_xml = defined $layout_back ? XMLin($layout_back->get_attr('layout_xml'), ForceArray => 1) : undef;
(-)a/patroncards/print.pl (-16 / +15 lines)
Lines 71-81 if ($op eq 'cud-export') { #FIXME Seems like a GET operation? Link Here
71
                         card_count      => scalar(@label_ids),
71
                         card_count      => scalar(@label_ids),
72
                        });
72
                        });
73
        $template->param(
73
        $template->param(
74
                        batches     => \@batches,
74
            batches  => \@batches,
75
                        referer     => $referer,
75
            referer  => $referer,
76
                        );
76
            order_by => $order_by,
77
    }
77
        );
78
    elsif (@borrower_numbers) {
78
    } elsif (@borrower_numbers) {
79
        my $borrower_number_param = '&amp;borrower_number=';
79
        my $borrower_number_param = '&amp;borrower_number=';
80
        $borrower_number_param .= join ('&amp;borrower_number=',@borrower_numbers);
80
        $borrower_number_param .= join ('&amp;borrower_number=',@borrower_numbers);
81
        push (@batches, {create_script   => ($output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl'),    #FIXME csv not supported, no script?
81
        push (@batches, {create_script   => ($output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl'),    #FIXME csv not supported, no script?
Lines 87-97 if ($op eq 'cud-export') { #FIXME Seems like a GET operation? Link Here
87
                         card_count      => scalar(@borrower_numbers),
87
                         card_count      => scalar(@borrower_numbers),
88
                        });
88
                        });
89
        $template->param(
89
        $template->param(
90
                        batches     => \@batches,
90
            batches  => \@batches,
91
                        referer     => $referer,
91
            referer  => $referer,
92
                        );
92
            order_by => $order_by,
93
    }
93
        );
94
    elsif (@batch_ids) {
94
    } elsif (@batch_ids) {
95
        foreach my $batch_id (@batch_ids) {
95
        foreach my $batch_id (@batch_ids) {
96
           push (@batches, {create_script   => ($output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl'),    #FIXME csv not supported, no script?
96
           push (@batches, {create_script   => ($output_format eq 'pdf' ? 'create-pdf.pl' : 'create-csv.pl'),    #FIXME csv not supported, no script?
97
                            batch_id        => $batch_id,
97
                            batch_id        => $batch_id,
Lines 102-112 if ($op eq 'cud-export') { #FIXME Seems like a GET operation? Link Here
102
                            });
102
                            });
103
        }
103
        }
104
        $template->param(
104
        $template->param(
105
                        batches     => \@batches,
105
            batches  => \@batches,
106
                        referer     => $referer,
106
            referer  => $referer,
107
                        );
107
            order_by => $order_by,
108
    }
108
        );
109
    elsif ($patronlist_id ) {
109
    } elsif ($patronlist_id) {
110
        $template->param(
110
        $template->param(
111
                         patronlist_id   => $patronlist_id,
111
                         patronlist_id   => $patronlist_id,
112
                         template_id     => $template_id,
112
                         template_id     => $template_id,
113
- 

Return to bug 32742