Lines 17-25
Link Here
|
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
19 |
|
20 |
use strict; |
20 |
use Modern::Perl; |
21 |
#use warnings; FIXME - Bug 2505 |
|
|
22 |
use CGI; |
21 |
use CGI; |
|
|
22 |
use List::MoreUtils qw/uniq/; |
23 |
|
23 |
use C4::Auth; |
24 |
use C4::Auth; |
24 |
use C4::Context; |
25 |
use C4::Context; |
25 |
use C4::Branch; # GetBranches |
26 |
use C4::Branch; # GetBranches |
Lines 60-66
my $borstat1 = $input->param("activity");
Link Here
|
60 |
my $output = $input->param("output"); |
61 |
my $output = $input->param("output"); |
61 |
my $basename = $input->param("basename"); |
62 |
my $basename = $input->param("basename"); |
62 |
our $sep = $input->param("sep"); |
63 |
our $sep = $input->param("sep"); |
63 |
$sep = "\t" if ($sep eq 'tabulation'); |
64 |
$sep = "\t" if ($sep and $sep eq 'tabulation'); |
64 |
my $selected_branch; # = $input->param("?"); |
65 |
my $selected_branch; # = $input->param("?"); |
65 |
|
66 |
|
66 |
our $branches = GetBranches; |
67 |
our $branches = GetBranches; |
Lines 75-81
my ($template, $borrowernumber, $cookie)
Link Here
|
75 |
}); |
76 |
}); |
76 |
$template->param(do_it => $do_it); |
77 |
$template->param(do_it => $do_it); |
77 |
if ($do_it) { |
78 |
if ($do_it) { |
78 |
my $results = calculate($line, $column, $digits, $borstat,$borstat1 ,\@filters); |
79 |
my $attributes; |
|
|
80 |
if (C4::Context->preference('ExtendedPatronAttributes')) { |
81 |
$attributes = parse_extended_patron_attributes($input); |
82 |
} |
83 |
my $results = calculate($line, $column, $digits, $borstat,$borstat1 ,\@filters, $attributes); |
79 |
if ($output eq "screen"){ |
84 |
if ($output eq "screen"){ |
80 |
$template->param(mainloop => $results); |
85 |
$template->param(mainloop => $results); |
81 |
output_html_with_http_headers $input, $cookie, $template->output; |
86 |
output_html_with_http_headers $input, $cookie, $template->output; |
Lines 142-148
if ($do_it) {
Link Here
|
142 |
CGIsepChoice => $CGIsepChoice, |
147 |
CGIsepChoice => $CGIsepChoice, |
143 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
148 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
144 |
); |
149 |
); |
145 |
|
150 |
if (C4::Context->preference('ExtendedPatronAttributes')) { |
|
|
151 |
$template->param(ExtendedPatronAttributes => 1); |
152 |
patron_attributes_form($template); |
153 |
} |
146 |
} |
154 |
} |
147 |
output_html_with_http_headers $input, $cookie, $template->output; |
155 |
output_html_with_http_headers $input, $cookie, $template->output; |
148 |
|
156 |
|
Lines 161-167
sub catcodes_hash() {
Link Here
|
161 |
} |
169 |
} |
162 |
|
170 |
|
163 |
sub calculate { |
171 |
sub calculate { |
164 |
my ($line, $column, $digits, $status, $activity, $filters) = @_; |
172 |
my ($line, $column, $digits, $status, $activity, $filters, $attr_filters) = @_; |
|
|
173 |
|
165 |
my @mainloop; |
174 |
my @mainloop; |
166 |
my @loopfooter; |
175 |
my @loopfooter; |
167 |
my @loopcol; |
176 |
my @loopcol; |
Lines 172-220
sub calculate {
Link Here
|
172 |
# extract parameters |
181 |
# extract parameters |
173 |
my $dbh = C4::Context->dbh; |
182 |
my $dbh = C4::Context->dbh; |
174 |
|
183 |
|
175 |
# Filters |
184 |
# Filters |
176 |
my $linefilter = ""; |
185 |
my $linefilter; |
177 |
# warn "filtres ".@filters[0]; |
186 |
given ($line) { |
178 |
# warn "filtres ".@filters[4]; |
187 |
when (/categorycode/) { $linefilter = @$filters[0] } |
179 |
# warn "filtres ".@filters[5]; |
188 |
when (/zipcode/) { $linefilter = @$filters[1] } |
180 |
# warn "filtres ".@filters[6]; |
189 |
when (/branchcode/) { $linefilter = @$filters[2] } |
181 |
|
190 |
when (/sex/) { $linefilter = @$filters[5] } |
182 |
$linefilter = @$filters[0] if ($line =~ /categorycode/ ) ; |
191 |
when (/sort1/) { $linefilter = @$filters[6] } |
183 |
$linefilter = @$filters[1] if ($line =~ /zipcode/ ) ; |
192 |
when (/sort2/) { $linefilter = @$filters[7] } |
184 |
$linefilter = @$filters[2] if ($line =~ /branchcode/ ) ; |
193 |
when (/^patron_attr\.(.*)$/) { $linefilter = $attr_filters->{$1} } |
185 |
$linefilter = @$filters[5] if ($line =~ /sex/); |
194 |
default { $linefilter = '' } |
186 |
$linefilter = @$filters[6] if ($line =~ /sort1/ ) ; |
195 |
} |
187 |
$linefilter = @$filters[7] if ($line =~ /sort2/ ) ; |
196 |
|
188 |
# |
197 |
my $colfilter; |
189 |
my $colfilter = ""; |
198 |
given ($column) { |
190 |
$colfilter = @$filters[0] if ($column =~ /categorycode/); |
199 |
when (/categorycode/) { $colfilter = @$filters[0] } |
191 |
$colfilter = @$filters[1] if ($column =~ /zipcode/); |
200 |
when (/zipcode/) { $colfilter = @$filters[1] } |
192 |
$colfilter = @$filters[2] if ($column =~ /branchcode/); |
201 |
when (/branchcode/) { $colfilter = @$filters[2] } |
193 |
$colfilter = @$filters[5] if ($column =~ /sex/); |
202 |
when (/sex/) { $colfilter = @$filters[5] } |
194 |
$colfilter = @$filters[6] if ($column =~ /sort1/); |
203 |
when (/sort1/) { $colfilter = @$filters[6] } |
195 |
$colfilter = @$filters[7] if ($column =~ /sort2/); |
204 |
when (/sort2/) { $colfilter = @$filters[7] } |
196 |
|
205 |
when (/^patron_attr\.(.*)$/) { $colfilter = $attr_filters->{$1} } |
197 |
my @loopfilter; |
206 |
default { $colfilter = '' } |
198 |
for (my $i=0;$i<=7;$i++) { |
207 |
} |
199 |
my %cell; |
208 |
|
200 |
if ( @$filters[$i] ) { |
209 |
my @loopfilter; |
201 |
if($i == 3 or $i == 4){ |
210 |
for (my $i = 0; $i <= scalar @$filters; $i++) { |
202 |
$cell{filter} .= format_date(@$filters[$i]); |
211 |
my %cell; |
203 |
}else{ |
212 |
if ( @$filters[$i] ) { |
204 |
$cell{filter} .= @$filters[$i]; |
213 |
if ($i == 3 or $i == 4) { |
205 |
} |
214 |
$cell{filter} = format_date(@$filters[$i]); |
206 |
|
215 |
} else { |
207 |
$cell{crit} .="Cat Code " if ($i==0); |
216 |
$cell{filter} = @$filters[$i]; |
208 |
$cell{crit} .="Zip Code" if ($i==1); |
217 |
} |
209 |
$cell{crit} .="Branchcode" if ($i==2); |
218 |
|
210 |
$cell{crit} .="Date of Birth" if ($i==3); |
219 |
given ($i) { |
211 |
$cell{crit} .="Date of Birth" if ($i==4); |
220 |
when (0) { $cell{crit} = "Cat code" } |
212 |
$cell{crit} .="Sex" if ($i==5); |
221 |
when (1) { $cell{crit} = "Zip code" } |
213 |
$cell{crit} .="Sort1" if ($i==6); |
222 |
when (2) { $cell{crit} = "Branch code" } |
214 |
$cell{crit} .="Sort2" if ($i==7); |
223 |
when ([3,4]) { $cell{crit} = "Date of birth" } |
215 |
push @loopfilter, \%cell; |
224 |
when (5) { $cell{crit} = "Sex" } |
216 |
} |
225 |
when (6) { $cell{crit} = "Sort1" } |
217 |
} |
226 |
when (7) { $cell{crit} = "Sort2" } |
|
|
227 |
default { $cell{crit} = "Unknown" } |
228 |
} |
229 |
push @loopfilter, \%cell; |
230 |
} |
231 |
} |
232 |
foreach my $type (keys %$attr_filters) { |
233 |
if($attr_filters->{$type}) { |
234 |
push @loopfilter, { |
235 |
crit => "Attribute $type", |
236 |
filter => $attr_filters->{$type} |
237 |
} |
238 |
} |
239 |
} |
240 |
|
218 |
($status ) and push @loopfilter,{crit=>"Status", filter=>$status }; |
241 |
($status ) and push @loopfilter,{crit=>"Status", filter=>$status }; |
219 |
($activity) and push @loopfilter,{crit=>"Activity",filter=>$activity}; |
242 |
($activity) and push @loopfilter,{crit=>"Activity",filter=>$activity}; |
220 |
push @loopfilter,{debug=>1, crit=>"Branches",filter=>join(" ", sort keys %$branches)}; |
243 |
push @loopfilter,{debug=>1, crit=>"Branches",filter=>join(" ", sort keys %$branches)}; |
Lines 224-253
sub calculate {
Link Here
|
224 |
my $newperioddate=$period_year."-".$period_month."-".$period_day; |
247 |
my $newperioddate=$period_year."-".$period_month."-".$period_day; |
225 |
# 1st, loop rows. |
248 |
# 1st, loop rows. |
226 |
my $linefield; |
249 |
my $linefield; |
227 |
if (($line =~/zipcode/) and ($digits)) { |
250 |
|
228 |
$linefield .="left($line,$digits)"; |
251 |
my $line_attribute_type; |
229 |
} else{ |
252 |
if ($line =~/^patron_attr.(.*)$/) { |
230 |
$linefield .= $line; |
253 |
$line_attribute_type = $1; |
231 |
} |
254 |
$line = 'borrower_attributes.attribute'; |
|
|
255 |
} |
256 |
|
257 |
if (($line =~/zipcode/) and ($digits)) { |
258 |
$linefield = "left($line,$digits)"; |
259 |
} else { |
260 |
$linefield = $line; |
261 |
} |
232 |
|
262 |
|
233 |
my %cathash = ($line eq 'categorycode' or $column eq 'categorycode') ? &catcodes_hash : (); |
263 |
my %cathash = ($line eq 'categorycode' or $column eq 'categorycode') ? &catcodes_hash : (); |
234 |
push @loopfilter, {debug=>1, crit=>"\%cathash", filter=>join(", ", map {$cathash{$_}} sort keys %cathash)}; |
264 |
push @loopfilter, {debug=>1, crit=>"\%cathash", filter=>join(", ", map {$cathash{$_}} sort keys %cathash)}; |
235 |
|
265 |
|
236 |
my $strsth = "SELECT distinctrow $linefield FROM borrowers WHERE $line IS NOT NULL "; |
266 |
my $strsth; |
|
|
267 |
my @strparams; # bind parameters for the query |
268 |
if ($line_attribute_type) { |
269 |
$strsth = "SELECT distinct attribute FROM borrower_attributes |
270 |
WHERE attribute IS NOT NULL AND code=?"; |
271 |
push @strparams, $line_attribute_type; |
272 |
} else { |
273 |
$strsth = "SELECT distinctrow $linefield FROM borrowers |
274 |
WHERE $line IS NOT NULL "; |
275 |
} |
276 |
|
237 |
$linefilter =~ s/\*/%/g; |
277 |
$linefilter =~ s/\*/%/g; |
238 |
if ( $linefilter ) { |
278 |
if ( $linefilter ) { |
239 |
$strsth .= " AND $linefield LIKE ? " ; |
279 |
$strsth .= " AND $linefield LIKE ? " ; |
|
|
280 |
push @strparams, $linefilter; |
240 |
} |
281 |
} |
241 |
$strsth .= " AND $status='1' " if ($status); |
282 |
$strsth .= " AND $status='1' " if ($status); |
242 |
$strsth .=" order by $linefield"; |
283 |
$strsth .=" order by $linefield"; |
243 |
|
284 |
|
244 |
push @loopfilter, {sql=>1, crit=>"Query", filter=>$strsth}; |
285 |
push @loopfilter, {sql=>1, crit=>"Query", filter=>$strsth}; |
245 |
my $sth = $dbh->prepare($strsth); |
286 |
my $sth = $dbh->prepare($strsth); |
246 |
if ( $linefilter ) { |
287 |
$sth->execute(@strparams); |
247 |
$sth->execute($linefilter); |
|
|
248 |
} else { |
249 |
$sth->execute; |
250 |
} |
251 |
while (my ($celvalue) = $sth->fetchrow) { |
288 |
while (my ($celvalue) = $sth->fetchrow) { |
252 |
my %cell; |
289 |
my %cell; |
253 |
if ($celvalue) { |
290 |
if ($celvalue) { |
Lines 261-285
sub calculate {
Link Here
|
261 |
|
298 |
|
262 |
# 2nd, loop cols. |
299 |
# 2nd, loop cols. |
263 |
my $colfield; |
300 |
my $colfield; |
|
|
301 |
|
302 |
my $column_attribute_type; |
303 |
if ($column =~/^patron_attr.(.*)$/) { |
304 |
$column_attribute_type = $1; |
305 |
$column = 'borrower_attributes.attribute'; |
306 |
} |
307 |
|
264 |
if (($column =~/zipcode/) and ($digits)) { |
308 |
if (($column =~/zipcode/) and ($digits)) { |
265 |
$colfield = "left($column,$digits)"; |
309 |
$colfield = "left($column,$digits)"; |
266 |
} else { |
310 |
} else { |
267 |
$colfield = $column; |
311 |
$colfield = $column; |
268 |
} |
312 |
} |
269 |
my $strsth2 = "select distinctrow $colfield from borrowers where $column is not null"; |
313 |
|
|
|
314 |
my $strsth2; |
315 |
my @strparams2; # bind parameters for the query |
316 |
if ($column_attribute_type) { |
317 |
$strsth2 = "SELECT DISTINCT attribute FROM borrower_attributes |
318 |
WHERE attribute IS NOT NULL AND code=?"; |
319 |
push @strparams2, $column_attribute_type; |
320 |
} else { |
321 |
$strsth2 = "SELECT DISTINCTROW $colfield FROM borrowers |
322 |
WHERE $column IS NOT NULL"; |
323 |
} |
324 |
|
270 |
if ($colfilter) { |
325 |
if ($colfilter) { |
271 |
$colfilter =~ s/\*/%/g; |
326 |
$colfilter =~ s/\*/%/g; |
272 |
$strsth2 .= " AND $colfield LIKE ? "; |
327 |
$strsth2 .= " AND $colfield LIKE ? "; |
|
|
328 |
push @strparams2, $colfield; |
273 |
} |
329 |
} |
274 |
$strsth2 .= " AND $status='1' " if ($status); |
330 |
$strsth2 .= " AND $status='1' " if ($status); |
275 |
$strsth2 .= " order by $colfield"; |
331 |
|
|
|
332 |
$strsth2 .= " order by $colfield"; |
276 |
push @loopfilter, {sql=>1, crit=>"Query", filter=>$strsth2}; |
333 |
push @loopfilter, {sql=>1, crit=>"Query", filter=>$strsth2}; |
277 |
my $sth2 = $dbh->prepare($strsth2); |
334 |
my $sth2 = $dbh->prepare($strsth2); |
278 |
if ($colfilter) { |
335 |
$sth2->execute(@strparams2); |
279 |
$sth2->execute($colfilter); |
|
|
280 |
} else { |
281 |
$sth2->execute; |
282 |
} |
283 |
while (my ($celvalue) = $sth2->fetchrow) { |
336 |
while (my ($celvalue) = $sth2->fetchrow) { |
284 |
my %cell; |
337 |
my %cell; |
285 |
if ($celvalue) { |
338 |
if ($celvalue) { |
Lines 296-310
sub calculate {
Link Here
|
296 |
# warn "init table"; |
349 |
# warn "init table"; |
297 |
foreach my $row (@loopline) { |
350 |
foreach my $row (@loopline) { |
298 |
foreach my $col ( @loopcol ) { |
351 |
foreach my $col ( @loopcol ) { |
299 |
# warn " init table : $row->{rowtitle} / $col->{coltitle} "; |
352 |
my $rowtitle = $row->{rowtitle} // ''; |
300 |
$table{$row->{rowtitle}}->{$col->{coltitle}}=0; |
353 |
my $coltitle = $row->{coltitle} // ''; |
|
|
354 |
$table{$rowtitle}->{$coltitle} = 0; |
301 |
} |
355 |
} |
302 |
$table{$row->{rowtitle}}->{totalrow}=0; |
356 |
$table{$row->{rowtitle}}->{totalrow}=0; |
303 |
$table{$row->{rowtitle}}->{rowtitle_display} = $row->{rowtitle_display}; |
357 |
$table{$row->{rowtitle}}->{rowtitle_display} = $row->{rowtitle_display}; |
304 |
} |
358 |
} |
305 |
|
359 |
|
306 |
# preparing calculation |
360 |
# preparing calculation |
307 |
my $strcalc .= "SELECT $linefield, $colfield, count( * ) FROM borrowers WHERE 1 "; |
361 |
my $strcalc; |
|
|
362 |
my @calcparams; |
363 |
$strcalc = "SELECT "; |
364 |
if ($line_attribute_type) { |
365 |
$strcalc .= " attribute_$line_attribute_type.attribute AS line_attribute, "; |
366 |
} else { |
367 |
$strcalc .= " $linefield, "; |
368 |
} |
369 |
if ($column_attribute_type) { |
370 |
$strcalc .= " attribute_$column_attribute_type.attribute AS column_attribute, "; |
371 |
} else { |
372 |
$strcalc .= " $colfield, "; |
373 |
} |
374 |
|
375 |
$strcalc .= " COUNT(*) FROM borrowers "; |
376 |
foreach my $type (keys %$attr_filters) { |
377 |
if ( |
378 |
($line_attribute_type and $line_attribute_type eq $type) |
379 |
or ($column_attribute_type and $column_attribute_type eq $type) |
380 |
or ($attr_filters->{$type}) |
381 |
) { |
382 |
$strcalc .= " LEFT JOIN borrower_attributes AS attribute_$type |
383 |
ON (borrowers.borrowernumber = attribute_$type.borrowernumber |
384 |
AND attribute_$type.code = " . $dbh->quote($type) . ") "; |
385 |
} |
386 |
} |
387 |
$strcalc .= " WHERE 1 "; |
388 |
|
308 |
@$filters[0]=~ s/\*/%/g if (@$filters[0]); |
389 |
@$filters[0]=~ s/\*/%/g if (@$filters[0]); |
309 |
$strcalc .= " AND categorycode like '" . @$filters[0] ."'" if ( @$filters[0] ); |
390 |
$strcalc .= " AND categorycode like '" . @$filters[0] ."'" if ( @$filters[0] ); |
310 |
@$filters[1]=~ s/\*/%/g if (@$filters[1]); |
391 |
@$filters[1]=~ s/\*/%/g if (@$filters[1]); |
Lines 321-333
sub calculate {
Link Here
|
321 |
$strcalc .= " AND sort1 like '" . @$filters[6] ."'" if ( @$filters[6] ); |
402 |
$strcalc .= " AND sort1 like '" . @$filters[6] ."'" if ( @$filters[6] ); |
322 |
@$filters[7]=~ s/\*/%/g if (@$filters[7]); |
403 |
@$filters[7]=~ s/\*/%/g if (@$filters[7]); |
323 |
$strcalc .= " AND sort2 like '" . @$filters[7] ."'" if ( @$filters[7] ); |
404 |
$strcalc .= " AND sort2 like '" . @$filters[7] ."'" if ( @$filters[7] ); |
|
|
405 |
|
406 |
foreach my $type (keys %$attr_filters) { |
407 |
if($attr_filters->{$type}) { |
408 |
my $filter = $attr_filters->{$type}; |
409 |
$filter =~ s/\*/%/g; |
410 |
$strcalc .= " AND attribute_$type.attribute LIKE '" . $filter . "' "; |
411 |
} |
412 |
} |
324 |
$strcalc .= " AND borrowernumber in (select distinct(borrowernumber) from old_issues where issuedate > '" . $newperioddate . "')" if ($activity eq 'active'); |
413 |
$strcalc .= " AND borrowernumber in (select distinct(borrowernumber) from old_issues where issuedate > '" . $newperioddate . "')" if ($activity eq 'active'); |
325 |
$strcalc .= " AND borrowernumber not in (select distinct(borrowernumber) from old_issues where issuedate > '" . $newperioddate . "')" if ($activity eq 'nonactive'); |
414 |
$strcalc .= " AND borrowernumber not in (select distinct(borrowernumber) from old_issues where issuedate > '" . $newperioddate . "')" if ($activity eq 'nonactive'); |
326 |
$strcalc .= " AND $status='1' " if ($status); |
415 |
$strcalc .= " AND $status='1' " if ($status); |
327 |
$strcalc .= " group by $linefield, $colfield"; |
416 |
|
|
|
417 |
$strcalc .= " GROUP BY "; |
418 |
if ($line_attribute_type) { |
419 |
$strcalc .= " line_attribute, "; |
420 |
} else { |
421 |
$strcalc .= " $linefield, "; |
422 |
} |
423 |
if ($column_attribute_type) { |
424 |
$strcalc .= " column_attribute "; |
425 |
} else { |
426 |
$strcalc .= " $colfield "; |
427 |
} |
428 |
|
328 |
push @loopfilter, {sql=>1, crit=>"Query", filter=>$strcalc}; |
429 |
push @loopfilter, {sql=>1, crit=>"Query", filter=>$strcalc}; |
329 |
my $dbcalc = $dbh->prepare($strcalc); |
430 |
my $dbcalc = $dbh->prepare($strcalc); |
330 |
$dbcalc->execute; |
431 |
(scalar(@calcparams)) ? $dbcalc->execute(@calcparams) : $dbcalc->execute(); |
331 |
|
432 |
|
332 |
my $emptycol; |
433 |
my $emptycol; |
333 |
while (my ($row, $col, $value) = $dbcalc->fetchrow) { |
434 |
while (my ($row, $col, $value) = $dbcalc->fetchrow) { |
Lines 348-359
sub calculate {
Link Here
|
348 |
#@loopcol ensures the order for columns is common with column titles |
449 |
#@loopcol ensures the order for columns is common with column titles |
349 |
# and the number matches the number of columns |
450 |
# and the number matches the number of columns |
350 |
foreach my $col ( @loopcol ) { |
451 |
foreach my $col ( @loopcol ) { |
351 |
my $value =$table{$row}->{($col->{coltitle} eq "NULL")?"zzEMPTY":$col->{coltitle}}; |
452 |
my $coltitle = $col->{coltitle} // ''; |
|
|
453 |
$coltitle = $coltitle eq "NULL" ? "zzEMPTY" : $coltitle; |
454 |
my $value =$table{$row}->{$coltitle}; |
352 |
push @loopcell, {value => $value}; |
455 |
push @loopcell, {value => $value}; |
353 |
} |
456 |
} |
354 |
push @looprow,{ |
457 |
push @looprow,{ |
355 |
'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row, |
458 |
'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row, |
356 |
'rowtitle_display' => $table{$row}->{rowtitle_display} || $row, |
459 |
'rowtitle_display' => $table{$row}->{rowtitle_display} || ($row eq "zzEMPTY" ? "NULL" : $row), |
357 |
'loopcell' => \@loopcell, |
460 |
'loopcell' => \@loopcell, |
358 |
'totalrow' => $table{$row}->{totalrow} |
461 |
'totalrow' => $table{$row}->{totalrow} |
359 |
}; |
462 |
}; |
Lines 362-368
sub calculate {
Link Here
|
362 |
foreach my $col ( @loopcol ) { |
465 |
foreach my $col ( @loopcol ) { |
363 |
my $total=0; |
466 |
my $total=0; |
364 |
foreach my $row ( @looprow ) { |
467 |
foreach my $row ( @looprow ) { |
365 |
$total += $table{($row->{rowtitle} eq "NULL")?"zzEMPTY":$row->{rowtitle}}->{($col->{coltitle} eq "NULL")?"zzEMPTY":$col->{coltitle}}; |
468 |
my $rowtitle = $row->{rowtitle} // ''; |
|
|
469 |
$rowtitle = ($rowtitle eq "NULL") ? "zzEMPTY" : $rowtitle; |
470 |
my $coltitle = $col->{coltitle} // ''; |
471 |
$coltitle = ($coltitle eq "NULL") ? "zzEMPTY" : $coltitle; |
472 |
|
473 |
$total += $table{$rowtitle}->{$coltitle} || 0; |
366 |
# warn "value added ".$table{$row->{rowtitle}}->{$col->{coltitle}}. "for line ".$row->{rowtitle}; |
474 |
# warn "value added ".$table{$row->{rowtitle}}->{$col->{coltitle}}. "for line ".$row->{rowtitle}; |
367 |
} |
475 |
} |
368 |
# warn "summ for column ".$col->{coltitle}." = ".$total; |
476 |
# warn "summ for column ".$col->{coltitle}." = ".$total; |
Lines 378-386
sub calculate {
Link Here
|
378 |
# # the foot (totals by borrower type) |
486 |
# # the foot (totals by borrower type) |
379 |
$globalline{loopfooter} = \@loopfooter; |
487 |
$globalline{loopfooter} = \@loopfooter; |
380 |
$globalline{total}= $grantotal; |
488 |
$globalline{total}= $grantotal; |
381 |
$globalline{line} = $line; |
489 |
$globalline{line} = ($line_attribute_type) ? $line_attribute_type : $line; |
382 |
$globalline{column} = $column; |
490 |
$globalline{column} = ($column_attribute_type) ? $column_attribute_type : $column; |
383 |
push @mainloop,\%globalline; |
491 |
push @mainloop,\%globalline; |
384 |
return \@mainloop; |
492 |
return \@mainloop; |
385 |
} |
493 |
} |
386 |
|
494 |
|
387 |
- |
495 |
sub parse_extended_patron_attributes { |
|
|
496 |
my ($input) = @_; |
497 |
|
498 |
my @params_names = $input->param; |
499 |
my %attr; |
500 |
foreach my $name (@params_names) { |
501 |
if ($name =~ /^Filter_patron_attr\.(.*)$/) { |
502 |
my $code = $1; |
503 |
my $value = $input->param($name); |
504 |
$attr{$code} = $value; |
505 |
} |
506 |
} |
507 |
|
508 |
return \%attr; |
509 |
} |
510 |
|
511 |
|
512 |
sub patron_attributes_form { |
513 |
my $template = shift; |
514 |
|
515 |
my @types = C4::Members::AttributeTypes::GetAttributeTypes(); |
516 |
|
517 |
my %items_by_class; |
518 |
foreach my $type (@types) { |
519 |
my $attr_type = C4::Members::AttributeTypes->fetch($type->{code}); |
520 |
my $entry = { |
521 |
class => $attr_type->class(), |
522 |
code => $attr_type->code(), |
523 |
description => $attr_type->description(), |
524 |
repeatable => $attr_type->repeatable(), |
525 |
category => $attr_type->authorised_value_category(), |
526 |
category_code => $attr_type->category_code(), |
527 |
}; |
528 |
|
529 |
my $newentry = { %$entry }; |
530 |
if ($attr_type->authorised_value_category()) { |
531 |
$newentry->{use_dropdown} = 1; |
532 |
$newentry->{auth_val_loop} = GetAuthorisedValues( |
533 |
$attr_type->authorised_value_category() |
534 |
); |
535 |
} |
536 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
537 |
} |
538 |
|
539 |
my @attribute_loop; |
540 |
foreach my $class ( sort keys %items_by_class ) { |
541 |
my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class; |
542 |
push @attribute_loop, { |
543 |
class => $class, |
544 |
items => $items_by_class{$class}, |
545 |
lib => $lib, |
546 |
}; |
547 |
} |
548 |
|
549 |
$template->param(patron_attributes => \@attribute_loop); |
550 |
|
551 |
} |