Add option to generate autoBarcode with itemtype as prefix
To Test:
1) Go to More->Adminstration->Global system preferences
2) Choose (generated in the form itemtypecode) under autobarcode option.
3) Create one bibliographic record and add item.
4) Click on barcode field it will generate barcode automatically for ex: BK0001
---
cataloguing/value_builder/barcode.pl | 25 ++++++++++++++++++++
installer/data/mysql/sysprefs.sql | 1 +
installer/data/mysql/updatedatabase.pl | 7 +++++
.../en/modules/admin/preferences/cataloguing.pref | 1 +
4 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/cataloguing/value_builder/barcode.pl
b/cataloguing/value_builder/barcode.pl
index c5e1fd3..cb6abb0 100755
--- a/cataloguing/value_builder/barcode.pl
+++ b/cataloguing/value_builder/barcode.pl
@@ -60,6 +60,7 @@ sub plugin_javascript {
my ($year, $mon, $day) = split('-', C4::Dates->today('iso'));
my ($tag,$subfield) = GetMarcFromKohaField("items.barcode", '');
my ($loctag,$locsubfield) = GetMarcFromKohaField("items.homebranch",
'');
+ my ($itypetag,$itypesubfield) = GetMarcFromKohaField("items.itype", '');
my $nextnum;
my $query;
@@ -122,6 +123,30 @@ sub plugin_javascript {
\$('#' + id).val(document.f.field_value[fnum].value + '$nextnum');
}
";
+ }
+ elsif ($autoBarcodeType eq 'itypeincr') { # Generates a barcode where
itype = Itemtype, incr = incremental number
+
+ $query = "SELECT MAX(CAST(SUBSTRING(barcode,-4) AS signed)) AS number
FROM items WHERE barcode REGEXP ?";
+ my $sth = $dbh->prepare($query);
+ $sth->execute();
+ while (my ($count)= $sth->fetchrow_array) {
+ $nextnum = $count if $count;
+ $nextnum = 0 if $nextnum == 9999; # this sequence only allows for
cataloging 10000 books per month
+ warn "Existing incremental number = $nextnum" if $DEBUG;
+ }
+ $nextnum++;
+ $nextnum = sprintf("%0*d", "4",$nextnum);
+ warn "New itypeincr Barcode = $nextnum" if $DEBUG;
+ $scr = "
+ for (i=0 ; i<document.f.field_value.length ; i++) {
+ if (document.f.tag[i].value == '$itypetag' &&
document.f.subfield[i].value == '$itypesubfield') {
+ fnum = i;
+ }
+ }
+ if (\$('#' + id).val() == '' || force) {
+ \$('#' + id).val(document.f.field_value[fnum].value + '$nextnum');
+ }
+ ";
}
# default js body (if not filled by hbyymmincr)
diff --git a/installer/data/mysql/sysprefs.sql
b/installer/data/mysql/sysprefs.sql
index 2ffe2df..ad1797b 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -365,3 +365,4 @@ INSERT INTO systempreferences
(variable,value,explanation,options,type) VALUES (
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');
INSERT INTO systempreferences (variable,value,explanation,options,type)
VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report
web service.',NULL,'Integer');
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES
('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch
checked for members reservations rights','Choice');
+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');
\ No newline at end of file
diff --git a/installer/data/mysql/updatedatabase.pl
b/installer/data/mysql/updatedatabase.pl
index dbbdee3..04854ab 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5308,6 +5308,13 @@ if (C4::Context->preference("Version") <
TransformToNum($DBversion)) {
SetVersion ($DBversion);
}
+$DBversion = "3.09.00.XXX";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $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'");
+ print "Upgrade to $DBversion done (Add option to generate autoBarcode with
itemtype as prefix)\n";
+ SetVersion ($DBversion);
+}
+
=head1 FUNCTIONS
=head2 TableExists($table)
diff --git
a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
index 10e1d13..68c1820 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref
@@ -89,6 +89,7 @@ Cataloging:
incremental: generated in the form 1, 2, 3.
annual: generated in the form <year>-0001,
<year>-0002.
hbyymmincr: generated in the form <branchcode>yymm0001.
+ itypeincr: generated in the form <itemtypecode>0001.
"OFF": not generated automatically.
Display:
-
--
1.6.4.2
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/