Lines 91-103
sub can_be_booked_in_advance {
Link Here
|
91 |
my $bookings_per_item_count = Koha::Bookings->search( { patron_id => $patron->borrowernumber, item_id => $item->itemnumber } )->count(); |
91 |
my $bookings_per_item_count = Koha::Bookings->search( { patron_id => $patron->borrowernumber, item_id => $item->itemnumber } )->count(); |
92 |
return { status => 'tooManyBookings', limit => $bookings_per_item, rule => 'bookings_per_item' } if defined($bookings_per_item) && $bookings_per_item <= $bookings_per_item_count; |
92 |
return { status => 'tooManyBookings', limit => $bookings_per_item, rule => 'bookings_per_item' } if defined($bookings_per_item) && $bookings_per_item <= $bookings_per_item_count; |
93 |
|
93 |
|
94 |
my $querycount = q{ |
94 |
|
95 |
SELECT count(*) AS count |
95 |
my $querycount; |
96 |
FROM bookings AS b |
96 |
if (C4::Context->preference('item-level_itypes')) { |
97 |
LEFT JOIN biblioitems AS bi ON (b.biblio_id=bi.biblionumber) |
97 |
$querycount = q{ |
98 |
WHERE b.patron_id = ? |
98 |
SELECT count(*) AS count |
99 |
AND bi.itemtype = ? |
99 |
FROM bookings AS b |
100 |
}; |
100 |
LEFT JOIN items AS i ON (b.biblio_id=i.biblionumber) |
|
|
101 |
WHERE b.patron_id = ? |
102 |
AND i.itype = ? |
103 |
}; |
104 |
} else { |
105 |
$querycount = q{ |
106 |
SELECT count(*) AS count |
107 |
FROM bookings AS b |
108 |
LEFT JOIN biblioitems AS bi ON (b.biblio_id=bi.biblionumber) |
109 |
WHERE b.patron_id = ? |
110 |
AND bi.itemtype = ? |
111 |
}; |
112 |
} |
101 |
|
113 |
|
102 |
my $sthcount = $dbh->prepare($querycount); |
114 |
my $sthcount = $dbh->prepare($querycount); |
103 |
$sthcount->execute( $patron->borrowernumber, $item->effective_itemtype ); |
115 |
$sthcount->execute( $patron->borrowernumber, $item->effective_itemtype ); |
104 |
- |
|
|