|
Lines 789-800
if ( $op eq 'run' ) {
Link Here
|
| 789 |
my $template_id = $input->param('template'); |
789 |
my $template_id = $input->param('template'); |
| 790 |
my $want_full_chart = $input->param('want_full_chart') || 0; |
790 |
my $want_full_chart = $input->param('want_full_chart') || 0; |
| 791 |
|
791 |
|
|
|
792 |
# Determine if the user is running this report too many times |
| 792 |
my @duplicate_running_report_ids; |
793 |
my @duplicate_running_report_ids; |
| 793 |
my $duplicate_running_reports_per_user_limit = C4::Context->config('duplicate_running_reports_per_user_limit'); |
794 |
my $duplicate_running_reports_per_user_limit = C4::Context->config('duplicate_running_reports_per_user_limit'); |
| 794 |
if ( $duplicate_running_reports_per_user_limit && C4::Context->userenv ) { |
795 |
if ( $duplicate_running_reports_per_user_limit && C4::Context->userenv ) { |
| 795 |
my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; |
796 |
my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; |
| 796 |
@duplicate_running_report_ids = Koha::Reports->running( { report_id => $report_id, user_id => $user_id } ); |
797 |
@duplicate_running_report_ids = Koha::Reports->running( { report_id => $report_id, user_id => $user_id } ); |
| 797 |
} |
798 |
} |
|
|
799 |
my $duplicate_running_reports_per_user_limit_exceeded = |
| 800 |
$duplicate_running_reports_per_user_limit |
| 801 |
? scalar(@duplicate_running_report_ids) >= $duplicate_running_reports_per_user_limit |
| 802 |
: 0; |
| 803 |
|
| 804 |
# Determine if the user is running too many reports in total |
| 805 |
my @total_running_report_ids; |
| 806 |
my $total_running_reports_per_user_limit = C4::Context->config('total_running_reports_per_user_limit'); |
| 807 |
if ( $total_running_reports_per_user_limit && C4::Context->userenv ) { |
| 808 |
my $user_id = C4::Context->userenv ? C4::Context->userenv->{number} : undef; |
| 809 |
@total_running_report_ids = Koha::Reports->running( { user_id => $user_id } ); |
| 810 |
} |
| 811 |
my $total_running_reports_per_user_limit_exceeded = |
| 812 |
$total_running_reports_per_user_limit |
| 813 |
? scalar(@total_running_report_ids) >= $total_running_reports_per_user_limit |
| 814 |
: 0; |
| 798 |
|
815 |
|
| 799 |
# offset algorithm |
816 |
# offset algorithm |
| 800 |
if ( $input->param('page') ) { |
817 |
if ( $input->param('page') ) { |
|
Lines 980-987
if ( $op eq 'run' ) {
Link Here
|
| 980 |
'id' => $report_id, |
997 |
'id' => $report_id, |
| 981 |
'template_id' => $template_id, |
998 |
'template_id' => $template_id, |
| 982 |
); |
999 |
); |
| 983 |
} elsif ( $duplicate_running_reports_per_user_limit |
1000 |
} elsif ( $duplicate_running_reports_per_user_limit_exceeded || $total_running_reports_per_user_limit_exceeded ) |
| 984 |
&& ( scalar @duplicate_running_report_ids >= $duplicate_running_reports_per_user_limit ) ) |
|
|
| 985 |
{ |
1001 |
{ |
| 986 |
$template->param( |
1002 |
$template->param( |
| 987 |
'sql' => $sql, |
1003 |
'sql' => $sql, |
|
Lines 990-998
if ( $op eq 'run' ) {
Link Here
|
| 990 |
'execute' => 1, |
1006 |
'execute' => 1, |
| 991 |
'name' => $name, |
1007 |
'name' => $name, |
| 992 |
'notes' => $notes, |
1008 |
'notes' => $notes, |
| 993 |
'errors' => [ { duplicate_running_report_ids => \@duplicate_running_report_ids } ], |
1009 |
'errors' => [ |
| 994 |
'sql_params' => \@sql_params, |
1010 |
$duplicate_running_reports_per_user_limit_exceeded |
| 995 |
'param_names' => \@param_names, |
1011 |
? { duplicate_running_report_ids => \@duplicate_running_report_ids } |
|
|
1012 |
: (), |
| 1013 |
$total_running_reports_per_user_limit_exceeded |
| 1014 |
? { total_running_reports_per_user_limit_exceeded => \@total_running_report_ids } |
| 1015 |
: () |
| 1016 |
], |
| 1017 |
'sql_params' => \@sql_params, |
| 1018 |
'param_names' => \@param_names, |
| 996 |
); |
1019 |
); |
| 997 |
} else { |
1020 |
} else { |
| 998 |
my ( $sql, $header_types ) = $report->prep_report( \@param_names, \@sql_params ); |
1021 |
my ( $sql, $header_types ) = $report->prep_report( \@param_names, \@sql_params ); |
| 999 |
- |
|
|