|
Lines 89-149
my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () :
Link Here
|
| 89 |
# 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 |
| 90 |
|
90 |
|
| 91 |
my $today = dt_from_string; |
91 |
my $today = dt_from_string; |
| 92 |
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay'); |
|
|
| 93 |
|
92 |
|
| 94 |
while ( my $hold = $holds->next ) { |
93 |
while ( my $hold = $holds->next ) { |
| 95 |
next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00'); |
94 |
next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00'); |
| 96 |
my $item = $hold->item; |
95 |
if ( $hold->waitingdate ) { |
| 97 |
my $patron = $hold->borrower; |
96 |
my $lastpickupdate = dt_from_string($hold->lastpickupdate); |
| 98 |
my $biblio = $item->biblio; |
|
|
| 99 |
my $holdingbranch = $item->holdingbranch; |
| 100 |
my $homebranch = $item->homebranch; |
| 101 |
my %getreserv = ( |
| 102 |
title => $biblio->title, |
| 103 |
itemnumber => $item->itemnumber, |
| 104 |
waitingdate => $hold->waitingdate, |
| 105 |
reservedate => $hold->reservedate, |
| 106 |
borrowernumber => $patron->borrowernumber, |
| 107 |
biblionumber => $biblio->biblionumber, |
| 108 |
barcode => $item->barcode, |
| 109 |
homebranch => $homebranch, |
| 110 |
holdingbranch => $item->holdingbranch, |
| 111 |
itemcallnumber => $item->itemcallnumber, |
| 112 |
enumchron => $item->enumchron, |
| 113 |
copynumber => $item->copynumber, |
| 114 |
borrowername => $patron->surname, # FIXME Let's send $patron to the template |
| 115 |
borrowerfirstname => $patron->firstname, |
| 116 |
borrowerphone => $patron->phone, |
| 117 |
lastpickupdate => $hold->lastpickupdate, |
| 118 |
); |
| 119 |
|
| 120 |
my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); |
| 121 |
$getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? |
| 122 |
$getreserv{'subtitle'} = GetRecordValue( |
| 123 |
'subtitle', |
| 124 |
GetMarcBiblio({ biblionumber => $biblio->biblionumber }), |
| 125 |
$biblio->frameworkcode); |
| 126 |
if ( $homebranch ne $holdingbranch ) { |
| 127 |
$getreserv{'dotransfer'} = 1; |
| 128 |
} |
| 129 |
|
| 130 |
$getreserv{patron} = $patron; |
| 131 |
warn $getreserv{'waitingdate'}; |
| 132 |
warn $getreserv{'lastpickupdate'}; |
| 133 |
if ( $getreserv{'waitingdate'} ) { |
| 134 |
my $lastpickupdate = dt_from_string($getreserv{'lastpickupdate'}); |
| 135 |
if ( DateTime->compare( $today, $lastpickupdate ) == 1 ) { |
97 |
if ( DateTime->compare( $today, $lastpickupdate ) == 1 ) { |
| 136 |
if ($cancelall) { |
98 |
if ($cancelall) { |
| 137 |
my $res = cancel( $item->itemnumber, $patron->borrowernumber, $item->holdingbranch, $homebranch, !$transfer_when_cancel_all ); |
99 |
my $res = cancel( $hold->item->itemnumber, $hold->borrowernumber, $hold->item->holdingbranch, $hold->item->homebranch, !$transfer_when_cancel_all ); |
| 138 |
push @cancel_result, $res if $res; |
100 |
push @cancel_result, $res if $res; |
| 139 |
next; |
101 |
next; |
| 140 |
} else { |
102 |
} else { |
| 141 |
push @overloop, \%getreserv; |
103 |
push @over_loop, $hold; |
| 142 |
$overcount++; |
|
|
| 143 |
} |
104 |
} |
| 144 |
}else{ |
105 |
}else{ |
| 145 |
push @reservloop, \%getreserv; |
106 |
push @reserve_loop, $hold; |
| 146 |
$reservcount++; |
|
|
| 147 |
} |
107 |
} |
| 148 |
} |
108 |
} |
| 149 |
} |
109 |
} |