@@ -, +, @@ to several batches -Added code to make a placeholder and thus reserve the batch number. -Added code to delete old placeholders everytime a new batch is made. -Modified code in SELECT query to discount placeholders from batch items. -Open two koha staff windows in different browsers/inprivate. -On both navigate Home>Tools>Label Creator -Make a new batch in the first window -Make a new batch in the second window -Add items to one of the batches -Go back to manage batches page on either window --- C4/Creators/Batch.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/C4/Creators/Batch.pm +++ a/C4/Creators/Batch.pm @@ -56,6 +56,16 @@ sub new { 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); + + #Delete previous placeholders to clean up data + my $query = "DELETE FROM creator_batches WHERE creator = 'PLACEHOLDER';"; + my $sth = C4::Context->dbh->prepare($query); + $sth->execute(); + + #Make a placeholder to ensure the batch number is reserved and not assigned to multople clients + my $query = "INSERT INTO creator_batches (batch_id, branch_code, creator) VALUES (?, ?, ?);"; + my $sth = C4::Context->dbh->prepare($query); + $sth->execute($self->{'batch_id'}, $self->{'branch_code'}, "PLACEHOLDER"); return $self; } @@ -139,7 +149,8 @@ sub retrieve { $type =~ m/C4::(.+)::.+$/; my $number_type = ($1 eq 'Patroncards' ? 'borrower_number' : 'item_number'); my $record_flag = 0; - my $query = "SELECT * FROM creator_batches WHERE batch_id = ? ORDER BY label_id"; + #Added check to query to exclude placeholder results + my $query = "SELECT * FROM creator_batches WHERE batch_id = ? AND NOT creator = 'PLACEHOLDER' ORDER BY label_id;"; my $sth = C4::Context->dbh->prepare($query); # $sth->{'TraceLevel'} = 3; $sth->execute($opts{'batch_id'}); --