Bug 5698: Add date picker option to SQL Runtime Parameters
authorIan Walls <koha.sekjal@gmail.com>
Sat, 10 Mar 2012 14:03:20 +0000 (09:03 -0500)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 19 Mar 2012 15:20:29 +0000 (16:20 +0100)
Adds a date picker for SQL reports with the 'date' authorised_value.  Updates help
documentation for this new feature, as well.

To test:
1.  Create a new report with two date parameters, using the syntax:
<<Label for this selection of date|date>>
2.  Run the report
3.  Select dates
4.  The SQL generated should format the dates properly in ISO, and keep track of which
date is which

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
koha-tmpl/intranet-tmpl/prog/en/modules/help/reports/guided_reports.tt
reports/guided_reports.pl

index f89e887..2eaba5a 100644 (file)
@@ -62,7 +62,7 @@
 <ul>
 <li>The &lt;&lt; and &gt;&gt; are just delimiters. You must put &lt;&lt; at the beginning and &gt;&gt; at the end of your parameter</li>
 <li>The <strong>Question to ask</strong> will be displayed on the left of the string to enter. 
-<li>The <strong>authorised_value</strong> can be omitted if not applicable. If it contains an authorised value category, or <strong>branches</strong> or <strong>itemtype</strong> or <strong>categorycode</strong>, a list with the Koha authorised values will be displayed instead of a free field</li>
+<li>The <strong>authorised_value</strong> can be omitted if not applicable. If it contains an authorised value category, or <strong>branches</strong> or <strong>itemtype</strong> or <strong>categorycode</strong>, a list with the Koha authorised values will be displayed instead of a free field.  If the authorised value is <strong>date</strong>, a date selector button will be added after the input field</li>
 </ul>
 
 <p>Note that you can have more than one parameter in a given SQL</p>
index 27377e0..ce9370a 100755 (executable)
@@ -420,7 +420,21 @@ elsif ($phase eq 'Run this report'){
         for(my $i=0;$i<($#split/2);$i++) {
             my ($text,$authorised_value) = split /\|/,$split[$i*2+1];
             my $input;
-            if ($authorised_value) {
+            if ($authorised_value eq "date") {
+               $input = qq(<input id="date_$text" type="text" value="" size="10" name="sql_params">
+                         <img id="date_picker_$text" alt="Show Calendar" src="/intranet-tmpl/prog/en/lib/calendar/cal.gif">
+                         <script type="text/javascript">
+                              Calendar.setup(
+                              {
+                                 inputField : "date_$text",
+                                 ifFormat : "%Y-%m-%d",
+                                 button : "date_picker_$text"
+                              }
+                              );
+                         </script>
+                         );
+            }
+            elsif ($authorised_value) {
                 my $dbh=C4::Context->dbh;
                 my @authorised_values;
                 my %authorised_lib;