From ff026f1076d98123b4efc5bc8bb20db274e84c40 Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Sat, 16 Feb 2008 09:19:00 +1300 Subject: [PATCH] Adding another barcode autogeneration sequence to barcode.pl - bumped ver to 054 Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- cataloguing/value_builder/barcode.pl | 82 ++++++++++++++----- .../data/mysql/en/mandatory/sysprefs.sql | 2 +- installer/data/mysql/updatedatabase.pl | 7 ++ kohaversion.pl | 2 +- 4 files changed, 70 insertions(+), 23 deletions(-) diff --git a/cataloguing/value_builder/barcode.pl b/cataloguing/value_builder/barcode.pl index 662b7c4843..21fd1ece28 100755 --- a/cataloguing/value_builder/barcode.pl +++ b/cataloguing/value_builder/barcode.pl @@ -22,6 +22,8 @@ require Exporter; use C4::Context; +my $DEBUG = 0; + =head1 plugin_parameters : other parameters added when the plugin is called by the dopop function @@ -74,11 +76,13 @@ sub plugin_javascript { my $date = "$year"; my ($tag,$subfield) = GetMarcFromKohaField("items.barcode"); + my ($loctag,$locsubfield) = GetMarcFromKohaField("items.homebranch"); my $nextnum; my $query; + my $scr; my $autoBarcodeType = C4::Context->preference("autoBarcode"); - warn "Barcode type = $autoBarcodeType"; + warn "Barcode type = $autoBarcodeType" if $DEBUG; unless ($autoBarcodeType eq 'OFF' or !$autoBarcodeType) { if ($autoBarcodeType eq 'annual') { @@ -86,11 +90,20 @@ sub plugin_javascript { my $sth=$dbh->prepare($query); $sth->execute("$year%"); while (my ($count)= $sth->fetchrow_array) { + warn "Examining Record: $count" if $DEBUG; $nextnum = $count if $count; } $nextnum++; $nextnum = sprintf("%0*d", "4",$nextnum); $nextnum = "$year-$nextnum"; + $scr = " + for (i=0 ; iprepare($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 // "; - # don't return a value unless we have the appropriate syspref set return ($function_name,$res); } diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 23554e5f31..1185a385ca 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -11,7 +11,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonSuggestions',0,'Set to anonymous borrowernumber to enable Anonymous suggestions',NULL,'free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('authoritysep','--','Used to separate a list of authorities in a display. Usually --',10,'free'); -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','incremental|annual|OFF','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','incremental|annual|hbyymmincr|OFF','Choice'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutoLocation',0,'If ON, IP authentication is enabled, blocking access to the staff client from unauthorized IP addresses',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AutomaticItemReturn',1,'If ON, Koha will automatically set up a transfer of this item to its homebranch',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('autoMemberNum',1,'If ON, patron number is auto-calculated','','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index c11e66d60c..05c3bcbce4 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1014,6 +1014,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.054"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("UPDATE systempreferences SET options = 'incremental|annual|hbyymmincr|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' WHERE variable = 'autoBarcode';"); + print "Upgrade to $DBversion done ( Added another barcode autogeneration sequence to barcode.pl. )\n"; + SetVersion ($DBversion); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table diff --git a/kohaversion.pl b/kohaversion.pl index 10af996790..ab84da6988 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = "3.00.00.053"; + our $VERSION = "3.00.00.054"; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install -- 2.39.5