- $scr = "
- for (i=0 ; i<document.f.field_value.length ; i++) {
- if (document.f.tag[i].value == '$tag' && document.f.subfield[i].value == '$subfield') {
- if (document.f.field_value[i].value == '') {
- document.f.field_value[i].value = '$nextnum';
- }
- }
- }";
- }
- elsif ($autoBarcodeType eq 'hbyymmincr') { # Generates a barcode where hb = home branch Code, yymm = year/month catalogued, incr = incremental number, reset yearly -fbcit
- $year = substr($year, -2);
- $query = "SELECT MAX(CAST(SUBSTRING(barcode,7,4) AS signed)) FROM items WHERE barcode REGEXP ?";
- my $sth=$dbh->prepare($query);
- $sth->execute("^[a-zA-Z]{1,}$year");
- while (my ($count)= $sth->fetchrow_array) {
- $nextnum = $count if $count;
- warn "Existing incremental number = $nextnum" if $DEBUG;
- }
- $nextnum++;
- $nextnum = sprintf("%0*d", "4",$nextnum);
- $nextnum = $year . $mon . $nextnum;
- warn "New Barcode = $nextnum" if $DEBUG;
- $scr = "
- for (i=0 ; i<document.f.field_value.length ; i++) {
- if (document.f.tag[i].value == '$loctag' && document.f.subfield[i].value == '$locsubfield') {
- fnum = i;
- }
- }
- for (i=0 ; i<document.f.field_value.length ; i++) {
- if (document.f.tag[i].value == '$tag' && document.f.subfield[i].value == '$subfield') {
- if (document.f.field_value[i].value == '') {
- document.f.field_value[i].value = document.f.field_value[fnum].value + '$nextnum';
- }
- }
- }";
+ }
+ elsif ($autoBarcodeType eq 'hbyymmincr') { # Generates a barcode where hb = home branch Code, yymm = year/month catalogued, incr = incremental number, reset yearly -fbcit
+ $year = substr($year, -2);
+ $query = "SELECT MAX(CAST(SUBSTRING(barcode,7,4) AS signed)) FROM items WHERE barcode REGEXP ?";
+ my $sth = $dbh->prepare($query);
+ $sth->execute("^[a-zA-Z]{1,}$year");
+ while (my ($count)= $sth->fetchrow_array) {
+ $nextnum = $count if $count;
+ warn "Existing incremental number = $nextnum" if $DEBUG;
+ }
+ $nextnum++;
+ $nextnum = sprintf("%0*d", "4",$nextnum);
+ $nextnum = $year . $mon . $nextnum;
+ warn "New hbyymmincr Barcode = $nextnum" if $DEBUG;
+ $scr = "
+ for (i=0 ; i<document.f.field_value.length ; i++) {
+ if (document.f.tag[i].value == '$loctag' && document.f.subfield[i].value == '$locsubfield') {
+ fnum = i;
+ }
+ }
+ if (\$('#' + id).val() == '' || force) {
+ \$('#' + id).val(document.f.field_value[fnum].value + '$nextnum');