Bug 8428 - can't save contracts
authorOwen Leonard <oleonard@myacpl.org>
Thu, 23 Aug 2012 17:01:02 +0000 (13:01 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 14 Sep 2012 15:30:44 +0000 (17:30 +0200)
When I replaced the old calendar widget with the jQueryUI version
we lost a JavaScript function which is required by a couple of
pages: Date_from_syspref. This patch adds the function back
to the calendar include and corrects variables in the two
affected templates to make it work again.

To test:

- create a new contract. Submitting should work properly and
  without JavaScript errors.
- Open the serials claims page (serials/claims.pl) and filter
  the results by date. Submitting the filter form should
  work properly and without JavaScript errors.

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Both tests passed.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt

index d77e9e0..fc8a1a3 100644 (file)
@@ -1,5 +1,26 @@
 <script type="text/javascript">
 //<![CDATA[
+
+var debug    = "[% debug %]";
+var dformat  = "[% dateformat %]";
+var sentmsg = 0;
+if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
+
+function Date_from_syspref(dstring) {
+        var dateX = dstring.split(/[-/]/);
+        if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
+        if (dformat === "iso") {
+                return new Date(dateX[0], (dateX[1] - 1), dateX[2]);  // YYYY-MM-DD to (YYYY,m(0-11),d)
+        } else if (dformat === "us") {
+                return new Date(dateX[2], (dateX[0] - 1), dateX[1]);  // MM/DD/YYYY to (YYYY,m(0-11),d)
+        } else if (dformat === "metric") {
+                return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD/MM/YYYY to (YYYY,m(0-11),d)
+        } else {
+                if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
+                return 0;
+        }
+}
+
 /* Instead of including multiple localization files as you would normally see with
    jQueryUI we expose the localization strings in the default configuration */
 jQuery(function($){
index 7103971..e723ed4 100644 (file)
@@ -22,8 +22,8 @@ function Check(ff) {
         ok=1;
         _alertString += _("- Name missing") + "\n";
     }
-    var startDate = Date_from_syspref($("#contractstartdate").val());
-    var endDate   = Date_from_syspref($("#contractenddate").val());
+    var startDate = Date_from_syspref($("#from").val());
+    var endDate   = Date_from_syspref($("#to").val());
     if (!parseInt(startDate.getTime())) {
         ok=1;
         _alertString += _("- Start date missing or invalid.") + "\n";
index b47b51b..5d9f7a9 100644 (file)
@@ -92,8 +92,8 @@
        }
        // Filter by date
        function filterByDate() {
-           var beginDate = Date_from_syspref($("#begindate").val()).getTime();
-           var endDate   = Date_from_syspref($("#enddate").val()).getTime();
+        var beginDate = Date_from_syspref($("#from").val()).getTime();
+        var endDate   = Date_from_syspref($("#to").val()).getTime();
            
            // Checks if the beginning date is valid
            if (!parseInt(beginDate)) {