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

(-)a/C4/Barcodes/hbyymmincr.pm (-14 / +12 lines)
Lines 24-30 use Carp; Link Here
24
24
25
use C4::Context;
25
use C4::Context;
26
use C4::Debug;
26
use C4::Debug;
27
use C4::Dates;
28
27
29
use vars qw($VERSION @ISA);
28
use vars qw($VERSION @ISA);
30
use vars qw($debug $cgi_debug);	# from C4::Debug, of course
29
use vars qw($debug $cgi_debug);	# from C4::Debug, of course
Lines 48-63 sub db_max { Link Here
48
	$debug and print STDERR "(hbyymmincr) db_max query: $query\n";
47
	$debug and print STDERR "(hbyymmincr) db_max query: $query\n";
49
	my $sth = C4::Context->dbh->prepare($query);
48
	my $sth = C4::Context->dbh->prepare($query);
50
	my ($iso);
49
	my ($iso);
51
	if (@_) {
50
        if (@_) {
52
		my $input = shift;
51
                my $input = shift;
53
		$iso = C4::Dates->new($input,'iso')->output('iso'); # try to set the date w/ 2nd arg
52
                $iso = output_pref({ dt => dt_from_string( $input, 'iso' ), dateformat => 'iso', dateonly => 1 }); # try to set the date w/ 2nd arg
54
		unless ($iso) {
53
                unless ($iso) {
55
			warn "Failed to create 'iso' Dates object with input '$input'.  Reverting to today's date.";
54
                        warn "Failed to create 'iso' Dates object with input '$input'.  Reverting to today's date.";
56
			$iso = C4::Dates->new->output('iso');	# failover back to today
55
                        $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });      # failover back to today
57
		}
56
                }
58
	} else {
57
        } else {
59
		$iso = C4::Dates->new->output('iso');
58
                $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
60
	}
59
        }
61
	my $year = substr($iso,2,2);    # i.e. "08" for 2008
60
	my $year = substr($iso,2,2);    # i.e. "08" for 2008
62
	my $andtwo = $width+2;
61
	my $andtwo = $width+2;
63
	$sth->execute("^[a-zA-Z]{1,}" . $year . "[0-9]{$andtwo}");	# the extra two digits are the month.  we don't care what they are, just that they are there.
62
	$sth->execute("^[a-zA-Z]{1,}" . $year . "[0-9]{$andtwo}");	# the extra two digits are the month.  we don't care what they are, just that they are there.
Lines 74-80 sub db_max { Link Here
74
sub initial {
73
sub initial {
75
	my $self = shift;
74
	my $self = shift;
76
	# FIXME: populated branch?
75
	# FIXME: populated branch?
77
	my $iso = C4::Dates->new->output('iso'); 	# like "2008-07-02"
76
	my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); 	# like "2008-07-02"
78
	return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1);
77
	return $self->branch . substr($iso,2,2) . substr($iso,5,2) . sprintf('%' . "$width.$width" . 'd',1);
79
}
78
}
80
79
Lines 104-110 sub process_head { # (self,head,whole,specific) Link Here
104
	my ($self,$head,$whole,$specific) = @_;
103
	my ($self,$head,$whole,$specific) = @_;
105
	$specific and return $head;	# if this is built off an existing barcode, just return the head unchanged.
104
	$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
105
	$head =~ s/\d{4}$//;		# else strip the old yymm
107
	my $iso = C4::Dates->new->output('iso'); 	# like "2008-07-02"
106
	my $iso = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); 	# like "2008-07-02"
108
	return $head . substr($iso,2,2) . substr($iso,5,2);
107
	return $head . substr($iso,2,2) . substr($iso,5,2);
109
}
108
}
110
109
111
- 

Return to bug 13813