Lines 46-51
my $borrowernumber = $input->param('borrowernumber');
Link Here
|
46 |
my $fbr = $input->param('fbr') || ''; |
46 |
my $fbr = $input->param('fbr') || ''; |
47 |
my $tbr = $input->param('tbr') || ''; |
47 |
my $tbr = $input->param('tbr') || ''; |
48 |
my $all_branches = $input->param('allbranches') || ''; |
48 |
my $all_branches = $input->param('allbranches') || ''; |
|
|
49 |
my $cancelall = $input->param('cancelall'); |
49 |
|
50 |
|
50 |
my $cancel; |
51 |
my $cancel; |
51 |
|
52 |
|
Lines 62-103
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
62 |
|
63 |
|
63 |
my $default = C4::Context->userenv->{'branch'}; |
64 |
my $default = C4::Context->userenv->{'branch'}; |
64 |
|
65 |
|
|
|
66 |
my $transfer_when_cancel_all = C4::Context->preference('TransferWhenCancelAllWaitingHolds'); |
67 |
$template->param( TransferWhenCancelAllWaitingHolds => 1 ) if $transfer_when_cancel_all; |
68 |
|
69 |
my @cancel_result; |
65 |
# if we have a return from the form we launch the subroutine CancelReserve |
70 |
# if we have a return from the form we launch the subroutine CancelReserve |
66 |
if ($item) { |
71 |
if ($item) { |
67 |
my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber ); |
72 |
my $res = cancel( $item, $borrowernumber, $fbr, $tbr ); |
68 |
# if we have a result |
73 |
push @cancel_result, $res if $res; |
69 |
if ($nextreservinfo) { |
|
|
70 |
my $borrowerinfo = GetMemberDetails( $nextreservinfo ); |
71 |
my $iteminfo = GetBiblioFromItemNumber($item); |
72 |
if ( $messages->{'transfert'} ) { |
73 |
$template->param( |
74 |
messagetransfert => $messages->{'transfert'}, |
75 |
branchname => GetBranchName($messages->{'transfert'}), |
76 |
); |
77 |
} |
78 |
|
79 |
$template->param( |
80 |
message => 1, |
81 |
nextreservnumber => $nextreservinfo, |
82 |
nextreservsurname => $borrowerinfo->{'surname'}, |
83 |
nextreservfirstname => $borrowerinfo->{'firstname'}, |
84 |
nextreservitem => $item, |
85 |
nextreservtitle => $iteminfo->{'title'}, |
86 |
waiting => ($messages->{'waiting'}) ? 1 : 0, |
87 |
); |
88 |
} |
89 |
|
90 |
# if the document is not in his homebranch location and there is not reservation after, we transfer it |
91 |
if ($fbr ne $tbr and not $nextreservinfo) { |
92 |
ModItemTransfer( $item, $fbr, $tbr ); |
93 |
} |
94 |
} |
74 |
} |
|
|
75 |
|
95 |
if ( C4::Context->preference('IndependantBranches') ) { |
76 |
if ( C4::Context->preference('IndependantBranches') ) { |
96 |
undef $all_branches; |
77 |
undef $all_branches; |
97 |
} else { |
78 |
} else { |
98 |
$template->param( all_branches_link => $input->url . '?allbranches=1&' . $input->query_string ) |
79 |
$template->param( all_branches_link => $input->url . '?allbranches=1' ) |
99 |
unless $all_branches; |
80 |
unless $all_branches; |
100 |
} |
81 |
} |
|
|
82 |
$template->param( all_branches => 1 ) if $all_branches; |
101 |
|
83 |
|
102 |
my (@reservloop, @overloop); |
84 |
my (@reservloop, @overloop); |
103 |
my ($reservcount, $overcount); |
85 |
my ($reservcount, $overcount); |
Lines 107-114
my @getreserves = $all_branches ? GetReservesForBranch() : GetReservesForBranch(
Link Here
|
107 |
my $today = Date_to_Days(&Today); |
89 |
my $today = Date_to_Days(&Today); |
108 |
foreach my $num (@getreserves) { |
90 |
foreach my $num (@getreserves) { |
109 |
next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00'); |
91 |
next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00'); |
110 |
my %getreserv; |
92 |
|
111 |
my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} ); |
93 |
my $itemnumber = $num->{'itemnumber'}; |
|
|
94 |
my $gettitle = GetBiblioFromItemNumber( $itemnumber ); |
95 |
my $borrowernum = $num->{'borrowernumber'}; |
96 |
my $holdingbranch = $gettitle->{'holdingbranch'}; |
97 |
my $homebranch = $gettitle->{'homebranch'}; |
98 |
|
99 |
if ($cancelall) { |
100 |
my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); |
101 |
push @cancel_result, $res if $res; |
102 |
next; |
103 |
} |
104 |
|
105 |
my %getreserv = ( |
106 |
itemnumber => $itemnumber, |
107 |
borrowernum => $borrowernum, |
108 |
); |
109 |
|
112 |
# fix up item type for display |
110 |
# fix up item type for display |
113 |
$gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'}; |
111 |
$gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'}; |
114 |
my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'}); |
112 |
my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'}); |
Lines 122-128
foreach my $num (@getreserves) {
Link Here
|
122 |
|
120 |
|
123 |
$getreserv{'itemtype'} = $itemtypeinfo->{'description'}; |
121 |
$getreserv{'itemtype'} = $itemtypeinfo->{'description'}; |
124 |
$getreserv{'title'} = $gettitle->{'title'}; |
122 |
$getreserv{'title'} = $gettitle->{'title'}; |
125 |
$getreserv{'itemnumber'} = $gettitle->{'itemnumber'}; |
|
|
126 |
$getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; |
123 |
$getreserv{'biblionumber'} = $gettitle->{'biblionumber'}; |
127 |
$getreserv{'barcode'} = $gettitle->{'barcode'}; |
124 |
$getreserv{'barcode'} = $gettitle->{'barcode'}; |
128 |
$getreserv{'branchname'} = GetBranchName($gettitle->{'homebranch'}); |
125 |
$getreserv{'branchname'} = GetBranchName($gettitle->{'homebranch'}); |
Lines 131-140
foreach my $num (@getreserves) {
Link Here
|
131 |
$getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; |
128 |
$getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'}; |
132 |
$getreserv{'enumchron'} = $gettitle->{'enumchron'}; |
129 |
$getreserv{'enumchron'} = $gettitle->{'enumchron'}; |
133 |
$getreserv{'copynumber'} = $gettitle->{'copynumber'}; |
130 |
$getreserv{'copynumber'} = $gettitle->{'copynumber'}; |
134 |
if ( $gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'} ) { |
131 |
if ( $homebranch ne $holdingbranch ) { |
135 |
$getreserv{'dotransfer'} = 1; |
132 |
$getreserv{'dotransfer'} = 1; |
136 |
} |
133 |
} |
137 |
$getreserv{'borrowernum'} = $getborrower->{'borrowernumber'}; |
|
|
138 |
$getreserv{'borrowername'} = $getborrower->{'surname'}; |
134 |
$getreserv{'borrowername'} = $getborrower->{'surname'}; |
139 |
$getreserv{'borrowerfirstname'} = $getborrower->{'firstname'}; |
135 |
$getreserv{'borrowerfirstname'} = $getborrower->{'firstname'}; |
140 |
$getreserv{'borrowerphone'} = $getborrower->{'phone'}; |
136 |
$getreserv{'borrowerphone'} = $getborrower->{'phone'}; |
Lines 152-157
foreach my $num (@getreserves) {
Link Here
|
152 |
|
148 |
|
153 |
} |
149 |
} |
154 |
|
150 |
|
|
|
151 |
$template->param(cancel_result => \@cancel_result) if @cancel_result; |
155 |
$template->param( |
152 |
$template->param( |
156 |
reserveloop => \@reservloop, |
153 |
reserveloop => \@reservloop, |
157 |
reservecount => $reservcount, |
154 |
reservecount => $reservcount, |
Lines 163-165
$template->param(
Link Here
|
163 |
); |
160 |
); |
164 |
|
161 |
|
165 |
output_html_with_http_headers $input, $cookie, $template->output; |
162 |
output_html_with_http_headers $input, $cookie, $template->output; |
|
|
163 |
|
164 |
exit; |
165 |
|
166 |
sub cancel { |
167 |
my ($item, $borrowernumber, $fbr, $tbr, $skip_transfers ) = @_; |
168 |
|
169 |
my $transfer = $fbr ne $tbr; # XXX && !$nextreservinfo; |
170 |
|
171 |
return if $transfer && $skip_transfers; |
172 |
|
173 |
my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber ); |
174 |
|
175 |
# if the document is not in his homebranch location and there is not reservation after, we transfer it |
176 |
if ($transfer && !$nextreservinfo) { |
177 |
ModItemTransfer( $item, $fbr, $tbr ); |
178 |
} |
179 |
# if we have a result |
180 |
if ($nextreservinfo) { |
181 |
my %res; |
182 |
my $borrowerinfo = GetMemberDetails( $nextreservinfo ); |
183 |
my $iteminfo = GetBiblioFromItemNumber($item); |
184 |
if ( $messages->{'transfert'} ) { |
185 |
$res{messagetransfert} = $messages->{'transfert'}; |
186 |
$res{branchname} = GetBranchName($messages->{'transfert'}); |
187 |
} |
188 |
|
189 |
$res{message} = 1; |
190 |
$res{nextreservnumber} = $nextreservinfo; |
191 |
$res{nextreservsurname} = $borrowerinfo->{'surname'}; |
192 |
$res{nextreservfirstname} = $borrowerinfo->{'firstname'}; |
193 |
$res{nextreservitem} = $item; |
194 |
$res{nextreservtitle} = $iteminfo->{'title'}; |
195 |
$res{waiting} = $messages->{'waiting'} ? 1 : 0; |
196 |
|
197 |
return \%res; |
198 |
} |
199 |
|
200 |
return; |
201 |
} |