X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=patroncards%2Fcreate-pdf.pl;h=961dfbfc055e9cf90abbcb38e97997921102d966;hb=481f620455d40f93a3cb37136ef2c3964497751e;hp=02ba79348a064d38d8711f24280998133561af4f;hpb=d91ebf445fc3ad591b9e1b4282088742c3ed501b;p=koha.git diff --git a/patroncards/create-pdf.pl b/patroncards/create-pdf.pl index 02ba79348a..961dfbfc05 100755 --- a/patroncards/create-pdf.pl +++ b/patroncards/create-pdf.pl @@ -13,14 +13,15 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; use warnings; use CGI; +use C4::Auth; use Graphics::Magick; use XML::Simple; use POSIX qw(ceil); @@ -34,6 +35,16 @@ use C4::Patroncards 1.000000; my $cgi = new CGI; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ + template_name => "labels/label-home.tt", + query => $cgi, + type => "intranet", + authnotrequired => 0, + flagsrequired => { tools => 'label_creator' }, + debug => 1, + }); + + my $batch_id = $cgi->param('batch_id') if $cgi->param('batch_id'); my $template_id = $cgi->param('template_id') || undef; my $layout_id = $cgi->param('layout_id') || undef; @@ -41,7 +52,8 @@ my $start_label = $cgi->param('start_label') || 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 $items = undef; # items = cards +my $items = undef; # items = cards +my $new_page = 0; my $pdf_file = (@label_ids || @borrower_numbers ? "card_single_" . scalar(@label_ids || @borrower_numbers) : "card_batch_$batch_id"); print $cgi->header( -type => 'application/pdf', @@ -101,7 +113,6 @@ if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page t CARD_ITEMS: foreach my $item (@{$items}) { - my $new_page = 0; #FIXME: this needs to be implimented or removed if ($item) { my $borrower_number = $item->{'borrower_number'}; my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'}; @@ -141,13 +152,13 @@ foreach my $item (@{$items}) { elsif ($images->{$_}->{'data_source'}->[0]->{'image_source'} eq 'creator_images') { my $dbh = C4::Context->dbh(); $dbh->{LongReadLen} = 1000000; # allows us to read approx 1MB - $image_data = $dbh->selectrow_hashref("SELECT imagefile FROM creator_images WHERE image_name = \'$$layout_xml{'images'}{$_}{'data_source'}{'image_name'}\'"); + $image_data = $dbh->selectrow_hashref("SELECT imagefile FROM creator_images WHERE image_name = \'$images->{$_}->{'data_source'}->[0]->{'image_name'}\'"); warn sprintf('Database returned the following error: %s.', $error) if $error; - warn sprintf('Image does not exists in db table %s.', $$layout_xml{'images'}{$_}{'data_source'}{'image_source'}) if !$image_data; + warn sprintf('Image does not exists in db table %s.', $images->{$_}->{'data_source'}->[0]->{'image_name'}) if !$image_data; next PROCESS_IMAGES if !$image_data; } else { - warn sprintf('No retrieval method for image source %s.', $$layout_xml{'images'}{$_}{'data_source'}{'image_source'}); + warn sprintf('No retrieval method for image source %s.', $images->{$_}->{'data_source'}->[0]->{'image_source'}); next PROCESS_IMAGES; } } @@ -193,11 +204,11 @@ foreach my $item (@{$items}) { $patron_card->draw_text($pdf); } ($llx, $lly, $new_page) = $template->get_next_label_pos(); - #$pdf->Page() if $new_page; + $pdf->Page() if $new_page; } $pdf->End(); # FIXME: Possibly do a redirect here if there were error encountered during PDF creation. -exit 0; +1;