|
Lines 19-24
Link Here
|
| 19 |
|
19 |
|
| 20 |
|
20 |
|
| 21 |
use strict; |
21 |
use strict; |
|
|
22 |
use warnings; |
| 22 |
|
23 |
|
| 23 |
use CGI; |
24 |
use CGI; |
| 24 |
|
25 |
|
|
Lines 74-80
my ($template, $borrowernumber, $cookie) = get_template_and_user({
Link Here
|
| 74 |
flagsrequired => {reports => '*'}, |
75 |
flagsrequired => {reports => '*'}, |
| 75 |
debug => 0, |
76 |
debug => 0, |
| 76 |
}); |
77 |
}); |
| 77 |
our $sep = $input->param("sep"); |
78 |
our $sep = $input->param("sep") || ''; |
| 78 |
$sep = "\t" if ($sep eq 'tabulation'); |
79 |
$sep = "\t" if ($sep eq 'tabulation'); |
| 79 |
$template->param(do_it => $do_it, |
80 |
$template->param(do_it => $do_it, |
| 80 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
81 |
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), |
|
Lines 169-174
my $CGIsepChoice=GetDelimiterChoices;
Link Here
|
| 169 |
$template->param( |
170 |
$template->param( |
| 170 |
categoryloop => $categoryloop, |
171 |
categoryloop => $categoryloop, |
| 171 |
itemtypeloop => \@itemtypeloop, |
172 |
itemtypeloop => \@itemtypeloop, |
|
|
173 |
locationloop => \@locations, |
| 172 |
ccodeloop => \@ccodes, |
174 |
ccodeloop => \@ccodes, |
| 173 |
branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}), |
175 |
branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'}), |
| 174 |
hassort1=> $hassort1, |
176 |
hassort1=> $hassort1, |
|
Lines 194-211
sub calculate {
Link Here
|
| 194 |
# Filters |
196 |
# Filters |
| 195 |
# Checking filters |
197 |
# Checking filters |
| 196 |
# |
198 |
# |
| 197 |
my @loopfilter; |
199 |
my @loopfilter; |
| 198 |
foreach my $filter (keys %$filters_hashref){ |
200 |
foreach my $filter ( keys %$filters_hashref ) { |
| 199 |
$$filters_hashref{$filter} =~s/\*/%/; |
201 |
$filters_hashref->{$filter} =~ s/\*/%/; |
| 200 |
$$filters_hashref{$filter} = format_date_in_iso($$filters_hashref{$_}) if ($_=~/date/); |
202 |
$filters_hashref->{$filter} = |
| 201 |
} |
203 |
format_date_in_iso( $filters_hashref->{$filter} ) |
| 202 |
#display |
204 |
if ( $filter =~ /date/ ); |
| 203 |
@loopfilter= map{{ crit=>$_ ,filter=>($_=~/date/? |
205 |
} |
| 204 |
format_date($$filters_hashref{$_}) |
206 |
|
| 205 |
:$$filters_hashref{$_} |
207 |
#display |
| 206 |
) |
208 |
@loopfilter = map { |
| 207 |
} |
209 |
{ |
| 208 |
} sort keys %$filters_hashref; |
210 |
crit => $_, |
|
|
211 |
filter => ( |
| 212 |
$_ =~ /date/ |
| 213 |
? format_date( $filters_hashref->{$_} ) |
| 214 |
: $filters_hashref->{$_} |
| 215 |
) |
| 216 |
} |
| 217 |
} sort keys %$filters_hashref; |
| 209 |
|
218 |
|
| 210 |
|
219 |
|
| 211 |
|
220 |
|
|
Lines 228-234
sub calculate {
Link Here
|
| 228 |
if ($linefield =~ /^biblio\./ or $colfield =~ /^biblio\./ or any {$_=~/biblio/}keys %$filters_hashref); |
237 |
if ($linefield =~ /^biblio\./ or $colfield =~ /^biblio\./ or any {$_=~/biblio/}keys %$filters_hashref); |
| 229 |
$strcalc .= "LEFT JOIN items ON reserves.itemnumber=items.itemnumber " |
238 |
$strcalc .= "LEFT JOIN items ON reserves.itemnumber=items.itemnumber " |
| 230 |
if ($linefield =~ /^items\./ or $colfield =~ /^items\./ or any {$_=~/items/}keys %$filters_hashref); |
239 |
if ($linefield =~ /^items\./ or $colfield =~ /^items\./ or any {$_=~/items/}keys %$filters_hashref); |
| 231 |
|
240 |
|
| 232 |
my @sqlparams; |
241 |
my @sqlparams; |
| 233 |
my @sqlorparams; |
242 |
my @sqlorparams; |
| 234 |
my @sqlor; |
243 |
my @sqlor; |
|
Lines 238-244
sub calculate {
Link Here
|
| 238 |
my $string; |
247 |
my $string; |
| 239 |
my $stringfield=$filter; |
248 |
my $stringfield=$filter; |
| 240 |
$stringfield=~s/\_[a-z_]+$//; |
249 |
$stringfield=~s/\_[a-z_]+$//; |
| 241 |
warn $stringfield; |
|
|
| 242 |
if ($filter=~/ /){ |
250 |
if ($filter=~/ /){ |
| 243 |
$string=$stringfield; |
251 |
$string=$stringfield; |
| 244 |
} |
252 |
} |
|
Lines 246-251
sub calculate {
Link Here
|
| 246 |
push @sqlor, qq{( }.changeifreservestatus($filter)." = ? ) "; |
254 |
push @sqlor, qq{( }.changeifreservestatus($filter)." = ? ) "; |
| 247 |
push @sqlorparams, $$filters_hashref{$filter}; |
255 |
push @sqlorparams, $$filters_hashref{$filter}; |
| 248 |
} |
256 |
} |
|
|
257 |
elsif ($filter=~/_endex$/){ |
| 258 |
$string = " $stringfield < ? "; |
| 259 |
} |
| 249 |
elsif ($filter=~/_end$/){ |
260 |
elsif ($filter=~/_end$/){ |
| 250 |
$string = " $stringfield <= ? "; |
261 |
$string = " $stringfield <= ? "; |
| 251 |
} |
262 |
} |
|
Lines 274-280
sub calculate {
Link Here
|
| 274 |
$dbcalc->execute(@sqlparams,@sqlparams); |
285 |
$dbcalc->execute(@sqlparams,@sqlparams); |
| 275 |
my ($emptycol,$emptyrow); |
286 |
my ($emptycol,$emptyrow); |
| 276 |
my $data = $dbcalc->fetchall_hashref([qw(line col)]); |
287 |
my $data = $dbcalc->fetchall_hashref([qw(line col)]); |
| 277 |
my @loopline; |
|
|
| 278 |
my %cols_hash; |
288 |
my %cols_hash; |
| 279 |
foreach my $row (keys %$data){ |
289 |
foreach my $row (keys %$data){ |
| 280 |
push @loopline, $row; |
290 |
push @loopline, $row; |
|
Lines 304-317
sub calculate {
Link Here
|
| 304 |
for my $col ( sort keys %cols_hash ) { |
314 |
for my $col ( sort keys %cols_hash ) { |
| 305 |
my $total = 0; |
315 |
my $total = 0; |
| 306 |
foreach my $row (@loopline) { |
316 |
foreach my $row (@loopline) { |
| 307 |
$total += $$data{$row}{$col}{calculation}; |
317 |
$total += $data->{$row}{$col}{calculation} if $data->{$row}{$col}{calculation}; |
| 308 |
$debug and warn "value added ".$$data{$row}{$col}{calculation}. "for line ".$row; |
318 |
$debug and warn "value added ".$$data{$row}{$col}{calculation}. "for line ".$row; |
| 309 |
} |
319 |
} |
| 310 |
push @loopfooter, {'totalcol' => $total}; |
320 |
push @loopfooter, {'totalcol' => $total}; |
| 311 |
push @loopcol, {'coltitle' => $col, |
321 |
push @loopcol, {'coltitle' => $col, |
| 312 |
coltitle_display=>display_value($colfield,$col)}; |
322 |
coltitle_display=>display_value($colfield,$col)}; |
| 313 |
} |
323 |
} |
| 314 |
|
|
|
| 315 |
# the header of the table |
324 |
# the header of the table |
| 316 |
$globalline{loopfilter}=\@loopfilter; |
325 |
$globalline{loopfilter}=\@loopfilter; |
| 317 |
# the core of the table |
326 |
# the core of the table |
|
Lines 331-352
sub null_to_zzempty ($) {
Link Here
|
| 331 |
($string eq "NULL") and return 'zzEMPTY'; |
340 |
($string eq "NULL") and return 'zzEMPTY'; |
| 332 |
return $string; # else return the valid value |
341 |
return $string; # else return the valid value |
| 333 |
} |
342 |
} |
| 334 |
sub display_value{ |
343 |
sub display_value { |
| 335 |
my ($crit,$value)=@_; |
344 |
my ( $crit, $value ) = @_; |
| 336 |
my $display_value = |
345 |
my $display_value = |
| 337 |
($crit =~ /ccode/ ) ? $ccodes->{$value} : |
346 |
( $crit =~ /ccode/ ) ? $ccodes->{$value} |
| 338 |
($crit =~ /location/) ? $locations->{$value} : |
347 |
: ( $crit =~ /location/ ) ? $locations->{$value} |
| 339 |
($crit =~ /itemtype/) ? $itemtypes->{$value}->{description} : |
348 |
: ( $crit =~ /itemtype/ ) ? $itemtypes->{$value}->{description} |
| 340 |
($crit =~ /branch/) ? GetBranchName($value): |
349 |
: ( $crit =~ /branch/ ) ? GetBranchName($value) |
| 341 |
($crit =~ /reservestatus/) ? reservestatushuman($value): |
350 |
: ( $crit =~ /reservestatus/ ) ? reservestatushuman($value) |
| 342 |
$value; # default fallback |
351 |
: $value; # default fallback |
| 343 |
if ($crit =~ /(sort1|sort2)/) { |
352 |
if ($crit =~ /sort1/) { |
| 344 |
$display_value=GetAuthorisedValues("B$_",$value); |
353 |
foreach (@$Bsort1) { |
| 345 |
} elsif ($crit =~ /category/) { |
354 |
($value eq $_->{authorised_value}) or next; |
| 346 |
my $element=any{$value eq $_->{categorycode}} @$categoryloop; |
355 |
$display_value = $_->{lib} and last; |
| 347 |
$display_value=$$element{description}; |
356 |
} |
| 348 |
} |
357 |
} |
| 349 |
return $display_value; |
358 |
elsif ($crit =~ /sort2/) { |
|
|
359 |
foreach (@$Bsort2) { |
| 360 |
($value eq $_->{authorised_value}) or next; |
| 361 |
$display_value = $_->{lib} and last; |
| 362 |
} |
| 363 |
} |
| 364 |
elsif ( $crit =~ /category/ ) { |
| 365 |
foreach (@$categoryloop) { |
| 366 |
( $value eq $_->{categorycode} ) or next; |
| 367 |
$display_value = $_->{description} and last; |
| 368 |
} |
| 369 |
} |
| 370 |
return $display_value; |
| 350 |
} |
371 |
} |
| 351 |
sub reservestatushuman{ |
372 |
sub reservestatushuman{ |
| 352 |
my ($val)=@_; |
373 |
my ($val)=@_; |
| 353 |
- |
|
|