-
Notifications
You must be signed in to change notification settings - Fork 0
/
placehold.pl
75 lines (72 loc) · 2.48 KB
/
placehold.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use C4::Reserves;
use Koha::Libraries;
use Koha::Biblios;
use Koha::Patrons;
use Koha::Holds;
use KOha::Old::Holds;
use Koha::Checkouts;
use Koha::Old::Checkouts;
print "Enter a borrowernumber: ";
my $cardnumber = <>;
chop( $cardnumber );
while ( $cardnumber ){
print "\n";
my $patron = Koha::Patrons->find({ cardnumber => $cardnumber });
die "Not found" unless $patron;
warn "Found ".$patron->surname.", ".$patron->firstname;
print "\nEnter pickup branchcode: ";
my $branchcode = <>;
chop($branchcode);
my $branch = Koha::Libraries->find({ branchcode => $branchcode });
die "Branch not found" unless $branch;
print "\nEnter a biblionumber: ";
my $biblionumber = <>;
chop($biblionumber);
while ( $biblionumber ){
print "\n";
my $biblio = Koha::Biblios->find($biblionumber);
die "No biblio found" unless $biblio;
warn "Found biblio: ".$biblio->title;
my $had = Koha::Old::Checkouts->search({
issuedate => {
">" =>"2022-03-26"
},
"item.biblionumber" => $biblionumber
}, {join => 'item'});
my $has = Koha::Checkouts->search({
issuedate => {
">" =>"2022-03-26"
},
"item.biblionumber" => $biblionumber
}, {join => 'item'});
my $had_reserve = Koha::Old::Holds->search({
reservdate => { ">" => "2022-03-26" },
biblionumber => $biblionumber,
itemnumebr => undef
});
my $has_reserve = Koha::Holds->search({
reservdate => { ">" => "2022-03-26" },
biblionumber => $biblionumber,
itemnumebr => undef
});
warn "is borrowing" if $has->count > 0;
warn "has borrowed" if $had->count > 0;
warn "had reserved" if $had_reserve->count > 0;
warn "has reserved" if $has_reserve->count > 0;
unless ( $has->count > 0 || $had->count > 0 || $had_reserve->count > 0 || $has_reserve->count > 0 ){
my $reserve = C4::Reserves::AddReserve({
borrowernumber => $patron->borrowernumber,
biblionumber => $biblionumber,
reservation_date => "2022-03-26",
branchcode => $branchcode
});
warn "Reserve placed with id ".$reserve;
}
print "Another bib: ";
$biblionumber = <>;
chop($biblionumber);
}
print "Another cardnumber: ";
$cardnumber = <>;
chop($cardnumber);
}