[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha fixBranches.pl,NONE,1.1
From: |
Finlay Thompson |
Subject: |
[Koha-cvs] CVS: koha fixBranches.pl,NONE,1.1 |
Date: |
Tue, 20 Aug 2002 19:42:56 -0700 |
Update of /cvsroot/koha/koha
In directory usw-pr-cvs1:/tmp/cvs-serv19714
Added Files:
fixBranches.pl
Log Message:
A little script for performing changes to the branch fields on items. This
script runs over the database.
--- NEW FILE ---
#!/usr/bin/perl
# script to fix all the branch settings in the items table of the koha database.
use strict;
use DBI;
use C4::Database;
# This script makes the following substitutions.
# on homebranch field:
my $home_default = 'C';
my %home = ( 'F' => 'FP' ,
'FM' => 'FP' ,
'M' => 'C' ,
'P' => 'C' ,
'S' => 'SP' ,
'T' => 'C' ,
'TR' => 'C' ,
'I' => 'C' ,
'D' => 'C' ,
'L' => 'LP' ,
'FP' => 'FP' ,
'SP' => 'SP' ,
'LP' => 'LP' ,
'C' => 'C' );
# on holdingbranch field:
my $hold_default = 'L';
my %hold = ( 'F' => 'F' ,
'FM' => 'FM' ,
'M' => 'M' ,
'P' => 'P' ,
'S' => 'S' ,
'T' => 'T' ,
'TR' => 'TR' ,
'I' => 'I' ,
'D' => 'D' ,
'L' => 'L' ,
'FP' => 'F' ,
'C' => 'L' ,
'SP' => 'S' ,
'LP' => 'L' );
# do the substitutions.....
my $dbh = &C4Connect;
my $sth = $dbh->prepare("SELECT barcode, holdingbranch, homebranch FROM items");
$sth->execute();
my $today = localtime(time());
print "Output from fixBranches.pl $today \n\n";
while (my $item = $sth->fetchrow_hashref) {
my $oldhold = $item->{'holdingbranch'};
my $newhold = $hold{$oldhold} ? $hold{$oldhold} : $hold_default ;
if ($oldhold ne $newhold) {
my $uth = $dbh->prepare("UPDATE items SET holdingbranch = ? WHERE
barcode = ?");
$uth->execute($newhold, $item->{'barcode'});
print "$item->{'barcode'} : Holding branch setting changed from
$oldhold -> $newhold \n";
$uth->finish;
}
my $oldhome = $item->{'homebranch'};
my $newhome = $home{$oldhome} ? $home{$oldhome} : $home_default ;
if ($oldhome ne $newhome) {
my $uth = $dbh->prepare("UPDATE items SET homebranch = ? WHERE barcode
= ?");
$uth->execute($newhome, $item->{'barcode'});
print "$item->{'barcode'} : Home branch setting changed from $oldhome
-> $newhome \n";
$uth->finish;
}
}
print "\nFinished output from fixbranches.pl\n";
$dbh->disconnect;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha fixBranches.pl,NONE,1.1,
Finlay Thompson <=
- Prev by Date:
[Koha-cvs] CVS: koha/circ circulation.pl,1.39,1.40
- Next by Date:
[Koha-cvs] CVS: koha placerequest.pl,1.2,1.3 request.pl,1.9,1.10
- Previous by thread:
[Koha-cvs] CVS: koha/circ circulation.pl,1.39,1.40
- Next by thread:
[Koha-cvs] CVS: koha placerequest.pl,1.2,1.3 request.pl,1.9,1.10
- Index(es):