Bug 8428 - can't save contracts

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>
This commit is contained in:
Owen Leonard 2012-08-23 13:01:02 -04:00 committed by Paul Poulain
parent 53e08d9811
commit d2b5963e2f
3 changed files with 25 additions and 4 deletions

View 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($){

View 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";

View 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)) {