Merge remote-tracking branch 'origin/new/bug_8597'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / guided_reports_start.tt
index f516f8a..aa6a627 100644 (file)
 
 <script type="text/javascript">
 //<![CDATA[
+var group_subgroups = {};
+var no_subgroup_label = _( "(None)" );
+function load_group_subgroups () {
+    var group = $("#group").val();
+    var sg = $("#subgroup");
+    var has_subgroups = false;
+    $(sg).empty().append('<option value="">' + no_subgroup_label + '</option>');
+    if (group) {
+        $.each( group_subgroups[group], function(index, value) {
+                has_subgroups = true;
+            $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(sg);
+        } );
+    }
+    if (has_subgroups) {
+        $(sg).show();
+    } else {
+        $(sg).hide();
+    }
+}
 $(document).ready(function(){
 [% IF ( showsql ) %]
     $("#sql").focus(function() {
@@ -56,6 +75,9 @@ $(document).ready(function(){
     positionFixed: false,
     size:          20
   });
+  // redefine the datepicker's default because reports require ISO
+  // http://jqueryui.com/demos/datepicker/#option-dateFormat
+  $( ".datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
 });
 //]]>
 </script>
@@ -135,9 +157,14 @@ canned reports and writing custom SQL reports.</p>
   <th>ID</th>
   <th>Report name</th>
   <th>Type</th>
+  <th>Area</th>
+  <th>Group</th>
+  <th>Subgroup</th>
   <th>Notes</th>
   <th>Author</th>
   <th>Creation date</th>
+  <th>Public</th>
+  [% IF (usecache) %] <th>Cache expiry (seconds)</th> [% END %]
   <th>Saved results</th>
   <th>Saved SQL</th>
   <th>&nbsp;</th>
@@ -150,9 +177,18 @@ canned reports and writing custom SQL reports.</p>
 <td>[% savedreport.id %]</td>
 <td>[% savedreport.report_name %]</td>
 <td>[% savedreport.type %]</td>
+<td>[% savedreport.areaname %]</td>
+<td>[% savedreport.groupname %]</td>
+<td>[% savedreport.subgroupname %]</td>
 <td>[% savedreport.notes %]</td>
 <td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td>
 <td>[% savedreport.date_created %]</td>
+[% IF (savedreport.public) %]
+<td>Yes</td>
+[% ELSE %]
+<td>No</td>
+[% END %]
+[% IF (usecache) %] <td>[% savedreport.cache_expiry %]</td> [% END %]
 <td>[% IF ( savedreport.date_run ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&amp;id=[% savedreport.id %]">[% savedreport.date_run %]</a>[% END %]
 </td>
     <td>
@@ -199,16 +235,36 @@ canned reports and writing custom SQL reports.</p>
 
 
 [% IF ( build1 ) %]
+[% IF ( cache_error) %]
+<div class="dialog alert">
+<b> Please choose a cache_expiry less than 30 days </b>
+</div>
+[% END %]
 <h1>Build a report</h1>
 <form action="/cgi-bin/koha/reports/guided_reports.pl">
 <fieldset class="rows">
-<legend>Step 1 of 6: Choose a module to report on</legend>
-<ol><li><label for="areas">Choose: </label><select name="areas" id="areas">
+<legend>Step 1 of 6: Choose a module to report on,[% IF (usecache) %] Set cache expiry, [% END %] and Choose report visibility </legend>
+<ol><li><label for="area">Choose: </label><select name="area" id="area">
 [% FOREACH area IN areas %]
 <option value="[% area.id %]">[% area.name %]</option>
 [% END %]
-</select></li></ol>
-</fieldset>
+</select></li>
+[% IF (public) %]
+  <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</public> </select></li>
+[% ELSE %]
+  <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0" selected="selected">No (default)</option> <option value="1">Yes</public> </select></li>
+[% END %]
+[% IF (usecache) %] <li>
+<label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry %]"></input>
+<select id="cache_expiry_units" name="cache_expiry_units">
+<option value="seconds">Seconds (default)</option>
+<option value="minutes">Minutes</option>
+<option value="hours">Hours</option>
+<option value="days">Days</option>
+</select>
+</li>[% END %]
+</ol>
+<ofieldset>
 <fieldset class="action">
 <input type="hidden" name="phase" value="Report on this Area" />
 <input type="submit" name="submit" value="Next &gt;&gt;" />
@@ -222,6 +278,8 @@ canned reports and writing custom SQL reports.</p>
 <h1>Build A Report</h1>
 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
 <input type="hidden" name="area" value="[% area %]" />
+<input type="hidden" name="public" value="[% public %]" />
+<input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
 <fieldset class="rows"><legend>Step 2 of 6: Pick a report type</legend>
 <ol><li><label for="types">Choose: </label>
     <select id="types" name="types">
@@ -255,6 +313,8 @@ canned reports and writing custom SQL reports.</p>
 <form id="column_submit" action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
     <input type="hidden" name="area" value="[% area %]" />
     <input type="hidden" name="type" value="[% type %]" />
+    <input type="hidden" name="public" value="[% public %]" />
+    <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
     <fieldset>
 <div class="yui-g">
 <div class="yui-u first">      <div style="float: left;"><select id="availableColumns" name="oldcolumns2" multiple="multiple" size="25" style="min-width: 200px;height:300px;">
@@ -303,6 +363,8 @@ canned reports and writing custom SQL reports.</p>
     <input type="hidden" name="area" value="[% area %]" />
     <input type="hidden" name="type" value="[% type %]" />
     <input type="hidden" name="column" value="[% column %]" />
+    <input type="hidden" name="public" value="[% public %]" />
+    <input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
     <fieldset><legend>Step 4 of 6: Select criteria to limit on</legend>
     <table>
         [% FOREACH criteri IN criteria %]
@@ -313,16 +375,7 @@ canned reports and writing custom SQL reports.</p>
         </td>
         [% IF ( criteri.date ) %]
         <td>
-            <input type="text" size="10" id="[% criteri.name %]_value" name="[% criteri.name %]_value" value="" />
-            <img src="[% themelang %]/lib/calendar/cal.gif" id="buttonfrom[% criteri.name %]" style="cursor: pointer;" alt="Show calendar" title="Show calendar" />
-            <script type="text/javascript">   
-            Calendar.setup({  
-            inputField     : "[% criteri.name %]_value",
-            ifFormat       : "[% DHTMLcalendar_dateformat %]",
-            button         : "buttonfrom[% criteri.name %]",
-            align          : "Tl" 
-            });     
-            </script>          
+            <input type="text" size="10" id="[% criteri.name %]_value" name="[% criteri.name %]_value" value="" class="datepicker" />
                <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
         </td>
         </tr>
@@ -336,27 +389,9 @@ canned reports and writing custom SQL reports.</p>
         [% ELSE %]
             [% IF ( criteri.daterange ) %]
             <td>from 
-            <input type="text" size="10" id="from_[% criteri.name %]_value" name="from_[% criteri.name %]_value" value="" />
-            <img src="[% themelang %]/lib/calendar/cal.gif" id="buttonfromfrom_[% criteri.name %]" style="cursor: pointer;" alt="Show calendar" title="Show calendar" />
-            <script type="text/javascript">   
-                Calendar.setup({  
-                inputField     : "from_[% criteri.name %]_value",
-                ifFormat       : "[% DHTMLcalendar_dateformat %]",
-                button         : "buttonfromfrom_[% criteri.name %]",
-                align          : "Tl" 
-                });     
-            </script>         
+            <input type="text" size="10" id="from_[% criteri.name %]_value" name="from_[% criteri.name %]_value" value="" class="datepickerfrom" />
             to
-            <input type="text" size="10" id="to_[% criteri.name %]_value" name="to_[% criteri.name %]_value" value="" />
-            <img src="[% themelang %]/lib/calendar/cal.gif" id="buttonfromto_[% criteri.name %]" style="cursor: pointer;" alt="Show calendar" title="Show calendar" />
-            <script type="text/javascript">   
-                Calendar.setup({  
-                inputField     : "to_[% criteri.name %]_value",
-                ifFormat       : "[% DHTMLcalendar_dateformat %]",
-                button         : "buttonfromto_[% criteri.name %]",
-                align          : "Tl" 
-                });     
-            </script>        
+            <input type="text" size="10" id="to_[% criteri.name %]_value" name="to_[% criteri.name %]_value" value="" class="datepickerto" />
                        <span class="hint">[% INCLUDE 'date-format.inc' %]</span>
             </td>
         </tr>
@@ -399,6 +434,8 @@ canned reports and writing custom SQL reports.</p>
 <input type="hidden" name="column" value="[% column %]" />
 <input type="hidden" name="definition" value="[% definition %]" />
 <input type="hidden" name="criteria" value="[% criteriastring %]" />
+<input type="hidden" name="public" value="[% public %]" />
+<input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
 <fieldset><table>
 [% FOREACH total_b IN total_by %]
 <tr><td><input type="checkbox" name="total_by" id="[% total_b.name %]" value="[% total_b.name %]" /> <label for="[% total_b.name %]">[% total_b.name %]</label></td>
@@ -429,6 +466,8 @@ canned reports and writing custom SQL reports.</p>
 <input type="hidden" name="criteria" value="[% criteriastring %]" />
 <input type="hidden" name="definition" value="[% definition %]" />
 <input type="hidden" name="totals" value="[% totals %]" />
+<input type="hidden" name="public" value="[% public %]" />
+<input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
 <fieldset><table>[% FOREACH order_b IN order_by %]
 <tr><td><input type="checkbox" id="[% order_b.name %]" name="order_by" value="[% order_b.name %]" /> <label for="[% order_b.name %]">[% order_b.name %]</label></td><td>
 <select name="[% order_b.name %]_ovalue">
@@ -459,6 +498,8 @@ canned reports and writing custom SQL reports.</p>
 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
 <input type="hidden" name="sql" value="[% sql %]" />
 <input type="hidden" name="type" value="[% type %]" />
+<input type="hidden" name="public" value="[% public %]" />
+<input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
 <p>You will need to save the report before you can execute it</p>
 <fieldset class="action"><input type="hidden" name="phase" value="Save" />  
 <input type="submit" name="submit" value="Save" />  </fieldset>
@@ -469,10 +510,38 @@ canned reports and writing custom SQL reports.</p>
 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
 <input type="hidden" name="sql" value="[% sql |html %]" />
 <input type="hidden" name="type" value="[% type %]" />
+<input type="hidden" name="area" value="[% area %]" />
+<input type="hidden" name="public" value="[% public %]" />
+<input type="hidden" name="cache_expiry" value="[% cache_expiry %]" />
 <fieldset class="rows">
 <legend>Save your custom report</legend>
 <ol>
     <li><label for="reportname">Report name: </label><input type="text" id="reportname" name="reportname" /></li>
+    [% IF groups_with_subgroups %]
+    <li><label for="group">Report group: </label><select name="group" id="group" onChange="load_group_subgroups();">
+        [% FOR g IN groups_with_subgroups %]
+            [% IF g.selected %]
+    <option value="[% g.id %]" selected>[% g.name %]</option>
+            [% ELSE %]
+    <option value="[% g.id %]">[% g.name %]</option>
+            [% END %]
+    <script type="text/javascript">
+        var g_sg = new Array();
+            [% FOR sg IN g.subgroups %]
+        g_sg.push(["[% sg.id %]", "[% sg.name %]"]);
+                [% IF sg.selected %]
+        $(document).ready(function() {
+            $("#subgroup").val("[% sg.id %]");
+        });
+                [% END %]
+            [% END %]
+        group_subgroups["[% g.id %]"] = g_sg;
+    </script>
+        [% END %]
+    </select></li>
+    <li><label for="subgroup">Report subgroup: </label><select name="subgroup" id="subgroup">
+    </select></li>
+    [% END %]
     <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li>
 </ol></fieldset>
 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
@@ -486,24 +555,22 @@ canned reports and writing custom SQL reports.</p>
         <input type='hidden' name='reports' value="[% reports %]" />
         <h1>Enter parameters for report [% name %]:</h1>
         [% IF ( notes ) %]<p>[% notes %]</p>[% END %]
+        <fieldset class="rows">
+            <ol>
         [% FOREACH sql_param IN sql_params %]
             [% IF sql_param.input == 'date' %]
-                <p>
-                [% sql_param.entry %]: <input id="date_[% sql_param_entry %]" type="text" value="" size="10" name="sql_params">
-                <img id="date_picker_[% sql_param_entry %]" alt="Show calendar" src="/intranet-tmpl/prog/en/lib/calendar/cal.gif">
-                <script type="text/javascript">
-                      Calendar.setup( {
-                         inputField : "date_[% sql_param_entry %]",
-                         ifFormat : "%Y-%m-%d",
-                         button : "date_picker_[% sql_param_entry %]"
-                      } );
-                </script>
-                </p>
+                <li>
+                <label for="date_[% sql_param_entry %][% loop.count %]">[% sql_param.entry %]:</label> <input id="date_[% sql_param_entry %][% loop.count %]" type="text" value="" size="10" name="sql_params" class="datepicker" />
+                </li>
+            [% ELSIF ( sql_param.input == 'text' ) %]
+                <li><label for="sql_params[% loop.count %]">[% sql_param.entry %]: </label><input id="sql_params[% loop.count %]" type="text" name="sql_params" /></li>
             [% ELSE %]
-                <p>[% sql_param.entry %]: [% sql_param.input %]</p>
+                <li><label for="sql_params_[% sql_param.labelid %]">[% sql_param.entry %]:</label> [% sql_param.input %]</li>
             [% END %]
         [% END %]
-        <input type='submit' value='Run the report'/>
+            </ol>
+        </fieldset>
+        <fieldset class="action"><input type="submit" value="Run the report" /></fieldset>
     </form>
 [% END %]
 
@@ -537,6 +604,11 @@ canned reports and writing custom SQL reports.</p>
 [% END %]
 
 [% IF ( create ) %]
+<script type="text/javascript">
+$(document).ready(function() {
+    load_group_subgroups();
+});
+</script>
 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
 <fieldset class="rows">
 <legend>Create report from SQL</legend>
@@ -545,6 +617,45 @@ canned reports and writing custom SQL reports.</p>
         [% IF ( reportname ) %]<input type="text" id="reportname" name="reportname" value="[% reportname %]" />
         [% ELSE %]<input type="text" id="reportname" name="reportname" />[% END %] 
     </li>
+    [% IF groups_with_subgroups %]
+    <li><label for="group">Report group: </label><select name="group" id="group" onChange="load_group_subgroups();">
+        [% FOR g IN groups_with_subgroups %]
+            [% IF g.selected %]
+    <option value="[% g.id %]" selected>[% g.name %]</option>
+            [% ELSE %]
+    <option value="[% g.id %]">[% g.name %]</option>
+            [% END %]
+    <script type="text/javascript">
+        var g_sg = new Array();
+            [% FOR sg IN g.subgroups %]
+        g_sg.push(["[% sg.id %]", "[% sg.name %]"]);
+                [% IF sg.selected %]
+        $(document).ready(function() {
+            $("#subgroup").val("[% sg.id %]");
+        });
+                [% END %]
+            [% END %]
+        group_subgroups["[% g.id %]"] = g_sg;
+    </script>
+        [% END %]
+    </select></li>
+    <li><label for="subgroup">Report subgroup: </label><select name="subgroup" id="subgroup">
+    </select></li>
+    [% END %]
+[% IF (public) %]
+  <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</public> </select></li>
+[% ELSE %]
+  <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0" selected="selected">No (default)</option> <option value="1">Yes</public> </select></li>
+[% END %]
+[% IF (usecache) %] <li>
+<label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry %]"></input>
+<select id="cache_expiry_units" name="cache_expiry_units">
+<option value="seconds" selected="selected">Seconds (default)</option>
+<option value="minutes">Minutes</option>
+<option value="hours">Hours</option>
+<option value="days">Days</option>
+</select>
+</li>[% END %]
     <li><label for="notes">Notes:</label> <textarea id="notes" name="notes" cols="50" rows="2">[% notes %]</textarea></li>
     <li><label for="types">Type:</label>
         <select id="types" name="types">
@@ -615,6 +726,11 @@ Sub report:<select name="subreport">
 [% END %]
 
 [% IF ( editsql ) %]
+<script type="text/javascript">
+$(document).ready(function() {
+    load_group_subgroups();
+});
+</script>
 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post">
 <input type="hidden" name="phase" value="Update SQL" />
 <input type="hidden" name="id" value="[% id %]"/>
@@ -622,6 +738,45 @@ Sub report:<select name="subreport">
 <legend>Edit SQL report</legend>
 <ol>
 <li><label for="reportname">Report name:</label><input type="text" id="reportname" name="reportname" value="[% reportname %]" size="50" /></li>
+    [% IF groups_with_subgroups %]
+    <li><label for="group">Report group: </label><select name="group" id="group" onChange="load_group_subgroups();">
+        [% FOR g IN groups_with_subgroups %]
+            [% IF g.selected %]
+    <option value="[% g.id %]" selected>[% g.name %]</option>
+            [% ELSE %]
+    <option value="[% g.id %]">[% g.name %]</option>
+            [% END %]
+    <script type="text/javascript">
+        var g_sg = new Array();
+            [% FOR sg IN g.subgroups %]
+        g_sg.push(["[% sg.id %]", "[% sg.name %]"]);
+                [% IF sg.selected %]
+        $(document).ready(function() {
+            $("#subgroup").val("[% sg.id %]");
+        });
+                [% END %]
+            [% END %]
+        group_subgroups["[% g.id %]"] = g_sg;
+    </script>
+        [% END %]
+    </select></li>
+    <li><label for="subgroup">Report subgroup: </label><select name="subgroup" id="subgroup">
+    </select></li>
+    [% END %]
+[% IF (public) %]
+  <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</public> </select></li>
+[% ELSE %]
+  <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0" selected="selelcted">No (default)</option> <option value="1">Yes</public> </select></li>
+[% END %]
+[% IF (usecache) %] <li>
+<label for="cache_expiry">Cache expiry:</label><input type="text" id="cache_expiry" name="cache_expiry" value="[% cache_expiry %]"></input>
+<select id="cache_expiry_units" name="cache_expiry_units">
+<option value="seconds">Seconds (default)</option>
+<option value="minutes">Minutes</option>
+<option value="hours">Hours</option>
+<option value="days">Days</option>
+</select>
+</li>[% END %]
 <li><label for="notes">Notes:</label><textarea id="notes" name="notes" cols="50" rows="2">[% notes %]</textarea></li>
 <li><textarea id="sql" name="sql" rows="10" cols="60">[% sql %]</textarea></li>
 </ol>
@@ -659,6 +814,7 @@ Sub report:<select name="subreport">
     <br />Use of this keyword is not allowed in Koha reports due to security and data integrity risks. Only SELECT queries are allowed.
     <br />Please return to the &quot;Saved Reports&quot; screen and delete this report or retry creating a new one.
     [% ELSIF ( error.queryerr ) %]The database returned the following error: <br />[% error.queryerr %]<br />Please check the log for further details.
+    [% ELSIF ( error.cache_expiry ) %]Please select a cache expiry less than 30 days.
     [% ELSE %]
     [% END %]
 [% END %]
@@ -674,24 +830,46 @@ Sub report:<select name="subreport">
 
 [% IF ( saved1 ) %]
 <div id="saved-reports-filter">
+<script type="text/javascript">
+$(document).ready(function() {
+    no_subgroup_label = _( "-- All --" );
+    load_group_subgroups();
+});
+</script>
 <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get">
   <input type="hidden" name="phase" value="Use saved" />
   <input type="hidden" name="filter_set" value="1" />
   <fieldset class="brief">
   <h3>Filter</h3>
   <ol>
-    <li><label for="filter_date">Date:
-  <img src="[% themelang %]/lib/calendar/cal.gif" id="datedueto_button" alt="Show calendar" /></label> <input type="text" id="filter_date" name="filter_date" size="10" value="[% filter_date %]" />
+    <li><label for="group">Choose Group and Subgroup: </label>
+    <select name="group" id="group" onChange="load_group_subgroups();">
+        <option value="">-- All --</option>
+    [% FOR g IN groups_with_subgroups %]
+        [% IF g.selected %]
+        <option value="[% g.id %]" selected>[% g.name %]</option>
+        [% ELSE %]
+        <option value="[% g.id %]">[% g.name %]</option>
+        [% END %]
+        <script type="text/javascript">
+            var g_sg = new Array();
+        [% FOR sg IN g.subgroups %]
+            g_sg.push(["[% sg.id %]", "[% sg.name %]"]);
+            [% IF sg.selected %]
+            $(document).ready(function() {
+                $("#subgroup").val("[% sg.id %]");
+            });
+            [% END %]
+        [% END %]
+            group_subgroups["[% g.id %]"] = g_sg;
+        </script>
+    [% END %]
+    </select>
+    <select name="subgroup" id="subgroup"></select>
+    </li>
+    <li><label for="filter_date">Date:</label> <input type="text" id="filter_date" name="filter_date" size="10" value="[% filter_date %]" class="datepicker" />
     <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
-    <script type="text/javascript">
-        Calendar.setup(
-        {
-          inputField : "filter_date",
-          ifFormat : "[% DHTMLcalendar_dateformat %]",
-          button : "filter_date_button"
-        }
-        );
-    </script>
+
     </li>
     <li><label for="filter_author">Author:</label> <input type="text" id="filter_author" name="filter_author" value="[% filter_author %]" /></li>
     <li><label for="filter_keyword">Keyword:</label> <input type="text" id="filter_keyword" name="filter_keyword" value="[% filter_keyword %]" /></li>