X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=labels%2Flabel-edit-batch.pl;h=94d56b4e726a8ca74e260dfffeb28f3718bab8fe;hb=6843f5a346da3d0c0e55b7168750190c9194297b;hp=1278df90c06120c0cc3d5acedaa5370c9cc478f7;hpb=c468a724b444a0b632ee68383e6c9515fa146f64;p=srvgit diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl index 1278df90c0..94d56b4e72 100755 --- a/labels/label-edit-batch.pl +++ b/labels/label-edit-batch.pl @@ -4,7 +4,7 @@ # Parts Copyright 2009 Foundations Bible College. # # This file is part of Koha. -# +# # Koha is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later @@ -14,23 +14,21 @@ # 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 vars qw($debug); -use Sys::Syslog qw(syslog); use CGI; -use HTML::Template::Pro; use C4::Auth qw(get_template_and_user); use C4::Output qw(output_html_with_http_headers); use C4::Branch qw(get_branch_code_from_name); -use C4::Labels::Lib 1.000000 qw(get_label_summary html_table); -use C4::Labels::Batch 1.000000; +use C4::Creators 1.000000; +use C4::Labels 1.000000; my $cgi = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -56,7 +54,7 @@ my $display_columns = [ {_label_number => {label => 'Label Number', link_field {_barcode => {label => 'Barcode', link_field => 0}}, {select => {label => 'Select', value => '_label_id'}}, ]; -my $op = $cgi->param('op') || undef; +my $op = $cgi->param('op') || 'edit'; my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || undef; my @label_ids = $cgi->param('label_id') if $cgi->param('label_id'); my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number'); @@ -80,10 +78,16 @@ elsif ($op eq 'delete') { elsif ($op eq 'add') { $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id); $batch = C4::Labels::Batch->new(branch_code => $branch_code) if $batch == -2; - foreach my $item_number (@item_numbers) { - $err = $batch->add_item($item_number); + if ($branch_code){ + foreach my $item_number (@item_numbers) { + $err = $batch->add_item($item_number); + } + $errstr = "item(s) not added to batch $batch_id." if $err; + } + else { + $err = 1; + $errstr = "items(s) not added, the error was: Branch is not set, you please set your branch before adding items to a batch"; } - $errstr = "item(s) not added to batch $batch_id." if $err; } elsif ($op eq 'new') { $batch = C4::Labels::Batch->new(branch_code => $branch_code); @@ -105,19 +109,16 @@ $db_rows = get_label_summary(items => $items, batch_id => $batch_id); my $table = html_table($display_columns, $db_rows); $template->param( - duplicate_message => $duplicate_message, - duplicate_count => $duplicate_count, - ); - -$template->param( err => $err, errstr => $errstr, ) if ($err ne 0); $template->param( - op => $op, - batch_id => $batch_id, - table_loop => $table, + op => $op, + batch_id => $batch_id, + table_loop => $table, + duplicate_message => $duplicate_message, + duplicate_count => $duplicate_count, ); output_html_with_http_headers $cgi, $cookie, $template->output;