Lines 42-48
INIT {
Link Here
|
42 |
# Generates barcode where hb = home branch Code, yymm = year/month catalogued, incr = incremental number, |
42 |
# Generates barcode where hb = home branch Code, yymm = year/month catalogued, incr = incremental number, |
43 |
# increment resets yearly -fbcit |
43 |
# increment resets yearly -fbcit |
44 |
|
44 |
|
45 |
sub db_max ($;$) { |
45 |
sub db_max { |
46 |
my $self = shift; |
46 |
my $self = shift; |
47 |
my $query = "SELECT MAX(SUBSTRING(barcode,-$width)), barcode FROM items WHERE barcode REGEXP ? GROUP BY barcode"; |
47 |
my $query = "SELECT MAX(SUBSTRING(barcode,-$width)), barcode FROM items WHERE barcode REGEXP ? GROUP BY barcode"; |
48 |
$debug and print STDERR "(hbyymmincr) db_max query: $query\n"; |
48 |
$debug and print STDERR "(hbyymmincr) db_max query: $query\n"; |
Lines 71-84
sub db_max ($;$) {
Link Here
|
71 |
return ($max || 0); |
71 |
return ($max || 0); |
72 |
} |
72 |
} |
73 |
|
73 |
|
74 |
sub initial () { |
74 |
sub initial { |
75 |
my $self = shift; |
75 |
my $self = shift; |
76 |
# FIXME: populated branch? |
76 |
# FIXME: populated branch? |
77 |
my $iso = C4::Dates->new->output('iso'); # like "2008-07-02" |
77 |
my $iso = C4::Dates->new->output('iso'); # like "2008-07-02" |
78 |
return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1); |
78 |
return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1); |
79 |
} |
79 |
} |
80 |
|
80 |
|
81 |
sub parse ($;$) { # return 3 parts of barcode: non-incrementing, incrementing, non-incrementing |
81 |
sub parse { # return 3 parts of barcode: non-incrementing, incrementing, non-incrementing |
82 |
my $self = shift; |
82 |
my $self = shift; |
83 |
my $barcode = (@_) ? shift : $self->value; |
83 |
my $barcode = (@_) ? shift : $self->value; |
84 |
my $branch = $self->branch; |
84 |
my $branch = $self->branch; |
Lines 90-106
sub parse ($;$) { # return 3 parts of barcode: non-incrementing, incrementing,
Link Here
|
90 |
return ($1,$2,''); # the third part is in anticipation of barcodes that include checkdigits |
90 |
return ($1,$2,''); # the third part is in anticipation of barcodes that include checkdigits |
91 |
} |
91 |
} |
92 |
|
92 |
|
93 |
sub branch ($;$) { |
93 |
sub branch { |
94 |
my $self = shift; |
94 |
my $self = shift; |
95 |
(@_) and $self->{branch} = shift; |
95 |
(@_) and $self->{branch} = shift; |
96 |
return $self->{branch}; |
96 |
return $self->{branch}; |
97 |
} |
97 |
} |
98 |
sub width ($;$) { |
98 |
sub width { |
99 |
my $self = shift; |
99 |
my $self = shift; |
100 |
(@_) and $width = shift; # hitting the class variable. |
100 |
(@_) and $width = shift; # hitting the class variable. |
101 |
return $width; |
101 |
return $width; |
102 |
} |
102 |
} |
103 |
sub process_head($$;$$) { # (self,head,whole,specific) |
103 |
sub process_head { # (self,head,whole,specific) |
104 |
my ($self,$head,$whole,$specific) = @_; |
104 |
my ($self,$head,$whole,$specific) = @_; |
105 |
$specific and return $head; # if this is built off an existing barcode, just return the head unchanged. |
105 |
$specific and return $head; # if this is built off an existing barcode, just return the head unchanged. |
106 |
$head =~ s/\d{4}$//; # else strip the old yymm |
106 |
$head =~ s/\d{4}$//; # else strip the old yymm |
107 |
- |
|
|