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

(-)a/C4/Barcodes/ValueBuilder.pm (-5 / +5 lines)
Lines 44-62 my $DEBUG = 0; Link Here
44
44
45
sub get_barcode {
45
sub get_barcode {
46
    my ($args) = @_;
46
    my ($args) = @_;
47
    my $nextnum;
47
    my $nextnum = 0;
48
    my $year = substr($args->{year}, -2);
48
    my $year = substr($args->{year}, -2);
49
    my $month = $args->{mon};
49
    my $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?";
50
    my $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?";
50
    my $sth = C4::Context->dbh->prepare($query);
51
    my $sth = C4::Context->dbh->prepare($query);
51
    $sth->execute("^[-a-zA-Z]{1,}$year");
52
    $sth->execute("^[-a-zA-Z]{1,}$year$month");
52
    while (my ($count)= $sth->fetchrow_array) {
53
    while (my ($count)= $sth->fetchrow_array) {
53
        $nextnum = $count if $count;
54
        $nextnum = $count if $count;
54
        $nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 10000 books per month
55
        $nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 9999 items per month
55
            warn "Existing incremental number = $nextnum" if $DEBUG;
56
            warn "Existing incremental number = $nextnum" if $DEBUG;
56
    }
57
    }
57
    $nextnum++;
58
    $nextnum++;
58
    $nextnum = sprintf("%0*d", "4",$nextnum);
59
    $nextnum = sprintf("%0*d", "4",$nextnum);
59
    $nextnum = $year . $args->{mon} . $nextnum;
60
    $nextnum = $year . $month . $nextnum;
60
    warn "New hbyymmincr Barcode = $nextnum" if $DEBUG;
61
    warn "New hbyymmincr Barcode = $nextnum" if $DEBUG;
61
    my $scr = "
62
    my $scr = "
62
        for (i=0 ; i<document.f.field_value.length ; i++) {
63
        for (i=0 ; i<document.f.field_value.length ; i++) {
63
- 

Return to bug 13603