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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-36 / +63 lines)
Lines 1770-1775 Link Here
1770
    [% Asset.css("lib/codemirror/highlight.css") | $raw %]
1770
    [% Asset.css("lib/codemirror/highlight.css") | $raw %]
1771
    [% Asset.js( "js/mana.js" ) | $raw %]
1771
    [% Asset.js( "js/mana.js" ) | $raw %]
1772
    [% INCLUDE 'select2.inc' %]
1772
    [% INCLUDE 'select2.inc' %]
1773
    <script>
1774
        let op = "";
1775
        [% IF create %]
1776
            op = "create";
1777
        [% ELSIF editsql %]
1778
            op = "editsql";
1779
        [% ELSIF save %]
1780
            op = "save";
1781
        [% ELSIF showsql %]
1782
            op = "showsql";
1783
        [% ELSIF showreport %]
1784
            op = "showreport";
1785
        [% END %]
1786
1787
        let saved1 = [% saved1 ? 1 : 0 | html %];
1788
        const interface = "[% interface | html %]";
1789
        const theme = "[% theme | html %]";
1790
        const has_errors = [% errors ? 1 : 0 | html %];
1791
        const original_results = [% results.json || '[]'| $raw %];
1792
        const all_results = [% allresults.json || '[]' | $raw %];
1793
        const header_row = [% header_row.json || '[]' | $raw %];
1794
        const unlimited_total = [% unlimited_total || 0 | $raw %];
1795
1796
        var group_subgroups = {};
1797
        [% FOREACH group IN groups_with_subgroups %]
1798
            var gid = "[% group.id | html %]"
1799
            group_subgroups[gid] = new Array();
1800
            [% FOREACH subgroup IN group.subgroups %]
1801
                var sgid = "[% subgroup.id | html %]";
1802
                var sgname = "[% subgroup.name | html %]";
1803
                group_subgroups[gid].push([sgid, sgname]);
1804
            [% END %]
1805
        [% END %]
1806
1807
        var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
1808
1809
        const tables = [% To.json(tables || []) | $raw %];
1810
    </script>
1811
1773
    <script>
1812
    <script>
1774
        //  if the report param form has multiselects override default form submission
1813
        //  if the report param form has multiselects override default form submission
1775
        if( $('#report_param_form').find('select[multiple]').length ) {
1814
        if( $('#report_param_form').find('select[multiple]').length ) {
Lines 1819-1836 Link Here
1819
        }
1858
        }
1820
1859
1821
        var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1860
        var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
1822
        var group_subgroups = {};
1823
        [% FOREACH group IN groups_with_subgroups %]
1824
            var gid = "[% group.id | html %]"
1825
            group_subgroups[gid] = new Array();
1826
            [% FOREACH subgroup IN group.subgroups %]
1827
                var sgid = "[% subgroup.id | html %]";
1828
                var sgname = "[% subgroup.name | html %]";
1829
                group_subgroups[gid].push([sgid, sgname]);
1830
            [% END %]
1831
        [% END %]
1832
1861
1833
        [% IF ( create || editsql || save ) %]
1862
        if (op == "create" || op == "editsql" || op == "save" ) {
1834
1863
1835
            var editor = CodeMirror.fromTextArea(sql, {
1864
            var editor = CodeMirror.fromTextArea(sql, {
1836
                lineNumbers: true,
1865
                lineNumbers: true,
Lines 1843-1849 Link Here
1843
                },
1872
                },
1844
                hint: CodeMirror.hint.sql,
1873
                hint: CodeMirror.hint.sql,
1845
                hintOptions: {
1874
                hintOptions: {
1846
                    tables: [% To.json(tables) | $raw %]
1875
                    tables
1847
                }
1876
                }
1848
            });
1877
            });
1849
            var ExcludedTriggerKeys = { //key-code combinations of keys that will not fire the auto-complete script
1878
            var ExcludedTriggerKeys = { //key-code combinations of keys that will not fire the auto-complete script
Lines 1919-1927 Link Here
1919
                validator.resetForm();//remove error class on name elements and clear history
1948
                validator.resetForm();//remove error class on name elements and clear history
1920
                validator.reset();//remove all error and success data
1949
                validator.reset();//remove all error and success data
1921
            }
1950
            }
1922
        [% END %]
1951
        }
1923
1952
1924
        [% IF ( showsql || showreport ) %]
1953
        if (op == "showsql" || op == "showreport") {
1925
1954
1926
            var editor = CodeMirror.fromTextArea(sql, {
1955
            var editor = CodeMirror.fromTextArea(sql, {
1927
                lineNumbers: false,
1956
                lineNumbers: false,
Lines 1933-1939 Link Here
1933
                    "<<(.*?)>>":"style1"
1962
                    "<<(.*?)>>":"style1"
1934
               },
1963
               },
1935
            });
1964
            });
1936
        [% END %]
1965
        }
1937
1966
1938
        function showParamModal( category ){
1967
        function showParamModal( category ){
1939
            var modal = $("#runtime_parameters");
1968
            var modal = $("#runtime_parameters");
Lines 2044-2050 Link Here
2044
            }
2073
            }
