123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- function hts_datetime(dateFrom,dateTo,msgs)
- {
- this.m_dateFrom = dateFrom;
- this.m_dateTo = dateTo;
- this.m_msgs = msgs;
- this.m_dateTimeUtil = new hts_dateTimeUtil();
- }
- hts_datetime.prototype = {
-
- checkDate: function(fromDate,newDate) {
- var dateIsTheSame=true;
- iYear = newDate.substring(0,4);
- iMonth = newDate.substring(5, 7);
- iDay = newDate.substring(8, 10);
-
- if (fromDate) {
- newDateFrom = this.getDateFromValue();
- iNewStartYear = newDateFrom.substring(0,4);
- iNewStartMonth = newDateFrom.substring(5, 7);
- iNewStartDay = newDateFrom.substring(8, 10);
- dateIsTheSame = iYear == iNewStartYear && iMonth == iNewStartMonth && iDay == iNewStartDay;
- }
- else {
- newDateTo = this.getDateToValue();
- iNewEndYear = newDateTo.substring(0,4);
- iNewEndMonth = newDateTo.substring(5, 7);
- iNewEndDay = newDateTo.substring(8, 10);
- dateIsTheSame = iYear == iNewEndYear && iMonth == iNewEndMonth && iDay == iNewEndDay;
- }
-
- return dateIsTheSame;
- },
-
- checkCurrentDate: function(newDate) {
-
- currentDate=this.getCurrentDateValue();
-
- iCurrentYear = currentDate.substring(0,4);
- iCurrentMonth = currentDate.substring(5, 7);
- iCurrentDay = currentDate.substring(8, 10);
- iNewYear = newDate.substring(0,4);
- iNewMonth = newDate.substring(5, 7);
- iNewDay = newDate.substring(8, 10);
-
- isTodaysDate = iCurrentYear == iNewYear && iCurrentMonth == iNewMonth && iCurrentDay == iNewDay;
-
- return isTodaysDate;
- },
- getCurrentDateValue: function() {
- return this.m_dateTimeUtil.getCurrentDateValue();
- },
- getDateFromFormatValue: function() {
- if (this.m_dateFrom != null && this.m_dateFrom != '')
- {
- return window['pickerControl'+ this.m_dateFrom].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- getDateToFormatValue: function() {
- if (this.m_dateTo != null && this.m_dateTo != '')
- {
- return window['pickerControl'+ this.m_dateTo].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- getDateFromValue: function() {
- if (this.m_dateFrom != null && this.m_dateFrom != '')
- {
- var picker = window['pickerControl'+ this.m_dateFrom];
- if (picker.isValid()) {
- return picker.sGetValue();
- }
- else {
-
- return "00000000";
- }
- } else
- {
- return '';
- }
- },
- getDateToValue: function() {
- if (this.m_dateTo != null && this.m_dateTo != '')
- {
- var picker = window['pickerControl'+ this.m_dateTo];
- if (picker.isValid()) {
- return picker.sGetValue();
- }
- else {
-
- return "00000000";
- }
- } else
- {
- return '';
- }
- },
- setDateFromValue: function (dateStr) {
- var picker = window['pickerControl'+ this.m_dateFrom];
- var ymd = this.convertDateToYMD(dateStr);
- picker.setValue(ymd);
- },
- setDateToValue: function (dateStr) {
- var picker = window['pickerControl'+ this.m_dateTo];
- var ymd = this.convertDateToYMD(dateStr);
- picker.setValue(ymd);
- },
- convertDateToYMD: function (dateStr) {
- var ymd="";
- if (dateStr!=='') {
- iYear = dateStr.substring(0,4);
- iMonth = dateStr.substring(5, 7);
- iDay = dateStr.substring(8, 10);
- ymd = iYear+'-'+iMonth+'-'+iDay;
- }
-
- return ymd;
- },
-
- simpleValidate:function(validateFrom){
- if (validateFrom) {
- if ( !this.isDateValid(this.m_dateFrom) )
- {
- alert (this.m_msgs['MSG_ERR_INVALID_START_DATE']);
- return false;
- }
- }
- else {
- if ( !this.isDateValid(this.m_dateTo) )
- {
- alert (this.m_msgs['MSG_ERR_INVALID_END_DATE']);
- return false;
- }
- }
- return (true);
- },
- isDateValid: function(str)
- {
- return this.m_dateTimeUtil.isDateValid(str);
- },
- validateFromDate: function () {
- if (!this.simpleValidate(true))
- {
- return false;
- }
-
- if (this.getDateFromValue() == '')
- {
- alert (this.m_msgs['MSG_ERR_INVALID_START_DATE']);
- return false;
- }
-
-
-
- if (this.getDateToValue()!='' && !(this.validateDateSequence()))
- {
- return false;
- }
-
- return (true);
- },
- validateToDate: function () {
- if (!this.simpleValidate(false))
- {
- return false;
- }
-
-
- if (this.getDateToValue() == '')
- {
- alert (this.m_msgs['MSG_ERR_INVALID_END_DATE']);
- return false;
- }
- if (this.checkCurrentDate(this.getDateToValue())) {
- alert (this.m_msgs['MSG_ERR_COMPLETE_CANNOT_USE_CURRENT_DATE']);
- return false;
- }
-
- if (this.getDateFromValue!='' && !(this.validateDateSequence())) {
- return false;
- }
- return (true);
- },
- validateDates: function()
- {
-
- if (!this.validateFromDate()) {
- return false;
- }
-
- if (!this.validateToDate()) {
- return false;
- }
-
-
-
- if (!(this.validateDateSequence()))
- {
- return false;
- }
- return(true);
- },
-
-
- validateDateSequence: function()
- {
- iStartYear = this.getDateFromValue().substring(0,4);
- iStartMonth = this.getDateFromValue().substring(5, 7);
- iStartDay = this.getDateFromValue().substring(8, 10);
- iEndYear = this.getDateToValue().substring(0,4);
- iEndMonth = this.getDateToValue().substring(5, 7);
- iEndDay = this.getDateToValue().substring(8, 10);
-
- var errMsg = 'MSG_ERR_INCOMPATIBLE_DATES';
- var bRetVal = this.m_dateTimeUtil.getDateSequence(iStartDay, iStartMonth, iStartYear, iEndDay, iEndMonth, iEndYear);
-
- if(bRetVal == 0)
- {
-
- errMsg = 'MSG_ERR_EQUAL_DATES';
- }
-
- if(bRetVal != 1)
- {
- alert(this.m_msgs[errMsg]);
- return false
- }
- else
- {
-
- return true;
- }
- }
- }
- function hts_datePickerUtil(dateTime)
- {
- this.dateTime = dateTime;
- this.m_dateTimeUtil = new hts_dateTimeUtil();
- }
- hts_datePickerUtil.prototype = {
- isDateValid: function()
- {
- return this.m_dateTimeUtil.isDateValid(this.dateTime);
- },
- isDateEmpty: function()
- {
- var isDateEmpty = false;
- if(this.getDateValue() == '')
- {
- isDateEmpty = true;
- }
- return isDateEmpty;
- },
- getDateValue: function()
- {
- var dateValue = '';
- if (this.dateTime != null && this.dateTime != '')
- {
- dateValue = window['pickerControl'+ this.dateTime].sGetValue();
- }
- return dateValue;
- },
-
-
- isDateLaterThanCurrentDate: function()
- {
- var isDateLaterThanCurrentDate = false;
-
- if(this.isDateValid())
- {
- iDateYear = this.getDateValue().substring(0,4);
- iDateMonth = this.getDateValue().substring(5, 7);
- iDateDay = this.getDateValue().substring(8, 10);
- isDateLaterThanCurrentDate = this.m_dateTimeUtil.isDateLaterThanCurrentDate(iDateDay, iDateMonth, iDateYear);
- }
-
- return isDateLaterThanCurrentDate;
-
- },
-
-
- isDateLaterThanOrEqualToCurrentDate: function()
- {
- var isDateLaterThanCurrentDate = false;
-
- if(this.isDateValid())
- {
- iDateYear = this.getDateValue().substring(0,4);
- iDateMonth = this.getDateValue().substring(5, 7);
- iDateDay = this.getDateValue().substring(8, 10);
- isDateLaterThanCurrentDate = this.m_dateTimeUtil.isDateLaterThanOrEqualToCurrentDate(iDateDay, iDateMonth, iDateYear);
- }
-
- return isDateLaterThanCurrentDate;
- }
- }
- function hts_dateTimeUtil()
- {
- }
- hts_dateTimeUtil.prototype = {
-
- isDateValid: function(str)
- {
- var t = true;
- if (str != '')
- {
- t = window['pickerControl' + str].isValid();
- }
- return t;
- },
- getCurrentDateValue: function()
- {
-
- currentDate = new Date();
- year = this.getYear(currentDate);
- month = this.getMonth(currentDate);
- day = this.getDay(currentDate);
-
- return year+"-"+month+"-"+day;
- },
-
-
-
-
-
-
-
-
-
-
- getDateSequence: function(iStartDay, iStartMonth, iStartYear, iEndDay, iEndMonth, iEndYear)
- {
- var bRetVal = 1;
- if (iEndYear < iStartYear)
- {
- bRetVal = -1;
- }
- else if (iEndYear == iStartYear)
- {
- if (iEndMonth < iStartMonth)
- {
- bRetVal = -1;
- }
- else if (iEndMonth == iStartMonth)
- {
- if (iEndDay < iStartDay)
- {
- bRetVal = -1;
- }
- else if (iEndDay == iStartDay)
- {
- bRetVal = 0;
- }
- }
- }
- return bRetVal;
- },
-
-
- isDateLaterThanCurrentDate: function(iDateDay, iDateMonth, iDateYear)
- {
- currentDate = new Date();
- var dateSequence = this.getDateSequence(this.getDay(currentDate), this.getMonth(currentDate), this.getYear(currentDate), iDateDay, iDateMonth, iDateYear);
-
- if(dateSequence == 1)
- {
-
- return true;
- }
- else
- {
-
- return false;
- }
- },
-
-
- isDateLaterThanOrEqualToCurrentDate: function(iDateDay, iDateMonth, iDateYear)
- {
- currentDate = new Date();
- var dateSequence = this.getDateSequence(this.getDay(currentDate), this.getMonth(currentDate), this.getYear(currentDate), iDateDay, iDateMonth, iDateYear);
-
- if(dateSequence != -1)
- {
-
- return true;
- }
- else
- {
-
- return false;
- }
- },
-
- getYear: function(dateValue)
- {
-
- year = dateValue.getFullYear();
- return year + "";
- },
- getMonth: function(dateValue)
- {
-
- month = (dateValue.getMonth()+1).toString();
-
-
- if (month.length==1) {
- month = "0"+month;
- }
-
- return month + "";
- },
- getDay: function(dateValue)
- {
-
- day = dateValue.getDate().toString();
-
-
- if (day.length==1) {
- day = "0"+day;
- }
- return day + "";
- }
- }
- function hts_disableDatePicker(datePickerId) {
-
- var dateInput= $('txtDate'+datePickerId);
- if(dateInput.disabled == true) {
-
- return;
- }
-
-
- dateInput.disabled=true;
-
-
- var dateImg= $(datePickerId+"imgPicker");
- dateImg.cacheOnClick = dateImg.onclick;
- dateImg.cacheOnMouseDown = dateImg.onmousedown;
- dateImg.cacheOnMouseOut = dateImg.onmouseout;
- dateImg.cacheOnMouseOver = dateImg.onmouseover;
- dateImg.cacheImgSrc = dateImg.src;
-
- dateImg.onclick = null;
- dateImg.onmousedown = null;
- dateImg.onmouseout = null;
- dateImg.onmouseover = null;
- dateImg.src = _F_Config.webContent + "/fragments/myinbox/images/icon_datepicker_disable.gif"
- }
- function hts_enableDatePicker(datePickerId) {
-
- var dateInput= $('txtDate'+datePickerId);
- if(dateInput.disabled == false) {
-
- return;
- }
-
- dateInput.disabled=false;
-
-
- var dateImg= $(datePickerId+"imgPicker");
- dateImg.onclick = dateImg.cacheOnClick;
- dateImg.onmousedown = dateImg.cacheOnMouseDown;
- dateImg.onmouseout = dateImg.cacheOnMouseOut;
- dateImg.onmouseover = dateImg.cacheOnMouseOver;
- dateImg.src = dateImg.cacheImgSrc;
-
- dateImg.cacheOnClick = null;
- dateImg.cacheOnMouseDown = null;
- dateImg.cacheOnMouseOut = null;
- dateImg.cacheOnMouseOver = null;
- dateImg.cacheImgSrc = null;
- }
|