Bug 20866: Make ArticleRequests.t pass even if table is not empty
[koha.git] / patroncards / create-pdf.pl
index 9f21a50..3bd28ba 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
-
+use Modern::Perl;
 use CGI qw ( -utf8 );
 use C4::Auth;
 use Graphics::Magick;
 use XML::Simple;
 use POSIX qw(ceil);
 use autouse 'Data::Dumper' => qw(Dumper);
-use Clone qw(clone);
 
 use C4::Debug;
 use C4::Context;
-use autouse 'C4::Members' => qw(GetMember);
 use C4::Creators;
 use C4::Patroncards;
 use Koha::List::Patron;
+use Koha::Patrons;
 use Koha::Patron::Images;
 
 my $cgi = new CGI;
@@ -131,14 +128,12 @@ if ($layout_xml->{'page_side'} eq 'B') { # rearrange items on backside of page t
 CARD_ITEMS:
 foreach my $item (@{$items}) {
     if ($item) {
-
-#my $print_layout_xml = $layout_back_xml;
         my $print_layout_xml = (( ($cardscount % 2  == 1) && ( $layout_back_id ) ) ?
-            clone($layout_back_xml) : clone($layout_xml) );
+            $layout_back_xml : $layout_xml );
 
         $cardscount ++;
         my $borrower_number = $item->{'borrower_number'};
-        my $card_number = GetMember(borrowernumber => $borrower_number)->{'cardnumber'};
+        my $card_number = Koha::Patrons->find( $borrower_number)->cardnumber;
 
 #       Set barcode data
         $print_layout_xml->{'barcode'}->[0]->{'data'} = $card_number if $print_layout_xml->{'barcode'};
@@ -156,6 +151,7 @@ foreach my $item (@{$items}) {
         );
 
         $patron_card->draw_guide_box($pdf) if $print_layout_xml->{'guide_box'};
+        $patron_card->draw_guide_grid($pdf) if $print_layout_xml->{'guide_grid'};
         $patron_card->draw_barcode($pdf) if $print_layout_xml->{'barcode'};
 
 #       Do image foo and place binary image data into layout hash