|
Lines 104-109
elsif ( $phase eq 'Build new' ) {
Link Here
|
| 104 |
'usecache' => $usecache, |
104 |
'usecache' => $usecache, |
| 105 |
'cache_expiry' => 300, |
105 |
'cache_expiry' => 300, |
| 106 |
'public' => '0', |
106 |
'public' => '0', |
|
|
107 |
'combine_params' => '0', |
| 107 |
); |
108 |
); |
| 108 |
} elsif ( $phase eq 'Use saved' ) { |
109 |
} elsif ( $phase eq 'Use saved' ) { |
| 109 |
|
110 |
|
|
Lines 122-127
elsif ( $phase eq 'Build new' ) {
Link Here
|
| 122 |
notes => $report->{notes}, |
123 |
notes => $report->{notes}, |
| 123 |
public => $report->{public}, |
124 |
public => $report->{public}, |
| 124 |
cache_expiry => $report->{cache_expiry}, |
125 |
cache_expiry => $report->{cache_expiry}, |
|
|
126 |
combine_params => $report->{combine_params}, |
| 125 |
} |
127 |
} |
| 126 |
); |
128 |
); |
| 127 |
$template->param( report_converted => $report->{report_name} ); |
129 |
$template->param( report_converted => $report->{report_name} ); |
|
Lines 194-199
elsif ( $phase eq 'Edit SQL'){
Link Here
|
| 194 |
'notes' => $report->{notes}, |
196 |
'notes' => $report->{notes}, |
| 195 |
'id' => $id, |
197 |
'id' => $id, |
| 196 |
'cache_expiry' => $report->{cache_expiry}, |
198 |
'cache_expiry' => $report->{cache_expiry}, |
|
|
199 |
'combine_params' => $report->{combine_params}, |
| 197 |
'public' => $report->{public}, |
200 |
'public' => $report->{public}, |
| 198 |
'usecache' => $usecache, |
201 |
'usecache' => $usecache, |
| 199 |
'editsql' => 1, |
202 |
'editsql' => 1, |
|
Lines 208-213
elsif ( $phase eq 'Update SQL'){
Link Here
|
| 208 |
my $subgroup = $input->param('subgroup'); |
211 |
my $subgroup = $input->param('subgroup'); |
| 209 |
my $notes = $input->param('notes'); |
212 |
my $notes = $input->param('notes'); |
| 210 |
my $cache_expiry = $input->param('cache_expiry'); |
213 |
my $cache_expiry = $input->param('cache_expiry'); |
|
|
214 |
my $combine_params = $input->param('combine_params'); |
| 211 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
215 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
| 212 |
my $public = $input->param('public'); |
216 |
my $public = $input->param('public'); |
| 213 |
my $save_anyway = $input->param('save_anyway'); |
217 |
my $save_anyway = $input->param('save_anyway'); |
|
Lines 259-264
elsif ( $phase eq 'Update SQL'){
Link Here
|
| 259 |
'subgroup' => $subgroup, |
263 |
'subgroup' => $subgroup, |
| 260 |
'notes' => $notes, |
264 |
'notes' => $notes, |
| 261 |
'public' => $public, |
265 |
'public' => $public, |
|
|
266 |
'combine_params' => $combine_params, |
| 262 |
'problematic_authvals' => $problematic_authvals, |
267 |
'problematic_authvals' => $problematic_authvals, |
| 263 |
'warn_authval_problem' => 1, |
268 |
'warn_authval_problem' => 1, |
| 264 |
'phase_update' => 1 |
269 |
'phase_update' => 1 |
|
Lines 274-279
elsif ( $phase eq 'Update SQL'){
Link Here
|
| 274 |
notes => $notes, |
279 |
notes => $notes, |
| 275 |
public => $public, |
280 |
public => $public, |
| 276 |
cache_expiry => $cache_expiry, |
281 |
cache_expiry => $cache_expiry, |
|
|
282 |
combine_params => $combine_params, |
| 277 |
} ); |
283 |
} ); |
| 278 |
$template->param( |
284 |
$template->param( |
| 279 |
'save_successful' => 1, |
285 |
'save_successful' => 1, |
|
Lines 305-310
elsif ($phase eq 'retrieve results') {
Link Here
|
| 305 |
elsif ( $phase eq 'Report on this Area' ) { |
311 |
elsif ( $phase eq 'Report on this Area' ) { |
| 306 |
my $cache_expiry_units = $input->param('cache_expiry_units'), |
312 |
my $cache_expiry_units = $input->param('cache_expiry_units'), |
| 307 |
my $cache_expiry = $input->param('cache_expiry'); |
313 |
my $cache_expiry = $input->param('cache_expiry'); |
|
|
314 |
my $combine_params = $input->param('combine_params'); |
| 308 |
|
315 |
|
| 309 |
# we need to handle converting units |
316 |
# we need to handle converting units |
| 310 |
if( $cache_expiry_units eq "minutes" ){ |
317 |
if( $cache_expiry_units eq "minutes" ){ |
|
Lines 322-327
elsif ( $phase eq 'Report on this Area' ) {
Link Here
|
| 322 |
'build1' => 1, |
329 |
'build1' => 1, |
| 323 |
'areas' => get_report_areas(), |
330 |
'areas' => get_report_areas(), |
| 324 |
'cache_expiry' => $cache_expiry, |
331 |
'cache_expiry' => $cache_expiry, |
|
|
332 |
'combine_params' => $combine_params, |
| 325 |
'usecache' => $usecache, |
333 |
'usecache' => $usecache, |
| 326 |
'public' => scalar $input->param('public'), |
334 |
'public' => scalar $input->param('public'), |
| 327 |
); |
335 |
); |
|
Lines 332-337
elsif ( $phase eq 'Report on this Area' ) {
Link Here
|
| 332 |
'area' => scalar $input->param('area'), |
340 |
'area' => scalar $input->param('area'), |
| 333 |
'types' => get_report_types(), |
341 |
'types' => get_report_types(), |
| 334 |
'cache_expiry' => $cache_expiry, |
342 |
'cache_expiry' => $cache_expiry, |
|
|
343 |
'combine_params' => $combine_params, |
| 335 |
'public' => scalar $input->param('public'), |
344 |
'public' => scalar $input->param('public'), |
| 336 |
); |
345 |
); |
| 337 |
} |
346 |
} |
|
Lines 348-353
elsif ( $phase eq 'Choose this type' ) {
Link Here
|
| 348 |
'type' => $type, |
357 |
'type' => $type, |
| 349 |
columns => get_columns($area,$input), |
358 |
columns => get_columns($area,$input), |
| 350 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
359 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
|
|
360 |
'combine_params' => scalar $input->param('combine_params'), |
| 351 |
'public' => scalar $input->param('public'), |
361 |
'public' => scalar $input->param('public'), |
| 352 |
); |
362 |
); |
| 353 |
} |
363 |
} |
|
Lines 372-377
elsif ( $phase eq 'Choose these columns' ) {
Link Here
|
| 372 |
if ( $usecache ) { |
382 |
if ( $usecache ) { |
| 373 |
$template->param( |
383 |
$template->param( |
| 374 |
cache_expiry => scalar $input->param('cache_expiry'), |
384 |
cache_expiry => scalar $input->param('cache_expiry'), |
|
|
385 |
combine_params => scalar $input->param('combine_params'), |
| 375 |
cache_expiry_units => scalar $input->param('cache_expiry_units'), |
386 |
cache_expiry_units => scalar $input->param('cache_expiry_units'), |
| 376 |
); |
387 |
); |
| 377 |
} |
388 |
} |
|
Lines 433-438
elsif ( $phase eq 'Choose these criteria' ) {
Link Here
|
| 433 |
'definition' => $definition, |
444 |
'definition' => $definition, |
| 434 |
'criteriastring' => $query_criteria, |
445 |
'criteriastring' => $query_criteria, |
| 435 |
'public' => scalar $input->param('public'), |
446 |
'public' => scalar $input->param('public'), |
|
|
447 |
'combine_params' => scalar $input->param('combine_params'), |
| 436 |
); |
448 |
); |
| 437 |
if ( $usecache ) { |
449 |
if ( $usecache ) { |
| 438 |
$template->param( |
450 |
$template->param( |
|
Lines 480-485
elsif ( $phase eq 'Choose these operations' ) {
Link Here
|
| 480 |
'totals' => $totals, |
492 |
'totals' => $totals, |
| 481 |
'definition' => $definition, |
493 |
'definition' => $definition, |
| 482 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
494 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
|
|
495 |
'combine_params' => scalar $input->param('combine_params'), |
| 483 |
'public' => scalar $input->param('public'), |
496 |
'public' => scalar $input->param('public'), |
| 484 |
); |
497 |
); |
| 485 |
|
498 |
|
|
Lines 533-538
elsif ( $phase eq 'Build report' ) {
Link Here
|
| 533 |
'sql' => $sql, |
546 |
'sql' => $sql, |
| 534 |
'type' => $type, |
547 |
'type' => $type, |
| 535 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
548 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
|
|
549 |
'combine_params' => scalar $input->param('combine_params'), |
| 536 |
'public' => scalar $input->param('public'), |
550 |
'public' => scalar $input->param('public'), |
| 537 |
); |
551 |
); |
| 538 |
} |
552 |
} |
|
Lines 548-553
elsif ( $phase eq 'Save' ) {
Link Here
|
| 548 |
'sql' => $sql, |
562 |
'sql' => $sql, |
| 549 |
'type' => $type, |
563 |
'type' => $type, |
| 550 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
564 |
'cache_expiry' => scalar $input->param('cache_expiry'), |
|
|
565 |
'combine_params' => scalar $input->param('combine_params'), |
| 551 |
'public' => scalar $input->param('public'), |
566 |
'public' => scalar $input->param('public'), |
| 552 |
'groups_with_subgroups' => groups_with_subgroups($area), # in case we have a report group that matches area |
567 |
'groups_with_subgroups' => groups_with_subgroups($area), # in case we have a report group that matches area |
| 553 |
); |
568 |
); |
|
Lines 563-568
elsif ( $phase eq 'Save Report' ) {
Link Here
|
| 563 |
my $type = $input->param('types'); |
578 |
my $type = $input->param('types'); |
| 564 |
my $notes = $input->param('notes'); |
579 |
my $notes = $input->param('notes'); |
| 565 |
my $cache_expiry = $input->param('cache_expiry'); |
580 |
my $cache_expiry = $input->param('cache_expiry'); |
|
|
581 |
my $combine_params = $input->param('combine_params'), |
| 566 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
582 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
| 567 |
my $public = $input->param('public'); |
583 |
my $public = $input->param('public'); |
| 568 |
my $save_anyway = $input->param('save_anyway'); |
584 |
my $save_anyway = $input->param('save_anyway'); |
|
Lines 601-606
elsif ( $phase eq 'Save Report' ) {
Link Here
|
| 601 |
'type' => $type, |
617 |
'type' => $type, |
| 602 |
'notes' => $notes, |
618 |
'notes' => $notes, |
| 603 |
'cache_expiry' => $cache_expiry, |
619 |
'cache_expiry' => $cache_expiry, |
|
|
620 |
'combine_params' => $combine_params, |
| 604 |
'public' => $public, |
621 |
'public' => $public, |
| 605 |
); |
622 |
); |
| 606 |
} else { |
623 |
} else { |
|
Lines 619-624
elsif ( $phase eq 'Save Report' ) {
Link Here
|
| 619 |
'type' => $type, |
636 |
'type' => $type, |
| 620 |
'notes' => $notes, |
637 |
'notes' => $notes, |
| 621 |
'public' => $public, |
638 |
'public' => $public, |
|
|
639 |
'combine_params' => $combine_params, |
| 622 |
'problematic_authvals' => $problematic_authvals, |
640 |
'problematic_authvals' => $problematic_authvals, |
| 623 |
'warn_authval_problem' => 1, |
641 |
'warn_authval_problem' => 1, |
| 624 |
'phase_save' => 1 |
642 |
'phase_save' => 1 |
|
Lines 641-646
elsif ( $phase eq 'Save Report' ) {
Link Here
|
| 641 |
type => $type, |
659 |
type => $type, |
| 642 |
notes => $notes, |
660 |
notes => $notes, |
| 643 |
cache_expiry => $cache_expiry, |
661 |
cache_expiry => $cache_expiry, |
|
|
662 |
combine_params => $combine_params, |
| 644 |
public => $public, |
663 |
public => $public, |
| 645 |
} ); |
664 |
} ); |
| 646 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
665 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
|
Lines 659-664
elsif ($phase eq 'Run this report'){
Link Here
|
| 659 |
my $offset = 0; |
678 |
my $offset = 0; |
| 660 |
my $report_id = $input->param('reports'); |
679 |
my $report_id = $input->param('reports'); |
| 661 |
my @sql_params = $input->multi_param('sql_params'); |
680 |
my @sql_params = $input->multi_param('sql_params'); |
|
|
681 |
my @param_name = $input->multi_param('param_name'); |
| 682 |
my @param_value = $input->multi_param('param_value'); |
| 683 |
my %lookup; |
| 684 |
@lookup{@param_name} = @param_value; |
| 685 |
|
| 662 |
# offset algorithm |
686 |
# offset algorithm |
| 663 |
if ($input->param('page')) { |
687 |
if ($input->param('page')) { |
| 664 |
$offset = ($input->param('page') - 1) * $limit; |
688 |
$offset = ($input->param('page') - 1) * $limit; |
|
Lines 669-679
elsif ($phase eq 'Run this report'){
Link Here
|
| 669 |
'report_id' => $report_id, |
693 |
'report_id' => $report_id, |
| 670 |
); |
694 |
); |
| 671 |
|
695 |
|
| 672 |
my ( $sql, $original_sql, $type, $name, $notes ); |
696 |
my ( $sql, $original_sql, $type, $name, $notes, $combine_params ); |
| 673 |
if (my $report = get_saved_report($report_id)) { |
697 |
if (my $report = get_saved_report($report_id)) { |
| 674 |
$sql = $original_sql = $report->{savedsql}; |
698 |
$sql = $original_sql = $report->{savedsql}; |
| 675 |
$name = $report->{report_name}; |
699 |
$name = $report->{report_name}; |
| 676 |
$notes = $report->{notes}; |
700 |
$notes = $report->{notes}; |
|
|
701 |
$combine_params = $report->{combine_params}; |
| 677 |
|
702 |
|
| 678 |
my @rows = (); |
703 |
my @rows = (); |
| 679 |
# if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters |
704 |
# if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters |
|
Lines 682-689
elsif ($phase eq 'Run this report'){
Link Here
|
| 682 |
my @split = split /<<|>>/,$sql; |
707 |
my @split = split /<<|>>/,$sql; |
| 683 |
my @tmpl_parameters; |
708 |
my @tmpl_parameters; |
| 684 |
my @authval_errors; |
709 |
my @authval_errors; |
|
|
710 |
my %uniq_params; |
| 685 |
for(my $i=0;$i<($#split/2);$i++) { |
711 |
for(my $i=0;$i<($#split/2);$i++) { |
| 686 |
my ($text,$authorised_value) = split /\|/,$split[$i*2+1]; |
712 |
my ($text,$authorised_value) = split /\|/,$split[$i*2+1]; |
|
|
713 |
if( defined $uniq_params{$text."|".$authorised_value} && $combine_params ){ |
| 714 |
next; |
| 715 |
} else { $uniq_params{$text."|".$authorised_value} = "$i"; } |
| 687 |
my $input; |
716 |
my $input; |
| 688 |
my $labelid; |
717 |
my $labelid; |
| 689 |
if ( not defined $authorised_value ) { |
718 |
if ( not defined $authorised_value ) { |
|
Lines 783-788
elsif ($phase eq 'Run this report'){
Link Here
|
| 783 |
'auth_val_errors' => \@authval_errors, |
812 |
'auth_val_errors' => \@authval_errors, |
| 784 |
'enter_params' => 1, |
813 |
'enter_params' => 1, |
| 785 |
'reports' => $report_id, |
814 |
'reports' => $report_id, |
|
|
815 |
'uniq_params' => \%uniq_params, |
| 786 |
); |
816 |
); |
| 787 |
} else { |
817 |
} else { |
| 788 |
# OK, we have parameters, or there are none, we run the report |
818 |
# OK, we have parameters, or there are none, we run the report |
|
Lines 791-797
elsif ($phase eq 'Run this report'){
Link Here
|
| 791 |
my @split = split /<<|>>/,$sql; |
821 |
my @split = split /<<|>>/,$sql; |
| 792 |
my @tmpl_parameters; |
822 |
my @tmpl_parameters; |
| 793 |
for(my $i=0;$i<$#split/2;$i++) { |
823 |
for(my $i=0;$i<$#split/2;$i++) { |
| 794 |
my $quoted = $sql_params[$i]; |
824 |
my $use_param = $combine_params ? $lookup{ $split[$i*2+1] } : $i; |
|
|
825 |
my $quoted = $sql_params[$use_param]; |
| 795 |
# if there are special regexp chars, we must \ them |
826 |
# if there are special regexp chars, we must \ them |
| 796 |
$split[$i*2+1] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g; |
827 |
$split[$i*2+1] =~ s/(\||\?|\.|\*|\(|\)|\%)/\\$1/g; |
| 797 |
if ($split[$i*2+1] =~ /\|\s*date\s*$/) { |
828 |
if ($split[$i*2+1] =~ /\|\s*date\s*$/) { |
|
Lines 956-961
elsif ( $phase eq 'Create report from SQL' ) {
Link Here
|
| 956 |
'groups_with_subgroups' => groups_with_subgroups($group, $subgroup), |
987 |
'groups_with_subgroups' => groups_with_subgroups($group, $subgroup), |
| 957 |
'public' => '0', |
988 |
'public' => '0', |
| 958 |
'cache_expiry' => 300, |
989 |
'cache_expiry' => 300, |
|
|
990 |
'combine_params' => 0, |
| 959 |
'usecache' => $usecache, |
991 |
'usecache' => $usecache, |
| 960 |
); |
992 |
); |
| 961 |
} |
993 |
} |