BUGFIXING mail alert on issue arrival
[koha_gimpoz] / reports / guided_reports.pl
index 4857eca..140f48a 100755 (executable)
 # You should have received a copy of the GNU General Public License along with
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
-use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
+
 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
@@ -36,6 +35,7 @@ Script to control the guided report creation
 
 my $input = new CGI;
 my $referer = $input->referer();
+
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {
         template_name   => "reports/guided_reports_start.tmpl",
@@ -86,13 +86,25 @@ elsif ( $phase eq 'Delete Saved') {
        
 }              
 
+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 = format_results($id);
+       my ($results,$name,$notes) = format_results($id);
        # do something
        $template->param(
                'retresults' => 1,
                'results' => $results,
+               'name' => $name,
+               'notes' => $notes,
                );
        
 }
@@ -125,7 +137,7 @@ elsif ( $phase eq 'Choose this type' ) {
     );
 
     # get columns
-    my $columns = get_columns($area);
+    my $columns = get_columns($area,$input);
     $template->param( 'columns' => $columns );
 }
 
@@ -144,7 +156,7 @@ elsif ( $phase eq 'Choose these columns' ) {
         'type'   => $type,
         'column' => $column,
     );
-    my $criteria = get_criteria($area);
+    my $criteria = get_criteria($area,$input);
     $template->param( 'criteria' => $criteria,
        'definitions' => $definitions);
 }
@@ -307,6 +319,9 @@ elsif ( $phase eq 'Save Report' ) {
     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' ) {
@@ -324,12 +339,14 @@ 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,
     );
 }