# Suite 330, Boston, MA 02111-1307 USA
use strict;
-use C4::Auth;
use CGI;
-use C4::Output;
use C4::Reports;
-
+use C4::Auth;
+use C4::Output;
=head1 NAME
Script to control the guided report creation
=cut
my $input = new CGI;
+my $referer = $input->referer();
+
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "reports/guided_reports_start.tmpl",
$template->param( 'savedreports' => $reports );
}
+elsif ( $phase eq 'Delete Saved') {
+
+ # delete a report from the saved reports list
+ $no_html = 1;
+ my $id = $input->param('reports');
+ delete_report($id);
+ print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Used%20saved");
+
+}
+
+elsif ( $phase eq 'Show SQL'){
+
+ my $id = $input->param('reports');
+ my $sql = get_sql($id);
+ $template->param(
+ 'sql' => $sql,
+ 'showsql' => 1,
+ );
+}
+
+elsif ($phase eq 'retrieve results') {
+ my $id = $input->param('id');
+ my ($results,$name,$notes) = format_results($id);
+ # do something
+ $template->param(
+ 'retresults' => 1,
+ 'results' => $results,
+ 'name' => $name,
+ 'notes' => $notes,
+ );
+
+}
+
elsif ( $phase eq 'Report on this Area' ) {
# they have choosen a new report and the area to report on
);
# get columns
- my $columns = get_columns($area);
+ my $columns = get_columns($area,$input);
$template->param( 'columns' => $columns );
}
my $type = $input->param('type');
my @columns = $input->param('columns');
my $column = join( ',', @columns );
+ my $definitions = get_from_dictionary($area);
$template->param(
'build4' => 1,
'area' => $area,
'type' => $type,
'column' => $column,
);
- my $criteria = get_criteria($area);
- $template->param( 'criteria' => $criteria );
+ my $criteria = get_criteria($area,$input);
+ $template->param( 'criteria' => $criteria,
+ 'definitions' => $definitions);
}
elsif ( $phase eq 'Choose these criteria' ) {
my $area = $input->param('area');
my $type = $input->param('type');
my $column = $input->param('column');
+ my @definitions = $input->param('definition');
+ my $definition = join (',',@definitions);
my @criteria = $input->param('criteria_column');
my $query_criteria;
foreach my $crit (@criteria) {
'area' => $area,
'type' => $type,
'column' => $column,
+ 'definition' => $definition,
'criteriastring' => $query_criteria,
);
$template->param( 'total_by' => \@total_by );
}
-elsif ( $phase eq 'Choose Totals' ) {
+elsif ( $phase eq 'Choose These Operations' ) {
my $area = $input->param('area');
my $type = $input->param('type');
my $column = $input->param('column');
my $criteria = $input->param('criteria');
+ my $definition = $input->param('definition');
my @total_by = $input->param('total_by');
my $totals;
foreach my $total (@total_by) {
'column' => $column,
'criteriastring' => $criteria,
'totals' => $totals,
+ 'definition' => $definition,
);
# get columns
my $column = $input->param('column');
my $crit = $input->param('criteria');
my $totals = $input->param('totals');
+ my $definition = $input->param('definition');
# my @criteria = split( ',', $crit );
my $query_criteria=$crit;
# split the columns up by ,
# get the sql
my $sql =
- build_query( \@columns, $query_criteria, $query_orderby, $area, $totals );
+ build_query( \@columns, $query_criteria, $query_orderby, $area, $totals, $definition );
$template->param(
'showreport' => 1,
'sql' => $sql,
my $type = $input->param('type');
my $notes = $input->param('notes');
save_report( $sql, $name, $type, $notes );
+ $template->param(
+ 'save_successful' => 1,
+ );
}
elsif ( $phase eq 'Execute' ) {
elsif ($phase eq 'Run this report'){
# execute a saved report
my $report = $input->param('reports');
- my ($sql,$type) = get_saved_report($report);
+ my ($sql,$type,$name,$notes) = get_saved_report($report);
my $results = execute_query($sql,$type);
$template->param(
'results' => $results,
'sql' => $sql,
- 'execute' => 1
+ 'execute' => 1,
+ 'name' => $name,
+ 'notes' => $notes,
);
}
}
+$template->param( 'referer' => $referer );
+
+
if (!$no_html){
output_html_with_http_headers $input, $cookie, $template->output;
}