Lines 25-30
use URI::Escape;
Link Here
|
25 |
use File::Temp; |
25 |
use File::Temp; |
26 |
use File::Basename qw( dirname ); |
26 |
use File::Basename qw( dirname ); |
27 |
use C4::Reports::Guided; |
27 |
use C4::Reports::Guided; |
|
|
28 |
use Koha::Reports; |
28 |
use C4::Auth qw/:DEFAULT get_session/; |
29 |
use C4::Auth qw/:DEFAULT get_session/; |
29 |
use C4::Output; |
30 |
use C4::Output; |
30 |
use C4::Debug; |
31 |
use C4::Debug; |
Lines 109-130
elsif ( $phase eq 'Build new' ) {
Link Here
|
109 |
|
110 |
|
110 |
if ( $op eq 'convert' ) { |
111 |
if ( $op eq 'convert' ) { |
111 |
my $report_id = $input->param('report_id'); |
112 |
my $report_id = $input->param('report_id'); |
112 |
my $report = C4::Reports::Guided::get_saved_report($report_id); |
113 |
my $report = Koha::Reports->find($report_id); |
113 |
if ($report) { |
114 |
if ($report) { |
114 |
my $updated_sql = C4::Reports::Guided::convert_sql( $report->{savedsql} ); |
115 |
my $updated_sql = C4::Reports::Guided::convert_sql( $report->savedsql ); |
115 |
C4::Reports::Guided::update_sql( |
116 |
C4::Reports::Guided::update_sql( |
116 |
$report_id, |
117 |
$report_id, |
117 |
{ |
118 |
{ |
118 |
sql => $updated_sql, |
119 |
sql => $updated_sql, |
119 |
name => $report->{report_name}, |
120 |
name => $report->report_name, |
120 |
group => $report->{report_group}, |
121 |
group => $report->report_group, |
121 |
subgroup => $report->{report_subgroup}, |
122 |
subgroup => $report->report_subgroup, |
122 |
notes => $report->{notes}, |
123 |
notes => $report->notes, |
123 |
public => $report->{public}, |
124 |
public => $report->public, |
124 |
cache_expiry => $report->{cache_expiry}, |
125 |
cache_expiry => $report->cache_expiry, |
125 |
} |
126 |
} |
126 |
); |
127 |
); |
127 |
$template->param( report_converted => $report->{report_name} ); |
128 |
$template->param( report_converted => $report->report_name ); |
128 |
} |
129 |
} |
129 |
} |
130 |
} |
130 |
|
131 |
|
Lines 172-200
elsif ( $phase eq 'Delete Saved') {
Link Here
|
172 |
elsif ( $phase eq 'Show SQL'){ |
173 |
elsif ( $phase eq 'Show SQL'){ |
173 |
|
174 |
|
174 |
my $id = $input->param('reports'); |
175 |
my $id = $input->param('reports'); |
175 |
my $report = get_saved_report($id); |
176 |
my $report = Koha::Reports->find($id); |
176 |
$template->param( |
177 |
$template->param( |
177 |
'id' => $id, |
178 |
'id' => $id, |
178 |
'reportname' => $report->{report_name}, |
179 |
'reportname' => $report->report_name, |
179 |
'notes' => $report->{notes}, |
180 |
'notes' => $report->notes, |
180 |
'sql' => $report->{savedsql}, |
181 |
'sql' => $report->savedsql, |
181 |
'showsql' => 1, |
182 |
'showsql' => 1, |
182 |
); |
183 |
); |
183 |
} |
184 |
} |
184 |
|
185 |
|
185 |
elsif ( $phase eq 'Edit SQL'){ |
186 |
elsif ( $phase eq 'Edit SQL'){ |
186 |
my $id = $input->param('reports'); |
187 |
my $id = $input->param('reports'); |
187 |
my $report = get_saved_report($id); |
188 |
my $report = Koha::Reports->find($id); |
188 |
my $group = $report->{report_group}; |
189 |
my $group = $report->report_group; |
189 |
my $subgroup = $report->{report_subgroup}; |
190 |
my $subgroup = $report->report_subgroup; |
190 |
$template->param( |
191 |
$template->param( |
191 |
'sql' => $report->{savedsql}, |
192 |
'sql' => $report->savedsql, |
192 |
'reportname' => $report->{report_name}, |
193 |
'reportname' => $report->report_name, |
193 |
'groups_with_subgroups' => groups_with_subgroups($group, $subgroup), |
194 |
'groups_with_subgroups' => groups_with_subgroups($group, $subgroup), |
194 |
'notes' => $report->{notes}, |
195 |
'notes' => $report->notes, |
195 |
'id' => $id, |
196 |
'id' => $id, |
196 |
'cache_expiry' => $report->{cache_expiry}, |
197 |
'cache_expiry' => $report->cache_expiry, |
197 |
'public' => $report->{public}, |
198 |
'public' => $report->public, |
198 |
'usecache' => $usecache, |
199 |
'usecache' => $usecache, |
199 |
'editsql' => 1, |
200 |
'editsql' => 1, |
200 |
); |
201 |
); |
Lines 684-693
elsif ($phase eq 'Run this report'){
Link Here
|
684 |
); |
685 |
); |
685 |
|
686 |
|
686 |
my ( $sql, $original_sql, $type, $name, $notes ); |
687 |
my ( $sql, $original_sql, $type, $name, $notes ); |
687 |
if (my $report = get_saved_report($report_id)) { |
688 |
if (my $report = Koha::Reports->find($report_id)) { |
688 |
$sql = $original_sql = $report->{savedsql}; |
689 |
$sql = $original_sql = $report->savedsql; |
689 |
$name = $report->{report_name}; |
690 |
$name = $report->report_name; |
690 |
$notes = $report->{notes}; |
691 |
$notes = $report->notes; |
691 |
|
692 |
|
692 |
my @rows = (); |
693 |
my @rows = (); |
693 |
# if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters |
694 |
# if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters |
Lines 842-849
elsif ($phase eq 'Export'){
Link Here
|
842 |
|
843 |
|
843 |
# export results to tab separated text or CSV |
844 |
# export results to tab separated text or CSV |
844 |
my $report_id = $input->param('report_id'); |
845 |
my $report_id = $input->param('report_id'); |
845 |
my $report = get_saved_report($report_id); |
846 |
my $report = Koha::Reports->fund($report_id); |
846 |
my $sql = $report->{savedsql}; |
847 |
my $sql = $report->savedsql; |
847 |
my @sql_params = $input->multi_param('sql_params'); |
848 |
my @sql_params = $input->multi_param('sql_params'); |
848 |
my $format = $input->param('format'); |
849 |
my $format = $input->param('format'); |
849 |
my $reportname = $input->param('reportname'); |
850 |
my $reportname = $input->param('reportname'); |