Thursday, January 2, 2014

PSD Koha Circulation Barcode Modification

So I spent a few summers ago upgrading the library system to Koha.  It was actually fairly painless to do with the help of linux.  But I ran into an issue of barcodes matching at both schools.  So to eliminate that I added an e to the barcodes for the elementary.  Now to get the scanner to put the e on at the end so the librarian wouldn't have to add it manually.

Instead of making the scanner do that work I found that you can modify the Circulation file in Koha to do that work for you.  In our situation that was good since the books at the high school have added number data in the barcode as well.

So here is the location of the file:
/usr/share/koha/lib/C4/Circulation.pm

This is what I modified to get it to work:
Original:
elsif ($filter eq 'T-prefix') {
  if ($barcode =~ /^[Tt](\d)/} {
    (defined($1) and $1 eq '0') and return $barcode;
  $barcode = substr($barcode, 2) + 0;
}
return sprintf("T%07d", $barcode);

New:
if($branch eq '0762' and substr($barcode, -1) eq 'e'){
  return $barcode;}
elsif($branch eq '0135' and length($barcode) >= 6){
  $barcode = substr($barcode, 2, 5);
}
if(substr($barcode, 0, 1) eq 'T'){
  if(substr($barcode, 1, 1) eq ' '){
    $barcode = substr($barcode, 2);}
  else{$barcode = substr($barcode, 1);}
}
$barcode = substr($barcode, -5);
if($branch eq '0762'){
  return sprintf("%05de", $barcode);
} else {
  return sprintf("%05d", $barcode);
}

No comments:

Post a Comment