2045
2074
2046
            $("body").on('click',".fetch_chart_data",function(){
2075
            $("body").on('click',".fetch_chart_data",function(){
2047
                if( [% unlimited_total || 0 | $raw %] > 1000 ){
2076
                if( unlimited_total > 1000 ){
2048
                    if( confirm( _("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you want to chart this report?") ) ){
2077
                    if( confirm( _("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you want to chart this report?") ) ){
2049
                        return true;
2078
                        return true;
2050
                    } else {
2079
                    } else {
Lines 2083-2089 Link Here
2083
            $('#download-chart').hide();
2112
            $('#download-chart').hide();
2084
            var chart;
2113
            var chart;
2085
2114
2086
            [% IF results && !errors %]
2115
            if ( original_results && !has_errors ) {
2087
                $('#draw-chart').click(function() {
2116
                $('#draw-chart').click(function() {
2088
2117
2089
                    var x_elements = $('select[name="x"]').val();
2118
                    var x_elements = $('select[name="x"]').val();
Lines 2092-2110 Link Here
2092
                    var lines = [];
2121
                    var lines = [];
2093
                    var options = {};
2122
                    var options = {};
2094
2123
2095
                    headers = [% header_row.json | $raw %];
2124
                    headers = header_row;
2096
2125
2097
                    var results;
2126
                    var results;
2098
                    [% IF allresults.size %]
2127
                    if (all_results.length){
2099
                        if ($('input[name="chart-include-all"]').prop('checked')) {
2128
                        if ($('input[name="chart-include-all"]').prop('checked')) {
2100
                            results = [% allresults.json | $raw %]
2129
                            results = all_results;
2101
                        }
2130
                        }
2102
                        else {
2131
                        else {
2103
                            results = [% results.json | $raw %]
2132
                            results = original_results;
2104
                        }
2133
                        }
2105
                    [% ELSE %]
2134
                    } else {
2106
                        results = [% results.json | $raw %];
2135
                        results = original_results;
2107
                    [% END %]
2136
                    }
2108
2137
2109
                    if ($('input[name="chart-exclude-last"]').prop('checked')) {
2138
                    if ($('input[name="chart-exclude-last"]').prop('checked')) {
2110
                        results.splice(-1, 1);
2139
                        results.splice(-1, 1);
Lines 2157-2166 Link Here
2157
                    $("#toggle_chart_settings_vis").hide();
2186
                    $("#toggle_chart_settings_vis").hide();
2158
                    $("#chartModal").modal("hide");
2187
                    $("#chartModal").modal("hide");
2159
                });
2188
                });
2160
            [% END %]
2189
            }
2161
            [% IF ( create ) %]
2190
            if (op == "create"){
2162
                load_group_subgroups();
2191
                load_group_subgroups();
2163
            [% END %]
2192
            }
2164
2193
2165
            $('#limit').change(function() {
2194
            $('#limit').change(function() {
2166
                $('#limitselect').submit();
2195
                $('#limitselect').submit();
Lines 2209-2216 Link Here
2209
                delColumn();
2238
                delColumn();
2210
            });
2239
            });
2211
2240
2212
            [% IF (saved1) %]
2241
            if (saved1){
2213
                var table_settings = [% TablesSettings.GetTableSettings( 'reports', 'saved-sql', 'table_reports', 'json' ) | $raw %];
2214
                var rtable = $("#table_reports").kohaTable(
2242
                var rtable = $("#table_reports").kohaTable(
2215
                    {
2243
                    {
2216
                        autoWidth: false,
2244
                        autoWidth: false,
Lines 2275-2289 Link Here
2275
2303
2276
                $("#update_sql").on("hidden.bs.modal", function(){
2304
                $("#update_sql").on("hidden.bs.modal", function(){
2277
                    $("#update_sql_label").html("");
2305
                    $("#update_sql_label").html("");
2278
                    $("#update_sql .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
2306
                    $("#update_sql .modal-body").html('<div id="loading"><img src="' + interface + "/" + theme + '/img/spinner-small.gif" alt="" /> ' + _("Loading") + "</div>");
2279
                });
2307
                });
2280
            [% END %]
2308
            }
2281
2309
2282
            [% IF ( showsql ) %]
2310
            if (op == "showsql"){
2283
                $("#sql").focus(function() {
2311
                $("#sql").focus(function() {
2284
                    $(this).select();
2312
                    $(this).select();
2285
                });
2313
                });
2286
            [% END %]
2314
            }
2287
2315
2288
            $("#toggle_sql").click(function(){
2316
            $("#toggle_sql").click(function(){
2289
                var sql_output = $("#sql_output");
2317
                var sql_output = $("#sql_output");
Lines 2307-2313 Link Here
2307
                $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
2335
                $("#chart, #toggle_chart_settings_hid, #toggle_chart_settings_vis").toggle();
2308
            });
2336
            });
2309
2337
2310
            [% IF (create || editsql || save) %]
2338
            if (op == "create" || op == "editsql" || op == "save"){
2311
2339
2312
                var validated_form = $("#sql_report_form").validate({
2340
                var validated_form = $("#sql_report_form").validate({
2313
                    reportname: "required",
2341
                    reportname: "required",
Lines 2452-2458 Link Here
2452
                    $("#param_category").val( $(this).val() );
2480
                    $("#param_category").val( $(this).val() );
2453
                });
2481
                });
2454
2482
2455
            [% END %]
2483
            }
2456
2484
2457
            $("#mana_search_form").submit(function(e){
2485
            $("#mana_search_form").submit(function(e){
2458
                e.preventDefault();
2486
                e.preventDefault();
2459
- 

Return to bug 41797