diff --git a/C4/Labels.pm b/C4/Labels.pm index 62fc873470..ae3e169395 100644 --- a/C4/Labels.pm +++ b/C4/Labels.pm @@ -312,11 +312,10 @@ sub get_highest_batch { } -#FIXME: Needs to be ported to receive $batch_type sub get_batches { - my ($batch_type) = @_; + my ( $batch_type ) = @_; my $dbh = C4::Context->dbh; - my $q = "select batch_id, count(*) as num from $batch_type 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; @@ -841,39 +840,41 @@ sub GetPatronCardItems { } sub deduplicate_batch { - my $batch_id = shift or return undef; + my ( $batch_id, $batch_type ) = @_; my $query = " SELECT DISTINCT - batch_id,itemnumber, - count(labelid) as count - FROM labels - WHERE batch_id = ? - GROUP BY itemnumber,batch_id - HAVING count > 1 + batch_id," . (($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber') . ", + count(". (($batch_type eq 'labels') ? 'labelid' : 'cardid') . ") as count + FROM $batch_type + WHERE batch_id = ? + GROUP BY " . (($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber') . ",batch_id + HAVING count > 1 ORDER BY batch_id, - count DESC "; + count DESC "; my $sth = C4::Context->dbh->prepare($query); $sth->execute($batch_id); - $sth->rows or return undef; + warn $sth->errstr if $sth->errstr; + $sth->rows or return undef, $sth->errstr; - my $del_query = qq( + my $del_query = " DELETE - FROM labels + FROM $batch_type WHERE batch_id = ? - AND itemnumber = ? + AND " . (($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber') . " = ? ORDER BY timestamp ASC - ); + "; my $killed = 0; while (my $data = $sth->fetchrow_hashref()) { - my $itemnumber = $data->{itemnumber} or next; + my $itemnumber = $data->{(($batch_type eq 'labels') ? 'itemnumber' : 'borrowernumber')} or next; my $limit = $data->{count} - 1 or next; my $sth2 = C4::Context->dbh->prepare("$del_query LIMIT $limit"); # die sprintf "$del_query LIMIT %s\n (%s, %s)", $limit, $batch_id, $itemnumber; # $sth2->execute($batch_id, C4::Context->dbh->quote($data->{itemnumber}), $data->{count} - 1) $sth2->execute($batch_id, $itemnumber) and $killed += ($data->{count} - 1); + warn $sth2->errstr if $sth2->errstr; } - return $killed; + return $killed, undef; } sub DrawSpineText { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc index 8b475ceaaf..b4b86ca287 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/label-status.inc @@ -3,6 +3,6 @@ - +
Layout:No Layout Specified: Select a Label Layout
Template: No Template Specified: Select a Label Template
Batch: No Batch Specified: Select items to print
Batch: ">Create a new batch
- \ No newline at end of file + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc index 9607ab49d0..819e2e9c6a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-menu.inc @@ -2,6 +2,6 @@
  • Layouts
  • Templates
  • Printer Profiles
  • -
  • Create or Print Label Batches
  • -
  • Create or Print Patron Card Batches
  • +
  • Manage Label Batches
  • +
  • Manage Patron Card Batches
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-batches-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-batches-toolbar.inc index 34d7cff022..d5ffb610ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-batches-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-labels-batches-toolbar.inc @@ -3,8 +3,8 @@
    @@ -74,9 +74,9 @@
    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 6b1b6f3eaf..fc1214a0be 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 @@ -20,6 +20,8 @@ +
    +

    Items to be Printed for Batch ( items)

    @@ -40,7 +42,10 @@
    +
    +
    +

    Patron Cards to be Printed for Batch ( items)

    @@ -61,7 +66,12 @@
    +
    +
    + +
    +
    @@ -95,7 +105,12 @@
    -

    No Label Batches Currently Defined

    +
    + No Label Batches Currently Defined +
    + Select "New Label Batch" to create a Label batch. +
    +
    @@ -133,7 +148,12 @@
    -

    No Patron Card Batches Currently Defined

    +
    + No Patron Card Batches Currently Defined +
    + Select "New Patron Card Batch" to create a Label batch. +
    +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl index 27ae15fbc6..3362b4dfd0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/result.tmpl @@ -13,7 +13,7 @@ $(document).ready(function(){ return false; }); }); -function add_item(itemnum,batch_id){ +function add_item(itemnum,batch_id,type_id){ var getstr=''; if (itemnum == 'checked') { itms= new Array; @@ -24,11 +24,13 @@ function add_item(itemnum,batch_id){ } } getstr = itms.join("&"); + } else { + getstr = "itemnumber="+document.resultform.itemnumber.value; } } else { getstr = "itemnumber="+itemnum; } - var myurl = "label-manager.pl?op=add&batch_id="+batch_id+"&"+getstr; + var myurl = "label-manager.pl?op=add&batch_id="+batch_id+"&type="+type_id+"&"+getstr; window.opener.location.href = myurl; } function add_item3(itemnumber){ @@ -68,7 +70,7 @@ function add_item3(itemnumber){

    -
    ); return false" />
    +
    ,''); return false" />
    @@ -95,7 +97,7 @@ function add_item3(itemnumber){ diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index c1a96f3f29..1087d28c13 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -197,6 +197,7 @@ if ( $show_results ) { to => $to, numbers => \@numbers, batch_id => $batch_id, + type => $type, ); } @@ -229,7 +230,8 @@ else { } $template->param( itemtypeloop =>\@itemtypeloop, - batch_id => $batch_id, + batch_id => $batch_id, + type => $type, ); } diff --git a/labels/label-manager.pl b/labels/label-manager.pl index 55e12576b9..f3208126b0 100755 --- a/labels/label-manager.pl +++ b/labels/label-manager.pl @@ -40,8 +40,8 @@ my $startlabel = $query->param('startlabel'); my $printingtype = $query->param('printingtype'); my $guidebox = $query->param('guidebox'); my $fontsize = $query->param('fontsize'); -my @itemnumber = $query->param('itemnumber') if ($query->param('type') eq 'labels'); -my @itemnumber = $query->param('borrowernumber') if ($query->param('type') eq 'patroncards'); +my @itemnumber; +($query->param('type') eq 'labels') ? (@itemnumber = $query->param('itemnumber')) : (@itemnumber = $query->param('borrowernumber')); my $batch_type = $query->param('type'); # little block for displaying active layout/template/batch in templates @@ -137,7 +137,7 @@ elsif ( $op eq 'delete' ) { } elsif ( $op eq 'delete_batch' ) { delete_batch($batch_id, $batch_type); - print $query->redirect("label-manager.pl"); + print $query->redirect("label-manager.pl?type=$batch_type"); exit; } elsif ( $op eq 'add_batch' ) { @@ -149,8 +149,9 @@ elsif ( $op eq 'set_active_layout' ) { exit; } elsif ( $op eq 'deduplicate' ) { - my $return = deduplicate_batch($batch_id); - my $msg = (($return) ? "Removed $return" : "Error revoving") . " duplicate items from Batch $batch_id"; + warn "\$batch_id=$batch_id and \$batch_type=$batch_type"; + my ($return, $dberror) = deduplicate_batch($batch_id, $batch_type); + my $msg = (($return) ? "Removed $return" : "Error removing") . " duplicate items from Batch $batch_id." . (($dberror) ? " Database returned: $dberror" : ""); push @messages, $msg; }
    - ',); return false" href="/cgi-bin/koha/barcodes/label-manager.pl?itemnumber=&batch_id=&op=add">Add + ',, ''); return false" href="/cgi-bin/koha/barcodes/label-manager.pl?itemnumber=&batch_id=&type=&op=add">Add