Lines 84-137
$template->param( all_branches => 1 ) if $all_branches;
Link Here
|
84 |
|
84 |
|
85 |
my (@reservloop, @overloop); |
85 |
my (@reservloop, @overloop); |
86 |
my ($reservcount, $overcount); |
86 |
my ($reservcount, $overcount); |
87 |
my @getreserves = $all_branches ? GetReservesForBranch() : GetReservesForBranch($default); |
87 |
# FIXME - Is priority => 0 useful? If yes it must be moved to waiting, otherwise we need to remove it from here. |
|
|
88 |
my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : ( branchcode => $default ) ) }, { order_by => ['waitingdate'] }); |
88 |
# get reserves for the branch we are logged into, or for all branches |
89 |
# get reserves for the branch we are logged into, or for all branches |
89 |
|
90 |
|
90 |
my $today = Date_to_Days(&Today); |
91 |
my $today = Date_to_Days(&Today); |
91 |
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay'); |
92 |
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay'); |
92 |
|
93 |
|
93 |
foreach my $num (@getreserves) { |
94 |
while ( my $hold = $holds->next ) { |
94 |
next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00'); |
95 |
next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00'); |
95 |
|
96 |
|
96 |
my $itemnumber = $num->{'itemnumber'}; |
97 |
my $item = $hold->item; |
97 |
my $item = Koha::Items->find( $itemnumber ); |
98 |
my $patron = $hold->borrower; |
98 |
my $biblio = $item->biblio; |
99 |
my $biblio = $item->biblio; |
99 |
my $borrowernum = $num->{'borrowernumber'}; |
|
|
100 |
my $holdingbranch = $item->holdingbranch; |
100 |
my $holdingbranch = $item->holdingbranch; |
101 |
my $homebranch = $item->homebranch; |
101 |
my $homebranch = $item->homebranch; |
102 |
|
102 |
|
103 |
my %getreserv = ( |
103 |
my %getreserv = ( |
104 |
itemnumber => $itemnumber, |
104 |
title => $biblio->title, |
105 |
borrowernum => $borrowernum, |
105 |
itemnumber => $item->itemnumber, |
|
|
106 |
waitingdate => $hold->waitingdate, |
107 |
borrowernum => $patron->borrowernumber, |
108 |
biblionumber => $biblio->biblionumber, |
109 |
barcode => $item->barcode, |
110 |
homebranch => $homebranch, |
111 |
holdingbranch => $item->holdingbranch, |
112 |
itemcallnumber => $item->itemcallnumber, |
113 |
enumchron => $item->enumchron, |
114 |
copynumber => $item->copynumber, |
115 |
borrowername => $patron->surname, # FIXME Let's send $patron to the template |
116 |
borrowerfirstname => $patron->firstname, |
117 |
borrowerphone => $patron->phone, |
106 |
); |
118 |
); |
107 |
|
119 |
|
108 |
my $patron = Koha::Patrons->find( $num->{borrowernumber} ); |
|
|
109 |
my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); |
120 |
my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); |
110 |
$getreserv{'waitingdate'} = $num->{'waitingdate'}; |
121 |
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate); |
111 |
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'}); |
|
|
112 |
my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ); |
122 |
my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ); |
113 |
|
123 |
|
114 |
$getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? |
124 |
$getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? |
115 |
$getreserv{'title'} = $biblio->title; |
|
|
116 |
$getreserv{'subtitle'} = GetRecordValue( |
125 |
$getreserv{'subtitle'} = GetRecordValue( |
117 |
'subtitle', |
126 |
'subtitle', |
118 |
GetMarcBiblio({ biblionumber => $biblio->biblionumber }), |
127 |
GetMarcBiblio({ biblionumber => $biblio->biblionumber }), |
119 |
$biblio->frameworkcode); |
128 |
$biblio->frameworkcode); |
120 |
$getreserv{'biblionumber'} = $biblio->biblionumber; |
|
|
121 |
$getreserv{'barcode'} = $item->barcode; |
122 |
$getreserv{'homebranch'} = $homebranch; |
123 |
$getreserv{'holdingbranch'} = $item->holdingbranch; |
124 |
$getreserv{'itemcallnumber'} = $item->itemcallnumber; |
125 |
$getreserv{'enumchron'} = $item->enumchron; |
126 |
$getreserv{'copynumber'} = $item->copynumber; |
127 |
if ( $homebranch ne $holdingbranch ) { |
129 |
if ( $homebranch ne $holdingbranch ) { |
128 |
$getreserv{'dotransfer'} = 1; |
130 |
$getreserv{'dotransfer'} = 1; |
129 |
} |
131 |
} |
130 |
$getreserv{'borrowername'} = $patron->surname; |
|
|
131 |
$getreserv{'borrowerfirstname'} = $patron->firstname; |
132 |
$getreserv{'borrowerphone'} = $patron->phone; |
133 |
|
132 |
|
134 |
my $borEmail = GetFirstValidEmailAddress( $borrowernum ); |
133 |
my $borEmail = $patron->first_valid_email_address; |
135 |
|
134 |
|
136 |
if ( $borEmail ) { |
135 |
if ( $borEmail ) { |
137 |
$getreserv{'borrowermail'} = $borEmail; |
136 |
$getreserv{'borrowermail'} = $borEmail; |
Lines 139-145
foreach my $num (@getreserves) {
Link Here
|
139 |
|
138 |
|
140 |
if ($today > $calcDate) { |
139 |
if ($today > $calcDate) { |
141 |
if ($cancelall) { |
140 |
if ($cancelall) { |
142 |
my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); |
141 |
my $res = cancel( $item->itemnumber, $patron->borrowernumber, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); |
143 |
push @cancel_result, $res if $res; |
142 |
push @cancel_result, $res if $res; |
144 |
next; |
143 |
next; |
145 |
} else { |
144 |
} else { |
146 |
- |
|
|