Merge branch 'master' of http://manage-gmc.dev.kohalibrary.com/koha-installer
[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 strict;
16 BEGIN {
17     # find Koha's Perl modules
18     # test carefully before changing this
19     use FindBin;
20     eval { require "$FindBin::Bin/../kohalib.pl" };
21 }
22 use C4::Context;
23
24 my $dbh = C4::Context->dbh;
25
26 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)");
27 my $put_sth=$dbh->prepare("UPDATE items SET itemlost=2 WHERE itemnumber=?");
28
29 #    get itemnumbers of items more than 90 days overdue
30 $itemnos_sth->execute();
31
32 while (my $row=$itemnos_sth->fetchrow_arrayref) {
33     my $item=$row->[0];
34
35     $put_sth->execute($item);
36     $put_sth->finish;
37 #    print "$item\n";
38 }
39
40 $itemnos_sth->finish;
41 $dbh->disconnect;