dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18154
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7539: Don't allow to set an date to the future in Enrollment form.
------------------------------------------------------------
revno: 7539
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-07-09 15:35:46 +0700
message:
Don't allow to set an date to the future in Enrollment form.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm 2012-07-05 09:07:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm 2012-07-09 08:35:46 +0000
@@ -106,6 +106,6 @@
validateProgramEnrollment();
});
- datePickerInRange( 'dateOfIncident' , 'enrollmentDate' );
+ datePickerInRangeValid( 'dateOfIncident' , 'enrollmentDate' );
});
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-06-19 03:52:43 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-07-09 08:35:46 +0000
@@ -976,6 +976,49 @@
$("#ui-datepicker-div").hide();
}
+function datePickerInRangeValid( startdate, enddate, setCurrentStartDate, setCurrentEndDate )
+{
+ if( setCurrentStartDate == undefined ) setCurrentStartDate = true;
+ if( setCurrentEndDate == undefined ) setCurrentEndDate = true;
+
+ s = jQuery("#" + startdate );
+ e = jQuery("#" + enddate );
+ if( setCurrentStartDate && s.val()=='') s.val( getCurrentDate() );
+ if( setCurrentEndDate && e.val()=='' ) e.val( getCurrentDate() );
+
+ var dates = $('#'+startdate+', #' + enddate).datepicker(
+ {
+ dateFormat: dateFormat,
+ defaultDate: "+1w",
+ changeMonth: true,
+ changeYear: true,
+ numberOfMonths: 1,
+
+ maxDate: '+0d +0w',
+ monthNamesShort: monthNames,
+ dayNamesMin: dayNamesMin,
+ showAnim: '',
+ showOn: 'both',
+ buttonImage: '../images/calendar.png',
+ buttonImageOnly: true,
+ constrainInput: true,
+ yearRange: '-100:+100',
+ onSelect: function(selectedDate)
+ {
+ var option = this.id == startdate ? "minDate" : "maxDate";
+ var instance = $(this).data("datepicker");
+ var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
+ dates.not(this).datepicker("option", option, date);
+ }
+ });
+
+ jQuery( "#" + startdate ).attr("readonly", true );
+ jQuery( "#" + enddate ).attr("readonly", true );
+
+ $("#ui-datepicker-div").hide();
+}
+
+
function getCurrentDate()
{
return jQuery.datepicker.formatDate( dateFormat , new Date() ) ;