From 90a8f310f3cf23f817e5e408263c0a44a645d6db Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Mon, 17 Mar 2008 10:43:53 -0400 Subject: [PATCH] Third installment Patron card generation feature Signed-off-by: Joshua Ferraro --- C4/Labels.pm | 22 +- .../prog/en/modules/labels/label-manager.tmpl | 225 +++++++++--------- labels/label-manager.pl | 35 +-- 3 files changed, 149 insertions(+), 133 deletions(-) diff --git a/C4/Labels.pm b/C4/Labels.pm index 1632eb2629..c257c924ff 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -33,7 +33,7 @@ BEGIN { require Exporter; @ISA = qw(Exporter); @EXPORT = qw( - &get_label_options &get_label_items + &get_label_options &GetLabelItems &build_circ_barcode &draw_boundaries &drawbox &GetActiveLabelTemplate &GetAllLabelTemplates &DeleteTemplate @@ -302,8 +302,9 @@ sub get_highest_batch { #FIXME: Needs to be ported to receive $batch_type sub get_batches { + my ($batch_type) = @_; my $dbh = C4::Context->dbh; - my $q = "select batch_id, count(*) as num from labels group by batch_id"; + my $q = "select batch_id, count(*) as num from $batch_type group by batch_id"; my $sth = $dbh->prepare($q); $sth->execute(); my @resultsloop; @@ -733,16 +734,16 @@ sub SetAssociatedProfile { $sth->finish; } -=item get_label_items; +=item GetLabelItems; - $options = get_label_items() + $options = GetLabelItems() Returns an array of references-to-hash, whos keys are the field from the biblio, biblioitems, items and labels tables in the Koha database. =cut #' -sub get_label_items { +sub GetLabelItems { my ($batch_id) = @_; my $dbh = C4::Context->dbh; @@ -808,18 +809,19 @@ sub GetPatronCardItems { my ( $batch_id ) = @_; my @resultsloop; - warn "Received batch id: $batch_id"; my $dbh = C4::Context->dbh; my $query = "SELECT * FROM patroncards WHERE batch_id = ? ORDER BY borrowernumber"; my $sth = $dbh->prepare($query); - warn "Executing query...\n"; $sth->execute($batch_id); - warn "Parsing results...\n"; + my $cardno = 1; while ( my $data = $sth->fetchrow_hashref ) { - warn "for borrowernumber $data->{'borrowernumber'}\n"; my $patron_data = GetMember( $data->{'borrowernumber'} ); $patron_data->{'branchname'} = GetBranchName( $patron_data->{'branchcode'} ); + $patron_data->{'cardno'} = $cardno; + $patron_data->{'cardid'} = $data->{'cardid'}; + $patron_data->{'batch_id'} = $batch_id; push( @resultsloop, $patron_data ); + $cardno++; } $sth->finish; return @resultsloop; @@ -1131,7 +1133,7 @@ sub DrawBarcode { build_circ_barcode( $x_pos, $y_pos, $barcode, $barcodetype, \$item); -$item is the result of a previous call to get_label_items(); +$item is the result of a previous call to GetLabelItems(); =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manager.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manager.tmpl index 8e76163913..24b011f1b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manager.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manager.tmpl @@ -22,118 +22,131 @@ function Plugin(batch_id) { - + + -
- -
-

Label Batches

- - - - - - - - - - - - - - - - -
ID#EditDeletePrint
records - ">Edit - - ">Delete - - - ">Generate PDF for Batch -
-
-
- -
-
+
+
+

Label Batches

+ + + + + + + + + + + + + + + + + +
ID#EditDeletePrint
records&type=labels">Edit&type=labels">Delete&type=labels">Generate PDF for Batch
+
+
+ +
+
-
-
-

No Label Batches Currently Defined

-
-
- -
-
+
+
+

No Label Batches Currently Defined

+
+
+ +
+
- + + +
+
+

Patron Card Batches

+ + + + + + + + + + + + + + + + + +
ID#EditDeletePrint
records&type=patroncards">Edit&type=patroncards">Delete&type=patroncards">Generate PDF for Batch
+
+
+ +
+
- -
- -
- -

Items to be Printed for Batch ( items)

- - - - - - - - - - - - - - - - - - -
Label
Num.
SummaryItem
Type
BarcodeDelete
"> : - : - - &batch_id=">Delete - -
+
+
+

No Patron Card Batches Currently Defined

+
+
+ +
+
+ + - + + +

Items to be Printed for Batch ( items)

+ + + + + + + + + + + + + + + + + + +
Label
Num.
SummaryItem
Type
BarcodeDelete
"> : : &batch_id=&type=labels">Delete
+ +

Patron Cards to be Printed for Batch ( items)

+ + + + + + + + + + + + + + + + + + +
Card
Num.
Patron NameBorrower NumberCard NumberDelete
"> . &batch_id=&type=patroncards">Delete
+ +
diff --git a/labels/label-manager.pl b/labels/label-manager.pl index 5947840f48..af8ce00cf0 100755 --- a/labels/label-manager.pl +++ b/labels/label-manager.pl @@ -41,22 +41,22 @@ my $printingtype = $query->param('printingtype'); my $guidebox = $query->param('guidebox'); my $fontsize = $query->param('fontsize'); my @itemnumber = $query->param('itemnumber'); - +my $batch_type = $query->param('type'); # little block for displaying active layout/template/batch in templates # ---------- -my $batch_id = $query->param('batch_id'); -my $active_layout = get_active_layout(); -my $active_template = GetActiveLabelTemplate(); -my $active_layout_name = $active_layout->{'layoutname'}; -my $active_template_name = $active_template->{'tmpl_code'}; +my $batch_id = $query->param('batch_id'); +my $active_layout = get_active_layout(); +my $active_template = GetActiveLabelTemplate(); +my $active_layout_name = $active_layout->{'layoutname'}; +my $active_template_name = $active_template->{'tmpl_code'}; # ---------- #if (!$batch_id ) { # $batch_id = get_highest_batch(); #} -my $batch_type = "labels"; #FIXME: Hardcoded for testing... +#my $batch_type = "labels"; #FIXME: Hardcoded for testing/development... my @messages; my ($itemnumber) = @itemnumber if (scalar(@itemnumber) == 1); @@ -154,8 +154,8 @@ elsif ( $op eq 'deduplicate' ) { # first lets do a read of the labels table , to get the a list of the # currently entered items to be prinited -my @batches = get_batches(); -my @resultsloop = get_label_items($batch_id); +my @batches = get_batches($batch_type); +my @resultsloop = ($batch_type eq 'labels') ? GetLabelItems($batch_id) : GetPatronCardItems($batch_id); #warn "$batches[0] (id $batch_id)"; #warn Dumper(@resultsloop); @@ -176,14 +176,15 @@ if (scalar @messages) { $template->param(message_loop => \@complex); } $template->param( - batch_id => $batch_id, - batch_count => scalar @resultsloop, - active_layout_name => $active_layout_name, - active_template_name => $active_template_name, - - resultsloop => \@resultsloop, - batches => \@batches, - tmpl_desc => $active_template->{'tmpl_desc'}, + batch_type => $batch_type, + batch_id => $batch_id, + batch_count => scalar @resultsloop, + active_layout_name => $active_layout_name, + active_template_name => $active_template_name, + + resultsloop => \@resultsloop, + batches => \@batches, + tmpl_desc => $active_template->{'tmpl_desc'}, # startrow => $startrow, # sheets => $sheets_needed, -- 2.39.5