(bug 1532) Reserves Updates Ported From Dev_Week
[koha.git] / misc / migration_tools / fix_onloan.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use  C4::Context;
5 use C4::Items;
6 use C4::Biblio;
7
8 #
9 # the items.onloan field did not exist in koha 2.2
10 # in koha 3.0, it's used to define item availability
11 # this script takes the items.onloan field
12 # and put it in the MARC::Record of the item
13 #
14
15 my $dbh=C4::Context->dbh;
16
17 # if (C4::Context->preference("marcflavour") ne "UNIMARC") {
18 #     print "this script is for UNIMARC only\n";
19 #     exit;
20 # }
21 my $rqbiblios=$dbh->prepare("SELECT biblionumber,itemnumber,onloan FROM items WHERE items.onloan IS NOT NULL");
22 $rqbiblios->execute;
23 $|=1;
24 while (my ($biblionumber,$itemnumber,$onloan)= $rqbiblios->fetchrow){
25     ModItem({onloan => "$onloan"}, $biblionumber, $itemnumber);
26     print "Onloan : $onloan for $biblionumber / $itemnumber\n";
27 }