|
Lines 26-31
use Graphics::Magick;
Link Here
|
| 26 |
use XML::Simple; |
26 |
use XML::Simple; |
| 27 |
use POSIX qw(ceil); |
27 |
use POSIX qw(ceil); |
| 28 |
use autouse 'Data::Dumper' => qw(Dumper); |
28 |
use autouse 'Data::Dumper' => qw(Dumper); |
|
|
29 |
use Clone qw(clone); |
| 29 |
|
30 |
|
| 30 |
use C4::Debug; |
31 |
use C4::Debug; |
| 31 |
use C4::Context; |
32 |
use C4::Context; |
|
Lines 48-53
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
Link Here
|
| 48 |
my $batch_id = $cgi->param('batch_id') if $cgi->param('batch_id'); |
49 |
my $batch_id = $cgi->param('batch_id') if $cgi->param('batch_id'); |
| 49 |
my $template_id = $cgi->param('template_id') || undef; |
50 |
my $template_id = $cgi->param('template_id') || undef; |
| 50 |
my $layout_id = $cgi->param('layout_id') || undef; |
51 |
my $layout_id = $cgi->param('layout_id') || undef; |
|
|
52 |
my $layout_back_id = $cgi->param('layout_back_id') || undef; |
| 51 |
my $start_card = $cgi->param('start_card') || 1; |
53 |
my $start_card = $cgi->param('start_card') || 1; |
| 52 |
my @label_ids = $cgi->multi_param('label_id') if $cgi->param('label_id'); |
54 |
my @label_ids = $cgi->multi_param('label_id') if $cgi->param('label_id'); |
| 53 |
my @borrower_numbers = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number'); |
55 |
my @borrower_numbers = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number'); |
|
Lines 70-75
$pdf = C4::Creators::PDF->new(InitVars => 0);
Link Here
|
| 70 |
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id); |
72 |
my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id); |
| 71 |
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1); |
73 |
my $pc_template = C4::Patroncards::Template->retrieve(template_id => $template_id, profile_id => 1); |
| 72 |
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id); |
74 |
my $layout = C4::Patroncards::Layout->retrieve(layout_id => $layout_id); |
|
|
75 |
my $layout_back = C4::Patroncards::Layout->retrieve(layout_id => $layout_back_id) if ( $layout_back_id ); |
| 73 |
|
76 |
|
| 74 |
$| = 1; |
77 |
$| = 1; |
| 75 |
|
78 |
|
|
Lines 110-115
else {
Link Here
|
| 110 |
} |
113 |
} |
| 111 |
|
114 |
|
| 112 |
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1); |
115 |
my $layout_xml = XMLin($layout->get_attr('layout_xml'), ForceArray => 1); |
|
|
116 |
my $layout_back_xml = XMLin($layout_back->get_attr('layout_xml'), ForceArray => 1) if ( defined $layout_back ); |
| 113 |
|
117 |
|
| 114 |
if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page to swap columns |
118 |
if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page to swap columns |
| 115 |
my $even = 1; |
119 |
my $even = 1; |
|
Lines 127-138
if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page t
Link Here
|
| 127 |
CARD_ITEMS: |
131 |
CARD_ITEMS: |
| 128 |
foreach my $item (@{$items}) { |
132 |
foreach my $item (@{$items}) { |
| 129 |
if ($item) { |
133 |
if ($item) { |
|
|
134 |
|
| 135 |
#my $print_layout_xml = $layout_back_xml; |
| 136 |
my $print_layout_xml = (( ($cardscount % 2 == 1) && ( $layout_back_id ) ) ? |
| 137 |
clone($layout_back_xml) : clone($layout_xml) ); |
| 138 |
|
| 130 |
$cardscount ++; |
139 |
$cardscount ++; |
| 131 |
my $borrower_number = $item->{'borrower_number'}; |
140 |
my $borrower_number = $item->{'borrower_number'}; |
| 132 |
my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'}; |
141 |
my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'}; |
| 133 |
|
142 |
|
| 134 |
# Set barcode data |
143 |
# Set barcode data |
| 135 |
$layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $layout_xml->{'barcode'}; |
144 |
$print_layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $print_layout_xml->{'barcode'}; |
| 136 |
|
145 |
|
| 137 |
# Create a new patroncard object |
146 |
# Create a new patroncard object |
| 138 |
my $patron_card = C4::Patroncards::Patroncard->new( |
147 |
my $patron_card = C4::Patroncards::Patroncard->new( |
|
Lines 142-158
foreach my $item (@{$items}) {
Link Here
|
| 142 |
lly => $lly, |
151 |
lly => $lly, |
| 143 |
height => $pc_template->get_attr('label_height'), # of the card |
152 |
height => $pc_template->get_attr('label_height'), # of the card |
| 144 |
width => $pc_template->get_attr('label_width'), |
153 |
width => $pc_template->get_attr('label_width'), |
| 145 |
layout => $layout_xml, |
154 |
layout => $print_layout_xml, |
| 146 |
text_wrap_cols => 30, #FIXME: hardcoded, |
155 |
text_wrap_cols => 30, #FIXME: hardcoded, |
| 147 |
); |
156 |
); |
| 148 |
|
157 |
|
| 149 |
$patron_card->draw_guide_box($pdf) if $layout_xml->{'guide_box'}; |
158 |
$patron_card->draw_guide_box($pdf) if $print_layout_xml->{'guide_box'}; |
| 150 |
$patron_card->draw_barcode($pdf) if $layout_xml->{'barcode'}; |
159 |
$patron_card->draw_barcode($pdf) if $print_layout_xml->{'barcode'}; |
| 151 |
|
160 |
|
| 152 |
# Do image foo and place binary image data into layout hash |
161 |
# Do image foo and place binary image data into layout hash |
| 153 |
my $image_data = {}; |
162 |
my $image_data = {}; |
| 154 |
my $error = undef; |
163 |
my $error = undef; |
| 155 |
my $images = $layout_xml->{'images'}; |
164 |
my $images = $print_layout_xml->{'images'}; |
| 156 |
PROCESS_IMAGES: |
165 |
PROCESS_IMAGES: |
| 157 |
foreach (keys %{$images}) { |
166 |
foreach (keys %{$images}) { |
| 158 |
if (grep{m/source/} keys(%{$images->{$_}->{'data_source'}->[0]})) { |
167 |
if (grep{m/source/} keys(%{$images->{$_}->{'data_source'}->[0]})) { |
|
Lines 232-237
foreach my $item (@{$items}) {
Link Here
|
| 232 |
$patron_card->draw_text($pdf); |
241 |
$patron_card->draw_text($pdf); |
| 233 |
} |
242 |
} |
| 234 |
($llx, $lly, $new_page) = $pc_template->get_next_label_pos(); |
243 |
($llx, $lly, $new_page) = $pc_template->get_next_label_pos(); |
|
|
244 |
|
| 245 |
if ( ($cardscount % 2 == 1) && ( $layout_back_id ) ) { |
| 246 |
$pdf->Page(); |
| 247 |
redo; # Use same patron data again for backside in card printer |
| 248 |
} |
| 249 |
|
| 235 |
$pdf->Page() if $new_page; |
250 |
$pdf->Page() if $new_page; |
| 236 |
} |
251 |
} |
| 237 |
# No errors occurred within eval, we can issue the pdf |
252 |
# No errors occurred within eval, we can issue the pdf |