View | Details | Raw Unified | Return to bug 12911
Collapse All | Expand All

(-)a/C4/Creators/Batch.pm (-5 / +7 lines)
Lines 51-60 sub new { Link Here
51
        batch_stat      => 0,   # False if any data has changed and the db has not been updated
51
        batch_stat      => 0,   # False if any data has changed and the db has not been updated
52
        @_,
52
        @_,
53
    };
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);
54
    bless ($self, $type);
59
    return $self;
55
    return $self;
60
}
56
}
Lines 64-75 sub add_item { Link Here
64
    my $number = shift;
60
    my $number = shift;
65
    ref($self) =~ m/C4::(.+)::.+$/;
61
    ref($self) =~ m/C4::(.+)::.+$/;
66
    my $number_type = ($1 eq 'Patroncards' ? 'borrower_number' : 'item_number');
62
    my $number_type = ($1 eq 'Patroncards' ? 'borrower_number' : 'item_number');
63
    if ($self->{'batch_id'} == 0){ #if this is a new batch batch_id must be created
64
        my $sth = C4::Context->dbh->prepare("SELECT MAX(batch_id) FROM creator_batches;");
65
        $sth->execute();
66
        my $batch_id = $sth->fetchrow_array;
67
        $self->{'batch_id'}= ++$batch_id;
68
    }
67
    my $query = "INSERT INTO creator_batches (batch_id, $number_type, branch_code, creator) VALUES (?,?,?,?);";
69
    my $query = "INSERT INTO creator_batches (batch_id, $number_type, branch_code, creator) VALUES (?,?,?,?);";
68
    my $sth = C4::Context->dbh->prepare($query);
70
    my $sth = C4::Context->dbh->prepare($query);
69
#    $sth->{'TraceLevel'} = 3;
71
#    $sth->{'TraceLevel'} = 3;
70
    $sth->execute($self->{'batch_id'}, $number, $self->{'branch_code'}, $1);
72
    $sth->execute($self->{'batch_id'}, $number, $self->{'branch_code'}, $1);
71
    if ($sth->err) {
73
    if ($sth->err) {
72
        warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
74
       warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
73
        return -1;
75
        return -1;
74
    }
76
    }
75
    $query = "SELECT max(label_id) FROM creator_batches WHERE batch_id=? AND $number_type=? AND branch_code=?;";
77
    $query = "SELECT max(label_id) FROM creator_batches WHERE batch_id=? AND $number_type=? AND branch_code=?;";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt (-1 / +1 lines)
Lines 262-268 Link Here
262
                                <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
262
                                <fieldset class="rows" style="border-bottom: 0px; border: 0px;">
263
                                <ol><li>
263
                                <ol><li>
264
                                    <div class="dialog message">
264
                                    <div class="dialog message">
265
                                        <h4>There are no items in Batch [% batch_id %] yet</h4>
265
                                        <h4>There are no items in this batch yet</h4>
266
                                        <p>Add items by barcode using the text area above or leave empty to add via item search.</p>
266
                                        <p>Add items by barcode using the text area above or leave empty to add via item search.</p>
267
                                    </div>
267
                                    </div>
268
                                </li></ol>
268
                                </li></ol>
(-)a/labels/label-edit-batch.pl (-1 / +1 lines)
Lines 95-100 elsif ($op eq 'add') { Link Here
95
        foreach my $item_number (@item_numbers) {
95
        foreach my $item_number (@item_numbers) {
96
            $err = $batch->add_item($item_number);
96
            $err = $batch->add_item($item_number);
97
        }
97
        }
98
        $batch_id = $batch->get_attr('batch_id') if $batch_id == 0; #update batch_id if we added to a new batch
98
        $errstr = "item(s) not added to batch $batch_id." if $err;
99
        $errstr = "item(s) not added to batch $batch_id." if $err;
99
    }
100
    }
100
    else {
101
    else {
101
- 

Return to bug 12911