Bugzilla – Attachment 35898 Details for
Bug 12911
batch_id for new label batches can be assigned to several batches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 12911 - batch_id for new labels batches can be asssigned to several batches
PASSED-QA-Bug-12911---batchid-for-new-labels-batch.patch (text/plain), 4.62 KB, created by
Kyle M Hall (khall)
on 2015-02-13 13:12:12 UTC
(
hide
)
Description:
[PASSED QA] Bug 12911 - batch_id for new labels batches can be asssigned to several batches
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-02-13 13:12:12 UTC
Size:
4.62 KB
patch
obsolete
>From d7320a297b7eb2f3b8c9616a9991e417810a5725 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@quecheelibrary.org> >Date: Sat, 7 Feb 2015 12:49:29 -0500 >Subject: [PATCH] [PASSED QA] Bug 12911 - batch_id for new labels batches can be asssigned to several batches > >Currently batch_id is assigned upon creation of a new batch object. This patch leaves batch_id as 0 at creation and adds a check when adding items. If batch is new then batch_id is created then > >Test plan: >1 -In one browser window, go to tools->label creator and click the new batch button >2 - Before adding items, open a new browser, and go tools->label creator and click the new batch button >3 - Note that both batches have the same number listed >4 - Add an item to the first batch - you should now see one item in the batch >5 - Add an item to the second batch, you should see two items in the batch >6 - Apply patch and repeat steps 1&2 >7 - Note that neither batch lists a batch number >8 - Add an item to the first batch, you should see one item and a batch number >9 - Add an item to the second batch, you should see one item and a new batch number > >Patch behaves as expected. >Signed-off-by: Marc Veron <veron@veron.ch> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Creators/Batch.pm | 12 +++++++----- > .../prog/en/modules/labels/label-edit-batch.tt | 2 +- > labels/label-edit-batch.pl | 1 + > 3 files changed, 9 insertions(+), 6 deletions(-) > >diff --git a/C4/Creators/Batch.pm b/C4/Creators/Batch.pm >index 28beeb7..13fc436 100644 >--- a/C4/Creators/Batch.pm >+++ b/C4/Creators/Batch.pm >@@ -51,10 +51,6 @@ sub new { > batch_stat => 0, # False if any data has changed and the db has not been updated > @_, > }; >- my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM creator_batches;"); >- $sth->execute(); >- my $batch_id = $sth->fetchrow_array; >- $self->{'batch_id'} = ++$batch_id unless $self->{'batch_id'} != 0; # this allows batch_id to be passed in for individual label printing > bless ($self, $type); > return $self; > } >@@ -64,12 +60,18 @@ sub add_item { > my $number = shift; > ref($self) =~ m/C4::(.+)::.+$/; > my $number_type = ($1 eq 'Patroncards' ? 'borrower_number' : 'item_number'); >+ if ($self->{'batch_id'} == 0){ #if this is a new batch batch_id must be created >+ my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM creator_batches;"); >+ $sth->execute(); >+ 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 $sth = C4::Context->dbh->prepare($query); > # $sth->{'TraceLevel'} = 3; > $sth->execute($self->{'batch_id'}, $number, $self->{'branch_code'}, $1); > if ($sth->err) { >- warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr); >+ warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr); > return -1; > } > $query = "SELECT max(label_id) FROM creator_batches WHERE batch_id=? AND $number_type=? AND branch_code=?;"; >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 f9f7b55..6832d56 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 >@@ -262,7 +262,7 @@ > <fieldset class="rows" style="border-bottom: 0px; border: 0px;"> > <ol><li> > <div class="dialog message"> >- <h4>There are no items in Batch [% batch_id %] yet</h4> >+ <h4>There are no items in this batch yet</h4> > <p>Add items by barcode using the text area above or leave empty to add via item search.</p> > </div> > </li></ol> >diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl >index 60d7b43..9c009e2 100755 >--- a/labels/label-edit-batch.pl >+++ b/labels/label-edit-batch.pl >@@ -95,6 +95,7 @@ elsif ($op eq 'add') { > foreach my $item_number (@item_numbers) { > $err = $batch->add_item($item_number); > } >+ $batch_id = $batch->get_attr('batch_id') if $batch_id == 0; #update batch_id if we added to a new batch > $errstr = "item(s) not added to batch $batch_id." if $err; > } > else { >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12911
:
35600
|
35719
|
35807
| 35898