@@ -, +, @@ --- C4/Creators/Batch.pm | 7 ++- C4/Creators/Lib.pm | 2 +- ..._15766_-_add_description_column_to_batches.perl | 9 +++ installer/data/mysql/kohastructure.sql | 1 + .../prog/en/modules/patroncards/edit-batch.tt | 42 ++++++++++++-- patroncards/edit-batch.pl | 3 + patroncards/manage.pl | 1 + svc/patroncards | 67 ++++++++++++++++++++++ 8 files changed, 123 insertions(+), 9 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_15766_-_add_description_column_to_batches.perl create mode 100644 svc/patroncards --- a/C4/Creators/Batch.pm +++ a/C4/Creators/Batch.pm @@ -15,6 +15,7 @@ sub _check_params { my @valid_template_params = ( 'label_id', 'batch_id', + 'description', 'item_number', 'card_number', 'branch_code', @@ -43,6 +44,7 @@ sub new { my $type = ref($invocant) || $invocant; my $self = { batch_id => 0, + description => '', items => [], branch_code => 'NB', batch_stat => 0, # False if any data has changed and the db has not been updated @@ -63,10 +65,10 @@ sub add_item { my $batch_id = $sth->fetchrow_array; $self->{'batch_id'}= ++$batch_id; } - my $query = "INSERT INTO creator_batches (batch_id, $number_type, branch_code, creator) VALUES (?,?,?,?);"; + my $query = "INSERT INTO creator_batches (batch_id, description, $number_type, branch_code, creator) VALUES (?,?,?,?,?);"; my $sth = C4::Context->dbh->prepare($query); # $sth->{'TraceLevel'} = 3; - $sth->execute($self->{'batch_id'}, $number, $self->{'branch_code'}, $1); + $sth->execute($self->{'batch_id'}, $self->{'description'}, $number, $self->{'branch_code'}, $1); if ($sth->err) { warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr); return -1; @@ -149,6 +151,7 @@ sub retrieve { while (my $record = $sth->fetchrow_hashref) { $self->{'branch_code'} = $record->{'branch_code'}; $self->{'creator'} = $record->{'creator'}; + $self->{'description'} = $record->{'description'}; push (@{$self->{'items'}}, {$number_type => $record->{$number_type}, label_id => $record->{'label_id'}}); $record_flag = 1; # true if one or more rows were retrieved } --- a/C4/Creators/Lib.pm +++ a/C4/Creators/Lib.pm @@ -279,7 +279,7 @@ NOTE: Do not pass in the keyword 'WHERE.' sub get_batch_summary { my ( $params ) = @_; my @batches = (); - $params->{fields} = ['batch_id', 'count(batch_id) as _item_count']; + $params->{fields} = ['batch_id', 'description', 'count(batch_id) as _item_count']; my ( $query, @where_args ) = _build_query( $params, 'creator_batches' ); $query .= " GROUP BY batch_id"; my $sth = C4::Context->dbh->prepare($query); --- a/installer/data/mysql/atomicupdate/bug_15766_-_add_description_column_to_batches.perl +++ a/installer/data/mysql/atomicupdate/bug_15766_-_add_description_column_to_batches.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( column_exists( 'creator_batches', 'description' ) ) { + $dbh->do(q|ALTER TABLE creator_batches ADD description mediumtext default NULL AFTER batch_id|); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 15766: Add column creator_batches.description)\n"; +} --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1813,6 +1813,7 @@ SET character_set_client = utf8; CREATE TABLE `creator_batches` ( `label_id` int(11) NOT NULL AUTO_INCREMENT, `batch_id` int(10) NOT NULL DEFAULT '1', + `description` mediumtext DEFAULT NULL, `item_number` int(11) DEFAULT NULL, `borrower_number` int(11) DEFAULT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt @@ -156,6 +156,32 @@ var batch_id = $(this).data("batch-id"); GB_showCenter( _("Export single card"),'/cgi-bin/koha/patroncards/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")); + } + }); + }); }); //]]> @@ -198,12 +224,16 @@