--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
@@ -94,7 +94,7 @@
// some pass-thru error trapping just in case...
}
};
- function selected_layout() {
+ function selected_layout() {
if (document.items.action.length) {
for (i=0;i
@@ -195,12 +221,16 @@
--- a/labels/label-edit-batch.pl
+++ a/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');
--- a/labels/label-manage.pl
+++ a/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'}},
--- a/patroncards/edit-batch.pl
+++ a/patroncards/edit-batch.pl
@@ -55,6 +55,7 @@ my $display_columns = [ {_summary => {label => 'Summary', link_field => 0}
];
my $op = $cgi->param('op') || 'new';
my $batch_id = $cgi->param('element_id') || $cgi->param('batch_id') || 0;
+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');
@@ -93,6 +94,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);
@@ -119,6 +121,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 '') {
--- a/patroncards/manage.pl
+++ a/patroncards/manage.pl
@@ -70,6 +70,7 @@ my $display_columns = { layout => [ # db column => {col label
{select => {label => 'Select', value => 'profile_id'}},
],
batch => [ {batch_id => {label => 'Batch ID', link_field => 0}},
+ {description => {label => 'Description', link_field => 0}},
{_item_count => {label => 'Patron Count', link_field => 0}},
{_action => {label => 'Actions', link_field => 0}},
{select => {label => 'Select', value => 'batch_id'}},
--- a/svc/creator_batches
+++ a/svc/creator_batches
@@ -0,0 +1,73 @@
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Copyright 2017 Aleisha Amohia
+#
+# 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 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY 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, see .
+
+use Modern::Perl;
+
+use JSON qw( encode_json );
+use CGI;
+use C4::Service;
+use C4::Context;
+use C4::Auth qw /check_cookie_auth/;
+use C4::Output qw(:DEFAULT :ajax);
+use C4::Patroncards::Batch;
+use C4::Labels::Batch;
+
+=head1 NAME
+
+svc/creator_batches - Web service for managing AJAX functionality for patroncards and label batches
+
+=head1 DESCRIPTION
+
+=cut
+
+# AJAX requests
+my $is_ajax = is_ajax();
+my $cgi = new CGI;
+my ( $auth_status, $sessionID ) = check_cookie_auth( $cgi->cookie('CGISESSID'), { catalogue => 1 } );
+if ( $auth_status ne "ok" ) {
+ exit 0;
+}
+
+if ($is_ajax) {
+ my $batch_id = $cgi->param('batch_id');
+ my $description = $cgi->param('newdescription');
+ my $status = '';
+ my $dbh = C4::Context->dbh;
+ my $query = "UPDATE creator_batches SET description = ? WHERE batch_id = ?";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($description, $batch_id);
+
+ # Check for success
+ my $creator = $cgi->param('creator');
+ if ( $creator eq 'patroncard' ) {
+ my $batch = C4::Patroncards::Batch->retrieve(batch_id => $batch_id);
+ if ( $batch->{description} eq $description ) {
+ $status = 'success';
+ }
+ } elsif ( $creator eq 'label' ) {
+ my $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
+ if ( $batch->{description} eq $description ) {
+ $status = 'success';
+ }
+ }
+
+ my $json = encode_json ( { status => $status, newdesc => $description } );
+ output_with_http_headers $cgi, undef, $json, 'js';
+ exit;
+}
--