View | Details | Raw Unified | Return to bug 20663
Collapse All | Expand All

(-)a/C4/Reports/Guided.pm (-30 / +1 lines)
Lines 39-45 BEGIN { Link Here
39
    @ISA    = qw(Exporter);
39
    @ISA    = qw(Exporter);
40
    @EXPORT = qw(
40
    @EXPORT = qw(
41
      get_report_types get_report_areas get_report_groups get_columns build_query get_criteria
41
      get_report_types get_report_areas get_report_groups get_columns build_query get_criteria
42
      save_report get_saved_reports execute_query get_saved_report create_compound run_compound
42
      save_report get_saved_reports execute_query get_saved_report
43
      get_column_type get_distinct_values save_dictionary get_from_dictionary
43
      get_column_type get_distinct_values save_dictionary get_from_dictionary
44
      delete_definition delete_report format_results get_sql
44
      delete_definition delete_report format_results get_sql
45
      nb_rows update_sql
45
      nb_rows update_sql
Lines 718-752 sub get_saved_report { Link Here
718
    return $dbh->selectrow_hashref($query, undef, $report_arg);
718
    return $dbh->selectrow_hashref($query, undef, $report_arg);
719
}
719
}
720
720
721
=head2 create_compound($masterID,$subreportID)
722
723
This will take 2 reports and create a compound report using both of them
724
725
=cut
726
727
sub create_compound {
728
    my ( $masterID, $subreportID ) = @_;
729
    my $dbh = C4::Context->dbh();
730
731
    # get the reports
732
    my $master = get_saved_report($masterID);
733
    my $mastersql = $master->{savedsql};
734
    my $mastertype = $master->{type};
735
    my $sub = get_saved_report($subreportID);
736
    my $subsql = $master->{savedsql};
737
    my $subtype = $master->{type};
738
739
    # now we have to do some checking to see how these two will fit together
740
    # or if they will
741
    my ( $mastertables, $subtables );
742
    if ( $mastersql =~ / from (.*) where /i ) {
743
        $mastertables = $1;
744
    }
745
    if ( $subsql =~ / from (.*) where /i ) {
746
        $subtables = $1;
747
    }
748
    return ( $mastertables, $subtables );
749
}
750
721
751
=head2 get_column_type($column)
722
=head2 get_column_type($column)
752
723
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-25 lines)
Lines 794-824 $(document).ready(function() { Link Here
794
</form>
794
</form>
795
[% END %]
795
[% END %]
796
796
797
[% IF ( compound ) %]
798
<form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
799
Master: <select name="master">
800
[% FOREACH savedreport IN savedreports %]
801
<option value="[% savedreport.id %]">[% savedreport.report_name %]</option>
802
[% END %]
803
</select>
804
&nbsp;
805
Sub report:<select name="subreport">
806
[% FOREACH savedreport IN savedreports %]
807
<option value="[% savedreport.id %]">[% savedreport.report_name %]</option>
808
[% END %]
809
</select>
810
<br />
811
<input type="hidden" name="phase" value="Save Compound" />
812
<input type="submit" name="submit" value="Save compound" />
813
</form>
814
[% END %]
815
816
[% IF ( save_compound ) %]
817
[% master %] <br />
818
[% subsql %]
819
[% END %]
820
821
822
[% IF saved_results %]
797
[% IF saved_results %]
823
<h1>Saved report results</h1>
798
<h1>Saved report results</h1>
824
<h2>[% name %]</h2>
799
<h2>[% name %]</h2>
(-)a/reports/guided_reports.pl (-17 lines)
Lines 974-995 elsif ( $phase eq 'Create report from SQL' ) { Link Here
974
    );
974
    );
975
}
975
}
976
976
977
elsif ($phase eq 'Create Compound Report'){
978
	$template->param( 'savedreports' => get_saved_reports(),
979
		'compound' => 1,
980
	);
981
}
982
983
elsif ($phase eq 'Save Compound'){
984
    my $master    = $input->param('master');
985
	my $subreport = $input->param('subreport');
986
	my ($mastertables,$subtables) = create_compound($master,$subreport);
987
	$template->param( 'save_compound' => 1,
988
		master=>$mastertables,
989
		subsql=>$subtables
990
	);
991
}
992
993
# pass $sth, get back an array of names for the column headers
977
# pass $sth, get back an array of names for the column headers
994
sub header_cell_values {
978
sub header_cell_values {
995
    my $sth = shift or return ();
979
    my $sth = shift or return ();
996
- 

Return to bug 20663