|
Lines 81-149
if ( C4::Context->preference('IndependentBranches') ) {
Link Here
|
| 81 |
} |
81 |
} |
| 82 |
$template->param( all_branches => 1 ) if $all_branches; |
82 |
$template->param( all_branches => 1 ) if $all_branches; |
| 83 |
|
83 |
|
| 84 |
my (@reservloop, @overloop); |
84 |
my (@reserve_loop, @over_loop); |
| 85 |
my ($reservcount, $overcount); |
|
|
| 86 |
# FIXME - Is priority => 0 useful? If yes it must be moved to waiting, otherwise we need to remove it from here. |
85 |
# FIXME - Is priority => 0 useful? If yes it must be moved to waiting, otherwise we need to remove it from here. |
| 87 |
my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : ( branchcode => $default ) ) }, { order_by => ['waitingdate'] }); |
86 |
my $holds = Koha::Holds->waiting->search({ priority => 0, ( $all_branches ? () : ( branchcode => $default ) ) }, { order_by => ['waitingdate'] }); |
|
|
87 |
|
| 88 |
# get reserves for the branch we are logged into, or for all branches |
88 |
# get reserves for the branch we are logged into, or for all branches |
| 89 |
|
89 |
|
| 90 |
my $today = Date_to_Days(&Today); |
90 |
my $today = Date_to_Days(&Today); |
| 91 |
my $max_pickup_delay = C4::Context->preference('ReservesMaxPickUpDelay'); |
|
|
| 92 |
|
91 |
|
| 93 |
while ( my $hold = $holds->next ) { |
92 |
while ( my $hold = $holds->next ) { |
| 94 |
next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00'); |
93 |
next unless ($hold->waitingdate && $hold->waitingdate ne '0000-00-00'); |
| 95 |
|
94 |
|
| 96 |
my $item = $hold->item; |
|
|
| 97 |
my $patron = $hold->borrower; |
| 98 |
my $biblio = $item->biblio; |
| 99 |
my $holdingbranch = $item->holdingbranch; |
| 100 |
my $homebranch = $item->homebranch; |
| 101 |
|
| 102 |
my %getreserv = ( |
| 103 |
title => $biblio->title, |
| 104 |
itemnumber => $item->itemnumber, |
| 105 |
waitingdate => $hold->waitingdate, |
| 106 |
reservedate => $hold->reservedate, |
| 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, |
| 118 |
); |
| 119 |
|
| 120 |
my $itemtype = Koha::ItemTypes->find( $item->effective_itemtype ); |
| 121 |
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate); |
95 |
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate); |
| 122 |
my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ); |
96 |
my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ); |
| 123 |
|
97 |
|
| 124 |
$getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description? |
|
|
| 125 |
$getreserv{'subtitle'} = GetRecordValue( |
| 126 |
'subtitle', |
| 127 |
GetMarcBiblio({ biblionumber => $biblio->biblionumber }), |
| 128 |
$biblio->frameworkcode); |
| 129 |
if ( $homebranch ne $holdingbranch ) { |
| 130 |
$getreserv{'dotransfer'} = 1; |
| 131 |
} |
| 132 |
|
| 133 |
$getreserv{patron} = $patron; |
| 134 |
|
| 135 |
if ($today > $calcDate) { |
98 |
if ($today > $calcDate) { |
| 136 |
if ($cancelall) { |
99 |
if ($cancelall) { |
| 137 |
my $res = cancel( $item->itemnumber, $patron->borrowernumber, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); |
100 |
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; |
101 |
push @cancel_result, $res if $res; |
| 139 |
next; |
102 |
next; |
| 140 |
} else { |
103 |
} else { |
| 141 |
push @overloop, \%getreserv; |
104 |
push @over_loop, $hold; |
| 142 |
$overcount++; |
|
|
| 143 |
} |
105 |
} |
| 144 |
}else{ |
106 |
}else{ |
| 145 |
push @reservloop, \%getreserv; |
107 |
push @reserve_loop, $hold; |
| 146 |
$reservcount++; |
|
|
| 147 |
} |
108 |
} |
| 148 |
|
109 |
|
| 149 |
} |
110 |
} |
|
Lines 151-162
while ( my $hold = $holds->next ) {
Link Here
|
| 151 |
$template->param(cancel_result => \@cancel_result) if @cancel_result; |
112 |
$template->param(cancel_result => \@cancel_result) if @cancel_result; |
| 152 |
|
113 |
|
| 153 |
$template->param( |
114 |
$template->param( |
| 154 |
reserveloop => \@reservloop, |
115 |
reserveloop => \@reserve_loop, |
| 155 |
reservecount => $reservcount, |
116 |
reservecount => scalar @reserve_loop, |
| 156 |
overloop => \@overloop, |
117 |
overloop => \@over_loop, |
| 157 |
overcount => $overcount, |
118 |
overcount => scalar @over_loop, |
| 158 |
show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), |
119 |
show_date => output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), |
| 159 |
ReservesMaxPickUpDelay => $max_pickup_delay, |
|
|
| 160 |
tab => $tab, |
120 |
tab => $tab, |
| 161 |
); |
121 |
); |
| 162 |
|
122 |
|