Adding another barcode autogeneration sequence to barcode.pl - bumped ver to 054
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
4ba0d87630
commit
ff026f1076
|
|
@ -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 ; 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 'incremental') {
|
||||
# not the best, two catalogers could add the same barcode easily this way :/
|
||||
|
|
@ -101,7 +114,44 @@ sub plugin_javascript {
|
|||
$nextnum = $count;
|
||||
}
|
||||
$nextnum++;
|
||||
$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';
|
||||
}
|
||||
}
|
||||
}";
|
||||
}
|
||||
|
||||
|
||||
my $res = "
|
||||
<script type=\"text/javascript\">
|
||||
//<![CDATA[
|
||||
|
|
@ -110,32 +160,22 @@ sub plugin_javascript {
|
|||
//need this?
|
||||
//}
|
||||
|
||||
// Commenting this out so that the user can enter their own text w/the script prefilling the field on-focus -fbcit
|
||||
//function Focus$function_name(subfield_managed) {
|
||||
// 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';
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//return 0;
|
||||
//}
|
||||
function Focus$function_name(subfield_managed) {";
|
||||
|
||||
function Clic$function_name(subfield_managed) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
}
|
||||
$res .= $scr;
|
||||
$res .= "
|
||||
return 0;
|
||||
}
|
||||
|
||||
function Clic$function_name(subfield_managed) {";
|
||||
|
||||
$res .= $scr;
|
||||
$res .= "
|
||||
return 0;
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
";
|
||||
|
||||
# don't return a value unless we have the appropriate syspref set
|
||||
return ($function_name,$res);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue