|
Lines 163-178
elsif ( $phase eq 'Delete Multiple') {
Link Here
|
| 163 |
} |
163 |
} |
| 164 |
|
164 |
|
| 165 |
elsif ( $phase eq 'Delete Saved') { |
165 |
elsif ( $phase eq 'Delete Saved') { |
| 166 |
|
166 |
|
| 167 |
# delete a report from the saved reports list |
167 |
# delete a report from the saved reports list |
| 168 |
my $ids = $input->param('reports'); |
168 |
my $ids = $input->param('reports'); |
| 169 |
delete_report($ids); |
169 |
delete_report($ids); |
| 170 |
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved"); |
170 |
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved"); |
| 171 |
exit; |
171 |
exit; |
| 172 |
} |
172 |
} |
| 173 |
|
173 |
|
| 174 |
elsif ( $phase eq 'Show SQL'){ |
174 |
elsif ( $phase eq 'Show SQL'){ |
| 175 |
|
175 |
|
| 176 |
my $id = $input->param('reports'); |
176 |
my $id = $input->param('reports'); |
| 177 |
my $report = Koha::Reports->find($id); |
177 |
my $report = Koha::Reports->find($id); |
| 178 |
$template->param( |
178 |
$template->param( |
|
Lines 192-197
elsif ( $phase eq 'Edit SQL'){
Link Here
|
| 192 |
my $report = Koha::Reports->find($id); |
192 |
my $report = Koha::Reports->find($id); |
| 193 |
my $group = $report->report_group; |
193 |
my $group = $report->report_group; |
| 194 |
my $subgroup = $report->report_subgroup; |
194 |
my $subgroup = $report->report_subgroup; |
|
|
195 |
my $tables = get_tables(); |
| 195 |
$template->param( |
196 |
$template->param( |
| 196 |
'sql' => $report->savedsql, |
197 |
'sql' => $report->savedsql, |
| 197 |
'reportname' => $report->report_name, |
198 |
'reportname' => $report->report_name, |
|
Lines 203-209
elsif ( $phase eq 'Edit SQL'){
Link Here
|
| 203 |
'usecache' => $usecache, |
204 |
'usecache' => $usecache, |
| 204 |
'editsql' => 1, |
205 |
'editsql' => 1, |
| 205 |
'mana_id' => $report->{mana_id}, |
206 |
'mana_id' => $report->{mana_id}, |
| 206 |
'mana_comments' => $report->{comments} |
207 |
'mana_comments' => $report->{comments}, |
|
|
208 |
'tables' => $tables |
| 207 |
); |
209 |
); |
| 208 |
} |
210 |
} |
| 209 |
|
211 |
|
|
Lines 219-224
elsif ( $phase eq 'Update SQL'){
Link Here
|
| 219 |
my $public = $input->param('public'); |
221 |
my $public = $input->param('public'); |
| 220 |
my $save_anyway = $input->param('save_anyway'); |
222 |
my $save_anyway = $input->param('save_anyway'); |
| 221 |
my @errors; |
223 |
my @errors; |
|
|
224 |
my $tables = get_tables(); |
| 222 |
|
225 |
|
| 223 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
226 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
| 224 |
if( $cache_expiry_units ){ |
227 |
if( $cache_expiry_units ){ |
|
Lines 263-269
elsif ( $phase eq 'Update SQL'){
Link Here
|
| 263 |
'public' => $public, |
266 |
'public' => $public, |
| 264 |
'problematic_authvals' => $problematic_authvals, |
267 |
'problematic_authvals' => $problematic_authvals, |
| 265 |
'warn_authval_problem' => 1, |
268 |
'warn_authval_problem' => 1, |
| 266 |
'phase_update' => 1 |
269 |
'phase_update' => 1, |
| 267 |
); |
270 |
); |
| 268 |
|
271 |
|
| 269 |
} else { |
272 |
} else { |
|
Lines 288-293
elsif ( $phase eq 'Update SQL'){
Link Here
|
| 288 |
'cache_expiry' => $cache_expiry, |
291 |
'cache_expiry' => $cache_expiry, |
| 289 |
'public' => $public, |
292 |
'public' => $public, |
| 290 |
'usecache' => $usecache, |
293 |
'usecache' => $usecache, |
|
|
294 |
'tables' => $tables |
| 291 |
); |
295 |
); |
| 292 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
296 |
logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); |
| 293 |
} |
297 |
} |
|
Lines 556-561
elsif ( $phase eq 'Save Report' ) {
Link Here
|
| 556 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
560 |
my $cache_expiry_units = $input->param('cache_expiry_units'); |
| 557 |
my $public = $input->param('public'); |
561 |
my $public = $input->param('public'); |
| 558 |
my $save_anyway = $input->param('save_anyway'); |
562 |
my $save_anyway = $input->param('save_anyway'); |
|
|
563 |
my $tables = get_tables(); |
| 559 |
|
564 |
|
| 560 |
|
565 |
|
| 561 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
566 |
# if we have the units, then we came from creating a report from SQL and thus need to handle converting units |
|
Lines 640-645
elsif ( $phase eq 'Save Report' ) {
Link Here
|
| 640 |
'cache_expiry' => $cache_expiry, |
645 |
'cache_expiry' => $cache_expiry, |
| 641 |
'public' => $public, |
646 |
'public' => $public, |
| 642 |
'usecache' => $usecache, |
647 |
'usecache' => $usecache, |
|
|
648 |
'tables' => $tables |
| 643 |
); |
649 |
); |
| 644 |
} |
650 |
} |
| 645 |
} |
651 |
} |
|
Lines 998-1003
elsif ( $phase eq 'Create report from SQL' || $phase eq 'Create report from exis
Link Here
|
| 998 |
$notes = $report->notes // ''; |
1004 |
$notes = $report->notes // ''; |
| 999 |
} |
1005 |
} |
| 1000 |
|
1006 |
|
|
|
1007 |
my $tables = get_tables(); |
| 1008 |
|
| 1001 |
$template->param( |
1009 |
$template->param( |
| 1002 |
sql => $sql, |
1010 |
sql => $sql, |
| 1003 |
reportname => $reportname, |
1011 |
reportname => $reportname, |
|
Lines 1007-1012
elsif ( $phase eq 'Create report from SQL' || $phase eq 'Create report from exis
Link Here
|
| 1007 |
'public' => '0', |
1015 |
'public' => '0', |
| 1008 |
'cache_expiry' => 300, |
1016 |
'cache_expiry' => 300, |
| 1009 |
'usecache' => $usecache, |
1017 |
'usecache' => $usecache, |
|
|
1018 |
'tables' => $tables, |
| 1010 |
|
1019 |
|
| 1011 |
); |
1020 |
); |
| 1012 |
} |
1021 |
} |
|
Lines 1024-1029
sub header_cell_loop {
Link Here
|
| 1024 |
return \@headers; |
1033 |
return \@headers; |
| 1025 |
} |
1034 |
} |
| 1026 |
|
1035 |
|
|
|
1036 |
#get a list of available tables for auto-complete |
| 1037 |
sub get_tables { |
| 1038 |
my $result = {}; |
| 1039 |
my $tables = C4::Reports::Guided->get_all_tables(); |
| 1040 |
for my $table (@{$tables}) { |
| 1041 |
my $sql = "SHOW COLUMNS FROM $table"; |
| 1042 |
my $rows = C4::Context->dbh->selectall_arrayref($sql, { Slice => {} }); |
| 1043 |
for my $row (@{$rows}) { |
| 1044 |
push @{$result->{$table}}, $row->{Field}; |
| 1045 |
} |
| 1046 |
} |
| 1047 |
return $result; |
| 1048 |
} |
| 1049 |
|
| 1027 |
foreach (1..6) { |
1050 |
foreach (1..6) { |
| 1028 |
$template->{VARS}->{'build' . $_} and last; |
1051 |
$template->{VARS}->{'build' . $_} and last; |
| 1029 |
} |
1052 |
} |
| 1030 |
- |
|
|