Lines 127-133
if ( !$op ) {
Link Here
|
127 |
'showsql' => 1, |
127 |
'showsql' => 1, |
128 |
'mana_success' => scalar $input->param('mana_success'), |
128 |
'mana_success' => scalar $input->param('mana_success'), |
129 |
'mana_id' => $report->{mana_id}, |
129 |
'mana_id' => $report->{mana_id}, |
130 |
'mana_comments' => $report->{comments} |
130 |
'mana_comments' => $report->{comments}, |
131 |
); |
131 |
); |
132 |
|
132 |
|
133 |
} elsif ( $op eq 'edit_form' ) { |
133 |
} elsif ( $op eq 'edit_form' ) { |
Lines 148-158
if ( !$op ) {
Link Here
|
148 |
'editsql' => 1, |
148 |
'editsql' => 1, |
149 |
'mana_id' => $report->{mana_id}, |
149 |
'mana_id' => $report->{mana_id}, |
150 |
'mana_comments' => $report->{comments}, |
150 |
'mana_comments' => $report->{comments}, |
151 |
'tables' => $tables |
151 |
'tables' => $tables, |
|
|
152 |
'report' => $report, |
152 |
); |
153 |
); |
153 |
|
154 |
|
154 |
} elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { |
155 |
} elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { |
155 |
my $id = $input->param('id'); |
156 |
my $id = $input->param('id'); |
|
|
157 |
my $report = Koha::Reports->find($id); |
156 |
my $sql = $input->param('sql'); |
158 |
my $sql = $input->param('sql'); |
157 |
my $reportname = $input->param('reportname'); |
159 |
my $reportname = $input->param('reportname'); |
158 |
my $group = $input->param('group'); |
160 |
my $group = $input->param('group'); |
Lines 163-169
if ( !$op ) {
Link Here
|
163 |
my $public = $input->param('public'); |
165 |
my $public = $input->param('public'); |
164 |
my $save_anyway = $input->param('save_anyway'); |
166 |
my $save_anyway = $input->param('save_anyway'); |
165 |
my @errors; |
167 |
my @errors; |
166 |
my $tables = get_tables(); |
168 |
my $tables = get_tables(); |
|
|
169 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
167 |
|
170 |
|
168 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
171 |
# 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) { |
172 |
if ($cache_expiry_units) { |
Lines 211-216
if ( !$op ) {
Link Here
|
211 |
'problematic_authvals' => $problematic_authvals, |
214 |
'problematic_authvals' => $problematic_authvals, |
212 |
'warn_authval_problem' => 1, |
215 |
'warn_authval_problem' => 1, |
213 |
'phase_update' => 1, |
216 |
'phase_update' => 1, |
|
|
217 |
'branches' => @branches, |
218 |
'report' => $report, |
214 |
); |
219 |
); |
215 |
|
220 |
|
216 |
} else { |
221 |
} else { |
Lines 225-234
if ( !$op ) {
Link Here
|
225 |
subgroup => $subgroup, |
230 |
subgroup => $subgroup, |
226 |
notes => $notes, |
231 |
notes => $notes, |
227 |
public => $public, |
232 |
public => $public, |
228 |
cache_expiry => $cache_expiry, |
233 |
cache_expiry => $cache_expiry |
229 |
} |
234 |
} |
230 |
); |
235 |
); |
231 |
|
236 |
|
|
|
237 |
$report->store; |
238 |
$report->replace_library_limits( \@branches ); |
239 |
|
232 |
my $editsql = 1; |
240 |
my $editsql = 1; |
233 |
if ( $op eq 'cud-update_and_run_sql' ) { |
241 |
if ( $op eq 'cud-update_and_run_sql' ) { |
234 |
$editsql = 0; |
242 |
$editsql = 0; |
Lines 245-251
if ( !$op ) {
Link Here
|
245 |
'cache_expiry' => $cache_expiry, |
253 |
'cache_expiry' => $cache_expiry, |
246 |
'public' => $public, |
254 |
'public' => $public, |
247 |
'usecache' => $usecache, |
255 |
'usecache' => $usecache, |
248 |
'tables' => $tables |
256 |
'tables' => $tables, |
|
|
257 |
'report' => $report |
249 |
); |
258 |
); |
250 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
259 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
251 |
} |
260 |
} |
Lines 514-519
if ( !$op ) {
Link Here
|
514 |
my $public = $input->param('public'); |
523 |
my $public = $input->param('public'); |
515 |
my $save_anyway = $input->param('save_anyway'); |
524 |
my $save_anyway = $input->param('save_anyway'); |
516 |
my $tables = get_tables(); |
525 |
my $tables = get_tables(); |
|
|
526 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
517 |
|
527 |
|
518 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
528 |
# 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) { |
529 |
if ($cache_expiry_units) { |
Lines 591-596
if ( !$op ) {
Link Here
|
591 |
public => $public, |
601 |
public => $public, |
592 |
} |
602 |
} |
593 |
); |
603 |
); |
|
|
604 |
my $report = Koha::Reports->find($id); |
605 |
$report->replace_library_limits( \@branches ); |
606 |
|
594 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
607 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
595 |
$template->param( |
608 |
$template->param( |
596 |
'save_successful' => 1, |
609 |
'save_successful' => 1, |
Lines 603-609
if ( !$op ) {
Link Here
|
603 |
'cache_expiry' => $cache_expiry, |
616 |
'cache_expiry' => $cache_expiry, |
604 |
'public' => $public, |
617 |
'public' => $public, |
605 |
'usecache' => $usecache, |
618 |
'usecache' => $usecache, |
606 |
'tables' => $tables |
619 |
'tables' => $tables, |
|
|
620 |
'report' => $report, |
607 |
); |
621 |
); |
608 |
} |
622 |
} |
609 |
} |
623 |
} |
Lines 746-765
if ( !$op ) {
Link Here
|
746 |
|
760 |
|
747 |
} elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) { |
761 |
} elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) { |
748 |
|
762 |
|
749 |
my ( $group, $subgroup, $sql, $reportname, $notes ); |
763 |
my ( $group, $subgroup, $sql, $reportname, $notes, @branches, $report ); |
750 |
if ( $input->param('sql') ) { |
764 |
if ( $input->param('sql') ) { |
751 |
$group = $input->param('report_group'); |
765 |
$group = $input->param('report_group'); |
752 |
$subgroup = $input->param('report_subgroup'); |
766 |
$subgroup = $input->param('report_subgroup'); |
753 |
$sql = $input->param('sql') // ''; |
767 |
$sql = $input->param('sql') // ''; |
754 |
$reportname = $input->param('reportname') // ''; |
768 |
$reportname = $input->param('reportname') // ''; |
755 |
$notes = $input->param('notes') // ''; |
769 |
$notes = $input->param('notes') // ''; |
|
|
770 |
@branches = grep { $_ ne q{} } $input->multi_param('branches'); |
771 |
|
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 1081-1104
if ( $op eq 'list' || $op eq 'convert' ) {
Link Here
|
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; |
1084 |
my $reports = get_saved_reports($filter); |
1103 |
|
1085 |
my $has_obsolete_reports; |
1104 |
my $pref_enable_filtering_reports = C4::Context->preference("EnableFilteringReports"); |
1086 |
for my $report (@$reports) { |
1105 |
if ( $pref_enable_filtering_reports == "1" ) { |
1087 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1106 |
my $reports_with_library_limits_results = |
1088 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |
1107 |
Koha::Reports->search_with_library_limits( {}, {}, C4::Context::mybranch() ); |
1089 |
$report->{seems_obsolete} = 1; |
1108 |
my $reports_list = $reports_with_library_limits_results->unblessed; |
1090 |
$has_obsolete_reports++; |
1109 |
my $has_obsolete_reports; |
|
|
1110 |
while ( my $report = $reports_with_library_limits_results->next ) { |
1111 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1112 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |
1113 |
$report->{seems_obsolete} = 1; |
1114 |
$has_obsolete_reports++; |
1115 |
} |
1116 |
$template->param( |
1117 |
'manamsg' => $input->param('manamsg') || '', |
1118 |
'saved1' => 1, |
1119 |
'savedreports' => $reports_list, |
1120 |
'usecache' => $usecache, |
1121 |
'groups_with_subgroups' => groups_with_subgroups( $group, $subgroup ), |
1122 |
filters => $filter, |
1123 |
has_obsolete_reports => $has_obsolete_reports, |
1124 |
); |
1125 |
} |
1126 |
} else { |
1127 |
|
1128 |
my $reports = get_saved_reports($filter); |
1129 |
my $has_obsolete_reports; |
1130 |
|
1131 |
for my $report (@$reports) { |
1132 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1133 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |
1134 |
$report->{seems_obsolete} = 1; |
1135 |
$has_obsolete_reports++; |
1136 |
} |
1091 |
} |
1137 |
} |
|
|
1138 |
$template->param( |
1139 |
'manamsg' => $input->param('manamsg') || '', |
1140 |
'saved1' => 1, |
1141 |
'savedreports' => $reports, |
1142 |
'usecache' => $usecache, |
1143 |
'groups_with_subgroups' => groups_with_subgroups( $group, $subgroup ), |
1144 |
filters => $filter, |
1145 |
has_obsolete_reports => $has_obsolete_reports, |
1146 |
); |
1092 |
} |
1147 |
} |
1093 |
$template->param( |
|
|
1094 |
'manamsg' => $input->param('manamsg') || '', |
1095 |
'saved1' => 1, |
1096 |
'savedreports' => $reports, |
1097 |
'usecache' => $usecache, |
1098 |
'groups_with_subgroups' => groups_with_subgroups( $group, $subgroup ), |
1099 |
filters => $filter, |
1100 |
has_obsolete_reports => $has_obsolete_reports, |
1101 |
); |
1102 |
} |
1148 |
} |
1103 |
|
1149 |
|
1104 |
# pass $sth, get back an array of names for the column headers |
1150 |
# pass $sth, get back an array of names for the column headers |