Lines 95-100
if ( $input->param("filter_set") or $input->param('clear_filters') ) {
Link Here
|
95 |
$filter = $session->param('report_filter'); |
95 |
$filter = $session->param('report_filter'); |
96 |
} |
96 |
} |
97 |
|
97 |
|
|
|
98 |
my $show_all = $input->param('show_all'); |
99 |
$template->param( show_all => $show_all ); |
100 |
|
98 |
my @errors = (); |
101 |
my @errors = (); |
99 |
if ( !$op ) { |
102 |
if ( !$op ) { |
100 |
$template->param( 'start' => 1 ); |
103 |
$template->param( 'start' => 1 ); |
Lines 127-133
if ( !$op ) {
Link Here
|
127 |
'showsql' => 1, |
130 |
'showsql' => 1, |
128 |
'mana_success' => scalar $input->param('mana_success'), |
131 |
'mana_success' => scalar $input->param('mana_success'), |
129 |
'mana_id' => $report->{mana_id}, |
132 |
'mana_id' => $report->{mana_id}, |
130 |
'mana_comments' => $report->{comments} |
133 |
'mana_comments' => $report->{comments}, |
131 |
); |
134 |
); |
132 |
|
135 |
|
133 |
} elsif ( $op eq 'edit_form' ) { |
136 |
} elsif ( $op eq 'edit_form' ) { |
Lines 148-158
if ( !$op ) {
Link Here
|
148 |
'editsql' => 1, |
151 |
'editsql' => 1, |
149 |
'mana_id' => $report->{mana_id}, |
152 |
'mana_id' => $report->{mana_id}, |
150 |
'mana_comments' => $report->{comments}, |
153 |
'mana_comments' => $report->{comments}, |
151 |
'tables' => $tables |
154 |
'tables' => $tables, |
|
|
155 |
'report' => $report, |
152 |
); |
156 |
); |
153 |
|
157 |
|
154 |
} elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { |
158 |
} elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { |
155 |
my $id = $input->param('id'); |
159 |
my $id = $input->param('id'); |
|
|
160 |
my $report = Koha::Reports->find($id); |
156 |
my $sql = $input->param('sql'); |
161 |
my $sql = $input->param('sql'); |
157 |
my $reportname = $input->param('reportname'); |
162 |
my $reportname = $input->param('reportname'); |
158 |
my $group = $input->param('group'); |
163 |
my $group = $input->param('group'); |
Lines 163-169
if ( !$op ) {
Link Here
|
163 |
my $public = $input->param('public'); |
168 |
my $public = $input->param('public'); |
164 |
my $save_anyway = $input->param('save_anyway'); |
169 |
my $save_anyway = $input->param('save_anyway'); |
165 |
my @errors; |
170 |
my @errors; |
166 |
my $tables = get_tables(); |
171 |
my $tables = get_tables(); |
|
|
172 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
167 |
|
173 |
|
168 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
174 |
# 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) { |
175 |
if ($cache_expiry_units) { |
Lines 211-216
if ( !$op ) {
Link Here
|
211 |
'problematic_authvals' => $problematic_authvals, |
217 |
'problematic_authvals' => $problematic_authvals, |
212 |
'warn_authval_problem' => 1, |
218 |
'warn_authval_problem' => 1, |
213 |
'phase_update' => 1, |
219 |
'phase_update' => 1, |
|
|
220 |
'branches' => @branches, |
221 |
'report' => $report, |
214 |
); |
222 |
); |
215 |
|
223 |
|
216 |
} else { |
224 |
} else { |
Lines 225-234
if ( !$op ) {
Link Here
|
225 |
subgroup => $subgroup, |
233 |
subgroup => $subgroup, |
226 |
notes => $notes, |
234 |
notes => $notes, |
227 |
public => $public, |
235 |
public => $public, |
228 |
cache_expiry => $cache_expiry, |
236 |
cache_expiry => $cache_expiry |
229 |
} |
237 |
} |
230 |
); |
238 |
); |
231 |
|
239 |
|
|
|
240 |
$report->store; |
241 |
$report->replace_library_limits( \@branches ); |
242 |
|
232 |
my $editsql = 1; |
243 |
my $editsql = 1; |
233 |
if ( $op eq 'cud-update_and_run_sql' ) { |
244 |
if ( $op eq 'cud-update_and_run_sql' ) { |
234 |
$editsql = 0; |
245 |
$editsql = 0; |
Lines 245-251
if ( !$op ) {
Link Here
|
245 |
'cache_expiry' => $cache_expiry, |
256 |
'cache_expiry' => $cache_expiry, |
246 |
'public' => $public, |
257 |
'public' => $public, |
247 |
'usecache' => $usecache, |
258 |
'usecache' => $usecache, |
248 |
'tables' => $tables |
259 |
'tables' => $tables, |
|
|
260 |
'report' => $report |
249 |
); |
261 |
); |
250 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
262 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
251 |
} |
263 |
} |
Lines 514-519
if ( !$op ) {
Link Here
|
514 |
my $public = $input->param('public'); |
526 |
my $public = $input->param('public'); |
515 |
my $save_anyway = $input->param('save_anyway'); |
527 |
my $save_anyway = $input->param('save_anyway'); |
516 |
my $tables = get_tables(); |
528 |
my $tables = get_tables(); |
|
|
529 |
my @branches = grep { $_ ne q{} } $input->multi_param('branches'); |
517 |
|
530 |
|
518 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
531 |
# 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) { |
532 |
if ($cache_expiry_units) { |
Lines 591-596
if ( !$op ) {
Link Here
|
591 |
public => $public, |
604 |
public => $public, |
592 |
} |
605 |
} |
593 |
); |
606 |
); |
|
|
607 |
my $report = Koha::Reports->find($id); |
608 |
$report->replace_library_limits( \@branches ); |
609 |
|
594 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
610 |
logaction( "REPORTS", "ADD", $id, "$name | $sql" ) if C4::Context->preference("ReportsLog"); |
595 |
$template->param( |
611 |
$template->param( |
596 |
'save_successful' => 1, |
612 |
'save_successful' => 1, |
Lines 603-609
if ( !$op ) {
Link Here
|
603 |
'cache_expiry' => $cache_expiry, |
619 |
'cache_expiry' => $cache_expiry, |
604 |
'public' => $public, |
620 |
'public' => $public, |
605 |
'usecache' => $usecache, |
621 |
'usecache' => $usecache, |
606 |
'tables' => $tables |
622 |
'tables' => $tables, |
|
|
623 |
'report' => $report, |
607 |
); |
624 |
); |
608 |
} |
625 |
} |
609 |
} |
626 |
} |
Lines 746-765
if ( !$op ) {
Link Here
|
746 |
|
763 |
|
747 |
} elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) { |
764 |
} elsif ( $op eq 'add_form_sql' || $op eq 'duplicate' ) { |
748 |
|
765 |
|
749 |
my ( $group, $subgroup, $sql, $reportname, $notes ); |
766 |
my ( $group, $subgroup, $sql, $reportname, $notes, @branches, $report ); |
750 |
if ( $input->param('sql') ) { |
767 |
if ( $input->param('sql') ) { |
751 |
$group = $input->param('report_group'); |
768 |
$group = $input->param('report_group'); |
752 |
$subgroup = $input->param('report_subgroup'); |
769 |
$subgroup = $input->param('report_subgroup'); |
753 |
$sql = $input->param('sql') // ''; |
770 |
$sql = $input->param('sql') // ''; |
754 |
$reportname = $input->param('reportname') // ''; |
771 |
$reportname = $input->param('reportname') // ''; |
755 |
$notes = $input->param('notes') // ''; |
772 |
$notes = $input->param('notes') // ''; |
|
|
773 |
@branches = grep { $_ ne q{} } $input->multi_param('branches'); |
774 |
|
756 |
} elsif ( my $report_id = $input->param('id') ) { |
775 |
} elsif ( my $report_id = $input->param('id') ) { |
757 |
my $report = Koha::Reports->find($report_id); |
776 |
$report = Koha::Reports->find($report_id); |
758 |
$group = $report->report_group; |
777 |
$group = $report->report_group; |
759 |
$subgroup = $report->report_subgroup; |
778 |
$subgroup = $report->report_subgroup; |
760 |
$sql = $report->savedsql // ''; |
779 |
$sql = $report->savedsql // ''; |
761 |
$reportname = $report->report_name // ''; |
780 |
$reportname = $report->report_name // ''; |
762 |
$notes = $report->notes // ''; |
781 |
$notes = $report->notes // ''; |
|
|
782 |
@branches = grep { $_ ne q{} } $input->multi_param('branches'); |
783 |
|
763 |
} |
784 |
} |
764 |
|
785 |
|
765 |
my $tables = get_tables(); |
786 |
my $tables = get_tables(); |
Lines 774-779
if ( !$op ) {
Link Here
|
774 |
'cache_expiry' => 300, |
795 |
'cache_expiry' => 300, |
775 |
'usecache' => $usecache, |
796 |
'usecache' => $usecache, |
776 |
'tables' => $tables, |
797 |
'tables' => $tables, |
|
|
798 |
'report' => $report, |
777 |
|
799 |
|
778 |
); |
800 |
); |
779 |
} |
801 |
} |
Lines 1081-1104
if ( $op eq 'list' || $op eq 'convert' ) {
Link Here
|
1081 |
my $subgroup = $input->param('subgroup'); |
1103 |
my $subgroup = $input->param('subgroup'); |
1082 |
$filter->{group} = $group; |
1104 |
$filter->{group} = $group; |
1083 |
$filter->{subgroup} = $subgroup; |
1105 |
$filter->{subgroup} = $subgroup; |
1084 |
my $reports = get_saved_reports($filter); |
1106 |
|
1085 |
my $has_obsolete_reports; |
1107 |
my $pref_enable_filtering_reports = C4::Context->preference("EnableFilteringReports"); |
1086 |
for my $report (@$reports) { |
1108 |
if ( !$show_all && $pref_enable_filtering_reports == "1" ) { |
1087 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1109 |
my $reports_with_library_limits_results = |
1088 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |
1110 |
Koha::Reports->search_with_library_limits( {}, {}, C4::Context::mybranch() ); |
1089 |
$report->{seems_obsolete} = 1; |
1111 |
my $reports_list = $reports_with_library_limits_results->unblessed; |
1090 |
$has_obsolete_reports++; |
1112 |
my $has_obsolete_reports; |
|
|
1113 |
while ( my $report = $reports_with_library_limits_results->next ) { |
1114 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1115 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |
1116 |
$report->{seems_obsolete} = 1; |
1117 |
$has_obsolete_reports++; |
1118 |
} |
1119 |
$template->param( |
1120 |
'manamsg' => $input->param('manamsg') || '', |
1121 |
'saved1' => 1, |
1122 |
'savedreports' => $reports_list, |
1123 |
'usecache' => $usecache, |
1124 |
'groups_with_subgroups' => groups_with_subgroups( $group, $subgroup ), |
1125 |
filters => $filter, |
1126 |
has_obsolete_reports => $has_obsolete_reports, |
1127 |
); |
1128 |
} |
1129 |
} else { |
1130 |
|
1131 |
my $reports = get_saved_reports($filter); |
1132 |
my $has_obsolete_reports; |
1133 |
|
1134 |
for my $report (@$reports) { |
1135 |
$report->{results} = C4::Reports::Guided::get_results( $report->{id} ); |
1136 |
if ( $report->{savedsql} =~ m|biblioitems| and $report->{savedsql} =~ m|marcxml| ) { |
1137 |
$report->{seems_obsolete} = 1; |
1138 |
$has_obsolete_reports++; |
1139 |
} |
1091 |
} |
1140 |
} |
|
|
1141 |
$template->param( |
1142 |
'manamsg' => $input->param('manamsg') || '', |
1143 |
'saved1' => 1, |
1144 |
'savedreports' => $reports, |
1145 |
'usecache' => $usecache, |
1146 |
'groups_with_subgroups' => groups_with_subgroups( $group, $subgroup ), |
1147 |
filters => $filter, |
1148 |
has_obsolete_reports => $has_obsolete_reports, |
1149 |
); |
1092 |
} |
1150 |
} |
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 |
} |
1151 |
} |
1103 |
|
1152 |
|
1104 |
# pass $sth, get back an array of names for the column headers |
1153 |
# pass $sth, get back an array of names for the column headers |