From fd020ae718321983eb250a907f548603a9857aad Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 8 Feb 2017 01:26:06 +0000 Subject: [PATCH] Bug 15766: Adding descriptions to label batches Same fix, but for Label creator. Follow same test plan but in Tools->Label creator. Sponsored-by: Catalyst IT Signed-off-by: Eric Gosselin --- .../prog/en/modules/labels/label-edit-batch.tt | 33 ++++++++++++++++++++-- labels/label-edit-batch.pl | 3 ++ labels/label-manage.pl | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt index ed905a9..fdb8212 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt @@ -124,7 +124,7 @@ return (-1); }; - $(document).ready(function() { + $(document).ready(function() { $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, { "autoWidth": false, "aoColumnDefs": [ @@ -167,7 +167,33 @@ var batch_id = $(this).data("batch-id"); GB_showCenter(_("Export labels"),"/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id, 400, 800); }); - }); + $("#savedesc").click(function(event){ + event.preventDefault(); // prevent form submission + var newdescription = $(this).siblings('input[name="description"]').val(); + var batch_id = $(this).data('batch_id'); + var ajaxData = { + 'newdescription': newdescription, + 'batch_id': batch_id, + 'card_element': "batch", + }; + + $.ajax({ + url: '/cgi-bin/koha/svc/patroncards', + type: 'POST', + dataType: 'json', + data: ajaxData, + }) + + .done(function(data){ + if (data.status == 'success') { + $("input[name='description']").text(data.newdesc); + $("#change-status").text(_("Saved")); + } else { + $("#change-status").text(_("Unable to save description")); + } + }); + }); + }); //]]> @@ -208,6 +234,9 @@
  1. + + + Save description
  2. diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl index 5252213..88a9205 100755 --- a/labels/label-edit-batch.pl +++ b/labels/label-edit-batch.pl @@ -62,6 +62,7 @@ my @item_numbers; my $number_list; my $number_type = $cgi->param('number_type') || "barcode"; my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || 0; +my $description = $cgi->param('description') || ''; @label_ids = $cgi->multi_param('label_id') if $cgi->param('label_id'); @item_numbers = $cgi->multi_param('item_number') if $cgi->param('item_number'); $number_list = $cgi->param('number_list') if $cgi->param('number_list'); @@ -99,6 +100,7 @@ elsif ($op eq 'add') { } if ($batch_id != 0) {$batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);} if ($batch_id == 0 || $batch == -2) {$batch = C4::Labels::Batch->new(branch_code => $branch_code);} + $template->param( description => $batch->{description} ); if ($branch_code){ foreach my $item_number (@item_numbers) { $err = $batch->add_item($item_number); @@ -123,6 +125,7 @@ elsif ($op eq 'de_duplicate') { } else { # edit $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id); + $template->param( description => $batch->{description} ); } my $items = $batch->get_attr('items'); diff --git a/labels/label-manage.pl b/labels/label-manage.pl index 1d8a34e..8ee73b1 100755 --- a/labels/label-manage.pl +++ b/labels/label-manage.pl @@ -66,6 +66,7 @@ my $display_columns = { layout => [ # db column => {col label ], batch => [ {batch_id => {label => 'Batch ID', link_field => 0}}, + {description => {label => 'Description', link_field => 0}}, {_item_count => {label => 'Item Count', link_field => 0}}, {select => {label => 'Actions', value => 'batch_id'}}, {select1 => {label => ' ', link_field => 'batch_id'}}, -- 2.7.4