X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=patroncards%2Fedit-batch.pl;h=dbb3d9cc876d597980673c95b299e45f69292fe7;hb=a63b0d00306d639241a400cecbe3b0125ee8d303;hp=f554a33c783f020b28e351fdcf6700d29056ef84;hpb=a8a9c7b7fd75bda5fb9b1ced2cc9600a289b0fa6;p=koha-ffzg.git diff --git a/patroncards/edit-batch.pl b/patroncards/edit-batch.pl index f554a33c78..dbb3d9cc87 100755 --- a/patroncards/edit-batch.pl +++ b/patroncards/edit-batch.pl @@ -18,27 +18,25 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . -use strict; -use warnings; -use vars qw($debug); + +use Modern::Perl; use CGI qw ( -utf8 ); use autouse 'Data::Dumper' => qw(Dumper); -use C4::Auth qw(get_template_and_user); -use C4::Output qw(output_html_with_http_headers); -use C4::Creators; +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); +use C4::Creators qw( get_card_summary html_table ); use C4::Patroncards; -use C4::Members qw(GetMember); -my $cgi = new CGI; +use Koha::Patrons; + +my $cgi = CGI->new; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "patroncards/edit-batch.tt", query => $cgi, type => "intranet", - authnotrequired => 0, - flagsrequired => { catalogue => 1 }, - debug => 1, + flagsrequired => { tools => 'label_creator' }, } ); @@ -47,20 +45,29 @@ my $duplicate_count = undef; my $duplicate_message = undef; my $db_rows = {}; my $batch = undef; -my $display_columns = [ {_card_number => {label => 'Card Number', link_field => 0}}, - {_summary => {label => 'Summary', link_field => 0}}, +my $display_columns = [ {_summary => {label => 'Summary', link_field => 0}}, {borrowernumber => {label => 'Borrower Number', link_field => 0}}, + {_action => {label => 'Actions ', link_field => 0}}, {select => {label => 'Select', value => '_label_id'}}, ]; my $op = $cgi->param('op') || 'new'; my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || 0; -my @label_ids = $cgi->param('label_id') if $cgi->param('label_id'); -my @item_numbers = $cgi->param('item_number') if $cgi->param('item_number'); -my @borrower_numbers = $cgi->param('borrower_number') if $cgi->param('borrower_number'); +my $description = $cgi->param('description') || ''; +my ( @label_ids, @item_numbers, @borrower_numbers ); +@label_ids = $cgi->multi_param('label_id') if $cgi->param('label_id'); +@item_numbers = $cgi->multi_param('item_number') if $cgi->param('item_number'); +@borrower_numbers = $cgi->multi_param('borrower_number') if $cgi->param('borrower_number'); my $errstr = $cgi->param('error') || ''; my $bor_num_list = $cgi->param('bor_num_list') || undef; my $branch_code = C4::Context->userenv->{'branch'}; +my @errors = ( 'pdferr', 'errnocards', 'errba', 'errpl', 'errpt', 'errlo', 'errtpl', ); +foreach my $param (@errors) { + my $error = $cgi->param($param) ? 1 : 0; + $template->param( 'error_' . $param => $error ) + if $error; +} + if ($op eq 'remove') { $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id); foreach my $label_id (@label_ids) { @@ -83,7 +90,7 @@ if ($bor_num_list) { my @bor_nums_unchecked = split /\n/, $bor_num_list; # $bor_num_list is effectively passed in as a separated list foreach my $number (@bor_nums_unchecked) { $number =~ s/\r$//; # strip any naughty return chars - if ( GetMember(borrowernumber => $number)) { # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm + if ( Koha::Patrons->find( $number )) { # we must test in case an invalid borrowernumber is passed in; we effectively disgard them atm my $borrower_number = $number; push @borrower_numbers, $borrower_number; } @@ -91,6 +98,7 @@ if ($bor_num_list) { } if ($batch_id != 0) {$batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);} if ($batch_id == 0 || $batch == -2) {$batch = C4::Patroncards::Batch->new(branch_code => $branch_code);} + $template->param( description => $batch->{'description'} ); if ($branch_code){ foreach my $borrower_number (@borrower_numbers) { $err = $batch->add_item($borrower_number); @@ -117,6 +125,7 @@ elsif ($op eq 'de_duplicate') { } elsif ($op eq 'edit') { $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id); + $template->param( description => $batch->{'description'} ); } elsif ($op eq 'new') { if ($branch_code eq '') {