[Koha-bugs] [Bug 12911] New: batch_id for new label batches can be assigned to several batches
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Sep 11 21:04:01 CEST 2014
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12911
Bug ID: 12911
Summary: batch_id for new label batches can be assigned to
several batches
Change sponsored?: ---
Product: Koha
Version: master
Hardware: All
OS: All
Status: NEW
Severity: minor
Priority: P5 - low
Component: Tools
Assignee: gmcharlt at gmail.com
Reporter: nick at quecheelibrary.org
QA Contact: testopia at bugs.koha-community.org
When adding a new label batch the MAX batch_id is retrieved from
creator_batches and incremented, however, the updated value is not saved until
new items are added to the batch.
This means that if one library opens a new batch but does not add items before
another library opens the batch they will both be assigned the same batch
number
To recreate:
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
I can also verify this happens pretty often in our shared system.
C4:Creators
44 sub new {
45 my ($invocant) = shift;
46 my $type = ref($invocant) || $invocant;
47 my $self = {
48 batch_id => 0,
49 items => [],
50 branch_code => 'NB',
51 batch_stat => 0, # False if any data has changed and the db
has not been updated
52 @_,
53 };
54 my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM
creator_batches;");
55 $sth->execute();
56 my $batch_id = $sth->fetchrow_array;
57 $self->{'batch_id'} = ++$batch_id unless $self->{'batch_id'} != 0;
# this allows batch_id to be passed in for individual label printing
58 bless ($self, $type);
59 return $self;
60 }
61
62 sub add_item {
63 my $self = shift;
64 my $number = shift;
65 ref($self) =~ m/C4::(.+)::.+$/;
66 my $number_type = ($1 eq 'Patroncards' ? 'borrower_number' :
'item_number');
67 my $query = "INSERT INTO creator_batches (batch_id, $number_type,
branch_code, creator) VALUES (?,?,?,?);";
68 my $sth = C4::Context->dbh->prepare($query);
69 # $sth->{'TraceLevel'} = 3;
70 $sth->execute($self->{'batch_id'}, $number, $self->{'branch_code'},
$1);
71 if ($sth->err) {
72 warn sprintf('Database returned the following error on attempted
INSERT: %s', $sth->errstr);
73 return -1;
74 }
75 $query = "SELECT max(label_id) FROM creator_batches WHERE batch_id=?
AND $number_type=? AND branch_code=?;";
76 my $sth1 = C4::Context->dbh->prepare($query);
77 $sth1->execute($self->{'batch_id'}, $number, $self->{'branch_code'});
78 my $label_id = $sth1->fetchrow_array;
79 push (@{$self->{'items'}}, {$number_type => $number, label_id =>
$label_id});
80 $self->{'batch_stat'} = 1;
81 return 0;
82 }
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list