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 686-695
elsif ($phase eq 'Run this report'){
Link Here
|
686 |
); |
687 |
); |
687 |
|
688 |
|
688 |
my ( $sql, $original_sql, $type, $name, $notes ); |
689 |
my ( $sql, $original_sql, $type, $name, $notes ); |
689 |
if (my $report = get_saved_report($report_id)) { |
690 |
if (my $report = Koha::Reports->find($report_id)) { |
690 |
$sql = $original_sql = $report->{savedsql}; |
691 |
$sql = $original_sql = $report->savedsql; |
691 |
$name = $report->{report_name}; |
692 |
$name = $report->report_name; |
692 |
$notes = $report->{notes}; |
693 |
$notes = $report->notes; |
693 |
|
694 |
|
694 |
my @rows = (); |
695 |
my @rows = (); |
695 |
# if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters |
696 |
# if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters |
Lines 850-857
elsif ($phase eq 'Export'){
Link Here
|
850 |
|
851 |
|
851 |
# export results to tab separated text or CSV |
852 |
# export results to tab separated text or CSV |
852 |
my $report_id = $input->param('report_id'); |
853 |
my $report_id = $input->param('report_id'); |
853 |
my $report = get_saved_report($report_id); |
854 |
my $report = Koha::Reports->find($report_id); |
854 |
my $sql = $report->{savedsql}; |
855 |
my $sql = $report->savedsql; |
855 |
my @param_names = $input->multi_param('param_name'); |
856 |
my @param_names = $input->multi_param('param_name'); |
856 |
my @sql_params = $input->multi_param('sql_params'); |
857 |
my @sql_params = $input->multi_param('sql_params'); |
857 |
my $format = $input->param('format'); |
858 |
my $format = $input->param('format'); |