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

(-)a/cataloguing/value_builder/barcode.pl (+25 lines)
Lines 60-65 sub plugin_javascript { Link Here
60
	my ($year, $mon, $day) = split('-', C4::Dates->today('iso'));
60
	my ($year, $mon, $day) = split('-', C4::Dates->today('iso'));
61
	my ($tag,$subfield)       =  GetMarcFromKohaField("items.barcode", '');
61
	my ($tag,$subfield)       =  GetMarcFromKohaField("items.barcode", '');
62
	my ($loctag,$locsubfield) =  GetMarcFromKohaField("items.homebranch", '');
62
	my ($loctag,$locsubfield) =  GetMarcFromKohaField("items.homebranch", '');
63
    my ($itypetag,$itypesubfield) =  GetMarcFromKohaField("items.itype", '');
63
64
64
	my $nextnum;
65
	my $nextnum;
65
	my $query;
66
	my $query;
Lines 122-127 sub plugin_javascript { Link Here
122
            \$('#' + id).val(document.f.field_value[fnum].value + '$nextnum');
123
            \$('#' + id).val(document.f.field_value[fnum].value + '$nextnum');
123
        }
124
        }
124
        ";
125
        ";
126
    }   
127
    elsif ($autoBarcodeType eq 'itypeincr') {      # Generates a barcode where itype = Itemtype, incr = incremental number
128
      
129
        $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number FROM items WHERE barcode REGEXP ?";
130
        my $sth = $dbh->prepare($query);
131
        $sth->execute();
132
        while (my ($count)= $sth->fetchrow_array) {
133
            $nextnum = $count if $count;
134
            $nextnum = 0 if $nextnum == 9999; # this sequence only allows for cataloging 10000 books per month
135
            warn "Existing incremental number = $nextnum" if $DEBUG;
136
        }
137
        $nextnum++;
138
        $nextnum = sprintf("%0*d", "4",$nextnum);       
139
        warn "New itypeincr Barcode = $nextnum" if $DEBUG;
140
        $scr = "
141
        for (i=0 ; i<document.f.field_value.length ; i++) {
142
            if (document.f.tag[i].value == '$itypetag' && document.f.subfield[i].value == '$itypesubfield') {
143
                fnum = i;
144
            }
145
        }
146
        if (\$('#' + id).val() == '' || force) {
147
            \$('#' + id).val(document.f.field_value[fnum].value + '$nextnum');
148
        }
149
        ";
125
    }
150
    }
126
151
127
    # default js body (if not filled by hbyymmincr)
152
    # default js body (if not filled by hbyymmincr)
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 365-367 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
365
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
365
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
366
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
366
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
367
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice');
367
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice');
368
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('autoBarcode','OFF','Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch; itypeincr of the form BK0001 where itype=Item type.','incremental|annual|hbyymmincr|itypeincr|OFF','Choice');
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 5308-5313 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5308
    SetVersion ($DBversion);
5308
    SetVersion ($DBversion);
5309
}
5309
}
5310
5310
5311
$DBversion = "3.09.00.XXX";
5312
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5313
    $dbh->do("update systempreferences set options='incremental|annual|hbyymmincr|itypeincr|OFF', explanation= 'Used to autogenerate a barcode: incremental will be of the form 1, 2, 3; annual of the form 2007-0001, 2007-0002; hbyymmincr of the form HB08010001 where HB=Home Branch; itypeincr of the form BK0001 where itype=Item type.' where variable='autobarcode'");    
5314
    print "Upgrade to $DBversion done (Add option to generate autoBarcode with itemtype as prefix)\n";
5315
    SetVersion ($DBversion);
5316
}
5317
5311
=head1 FUNCTIONS
5318
=head1 FUNCTIONS
5312
5319
5313
=head2 TableExists($table)
5320
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-1 / +1 lines)
Lines 89-94 Cataloging: Link Here
89
                  incremental: generated in the form 1, 2, 3.
89
                  incremental: generated in the form 1, 2, 3.
90
                  annual: generated in the form &lt;year&gt;-0001, &lt;year&gt;-0002.
90
                  annual: generated in the form &lt;year&gt;-0001, &lt;year&gt;-0002.
91
                  hbyymmincr: generated in the form &lt;branchcode&gt;yymm0001.
91
                  hbyymmincr: generated in the form &lt;branchcode&gt;yymm0001.
92
                  itypeincr: generated in the form &lt;itemtypecode&gt;0001.
92
                  "OFF": not generated automatically.
93
                  "OFF": not generated automatically.
93
    Display:
94
    Display:
94
        -
95
        -
95
- 

Return to bug 7911