Lines 57-62
my $input = CGI->new;
Link Here
|
57 |
my $usecache = Koha::Caches->get_instance->memcached_cache; |
57 |
my $usecache = Koha::Caches->get_instance->memcached_cache; |
58 |
|
58 |
|
59 |
my $op = $input->param('op') // ''; |
59 |
my $op = $input->param('op') // ''; |
|
|
60 |
|
60 |
my $flagsrequired; |
61 |
my $flagsrequired; |
61 |
if ( ( $op eq 'add_form' ) |
62 |
if ( ( $op eq 'add_form' ) |
62 |
|| ( $op eq 'add_form_sql' ) |
63 |
|| ( $op eq 'add_form_sql' ) |
Lines 127-133
if ( !$op ) {
Link Here
|
127 |
'showsql' => 1, |
128 |
'showsql' => 1, |
128 |
'mana_success' => scalar $input->param('mana_success'), |
129 |
'mana_success' => scalar $input->param('mana_success'), |
129 |
'mana_id' => $report->{mana_id}, |
130 |
'mana_id' => $report->{mana_id}, |
130 |
'mana_comments' => $report->{comments} |
131 |
'mana_comments' => $report->{comments}, |
131 |
); |
132 |
); |
132 |
|
133 |
|
133 |
} elsif ( $op eq 'edit_form' ) { |
134 |
} elsif ( $op eq 'edit_form' ) { |
Lines 136-141
if ( !$op ) {
Link Here
|
136 |
my $group = $report->report_group; |
137 |
my $group = $report->report_group; |
137 |
my $subgroup = $report->report_subgroup; |
138 |
my $subgroup = $report->report_subgroup; |
138 |
my $tables = get_tables(); |
139 |
my $tables = get_tables(); |
|
|
140 |
|
139 |
$template->param( |
141 |
$template->param( |
140 |
'sql' => $report->savedsql, |
142 |
'sql' => $report->savedsql, |
141 |
'reportname' => $report->report_name, |
143 |
'reportname' => $report->report_name, |
Lines 148-158
if ( !$op ) {
Link Here
|
148 |
'editsql' => 1, |
150 |
'editsql' => 1, |
149 |
'mana_id' => $report->{mana_id}, |
151 |
'mana_id' => $report->{mana_id}, |
150 |
'mana_comments' => $report->{comments}, |
152 |
'mana_comments' => $report->{comments}, |
151 |
'tables' => $tables |
153 |
'tables' => $tables, |
|
|
154 |
'report' => $report, |
152 |
); |
155 |
); |
153 |
|
156 |
|
154 |
} elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { |
157 |
} elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { |
155 |
my $id = $input->param('id'); |
158 |
my $id = $input->param('id'); |
|
|
159 |
my $report = Koha::Reports->find($id); |
156 |
my $sql = $input->param('sql'); |
160 |
my $sql = $input->param('sql'); |
157 |
my $reportname = $input->param('reportname'); |
161 |
my $reportname = $input->param('reportname'); |
158 |
my $group = $input->param('group'); |
162 |
my $group = $input->param('group'); |
Lines 162-171
if ( !$op ) {
Link Here
|
162 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
166 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
163 |
my $public = $input->param('public'); |
167 |
my $public = $input->param('public'); |
164 |
my $save_anyway = $input->param('save_anyway'); |
168 |
my $save_anyway = $input->param('save_anyway'); |
|
|
169 |
my $tables = get_tables(); |
170 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
165 |
my @errors; |
171 |
my @errors; |
166 |
my $tables = get_tables(); |
|
|
167 |
|
172 |
|
168 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
|
|
169 |
if ($cache_expiry_units) { |
173 |
if ($cache_expiry_units) { |
170 |
if ( $cache_expiry_units eq "minutes" ) { |
174 |
if ( $cache_expiry_units eq "minutes" ) { |
171 |
$cache_expiry *= 60; |
175 |
$cache_expiry *= 60; |
Lines 211-216
if ( !$op ) {
Link Here
|
211 |
'problematic_authvals' => $problematic_authvals, |
215 |
'problematic_authvals' => $problematic_authvals, |
212 |
'warn_authval_problem' => 1, |
216 |
'warn_authval_problem' => 1, |
213 |
'phase_update' => 1, |
217 |
'phase_update' => 1, |
|
|
218 |
'branches' => @branches, |
219 |
'report' => $report, |
214 |
); |
220 |
); |
215 |
|
221 |
|
216 |
} else { |
222 |
} else { |
Lines 229-234
if ( !$op ) {
Link Here
|
229 |
} |
235 |
} |
230 |
); |
236 |
); |
231 |
|
237 |
|
|
|
238 |
$report->store; |
239 |
$report->replace_library_limits( \@branches ); |
240 |
|
232 |
my $editsql = 1; |
241 |
my $editsql = 1; |
233 |
if ( $op eq 'cud-update_and_run_sql' ) { |
242 |
if ( $op eq 'cud-update_and_run_sql' ) { |
234 |
$editsql = 0; |
243 |
$editsql = 0; |
Lines 245-251
if ( !$op ) {
Link Here
|
245 |
'cache_expiry' => $cache_expiry, |
254 |
'cache_expiry' => $cache_expiry, |
246 |
'public' => $public, |
255 |
'public' => $public, |
247 |
'usecache' => $usecache, |
256 |
'usecache' => $usecache, |
248 |
'tables' => $tables |
257 |
'tables' => $tables, |
|
|
258 |
'report' => $report, |
249 |
); |
259 |
); |
250 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
260 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
251 |
} |
261 |
} |
Lines 514-519
if ( !$op ) {
Link Here
|
514 |
my $public = $input->param('public'); |
524 |
my $public = $input->param('public'); |
515 |
my $save_anyway = $input->param('save_anyway'); |
525 |
my $save_anyway = $input->param('save_anyway'); |
516 |
my $tables = get_tables(); |
526 |
my $tables = get_tables(); |
|
|
527 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
517 |
|
528 |
|
518 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
529 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
519 |
if ($cache_expiry_units) { |
530 |
if ($cache_expiry_units) { |
Lines 591-596
if ( !$op ) {
Link Here
|
591 |
public => $public, |
602 |
public => $public, |
592 |
} |
603 |
} |
593 |
); |
604 |
); |
|
|
605 |
my $report = Koha::Reports->find($id); |
606 |
$report->replace_library_limits( \@branches ); |
607 |
|
594 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
608 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
595 |
$template->param( |
609 |
$template->param( |
596 |
'save_successful' => 1, |
610 |
'save_successful' => 1, |
Lines 603-609
if ( !$op ) {
Link Here
|
603 |
'cache_expiry' => $cache_expiry, |
617 |
'cache_expiry' => $cache_expiry, |
604 |
'public' => $public, |
618 |
'public' => $public, |
605 |
'usecache' => $usecache, |
619 |
'usecache' => $usecache, |
606 |
'tables' => $tables |
620 |
'tables' => $tables, |
|
|
621 |
'report' => $report, |
607 |
); |
622 |
); |
608 |
} |
623 |
} |
609 |
} |
624 |
} |
Lines 746-765
if ( !$op ) {
Link Here
|
746 |
|
761 |
|
747 |
} elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) { |
762 |
} elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) { |
748 |
|
763 |
|
749 |
my ( $group, $subgroup, $sql, $reportname, $notes ); |
764 |
my ( $group, $subgroup, $sql, $reportname, $notes, @branches, $report ); |
750 |
if ( $input->param('sql') ) { |
765 |
if ( $input->param('sql') ) { |
751 |
$group = $input->param('report_group'); |
766 |
$group = $input->param('report_group'); |
752 |
$subgroup = $input->param('report_subgroup'); |
767 |
$subgroup = $input->param('report_subgroup'); |
753 |
$sql = $input->param('sql') // ''; |
768 |
$sql = $input->param('sql') // ''; |
754 |
$reportname = $input->param('reportname') // ''; |
769 |
$reportname = $input->param('reportname') // ''; |
755 |
$notes = $input->param('notes') // ''; |
770 |
$notes = $input->param('notes') // ''; |
|
|
771 |
@branches = grep { $_ ne q{} } $input->multi_param('branches'); |
756 |
} elsif ( my $report_id = $input->param('id') ) { |
772 |
} elsif ( my $report_id = $input->param('id') ) { |
757 |
my $report = Koha::Reports->find($report_id); |
773 |
$report = Koha::Reports->find($report_id); |
758 |
$group = $report->report_group; |
774 |
$group = $report->report_group; |
759 |
$subgroup = $report->report_subgroup; |
775 |
$subgroup = $report->report_subgroup; |
760 |
$sql = $report->savedsql // ''; |
776 |
$sql = $report->savedsql // ''; |
761 |
$reportname = $report->report_name // ''; |
777 |
$reportname = $report->report_name // ''; |
762 |
$notes = $report->notes // ''; |
778 |
$notes = $report->notes // ''; |
|
|
779 |
@branches = grep { $_ ne q{} } $input->multi_param('branches'); |
780 |
|
763 |
} |
781 |
} |
764 |
|
782 |
|
765 |
my $tables = get_tables(); |
783 |
my $tables = get_tables(); |
Lines 774-779
if ( !$op ) {
Link Here
|
774 |
'cache_expiry' => 300, |
792 |
'cache_expiry' => 300, |
775 |
'usecache' => $usecache, |
793 |
'usecache' => $usecache, |
776 |
'tables' => $tables, |
794 |
'tables' => $tables, |
|
|
795 |
'report' => $report, |
777 |
|
796 |
|
778 |
); |
797 |
); |
779 |
} |
798 |
} |
Lines 1079-1088
if ( $op eq 'list' || $op eq 'convert' ) {
Link Here
|
1079 |
# get list of reports and display them |
1098 |
# get list of reports and display them |
1080 |
my $group = $input->param('group'); |
1099 |
my $group = $input->param('group'); |
1081 |
my $subgroup = $input->param('subgroup'); |
1100 |
my $subgroup = $input->param('subgroup'); |
1082 |
$filter->{group} = $group; |
1101 |
$filter->{group} = $group; |
1083 |
$filter->{subgroup} = $subgroup; |
1102 |
$filter->{subgroup} = $subgroup; |
|
|
1103 |
$filter->{branchcode} = C4::Context::mybranch(); |
1084 |
my $reports = get_saved_reports($filter); |
1104 |
my $reports = get_saved_reports($filter); |
1085 |
my $has_obsolete_reports; |
1105 |
my $has_obsolete_reports; |
|
|
1106 |
|
1086 |
for my $report (@$reports) { |
1107 |
for my $report (@$reports) { |
1087 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1108 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1088 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |
1109 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |