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

(-)a/C4/Barcodes/hbyymmincr.pm (-2 / +3 lines)
Lines 44-50 INIT { Link Here
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 SUBSTRING(barcode,-$width) AS chunk, barcode FROM items WHERE barcode REGEXP ?  ORDER BY chunk DESC LIMIT 1";
48
	$debug and print STDERR "(hbyymmincr) db_max query: $query\n";
48
	$debug and print STDERR "(hbyymmincr) db_max query: $query\n";
49
	my $sth = C4::Context->dbh->prepare($query);
49
	my $sth = C4::Context->dbh->prepare($query);
50
	my ($iso);
50
	my ($iso);
Lines 75-80 sub initial { Link Here
75
	my $self = shift;
75
	my $self = shift;
76
	# FIXME: populated branch?
76
	# FIXME: populated branch?
77
    my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02"
77
    my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); # like "2008-07-02"
78
    if ( $self->branch eq '' ) { warn "HBYYMM Barcode was not passed a branch, default is blank" }
78
	return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1);
79
	return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1);
79
}
80
}
80
81
Lines 116-121 sub new_object { Link Here
116
	my $self = $class_or_object->default_self('hbyymmincr');
117
	my $self = $class_or_object->default_self('hbyymmincr');
117
	bless $self, $type;
118
	bless $self, $type;
118
	$self->branch(@_ ? shift : $from_obj ? $class_or_object->branch : $branch);
119
	$self->branch(@_ ? shift : $from_obj ? $class_or_object->branch : $branch);
120
    if ( $self->branch() eq '' ) { warn "HBYYMM Barcode created with no branchcode, default is blank"; }
119
		# take the branch from argument, or existing object, or default
121
		# take the branch from argument, or existing object, or default
120
	use Data::Dumper;
122
	use Data::Dumper;
121
	$debug and print STDERR "(hbyymmincr) new_object: ", Dumper($self), "\n";
123
	$debug and print STDERR "(hbyymmincr) new_object: ", Dumper($self), "\n";
122
- 

Return to bug 15878