Adding some indexes.
[koha.git] / misc / cronjobs / longoverdue.pl
1 #!/usr/bin/perl -w
2 #-----------------------------------
3 # Script Name: longoverdue.pl
4 # Script Version: 1.0.0
5 # Date:  2004/04/01
6 # Author:  Stephen Hedges  shedges@skemotah.com
7 # Description: set itemlost status to '2'
8 #    ("long overdue") on items more than 90
9 #    days overdue.
10 # Usage: longoverdue.pl.
11 # Revision History:
12 #    1.0.0  2004/04/01:  original version
13 #-----------------------------------
14
15 use lib '/usr/local/koha/intranet/modules/';
16
17 use strict;
18 use C4::Context;
19
20 my $dbh = C4::Context->dbh;
21
22 my $itemnos_sth=$dbh->prepare("SELECT items.itemnumber FROM issues,items WHERE items.itemnumber=issues.itemnumber AND DATE_SUB(CURDATE(),INTERVAL 90 DAY) > date_due AND returndate IS NULL AND (itemlost=0 OR itemlost IS NULL)");
23 my $put_sth=$dbh->prepare("UPDATE items SET itemlost=2 WHERE itemnumber=?");
24
25 #    get itemnumbers of items more than 90 days overdue
26 $itemnos_sth->execute();
27
28 while (my $row=$itemnos_sth->fetchrow_arrayref) {
29     my $item=$row->[0];
30
31     $put_sth->execute($item);
32     $put_sth->finish;
33 #    print "$item\n";
34 }
35
36 $itemnos_sth->finish;
37 $dbh->disconnect;