Lines 26-32
use Koha::Items;
Link Here
|
26 |
use C4::Reserves; |
26 |
use C4::Reserves; |
27 |
use List::MoreUtils qw/uniq/; |
27 |
use List::MoreUtils qw/uniq/; |
28 |
|
28 |
|
29 |
|
|
|
30 |
my $input = new CGI; |
29 |
my $input = new CGI; |
31 |
my $op = $input->param('op') // ''; |
30 |
my $op = $input->param('op') // ''; |
32 |
my @itemnumbers; |
31 |
my @itemnumbers; |
Lines 40-78
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Link Here
|
40 |
} |
39 |
} |
41 |
); |
40 |
); |
42 |
|
41 |
|
43 |
if ($op eq "show"){ |
42 |
if ( $op eq "show" ) { |
44 |
my $filefh = $input->upload('uploadfile'); |
43 |
my $filefh = $input->upload('uploadfile'); |
45 |
my $filecontent = $input->param('filecontent'); |
44 |
my $filecontent = $input->param('filecontent'); |
46 |
my $borrowernumber = $input->param('borrowernumber'); |
45 |
my $borrowernumber = $input->param('borrowernumber'); |
47 |
my $branch = $input->param('branch'); |
46 |
my $branch = $input->param('branch'); |
48 |
my $action = $input->param('action'); |
47 |
my $action = $input->param('action'); |
49 |
my @notfoundbarcodes; |
48 |
my @notfoundbarcodes; |
50 |
|
49 |
|
51 |
my @contentlist; |
50 |
my @contentlist; |
52 |
if ($filefh){ |
51 |
if ($filefh) { |
53 |
while (my $content=<$filefh>){ |
52 |
while ( my $content = <$filefh> ) { |
54 |
$content =~ s/[\r\n]*$//; |
53 |
$content =~ s/[\r\n]*$//; |
55 |
push @contentlist, $content if $content; |
54 |
push @contentlist, $content if $content; |
56 |
} |
55 |
} |
57 |
|
56 |
|
58 |
foreach my $barcode (@contentlist) { |
57 |
foreach my $barcode (@contentlist) { |
59 |
my $item = Koha::Items->find({ barcode => $barcode }); |
58 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
60 |
if ($item) { |
59 |
if ($item) { |
61 |
push @itemnumbers,$item->itemnumber; |
60 |
push @itemnumbers, $item->itemnumber; |
62 |
} else { |
61 |
} |
|
|
62 |
else { |
63 |
push @notfoundbarcodes, $barcode; |
63 |
push @notfoundbarcodes, $barcode; |
64 |
} |
64 |
} |
65 |
} |
65 |
} |
66 |
} else { |
66 |
} |
67 |
if ( my $list=$input->param('barcodelist')){ |
67 |
else { |
68 |
push my @barcodelist, uniq( split(/\s\n/, $list) ); |
68 |
if ( my $list = $input->param('barcodelist') ) { |
|
|
69 |
push my @barcodelist, uniq( split( /\s\n/, $list ) ); |
69 |
|
70 |
|
70 |
foreach my $barcode (@barcodelist) { |
71 |
foreach my $barcode (@barcodelist) { |
71 |
|
72 |
|
72 |
my $item = Koha::Items->find({ barcode => $barcode }); |
73 |
my $item = Koha::Items->find( { barcode => $barcode } ); |
73 |
if ($item) { |
74 |
if ($item) { |
74 |
push @itemnumbers,$item->itemnumber; |
75 |
push @itemnumbers, $item->itemnumber; |
75 |
} else { |
76 |
} |
|
|
77 |
else { |
76 |
push @notfoundbarcodes, $barcode; |
78 |
push @notfoundbarcodes, $barcode; |
77 |
} |
79 |
} |
78 |
} |
80 |
} |
Lines 80-165
if ($op eq "show"){
Link Here
|
80 |
} |
82 |
} |
81 |
} |
83 |
} |
82 |
if (@notfoundbarcodes) { |
84 |
if (@notfoundbarcodes) { |
83 |
my @notfoundbarcodesloop = map{{barcode=>$_}}@notfoundbarcodes; |
85 |
my @notfoundbarcodesloop = map { { barcode => $_ } } @notfoundbarcodes; |
84 |
$template->param(notfoundbarcodes => \@notfoundbarcodesloop); |
86 |
$template->param( notfoundbarcodes => \@notfoundbarcodesloop ); |
85 |
} |
87 |
} |
86 |
my @holdloop; |
88 |
my @holdloop; |
87 |
if (@itemnumbers) { |
89 |
if (@itemnumbers) { |
88 |
foreach my $itemnumber (@itemnumbers) { |
90 |
foreach my $itemnumber (@itemnumbers) { |
89 |
my $item = Koha::Items->find({ itemnumber => $itemnumber }); |
91 |
my $item = Koha::Items->find( { itemnumber => $itemnumber } ); |
90 |
my $biblio = Koha::Biblios->find({ biblionumber => $item->biblionumber }); |
92 |
my $biblio = |
91 |
my $holdable = CanItemBeReserved($borrowernumber, $item->itemnumber)->{status}; |
93 |
Koha::Biblios->find( { biblionumber => $item->biblionumber } ); |
92 |
push @holdloop, { |
94 |
my $holdable = |
|
|
95 |
CanItemBeReserved( $borrowernumber, $item->itemnumber )->{status}; |
96 |
push @holdloop, |
97 |
{ |
93 |
'biblionumber' => $biblio->biblionumber, |
98 |
'biblionumber' => $biblio->biblionumber, |
94 |
'title' => $biblio->title, |
99 |
'title' => $biblio->title, |
95 |
'itemnumber' => $item->itemnumber, |
100 |
'itemnumber' => $item->itemnumber, |
96 |
'barcode' => $item->barcode, |
101 |
'barcode' => $item->barcode, |
97 |
'holdable' => ($action eq "cancel" || $holdable eq 'OK') ? 1 : 0, |
102 |
'holdable' => ( $action eq "cancel" || $holdable eq 'OK' ) |
98 |
}; |
103 |
? 1 |
|
|
104 |
: 0, |
105 |
}; |
99 |
} |
106 |
} |
100 |
|
107 |
|
101 |
} |
108 |
} |
102 |
my $borrower = Koha::Patrons->find({ borrowernumber => $borrowernumber }); |
109 |
my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } ); |
103 |
$template->param( |
110 |
$template->param( |
104 |
show => 1, |
111 |
show => 1, |
105 |
holdloop => \@holdloop, |
112 |
holdloop => \@holdloop, |
106 |
borrowernumber => $borrowernumber, |
113 |
borrowernumber => $borrowernumber, |
107 |
borrowersurname => $borrower->surname, |
114 |
borrowersurname => $borrower->surname, |
108 |
borrowerfirstname => $borrower->firstname, |
115 |
borrowerfirstname => $borrower->firstname, |
109 |
branch => $branch, |
116 |
branch => $branch, |
110 |
action => $action, |
117 |
action => $action, |
111 |
op => $op |
118 |
op => $op |
112 |
); |
119 |
); |
113 |
} |
120 |
} |
114 |
|
121 |
|
115 |
elsif ($op eq "result") { |
122 |
elsif ( $op eq "result" ) { |
116 |
my $branch = $input->param('branch'); |
123 |
my $branch = $input->param('branch'); |
117 |
my $borrowernumber = $input->param('borrowernumber'); |
124 |
my $borrowernumber = $input->param('borrowernumber'); |
118 |
my $action = $input->param('action'); |
125 |
my $action = $input->param('action'); |
119 |
my @itemnumbers = $input->multi_param('holdable'); |
126 |
my @itemnumbers = $input->multi_param('holdable'); |
120 |
my @holdloop; |
127 |
my @holdloop; |
121 |
foreach my $itemnumber (@itemnumbers) { |
128 |
foreach my $itemnumber (@itemnumbers) { |
122 |
if ($action eq "place") { |
129 |
if ( $action eq "place" ) { |
123 |
my $item = Koha::Items->find({ itemnumber => $itemnumber }); |
130 |
my $item = Koha::Items->find( { itemnumber => $itemnumber } ); |
124 |
my $biblionumber = $item->biblionumber; |
131 |
my $biblionumber = $item->biblionumber; |
125 |
my $biblio = Koha::Biblios->find({ biblionumber => $item->biblionumber }); |
132 |
my $biblio = |
126 |
my $reserve_id = AddReserve({ |
133 |
Koha::Biblios->find( { biblionumber => $item->biblionumber } ); |
127 |
branchcode => $branch, |
134 |
my $reserve_id = AddReserve( |
128 |
borrowernumber => $borrowernumber, |
135 |
{ |
129 |
biblionumber => $biblionumber, |
136 |
branchcode => $branch, |
130 |
itemnumber => $itemnumber |
137 |
borrowernumber => $borrowernumber, |
131 |
}); |
138 |
biblionumber => $biblionumber, |
132 |
push @holdloop, { |
139 |
itemnumber => $itemnumber |
|
|
140 |
} |
141 |
); |
142 |
push @holdloop, |
143 |
{ |
133 |
'biblionumber' => $biblio->biblionumber, |
144 |
'biblionumber' => $biblio->biblionumber, |
134 |
'title' => $biblio->title, |
145 |
'title' => $biblio->title, |
135 |
'itemnumber' => $itemnumber, |
146 |
'itemnumber' => $itemnumber, |
136 |
'barcode' => $item->barcode, |
147 |
'barcode' => $item->barcode, |
137 |
'reserve_id' => $reserve_id, |
148 |
'reserve_id' => $reserve_id, |
138 |
}; |
149 |
}; |
139 |
} else { |
150 |
} |
140 |
my $holds = Koha::Holds->search({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); |
151 |
else { |
|
|
152 |
my $holds = Koha::Holds->search( |
153 |
{ |
154 |
itemnumber => $itemnumber, |
155 |
borrowernumber => $borrowernumber |
156 |
} |
157 |
); |
141 |
if ($holds) { |
158 |
if ($holds) { |
142 |
while ( my $hold = $holds->next ) { |
159 |
while ( my $hold = $holds->next ) { |
143 |
$hold->cancel; |
160 |
$hold->cancel; |
144 |
} |
161 |
} |
145 |
|
162 |
|
146 |
push @holdloop, { |
163 |
push @holdloop, { 'itemnumber' => $itemnumber, }; |
147 |
'itemnumber' => $itemnumber, |
|
|
148 |
}; |
149 |
} |
164 |
} |
150 |
} |
165 |
} |
151 |
} |
166 |
} |
152 |
my $borrower = Koha::Patrons->find({ borrowernumber => $borrowernumber }); |
167 |
my $borrower = Koha::Patrons->find( { borrowernumber => $borrowernumber } ); |
153 |
$template->param( |
168 |
$template->param( |
154 |
result => 1, |
169 |
result => 1, |
155 |
holdloop => \@holdloop, |
170 |
holdloop => \@holdloop, |
156 |
borrowernumber => $borrowernumber, |
171 |
borrowernumber => $borrowernumber, |
157 |
borrowersurname => $borrower->surname, |
172 |
borrowersurname => $borrower->surname, |
158 |
borrowerfirstname => $borrower->firstname, |
173 |
borrowerfirstname => $borrower->firstname, |
159 |
branch => $branch, |
174 |
branch => $branch, |
160 |
cancel => $action eq "cancel" ? 1 : 0, |
175 |
cancel => $action eq "cancel" ? 1 : 0, |
161 |
place => $action eq "place" ? 1 : 0, |
176 |
place => $action eq "place" ? 1 : 0, |
162 |
op => $op |
177 |
op => $op |
163 |
); |
178 |
); |
164 |
|
179 |
|
165 |
} |
180 |
} |
166 |
- |
|
|