123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: cogadmin
- //
- // (C) Copyright IBM Corp. 2005, 2014
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- //
- //
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- function cogadmin_datetime(form)
- {
- this.m_dateFrom = null;
- this.m_timeFrom = null;
- this.m_dateTo = null;
- this.m_timeTo = null;
- this.m_form = form;
- this.m_isFromToDate = null;
- this.m_date = null;
- this.m_time = null;
-
- this.m_date1 = null;
- this.m_time1 = null;
- this.m_date2 = null;
- this.m_time2 = null;
- }
- cogadmin_datetime.prototype = {
- setGlobals: function(dateFrom, timeFrom, dateTo, timeTo)
- {
- this.m_dateFrom = dateFrom;
- this.m_timeFrom = timeFrom;
- this.m_dateTo = dateTo;
- this.m_timeTo = timeTo;
- this.m_isFromToDate = true;
- },
-
- setGlobalsSimple: function()
- {
- this.m_date = date;
- this.m_time = time;
- this.m_isFromToDate = false;
- },
-
- setHiddenInputs: function(date1, time1, date2, time2)
- {
- this.m_date1 = date1;
- this.m_time1 = time1;
- this.m_date2 = date2;
- this.m_time2 = time2;
- },
- setDateTimeFromTo: function(periodDiv, divInner) {
-
- if (this.dateTimeValidateDateTimeFromTo())
- {
- var dFrom = this.getDateFromFormatValue();
- var tFrom = this.getTimeFromFormatValue();
- var dTo = this.getDateToFormatValue();
- var tTo = this.getTimeToFormatValue();
- this.setHiddenDateTimeInterval(dFrom, this.getTimeFromValue(), dTo, this.getTimeToValue());
- var toFrom = getFormattedSummary(dFrom, tFrom, dTo, tTo);
- var div = document.getElementById(divInner);
- div.innerHTML = toFrom;
- }
- },
- getDateFromFormatValue: function() {
- if (this.m_dateFrom != null && this.m_dateFrom != '')
- {
- return window['pickerControl'+ this.m_dateFrom].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- getTimeFromFormatValue: function() {
- if (this.m_timeFrom != null && this.m_timeFrom != '')
- {
- return window['timePicker' + this.m_timeFrom].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- getDateToFormatValue: function() {
- if (this.m_dateTo != null && this.m_dateTo != '')
- {
- return window['pickerControl'+ this.m_dateTo].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- getTimeToFormatValue: function() {
- if (this.m_timeTo != null && this.m_timeTo != '')
- {
- return window['timePicker' + this.m_timeTo].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- getDateFromValue: function() {
- if (this.m_dateFrom != null && this.m_dateFrom != '')
- {
- return window['pickerControl'+ this.m_dateFrom].sGetValue();
- } else
- {
- return '';
- }
- },
- getTimeFromValue: function() {
- if (this.m_timeFrom != null && this.m_timeFrom != '')
- {
- return window['timePicker' + this.m_timeFrom].sGetValue();
- } else
- {
- return '';
- }
- },
- getDateToValue: function() {
- if (this.m_dateTo != null && this.m_dateTo != '')
- {
- return window['pickerControl'+ this.m_dateTo].sGetValue();
- } else
- {
- return '';
- }
- },
- getTimeToValue: function() {
- if (this.m_timeTo != null && this.m_timeTo != '')
- {
- return window['timePicker' + this.m_timeTo].sGetValue();
- } else
- {
- return '';
- }
- },
- getDateFormatValue: function() {
- if (this.m_date != null && this.m_date != '') {
- return window['pickerControl'+ this.m_date].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- getTimeFormatValue: function() {
- if (this.m_time != null && this.m_time != '')
- {
- return window['timePicker' + this.m_time].sGetFormatValue();
- } else
- {
- return '';
- }
- },
- simpleValidate:function(){
- if (this.m_isFromToDate != null)
- {
- if(this.m_isFromToDate)
- {
- if ( !this.isDateValid(this.m_dateFrom) )
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_START_DATE']);
- return false;
- }
- if ( !this.isDateValid(this.m_dateTo) )
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_END_DATE']);
- return false;
- }
- if ( !this.isTimeValid(this.m_timeFrom) )
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_START_TIME']);
- return false;
- }
- if ( !this.isTimeValid(this.m_timeTo) )
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_END_TIME']);
- return false;
- }
- } else
- {
- //we have just one date and/or one time.
- if (this.m_date != null && this.m_date != '')
- {
- if ( !this.isDateValid(this.m_date) )
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_DATE']);
- return false;
- }
- }
- if (this.m_time != null && this.m_time != '') {
- if ( !this.isTimeValid(this.m_time) )
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_TIME']);
- return false;
- }
- }
- }
- }
- return (true);
- },
- // Whenever the value changes, call the necessary javascript function if one was provided
- isTimeValid: function(str)
- {
- var t = true;
- if ( str != '')
- {
- t = window['timePicker' + str].isValid();
- }
- return t;
- },
- isDateValid: function(str)
- {
- var t = true;
- if ( str != '')
- {
- t = window['pickerControl' + str].isValid();
- }
- return t;
- },
- dateTimeValidateDateTimeFromTo: function()
- {
- var iStartDay, iStartMonth, iStartYear, iStartHour, iStartMinute, iEndDay, iEndMonth, iEndYear, iEndHour, iEndMinute;
-
- if (!this.simpleValidate())
- {
- return false;
- }
- // Check the Start Date Time.
- if (this.m_form[this.m_dateFrom].value == '' || this.m_form[this.m_timeFrom].value == '' )
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_START_DATE']);
- return false;
- }
- // Check the End Date Time.
- if (this.m_form[this.m_dateTo].value == '' || this.m_form[this.m_timeTo].value == '')
- {
- alert (m_datetime_msg_array['MSG_ERR_INVALID_END_DATE']);
- return false;
- }
-
- iStartYear = this.m_form[this.m_dateFrom].value.substring(0,4);
- iStartMonth = this.m_form[this.m_dateFrom].value.substring(5, 7);
- iStartDay = this.m_form[this.m_dateFrom].value.substring(8, 10);
- iStartHour = this.m_form[this.m_timeFrom].value.substring(0, 2);
- iStartMinute = this.m_form[this.m_timeFrom].value.substring(3, 5);
- iEndYear = this.m_form[this.m_dateTo].value.substring(0,4);
- iEndMonth = this.m_form[this.m_dateTo].value.substring(5, 7);
- iEndDay = this.m_form[this.m_dateTo].value.substring(8, 10);
- iEndHour = this.m_form[this.m_timeTo].value.substring(0, 2);
- iEndMinute = this.m_form[this.m_timeTo].value.substring(3, 5);
- // We could create date objects and compare them but that involves too much work to format
- // our date values to JS acceptable format.
- if (!(this.validateDateTimeSequence(iStartDay, iStartMonth, iStartYear, iStartHour, iStartMinute, iEndDay, iEndMonth, iEndYear, iEndHour, iEndMinute)))
- {
- return false;
- }
- return(true);
- },
- // ..............................................................................
- // Checks for end date being earlier than or the same as the start date.
- validateDateTimeSequence: function(iStartDay, iStartMonth, iStartYear, iStartHour, iStartMinute, iEndDay, iEndMonth, iEndYear, iEndHour, iEndMinute)
- {
- var bRetVal = true;
- if (iEndYear < iStartYear)
- bRetVal = false;
- else if (iEndYear == iStartYear)
- {
- if (iEndMonth < iStartMonth)
- bRetVal = false;
- else if (iEndMonth == iStartMonth)
- {
- if (iEndDay < iStartDay)
- bRetVal = false;
- else if (iEndDay == iStartDay)
- {
- if (iEndHour < iStartHour)
- bRetVal = false;
- else if (iEndHour == iStartHour)
- {
- if (iEndMinute < iStartMinute)
- bRetVal = false;
- else if (iEndMinute == iStartMinute)
- bRetVal = false;
- }
- }
- }
- }
- if (!bRetVal)
- {
- alert(m_datetime_msg_array['MSG_ERR_INCOMPATIBLE_DATES']);
- return false;
- }
- else
- return true;
- },
- setHiddenDateTimeInterval: function (fromDate, fromTime, toDate, toTime) {
- document.getElementById(this.m_date1).value = fromDate;
- document.getElementById(this.m_time1).value = fromTime;
- document.getElementById(this.m_date2).value = toDate;
- document.getElementById(this.m_time2).value = toTime;
- },
- cancelDateTimeInterval:function(control) {
- window['pickerControl'+ this.m_dateFrom].setValue(document.getElementById(this.m_date1).value);
- window['timePicker'+ this.m_timeFrom].setValue(document.getElementById(this.m_time1).value);
- window['pickerControl'+ this.m_dateTo].setValue(document.getElementById(this.m_date2).value);
- window['timePicker'+ this.m_timeTo].setValue(document.getElementById(this.m_time2).value);
- }
- }
- function setHiddenDateTime(dateFromId, timeFromId, dateToId, timeToId, dFrom, tFrom, dTo, tTo) {
- document.getElementById(dateFromId).value = dFrom;
- document.getElementById(timeFromId).value = tFrom;
- document.getElementById(dateToId).value = dTo;
- document.getElementById(timeToId).value = tTo;
- }
- function setDateValue(dateCtrl, dateVal) {
- if (dateCtrl != null && dateCtrl != '')
- {
- return window['pickerControl'+ dateCtrl].setValue(dateVal);
- } else
- {
- return '';
- }
- }
- function setTimeValue(timeCtrl, timeVal) {
- if (timeCtrl != null && timeCtrl != '')
- {
- return window['timePicker'+ timeCtrl].setValue(timeVal);
- } else
- {
- return '';
- }
- }
- function getDateFormatValue(dateCtrl) {
- if (dateCtrl != null && dateCtrl != '')
- {
- return window['pickerControl'+ dateCtrl].sGetFormatValue();
- } else
- {
- return '';
- }
- }
- function getTimeFormatValue(timeCtrl) {
- if (timeCtrl != null && timeCtrl != '')
- {
- return window['timePicker'+ timeCtrl].sGetFormatValue();
- } else
- {
- return '';
- }
- }
|