/**
* data.js - extractor extraordinaire
* Pulls out a properly structured, hierarchical tree
* of the control data of the form, and then massages
* it through a few steps to become XML output.
*/
var dataNS = odkmaker.namespace.load('odkmaker.data');
var modelTmp;
var lookupsMap = {};
var lookupDataFieldArray = [];
var showSkipWrning = false;
var MAX_LOOKUP_RECORD_COUNT_WARNING = 1000;
var hideToolbar;
var minHeight = 20;
var currentEmptyCellId = 0;
var hasEncryptField = false;
var rootDataCtrlWidth = 0;
var geofencesMap = {}; // CO-4372
var geofencesValue = {};
var isAutoAddEmptyRow = true;
var POD_QTY_COL_ID = '-100';
var POD_ACTUAL_COL_ID = '-101';
var POD_DAMAGED_COL_ID = '-102';
var POD_REJECTED_COL_ID = '-103';
var POD_DELIVER_COL_ID = '-104';
var POD_ID_COL_ID = '-105';
var POD_COMMENT_COL_ID = '-106';
var POD_STATUS_COL_ID = '-107';
var POD_AUTO_ID_COL_ID = '-108';
var POD_STOP_NO_COL_ID = '-109';
var POD_SIGN_GRID = '-110';
var POD_SIGN_CUSTOMER = '-111';
var POD_SIGN_CARRIER = '-112';
var POD_SIGN_CUSTOMER_TIME = '-113';
var POD_SIGN_CARRIER_TIME = '-114';
var REPLY_TO_SENDER_FLAG_COL_ID = '-115';
var POD_ID_COL_ID_COPIED = '-116';
var SCHEDULE_WIDGET_START_TIME_ID = '-200';
var SCHEDULE_WIDGET_DURATION_ID = '-201';
var INV_ID_COL_ID = '-300';
var INV_COMMENT_COL_ID = '-301';
var INV_IMAGE_COL_ID = '-302';
var INV_LU_FIELD_COL_ID = '-310';
var POD_RECORD_STATUS_NOT_DELIVERED = 1; // Not Delivered
var POD_RECORD_STATUS_DELIVERED = 2; // Delivered
var POD_RECORD_STATUS_SHORT = 4; // Short
var POD_RECORD_STATUS_OVER = 8; // Over
var POD_RECORD_STATUS_DAMAGED = 16; // Damaged
var POD_RECORD_STATUS_REJECT = 32; // Reject
var POD_RECORD_STATUS_HIDDEN = 64; // hidden
var POD_RECORD_STATUS_NOT_IN_MANIFEST = 128; // not in manifest
var TABLE_GRID_VERRTICAL_HEADER_PADDING = 3;
var TABLE_GRID_VERRTICAL_HEADER_PADDING_LR = 5;
var MESSAGE_WIDGET_TEMPLATE_ROW_COUNT = 30;
var COL_COUNT_WIDTH = 20;
var REPEATABLE_SUMMARY_COL_ID = '-1000';
if(hideToolbar == undefined) {
hideToolbar = false;
}
if(typeof isInDispatchPlusTab == 'undefined') {
isInDispatchPlusTab = false;
}
var isFormLoadding = false;
if(!keyWord){
var keyWord = [];
keyWord['start'] = true;
keyWord['end'] = true;
keyWord['today'] = true;
keyWord['deviceid'] = true;
keyWord['subscriberid'] = true;
keyWord['simid'] = true;
keyWord['phonenumber'] = true;
keyWord['recordid'] = true;
keyWord['mobilekey'] = true;
keyWord['projectkey'] = true;
keyWord['mobile_device'] = true;
keyWord['date_created'] = true;
keyWord['record_name'] = true;
keyWord['status'] = true;
keyWord['form_record'] = true;
keyWord['form_name'] = true;
keyWord['edited_by'] = true;
keyWord['edit_date'] = true;
keyWord['data'] = true;
keyWord['total_score'] = true;
keyWord['total_percent'] = true;
keyWord['total_possible'] = true;
keyWord['submission_complete'] = true;
keyWord['odkid'] = true;
keyWord['order'] = true;
keyWord['submitted_time'] = true;
keyWord['set_name'] = true;
keyWord['scheduled_time'] = true;
keyWord['nickname'] = true;
}
if(!timeZoneMap){
var timeZoneMap = [];
timeZoneMap['0'] = 0;
timeZoneMap['1'] = 43200000;
timeZoneMap['2'] = 39600000;
timeZoneMap['3'] = 36000000;
timeZoneMap['4'] = 32400000;
timeZoneMap['5'] = 28800000;
timeZoneMap['6'] = 25200000;
timeZoneMap['7'] = 25200000;
timeZoneMap['8'] = 25200000;
timeZoneMap['9'] = 21600000;
timeZoneMap['10'] = 21600000;
timeZoneMap['11'] = 21600000;
timeZoneMap['12'] = 21600000;
timeZoneMap['13'] = 18000000;
timeZoneMap['14'] = 18000000;
timeZoneMap['15'] = 18000000;
timeZoneMap['16'] = 14400000;
timeZoneMap['17'] = 14400000;
timeZoneMap['18'] = 14400000;
timeZoneMap['19'] = 12600000;
timeZoneMap['20'] = 10800000;
timeZoneMap['21'] = 10800000;
timeZoneMap['22'] = 10800000;
timeZoneMap['23'] = 7200000;
timeZoneMap['24'] = 3600000;
timeZoneMap['25'] = 3600000;
timeZoneMap['26'] = 0;
timeZoneMap['27'] = 0;
timeZoneMap['28'] = -3600000;
timeZoneMap['29'] = -3600000;
timeZoneMap['30'] = -3600000;
timeZoneMap['31'] = -3600000;
timeZoneMap['32'] = -3600000;
timeZoneMap['33'] = -7200000;
timeZoneMap['34'] = -7200000;
timeZoneMap['35'] = -7200000;
timeZoneMap['36'] = -7200000;
timeZoneMap['37'] = -7200000;
timeZoneMap['38'] = -7200000;
timeZoneMap['39'] = -10800000;
timeZoneMap['40'] = -10800000;
timeZoneMap['41'] = -10800000;
timeZoneMap['42'] = -12600000;
timeZoneMap['43'] = -14400000;
timeZoneMap['44'] = -14400000;
timeZoneMap['45'] = -14400000;
timeZoneMap['46'] = -16200000;
timeZoneMap['47'] = -18000000;
timeZoneMap['48'] = -18000000;
timeZoneMap['49'] = -19800000;
timeZoneMap['50'] = -20700000;
timeZoneMap['51'] = -21600000;
timeZoneMap['52'] = -21600000;
timeZoneMap['53'] = -21600000;
timeZoneMap['54'] = -23400000;
timeZoneMap['55'] = -25200000;
timeZoneMap['56'] = -25200000;
timeZoneMap['57'] = -28800000;
timeZoneMap['58'] = -28800000;
timeZoneMap['59'] = -28800000;
timeZoneMap['60'] = -28800000;
timeZoneMap['61'] = -28800000;
timeZoneMap['62'] = -32400000;
timeZoneMap['63'] = -32400000;
timeZoneMap['64'] = -32400000;
timeZoneMap['65'] = -34200000;
timeZoneMap['66'] = -34200000;
timeZoneMap['67'] = -36000000;
timeZoneMap['68'] = -36000000;
timeZoneMap['69'] = -36000000;
timeZoneMap['70'] = -36000000;
timeZoneMap['71'] = -36000000;
timeZoneMap['72'] = -39600000;
timeZoneMap['73'] = -43200000;
timeZoneMap['74'] = -43200000;
timeZoneMap['75'] = 43200000;
timeZoneMap['76'] = 39600000;
timeZoneMap['77'] = 36000000;
timeZoneMap['78'] = 32400000;
timeZoneMap['79'] = 28800000;
timeZoneMap['80'] = 25200000;
timeZoneMap['81'] = 25200000;
timeZoneMap['82'] = 25200000;
timeZoneMap['83'] = 21600000;
timeZoneMap['84'] = 21600000;
timeZoneMap['85'] = 21600000;
timeZoneMap['86'] = 21600000;
timeZoneMap['87'] = 18000000;
timeZoneMap['88'] = 18000000;
timeZoneMap['89'] = 18000000;
timeZoneMap['90'] = 14400000;
timeZoneMap['91'] = 14400000;
timeZoneMap['92'] = 14400000;
timeZoneMap['93'] = 12600000;
timeZoneMap['94'] = 10800000;
timeZoneMap['95'] = 10800000;
timeZoneMap['96'] = 10800000;
timeZoneMap['97'] = 7200000;
timeZoneMap['98'] = 3600000;
timeZoneMap['99'] = 3600000;
timeZoneMap['100'] = 0;
timeZoneMap['101'] = 0;
timeZoneMap['102'] = -3600000;
timeZoneMap['103'] = -3600000;
timeZoneMap['104'] = -3600000;
timeZoneMap['105'] = -3600000;
timeZoneMap['106'] = -3600000;
timeZoneMap['107'] = -7200000;
timeZoneMap['108'] = -7200000;
timeZoneMap['109'] = -7200000;
timeZoneMap['110'] = -7200000;
timeZoneMap['111'] = -7200000;
timeZoneMap['112'] = -7200000;
timeZoneMap['113'] = -10800000;
timeZoneMap['114'] = -10800000;
timeZoneMap['115'] = -10800000;
timeZoneMap['116'] = -10800000;
timeZoneMap['117'] = -12600000;
timeZoneMap['118'] = -14400000;
timeZoneMap['119'] = -14400000;
timeZoneMap['120'] = -16200000;
timeZoneMap['121'] = -18000000;
timeZoneMap['122'] = -18000000;
timeZoneMap['123'] = -19800000;
timeZoneMap['124'] = -20700000;
timeZoneMap['125'] = -21600000;
timeZoneMap['126'] = -21600000;
timeZoneMap['127'] = -21600000;
timeZoneMap['128'] = -23400000;
timeZoneMap['129'] = -25200000;
timeZoneMap['130'] = -25200000;
timeZoneMap['131'] = -28800000;
timeZoneMap['132'] = -28800000;
timeZoneMap['133'] = -28800000;
timeZoneMap['134'] = -28800000;
timeZoneMap['135'] = -28800000;
timeZoneMap['136'] = -32400000;
timeZoneMap['137'] = -32400000;
timeZoneMap['138'] = -32400000;
timeZoneMap['139'] = -34200000;
timeZoneMap['140'] = -34200000;
timeZoneMap['141'] = -36000000;
timeZoneMap['142'] = -36000000;
timeZoneMap['143'] = -36000000;
timeZoneMap['144'] = -36000000;
timeZoneMap['145'] = -36000000;
timeZoneMap['146'] = -39600000;
timeZoneMap['147'] = -43200000;
timeZoneMap['148'] = -43200000;
timeZoneMap['149'] = -46800000;
}
var isAllowEditOption4Signature = false;
var checkIsAllowEditOption4Signature = function(){
if(authNS.currentUser && authNS.currentUser.customerFunctionList && authNS.currentUser.customerFunctionList.allowEditSignature){
isAllowEditOption4Signature = authNS.currentUser.customerFunctionList.allowEditSignature;
}else{
isAllowEditOption4Signature = false;
}
}
var loadingQueue = [];
var pushToLoadingQueue = function(){
if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){
loadingQueue.push(true);
}
}
var popFromLoadingQueue = function(){
loadingQueue.pop();
}
var isEditLoading = function(){
if(fvDataNS.sent){
return true;
}
if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){
return true;
}
if(loadingQueue.length>0){
return true;
}
return false;
}
var getFieldType = function(fillControl){
if(!fillControl){
return CONST_STRING;
}
switch(fillControl.type){
case CONST_CTRL_TYPE_INPUT_NUMERIC:
case CONST_CTRL_TYPE_INPUTCOUNTER:
return CONST_CTRL_KIND_NUMBER;
default:
return CONST_STRING;
}
}
var isEmtyRow = function(lastRow){
var isEmpty = true;
var controls = lastRow.find('td.fvControl');
_.each(controls, function(control){
if(!isEmpty){
return false;
}
var ctrlPropreties = $(control).data('odkControl-ctrlPropreties');
if(ctrlPropreties.val != null && ctrlPropreties.val != '' && ctrlPropreties.defaultValue != ctrlPropreties.val){
if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTCALCULATE && ctrlPropreties.val == 0){
}else{
isEmpty = false;
}
}
});
return isEmpty;
}
function isCorrectIteControlType(iteControl){
if(!iteControl){
return false;
}
switch(iteControl.type){
case CONST_CTRL_TYPE_INPUT_TEXT:
case CONST_CTRL_TYPE_INPUT_NUMERIC:
case CONST_CTRL_TYPE_INPUTTRENDS:
case CONST_CTRL_TYPE_INPUTCOUNTER:
case CONST_CTRL_TYPE_INPUTDATE:
case CONST_CTRL_TYPE_INPUTSELECTONE:
case CONST_CTRL_TYPE_INPUTSCOREONE:
case CONST_CTRL_TYPE_INPUTSELECTMANY:
case CONST_CTRL_TYPE_INPUTLOCATION:
case mdi_kind_inputImage:
case mdi_kind_inputAudio:
case mdi_kind_inputVideo:
case CONST_CTRL_TYPE_INPUTMEDIA:
case mdi_kind_inputSketch:
case mdi_kind_inputSignature:
case 'inputDraw':
case CONST_CTRL_TYPE_INPUTBARCODE:
case CONST_CTRL_TYPE_INPUTNFC:
case CONST_CTRL_TYPE_INPUTFORWARD:
case CONST_CTRL_TYPE_INPUTPAGEBREAK:
case CONST_CTRL_TYPE_INPUTLABEL:
case CONST_CTRL_TYPE_INPUTACTION:
case CONST_CTRL_TYPE_INPUTPAYMENT:
case CONST_CTRL_TYPE_INPUTNEWPAYMENT:
case 'inputInstruction':
case CONST_CTRL_TYPE_INPUTSAVEANDSEND:
case CONST_CTRL_TYPE_INPUTSCORESUMMARY:
case CONST_CTRL_TYPE_INPUTNUMBERING:
case CONST_CTRL_TYPE_INPUTEMAILREPORT:
case CONST_CTRL_TYPE_INPUTFAX:
case CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT:
case CONST_CTRL_TYPE_INPUTAPPROVAL:
case CONST_CTRL_TYPE_INPUTCALCULATE:
case CONST_CTRL_TYPE_INPUTLOOKUP:
case CONST_CTRL_TYPE_INPUTLFBLUETOOTH:
case CONST_CTRL_TYPE_INPUTFACINGTABLE:
case CONST_CTRL_TYPE_INPUTLOOKUPMULTI:
case CONST_CTRL_TYPE_IMAGE_VIEWER:
return true;
}
return false;
}
function isTheSameGroupForPrevious(controls, ctrlId, endId){
var isParentGroup = false;
var end = false;
_.each(controls, function(control)
{
if(isParentGroup){
return false;
}
if(endId == control.id){
isParentGroup = true;
return false;
}
if(control.type == CONST_CTRL_TYPE_GROUP){
if(isTheSameGroupForPrevious(control.children, ctrlId, endId) == true){
end = true;
return false;
}
}else if(control.type == CONST_CTRL_TYPE_CTRLGRID){
_.each(control.children, function(control1)
{
if(isParentGroup){
return false;
}
if(endId == control1.id){
isParentGroup = true;
return false;
}
});
}
});
if(isParentGroup){
_.each(controls, function(control)
{
if(end){
return false;
}
if(ctrlId == control.id){
end = true;
return false;
}
if(control.type == CONST_CTRL_TYPE_CTRLGRID){
_.each(control.children, function(control1)
{
if(end){
return false;
}
if(ctrlId == control1.id){
end = true;
return false;
}
});
}
});
}
if(end){
return true;
}else{
return false;
}
}
var encodeXmlFileName = function(text){
if(text == undefined){
return '';
}else{
var ret = text.replace(/ /g, '').replace(/[^A-Za-z0-9.]+/g,'_');
ret = ret.replace(/^_+/,'').replace(/_+$/,'');
return ret;
}
}
function toDeviceTime(date, timezoneId, dst){
var deviceTimezoneOffset = (new Date()).getTimezoneOffset() * 60 * 1000;
var value = date.getTime();
//to utc
value += (timeZoneMap[timezoneId]);
if(dst){
value -= (deviceTimezoneOffset - 1*60*60*1000);
}else{
value -= deviceTimezoneOffset;
}
return new Date(value);
}
function getCurrentSettingTime(timezoneId, dst){
var currentDate = new Date();
var deviceTimezoneOffset = (currentDate).getTimezoneOffset() * 60 * 1000;
var value = currentDate.getTime();
//to utc
value += deviceTimezoneOffset;
if(dst){
value -= (timeZoneMap[timezoneId] - 1*60*60*1000);
}else{
value -= timeZoneMap[timezoneId];
}
return new Date(value);
}
function getJustification(control){
if(!control){
return '';
}
if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){
if(control.locationStype == CONST_TYPE_ADVANCED){
if(control.imgJustify != undefined){
ret = control.imgJustify;
}else{
ret = '1';
}
return ret;
}
}
var ret = '';
if(control.justificationCaption){
ret += control.justificationCaption;
}
ret += '|';
if(control.justificationHint){
ret += control.justificationHint;
}
ret += '|';
if(control.justificationAnswer){
ret += control.justificationAnswer;
}
if(ret == CONST_OR_OPT){
return '';
}
return ret;
}
function isControlHidden(obj){
if(!obj){
return false;
}
if(obj.isCtrlHidden != undefined && obj.isCtrlHidden){
return true;
}
if(obj.skipByCtrls != undefined && obj.skipByCtrls.length > 0){
return true;
}
if(obj.isParentCtrlHidden){
return true;
}
return false;
}
function reportFormResized () {
var height = 0;
var width = 0;
$('#body_contain, .fvWorkspace.data > *').each(function (index, element) {
height += element.offsetHeight;
width = Math.max(width, element.offsetWidth);
});
if (height && width) {
var eventData = {
eventType: 'doforms-form-resized',
height: height,
width: width
};
console.log(eventData);
top.postMessage(eventData, '*');
}
}
var resizeTextarea = function(el, isFocus) {
var offset = el.offsetHeight - el.clientHeight;
var rows = el.getAttribute('rows');
var height = el.scrollHeight + offset;
if(height < minHeight){
height = minHeight;
}
if(rows && rows != ''){
var minHeightCtrl = parseInt(rows, 10) * 16 + 5;
if(height < minHeightCtrl){
height = minHeightCtrl;
}
}
jQuery(el).css('height', height + 'px');
/*if(isFocus){
jQuery(el).focus();
}*/
};
function autoResizeTextarea(parentClass){
if(!parentClass){
parentClass = '';
}else{
parentClass = '.' + parentClass;
}
jQuery.each(jQuery('.formView ' + parentClass + ' textarea[data-autoresize]'), function() {
resizeTextarea(this, false);
jQuery(this).on('keyup input', function() { resizeTextarea(this, true); return true;});//.removeAttr('data-autoresize');
});
}
function convertInputSaveAndSendToInputAction(control){
control.type = CONST_CTRL_TYPE_INPUTACTION;
control.actionBtnText = control.label.eng;
control.imgAction = CONST_ACTION_SAVE_AND_SEND;
control.kind = 'Button';
return control;
}
function convertTableJustification(control){
if(!control || !control.children || !isVersion(VERSION_TOOL_NEW_JUSTIFICATION)){
if(control.justificationGroup){
control.justificationGroup = false;
}
return control;
}
_.each(control.children, function(item){
if(item.justificationCaption == undefined){
item.justificationCaption = '1';
}
if(item.justificationAnswer == undefined){
switch(item.type){
case CONST_CTRL_TYPE_INPUT_NUMERIC:
case CONST_CTRL_TYPE_INPUTCALCULATE:
item.justificationAnswer = '2';
break;
case CONST_CTRL_TYPE_INPUTCOUNTER:
item.justificationAnswer = '1';
break;
}
}
});
//if correct version then set true for justificationGroup
control.justificationGroup = true;
return control;
}
function convertGridJustification(control){
if(!control || !control.children || !isVersion(VERSION_TOOL_NEW_JUSTIFICATION)){
if(control.justificationGroup){
control.justificationGroup = false;
}
return control;
}
_.each(control.children, function(item){
if(item.justificationAnswer == undefined){
switch(item.type){
case CONST_CTRL_TYPE_INPUT_NUMERIC:
case CONST_CTRL_TYPE_INPUTCALCULATE:
item.justificationAnswer = '2';
break;
case CONST_CTRL_TYPE_INPUTCOUNTER:
item.justificationAnswer = '1';
break;
}
}
});
//if correct version then set true for justificationGroup
control.justificationGroup = true;
return control;
}
function convertLabelJustification(control){
if(!isVersion(VERSION_TOOL_NEW_JUSTIFICATION)){
if(control.justificationGroup){
control.justificationGroup = false;
}
return control;
}
if(control.imgJustify){
if(control.justificationGroup !== true){
switch(control.imgJustify){
case 'Center':
control.justificationCaption = '1';
control.justificationHint = '1';
break;
case 'Right':
control.justificationCaption = '2';
control.justificationHint = '2';
break;
default:
control.justificationCaption = '0';
control.justificationHint = '0';
break;
}
}
}else{
control.justificationCaption = '0';
control.justificationHint = '0';
}
//if correct version then set true for justificationGroup
control.justificationGroup = true;
return control;
}
function convertRestrictOption(control){
if(!isVersion(VERSION_RESTRICT_OPTION)){
return control;
}
if(control.isNotUseDispatchTab || control.isUseViewdataOnly || control.isUseDispOnly){
if(control.isUseViewdataOnly){
if(control.restViewEdit == undefined){
control.restViewEdit = false;
}
if(control.restViewNew == undefined){
control.restViewNew = false;
}
}else{
if(control.isUseViewdataOnly != undefined){
if(control.restViewEdit == undefined){
control.restViewEdit = true;
}
if(control.restViewNew == undefined){
control.restViewNew = true;
}
}
}
if(control.isUseDispOnly){
if(control.restDispatchEdit == undefined){
control.restDispatchEdit = false;
}
if(control.restDispatchNew == undefined){
control.restDispatchNew = false;
}
if(control.restViewFillAndSend == undefined){
control.restViewFillAndSend = true;
}
if(isVersion(VERSION_FNS_EDIT)){
if(control.restViewFillAndSendEdit == undefined){
control.restViewFillAndSendEdit = true;
}
}
if(control.restDispatchToEmail == undefined){
control.restDispatchToEmail = false;
}
if(control.restFormLinks == undefined){
control.restFormLinks = false;
}
if(control.isUseViewdataOnly == undefined){
if(control.isNotUseDispatchTab){
// If in production today both are selected
if(control.restViewEdit == undefined){
control.restViewEdit = false;
}
if(control.restViewNew == undefined){
control.restViewNew = false;
}
}else{
// If in Production today the lookup table has “Dispatch Only” selected
if(control.restViewEdit == undefined){
control.restViewEdit = true;
}
if(control.restViewNew == undefined){
control.restViewNew = true;
}
}
}
}else{
if(control.restDispatchEdit == undefined){
control.restDispatchEdit = true;
}
if(control.restDispatchNew == undefined){
control.restDispatchNew = true;
}
if(control.isUseViewdataOnly == undefined){
if(control.restViewEdit == undefined){
control.restViewEdit = false;
}
if(control.restViewNew == undefined){
control.restViewNew = false;
}
if(control.restViewFillAndSend == undefined){
control.restViewFillAndSend = false;
}
if(isVersion(VERSION_FNS_EDIT)){
if(control.restViewFillAndSendEdit == undefined){
control.restViewFillAndSendEdit = false;
}
}
if(control.restDispatchToEmail == undefined){
control.restDispatchToEmail = false;
}
if(control.restFormLinks == undefined){
control.restFormLinks = false;
}
}
}
if(control.isNotUseDispatchTab){
if(control.restMobile == undefined){
control.restMobile = false;
}
if(control.restWebapp == undefined){
control.restWebapp = false;
}
if(control.restViewFillAndSend == undefined){
control.restViewFillAndSend = true;
}
if(isVersion(VERSION_FNS_EDIT)){
if(control.restViewFillAndSendEdit == undefined){
control.restViewFillAndSendEdit = true;
}
}
if(control.restDispatchToEmail == undefined){
control.restDispatchToEmail = false;
}
if(control.restFormLinks == undefined){
control.restFormLinks = false;
}
}else{
if(control.restMobile == undefined){
control.restMobile = true;
}
if(control.restWebapp == undefined){
control.restWebapp = true;
}
}
}
if(control.restViewEdit == undefined){
control.restViewEdit = false;
}
if(control.restViewNew == undefined){
control.restViewNew = false;
}
if(control.restViewFillAndSend == undefined){
control.restViewFillAndSend = false;
}
if(isVersion(VERSION_FNS_EDIT)){
if(control.restViewFillAndSendEdit == undefined){
control.restViewFillAndSendEdit = false;
}
}
if(control.restDispatchToEmail == undefined){
control.restDispatchToEmail = false;
}
if(control.restDispatchEdit == undefined){
control.restDispatchEdit = false;
}
if(control.restDispatchNew == undefined){
control.restDispatchNew = false;
}
if(control.restMobile == undefined){
control.restMobile = false;
}
if(control.restWebapp == undefined){
control.restWebapp = false;
}
if(control.restFormLinks == undefined){
control.restFormLinks = false;
}
return control;
}
function convertRetrieveDS(control){
if(control.isRetrieve){
if(control.isRetrieveDS == undefined){
if(control.isModifyOnly){
control.isRetrieveDS = false;
}else{
control.isRetrieveDS = true;
}
}
if(control.retrieveKind == undefined){
if(control.autoActionStampTriggerRetrieve && control.autoActionStampTriggerRetrieve != '' && control.autoActionStampTriggerRetrieve != lbl_action_select_a_trigger){
control.retrieveKind = CONST_TYPE_AUTO_RUN;
}else{
control.retrieveKind = CONST_TYPE_BUTTON_LOWERCASE;
}
}
if(control.lookupfield4R == undefined){
control.lookupfield4R = control.lookupfield;
}
if(control.lookupConditionFields4R == undefined){
if(control.lookupConditionFields != undefined){
control.lookupConditionFields4R = control.lookupConditionFields.slice();
}
}
//if(control.retrieveKind == CONST_TYPE_AUTO_RUN){
control.hideRetrieveButtonAuto = true;
//}
}
if(isVersion(VERSION_RETRIEVE_RECORD_TYPE) && control.isRetrieveDS == true && control.retrieveRecordKind == undefined){
if(control.isRetrieveOldestRecord == true){
control.retrieveRecordKind = 'oldest';
}
}
return control;
}
function convertModifyOnly(control){
if(control.isRetrieve){
if(control.isModifyOnly == undefined || control.isModifyOnly == false){
var type;
if(lookupdatainf.lookupUFAutoTables != undefined && lookupdatainf.lookupUFAutoTables[control.datasource] != undefined){
type = 'UFAuto';
}else if(lookupdatainf.lookupUFTables != undefined && lookupdatainf.lookupUFTables[control.datasource] != undefined){
type = 'UF';
}else{
type = 'file';
}
if(type == 'UFAuto' && control.modifyFields && control.modifyFields.length>0){
control.isModifyOnly = true;
}else{
control.modifyFields = [];
}
}
_.each(control.modifyFields, function(item){
if(item.action == undefined){
item.action = {val: control.modifyFieldsAction};
}
});
}
return control;
}
function convertLookupValue(control){
if(control.isRetrieve){
if(control.lookupValue == undefined){
control.lookupValue = {val: '',
condCompareType: 'string'};
}else if(!jQuery.isPlainObject(control.lookupValue)){
control.lookupValue = {val: control.lookupValue,
condCompareType: 'string'};
}
if(control.lookupValue.usingUnderlyValue == undefined){
control.lookupValue.usingUnderlyValue = control.isChooseOneField || false;
}
if(control.isShowCmpType && control.lookupValue.showType == undefined){
control.lookupValue.showType = control.isShowCmpType;
if(control.lookupConditionFields4R != undefined){
_.each(control.lookupConditionFields4R, function(item){
item.text.showType = control.isShowCmpType;
});
}
control.isShowCmpType = false;
}
if(control.lookupConditionFields4R != undefined){
_.each(control.lookupConditionFields4R, function(item){
item.condType.val = 'and';
});
}
}else{
//control.lookupValue.showType = control.isShowCmpType;
_.each(control.lookupConditionFields, function(item){
item.text.showType = control.isShowCmpType;
});
control.isShowCmpType = false;
}
return control;
}
function setValueIfUndefined(control, key, value){
if(!control || key == undefined){
return control;
}
if(control[key] == undefined){
control[key] = value;
}
return control;
}
function setDefaultITEFlagForOldForm(control){
if(!control || !isVersion(VERSION_IF_THEN_ELSE)){
return control;
}
switch(control.type){
case CONST_CTRL_TYPE_INPUTNUMBERING:
case CONST_CTRL_TYPE_INPUTBARCODE:
case CONST_CTRL_TYPE_INPUTFORWARD:
case CONST_CTRL_TYPE_INPUTSECUREFORWARD:
case CONST_CTRL_TYPE_INPUTNFC:
case CONST_CTRL_TYPE_INPUTTRENDS:
case CONST_CTRL_TYPE_INPUTSELECTONE:
case CONST_CTRL_TYPE_INPUTCOUNTER:
case CONST_CTRL_TYPE_INPUTLOOKUP:
case CONST_CTRL_TYPE_INPUTLFBLUETOOTH:
case CONST_CTRL_TYPE_INPUTDATE:
case CONST_CTRL_TYPE_INPUTLOCATION:
case CONST_CTRL_TYPE_INPUT_NUMERIC:
case CONST_CTRL_TYPE_INPUTSCOREONE:
case CONST_CTRL_TYPE_INPUTSELECTMANY:
case CONST_CTRL_TYPE_INPUT_TEXT:
if(control.isShowITE == undefined){
control.isShowITE = false;
}
break
}
return control;
}
function setDefaultAddModifyFields(control){
if(!control || !isVersion(VERSION_MODIFY_ADD_FIELDS)){
return control;
}
if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP && control.isRetrieve){
if(control.isModifyAdd == true && control.modifyAddFields == undefined){
control.modifyAddFields = [...control.modifyFields];
}
}
return control;
}
function convertReadOnlyRequiredHide(control){
if(!isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION)){
return control;
}
//read only
if(control.readOnly){
control = setValueIfUndefined(control, 'readOnlyViewEdit', true);
control = setValueIfUndefined(control, 'readOnlyViewNew', true);
control = setValueIfUndefined(control, 'readOnlyFillAndSend', true);
if(isVersion(VERSION_FNS_EDIT)){
control = setValueIfUndefined(control, 'readOnlyFillAndSendEdit', true);
}
control = setValueIfUndefined(control, 'readOnlyDispatchToEmail', true);
control = setValueIfUndefined(control, 'readOnlyWebApp', true);
control = setValueIfUndefined(control, 'readOnlyFormLinks', true);
}
if(control.readOnlyDsp){
control = setValueIfUndefined(control, 'readOnlyDispatchEdit', true);
control = setValueIfUndefined(control, 'readOnlyDispatchNew', true);
}
if(control.readOnlyViewEdit == undefined){
control.readOnlyViewEdit = false;
}
if(control.readOnlyViewNew == undefined){
control.readOnlyViewNew = false;
}
if(control.readOnlyViewFillAndSend == undefined){
control.readOnlyViewFillAndSend = false;
}
if(control.readOnlyDispatchEdit == undefined){
control.readOnlyDispatchEdit = false;
}
if(control.readOnlyDispatchNew == undefined){
control.readOnlyDispatchNew = false;
}
//ignore readOnly in mobile (using old key)
if(control.readOnlyWebapp == undefined){
control.readOnlyWebapp = false;
}
if(control.readOnlyFormLinks == undefined){
control.readOnlyFormLinks = control.readOnlyViewNew;
}
//required
if(control.required){
control = setValueIfUndefined(control, 'requiredViewEdit', true);
control = setValueIfUndefined(control, 'requiredViewNew', true);
control = setValueIfUndefined(control, 'requiredFillAndSend', true);
if(isVersion(VERSION_FNS_EDIT)){
control = setValueIfUndefined(control, 'requiredFillAndSendEdit', true);
}
control = setValueIfUndefined(control, 'requiredDispatchToEmail', true);
control = setValueIfUndefined(control, 'requiredWebApp', true);
control = setValueIfUndefined(control, 'requiredFormLinks', true);
}
if(control.dispatchRequired){
control = setValueIfUndefined(control, 'requiredDispatchEdit', true);
control = setValueIfUndefined(control, 'requiredDispatchNew', true);
}
if(control.requiredViewEdit == undefined){
control.requiredViewEdit = false;
}
if(control.requiredViewNew == undefined){
control.requiredViewNew = false;
}
if(control.requiredViewFillAndSend == undefined){
control.requiredViewFillAndSend = false;
}
if(control.requiredDispatchEdit == undefined){
control.requiredDispatchEdit = false;
}
if(control.requiredDispatchNew == undefined){
control.requiredDispatchNew = false;
}
//ignore required in mobile (using old key)
if(control.requiredWebapp == undefined){
control.requiredWebapp = false;
}
if(control.requiredFormLinks == undefined){
control.requiredFormLinks = control.requiredViewNew;
}
//hide
switch(control.type){
case 'inputLabel':
case CONST_CTRL_TYPE_INPUTSCORESUMMARY:
if(control.dispMobile == false){
control = setValueIfUndefined(control, 'hideWebApp', true);
control = setValueIfUndefined(control, 'hideInMobile', true);
}
break;
default:
if(control.hideInMobile){
control = setValueIfUndefined(control, 'hideWebApp', true);
}
}
if(control.hideInWeb){
control = setValueIfUndefined(control, 'hideDispatchEdit', true);
control = setValueIfUndefined(control, 'hideDispatchNew', true);
control = setValueIfUndefined(control, 'hideViewEdit', true);
control = setValueIfUndefined(control, 'hideViewNew', true);
}
if(control.hideViewEdit == undefined){
control.hideViewEdit = false;
}
if(control.hideViewNew == undefined){
control.hideViewNew = false;
}
if(control.hideViewFillAndSend == undefined){
control.hideViewFillAndSend = false;
}
if(control.hideDispatchEdit == undefined){
control.hideDispatchEdit = false;
}
if(control.hideDispatchNew == undefined){
control.hideDispatchNew = false;
}
//ignore hide in mobile (using old key)
if(control.hideWebapp == undefined){
control.hideWebapp = false;
}
if(control.hideFormLinks == undefined){
control.hideFormLinks = control.hideViewNew;
}
return control;
}
function fvConvertApprovalToSelectOne(control){
control.realType = control.type;
control.type = CONST_CTRL_TYPE_INPUTSELECTONE;
control.apperance = 'Default';
control.defaultValue = 'pending';
control.displayType = CONST_DROPDOWN;
control.options = [];
var item = {
text: {eng: 'Pending'},
val: 'pending'
}
control.options.push(item);
item = {
text: {eng: 'Approve'},
val: 'approve un_date'
}
control.options.push(item);
item = {
text: {eng: 'Deny'},
val: 'deny un_date'
}
control.options.push(item);
control.isShowRelevanceCondition = false;
control.isShowSkipCondition = false;
control.relevanceconds = [];
control.skipconds = [];
return control;
}
function isIgnoreSkip(parentCtrlType){
if(!parentCtrlType){
return false;
}
switch(parentCtrlType){
case CONST_CTRL_TYPE_CTRLGRID:
if(isVersion(VERSION_SKIP_IN_GRID)){
return false;
}
case 'ctrlButtonGrid':
case CONST_CTRL_TYPE_CTRLTABLE:
case CONST_CTRL_TYPE_CTRLSCHEDULE:
case CONST_CTRL_TYPE_CTRLPOD:
/*
hqkhanh fix bug 0026036: Relevance of question inside Questionnaire is not displayed when opening form
case CONST_CTRL_TYPE_CTRLSCORETABLE:
*/
return true;
}
return false;
}
function isIgnoreRelevance(parentCtrlType){
if(!parentCtrlType){
return false;
}
switch(parentCtrlType){
case CONST_CTRL_TYPE_CTRLGRID:
case 'ctrlButtonGrid':
case CONST_CTRL_TYPE_CTRLTABLE:
case CONST_CTRL_TYPE_CTRLSCHEDULE:
case CONST_CTRL_TYPE_CTRLPOD:
/*
hqkhanh fix bug 0026036: Relevance of question inside Questionnaire is not displayed when opening form
case CONST_CTRL_TYPE_CTRLSCORETABLE:
*/
return true;
}
return false;
}
function isFormExitInProject(formKey){
var options = $('#cboFrom option[value="' + formKey+ '"]');
if(options.length>0){
return true;
}
return false;
}
function isCorrentLookupKind(control){
if(isWebAppDispatch()){
if(control.isNotUseDispatchTab){
return false;
}
}else{
if(control.isUseDispOnly){
return false;
}
}
return true;
}
function isKeyWord(text)
{
if(!keyWord[text]){
return false;
}else{
return true;
}
}
function HtmlEncode(s, isForMobile)
{
if(s == null){
return '';
}
if(isForMobile){
var el = document.createElement("div");
el.innerText = el.textContent = s;
s = el.innerHTML;
delete el;
s = s.replace(/ /gi, '\r\n');
s = s.replace(/'/gi, '''');
s = s.replace(/"/gi, '"');
return s;
}else{
var el = document.createElement("div");
el.innerText = el.textContent = s;
s = el.innerHTML;
delete el;
return s.replace(/ /gi, ' ');
}
}
var isExistGroupName = function(groupItemName, editRecordData){
if(editRecordData[groupItemName]){
return true;
}
if(editRecordData[groupItemName + 'text']){
return true;
}
if(editRecordData[groupItemName + 'string']){
return true;
}
if(editRecordData[groupItemName + 'LATITUDE']){
return true;
}
if(editRecordData[groupItemName + 'LONGITUDE']){
return true;
}
if(editRecordData[groupItemName + 'ALTITUDE']){
return true;
}
if(editRecordData[groupItemName + 'ACCURACY']){
return true;
}
return false;
}
var getParentIndexFromClassPath = function(classPath){
var ret = '';
var nameArr = classPath.split(' ');
if(nameArr.length <= 2){
return '';
}
for(var i = 1; i= 0){
ret += '(' + item.substring(pos + 6) + ')';
} else{
ret += '(1)'; // Grid case
}
}
return ret;
}
function getEditRecordDataGroupCount(groupControl, ctrlPropreties, editRecordData){
var ret = 0;
try{ // fix bug 27130: get group input index in entity
if(editRecordData != undefined
&& editRecordData[ctrlPropreties.name + 'string'] != undefined
&& editRecordData[ctrlPropreties.name + 'string'].value != undefined){
ret = parseInt(editRecordData[ctrlPropreties.name + 'string'].value);
if(ret == 0){ ret = 1; }
return ret;
}
} catch(e){}
var parentIndexStr = getParentIndexFromClassPath(ctrlPropreties.classPath);
_.each(groupControl.children, function(control){
var name = control.name + parentIndexStr;
if(ret != 0){
return false;
}
var i = 1;
while(true){
var groupItemName = name + '(' + i + ')';
if(isExistGroupName(groupItemName, editRecordData)){
i++;
}else{
i--;
break;
}
}
if(i > 0){
ret = i;
}
})
if(ret == 0){
return 1;
}else{
return ret;
}
}
function loadEditPODOSDReportData(ctrlPropreties, editRecordData){
var podCtrlName = ctrlPropreties.name;
var podCtrlName = ctrlPropreties.name;
if(!fvDataNS.inputData.PODData){
fvDataNS.inputData.PODData = {};
}
if(!fvDataNS.inputData.PODData[podCtrlName]){
fvDataNS.inputData.PODData[podCtrlName] = {'Qty': 0,
'Damaged': 0,
'Over': 0};
}
var fieldName = podCtrlName + '__Qty';
try{
fvDataNS.inputData.PODData[podCtrlName]['Qty'] = parseInt(editRecordData[fieldName].value);
if(isNaN(fvDataNS.inputData.PODData[podCtrlName]['Qty'])){
fvDataNS.inputData.PODData[podCtrlName]['Qty'] = 0;
}
}catch(ex){
fvDataNS.inputData.PODData[podCtrlName]['Qty'] = 0;
}
fieldName = podCtrlName + '__Damaged';
try{
fvDataNS.inputData.PODData[podCtrlName]['Damaged'] = parseInt(editRecordData[fieldName].value);
if(isNaN(fvDataNS.inputData.PODData[podCtrlName]['Damaged'])){
fvDataNS.inputData.PODData[podCtrlName]['Damaged'] = 0;
}
}catch(ex){
fvDataNS.inputData.PODData[podCtrlName]['Damaged'] = 0;
}
fieldName = podCtrlName + '__Over';
try{
fvDataNS.inputData.PODData[podCtrlName]['Over'] = parseInt(editRecordData[fieldName].value);
if(isNaN(fvDataNS.inputData.PODData[podCtrlName]['Over'])){
fvDataNS.inputData.PODData[podCtrlName]['Over'] = 0;
}
}catch(ex){
fvDataNS.inputData.PODData[podCtrlName]['Over'] = 0;
}
}
function loadEditPODDeliverReportData(groupControl, ctrlPropreties, editRecordData){
var podCtrlName = ctrlPropreties.name;
if(!editRecordData['__POD__DATA'] || !editRecordData['__POD__DATA'][podCtrlName]){
return;
}
var controlData = groupControl.find('.controlData');
_.each(editRecordData['__POD__DATA'][podCtrlName], function(dataItem){
var itemStatus = 0;
try{
itemStatus = parseInt(dataItem['__Status']);
if(isNaN(itemStatus)){
itemStatus = 0;
}
}catch(ex){
itemStatus = 0;
}
if(itemStatus == 0 ||
isNotDelivered(itemStatus) ||
isHidden(itemStatus)){
}else{
var id = dataItem['__AutoID'];
var parentRow = controlData.find('tr.TR__AutoID_' + id);
var parentClassPath;
var parentProperties;
var $parrentPropertiesCopy;
if(!id || parentRow.length == 0){
var parrentRowProperties = fvDataNS.dataArray['data ' + podCtrlName];
$parrentPropertiesCopy = jQuery.extend(true, {}, parrentRowProperties);
$parrentPropertiesCopy.classPath = '';
}else{
parentClassPath = parentRow.attr('data-class-path');
parentProperties = fvDataNS.dataArray[parentClassPath];
$parrentPropertiesCopy = jQuery.extend(true, {}, parentProperties);
}
if(!fvDataNS.inputData.PODExtData[$parrentPropertiesCopy.name]){
fvDataNS.inputData.PODExtData[$parrentPropertiesCopy.name] = [];
}
_.each($parrentPropertiesCopy.children, function(child){
if(child.name.indexOf('__Qty') >= 0){
try{
child.val = dataItem['__Qty'];
}catch(ex){
child.val = 1;
}
}else if(child.name.indexOf('__Status') >= 0){
try{
child.val = dataItem['__Status'];
}catch(ex){
child.val = '';
}
}else if(child.name.indexOf('__Actual') >= 0){
try{
child.val = dataItem['__Actual'];
}catch(ex){
child.val = '';
}
}else if(child.name.indexOf('__Damaged') >= 0){
try{
child.val = dataItem['__Damaged'];
}catch(ex){
child.val = '';
}
}else if(child.name.indexOf('__StopNo') >= 0){
try{
child.val = dataItem['__StopNo'];
}catch(ex){
child.val = '';
}
}else if(child.name.indexOf('__Comment') >= 0){
try{
child.val = dataItem['__Comment'];
}catch(ex){
child.val = '';
}
}else if(child.name.indexOf('__AutoID') >= 0){
try{
child.val = dataItem['__AutoID'];
}catch(ex){
child.val = '';
}
}
});
fvDataNS.inputData.PODExtData[$parrentPropertiesCopy.name].push($parrentPropertiesCopy);
}
});
}
function getEditPODRecordDataGroupCount(groupControl, ctrlPropreties, editRecordData){
var ret = 0;
var podCtrlName = ctrlPropreties.name;
if(!fvDataNS.inputData.PODData){
fvDataNS.inputData.PODData = {};
}
if(!fvDataNS.inputData.PODData[podCtrlName]){
fvDataNS.inputData.PODData[podCtrlName] = {'Qty': 0,
'Damaged': 0,
'Over': 0};
}
if(!fvDataNS.inputData.PODExtData){
fvDataNS.inputData.PODExtData = {};
}
if(fvDataNS.inputData.PODExtData[podCtrlName]){
fvDataNS.inputData.PODExtData[podCtrlName] = [];
}
if(!editRecordData['__POD__DATA'] || !editRecordData['__POD__DATA'][podCtrlName]){
return 0;
}
_.each(editRecordData['__POD__DATA'][podCtrlName], function(dataItem){
var itemStatus = 0;
try{
itemStatus = parseInt(dataItem['__Status']);
if(isNaN(itemStatus)){
itemStatus = 0;
}
}catch(ex){
itemStatus = 0;
}
if(itemStatus == 0 ||
isNotDelivered(itemStatus) ||
isHidden(itemStatus)){
ret++;
}
});
if(ret == 0){
return 1;
}else{
return ret;
}
}
function getEditRecordData(ctrlPropreties, editRecordData, control){
if(ctrlPropreties.clearOnRetrieve === true){
var value = undefined;
switch (ctrlPropreties.ctrlType) {
case CONST_CTRL_TYPE_INPUTPAYMENT:
case CONST_CTRL_TYPE_GROUP:
case CONST_CTRL_TYPE_CTRLTABLE:
case CONST_CTRL_TYPE_CTRLSCHEDULE:
case CONST_CTRL_TYPE_CTRLPOD:
case CONST_CTRL_TYPE_CTRLSCORETABLE:
case CONST_CTRL_TYPE_CTRLGRID:
return value;
default:
if(control != undefined && control.defaultValue){
value = control.defaultValue;
}
/*setCtrlPropretiesValue(ctrlPropreties, value, true);
return value;*/
if(!fvDataNS.currentForm.retrieveControlDataChange){
fvDataNS.currentForm.retrieveControlDataChange = [];
}
fvDataNS.currentForm.retrieveControlDataChange.push({type: 'clearOnRetrieve',
ctrlPropreties: ctrlPropreties,
value: value})
}
}
var ctrlName = ctrlPropreties.name;
var isPOD = false;
if(ctrlPropreties.parentKind){
switch (ctrlPropreties.parentKind) {
case 'table':
var index = 1;
if(ctrlPropreties.rowIndex){
index += ctrlPropreties.rowIndex;
}
ctrlName += '(' + index + ')';
break;
case 'scoreTable':
ctrlName += '(1)';
break;
case 'grid':
case CONST_CTRL_TYPE_GROUP:
ctrlName += getParentIndexFromClassPath(ctrlPropreties.classPath);
break;
case CONST_CTRL_TYPE_CTRLPOD:
isPOD = true;
var pos = ctrlName.indexOf('__');
if(pos > 0){
ctrlName = ctrlName.substring(pos);
}
break;
}
}
var ret = '';
if(isPOD){
var podCtrlName = ctrlPropreties.parentName;
var rowIndex = ctrlPropreties.rowIndex;
if(editRecordData['__POD__DATA'] && editRecordData['__POD__DATA'][podCtrlName] && editRecordData['__POD__DATA'][podCtrlName][rowIndex]){
var rowData = editRecordData['__POD__DATA'][podCtrlName][rowIndex];
ret = rowData[ctrlName];
if(ret == undefined){
ret = '';
}
ret = (''+ret).replace(/</g,"<").replace(/>/g,">")
.replace(/ /g,"\n"); // CO-1354
setCtrlPropretiesValue(ctrlPropreties, ret, true);
}
return ret;
}
switch (ctrlPropreties.ctrlType) {
case CONST_CTRL_TYPE_INPUTPAYMENT:
break;
case CONST_CTRL_TYPE_INPUT_TEXT:
case CONST_CTRL_TYPE_INPUTLOOKUP:
case CONST_CTRL_TYPE_INPUTLFBLUETOOTH:
case CONST_CTRL_TYPE_INPUTEMAILREPORT:
case CONST_CTRL_TYPE_INPUTFAX:
case CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT:
case CONST_CTRL_TYPE_INPUTFORWARD:
case CONST_CTRL_TYPE_INPUTSECUREFORWARD:
case CONST_CTRL_TYPE_INPUTCALCULATE:
case CONST_CTRL_TYPE_INPUTNEWPAYMENT:
case CONST_CTRL_TYPE_INPUTACTION:
var obj = editRecordData[ctrlName + 'text'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
if(ret == ''){
obj = editRecordData[ctrlName + 'string'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
if(obj == undefined){
ret = getPODData(ctrlPropreties, editRecordData);
}
setCtrlPropretiesValue(ctrlPropreties, ret, true);
break;
case CONST_CTRL_TYPE_INPUTNUMBERING:
var obj = editRecordData[ctrlName + 'text'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
if(ret == ''){
obj = editRecordData[ctrlName + 'string'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
if(ret == ''){
obj = editRecordData[ctrlName];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
if(obj == undefined){ ret = obj; } // 26605
setCtrlPropretiesValue(ctrlPropreties, ret, true);
break;
case CONST_CTRL_TYPE_INPUT_NUMERIC:
case CONST_CTRL_TYPE_INPUTTRENDS:
if(!editRecordData[ctrlName]){
var obj = getPODData(ctrlPropreties, editRecordData);
setCtrlPropretiesValue(ctrlPropreties, obj, true);
}else{
setCtrlPropretiesValue(ctrlPropreties, editRecordData[ctrlName].value, true);
}
break;
case CONST_CTRL_TYPE_INPUTDATE:
if(!editRecordData[ctrlName]){
setCtrlPropretiesValue(ctrlPropreties, undefined, true);
}else{
var date;
try{
date = new Date(editRecordData[ctrlName].value);
}catch(e){
}
if(date.toString() == 'Invalid Date'){
date = undefined;
}
if(date != undefined){
var kind = ctrlPropreties.kind;
if(!kind){
kind = CONST_VALUE_DATE_LOWERCASE;
}else{
kind = kind.toLowerCase();
}
switch(kind){
case CONST_VALUE_DATE_LOWERCASE:
setCtrlPropretiesValue(ctrlPropreties, date.format("yyyy-mm-dd"), true);
break;
case CONST_VALUE_TIME_LOWERCASE:
var timeVal = date.format("HH:MM:ss");
// CO-1738: Military time ability to use 24:00 (01/02/1970 00:00:00)
if(date.format("yyyy-mm-dd'T'HH:MM:ss") == '1970-01-02T00:00:00'){
timeVal = CONS_MILITARY_24;
}
setCtrlPropretiesValue(ctrlPropreties, timeVal, true);
break;
case 'date time':
setCtrlPropretiesValue(ctrlPropreties, date.format("yyyy-mm-dd'T'HH:MM:ss") + '.0', true);
break;
}
}else{
setCtrlPropretiesValue(ctrlPropreties, undefined, true);
}
}
break;
case CONST_CTRL_TYPE_INPUTSELECTONE:
case CONST_CTRL_TYPE_INPUTSELECTMANY:
case CONST_CTRL_TYPE_INPUTSCOREONE:
case CONST_CTRL_TYPE_INPUTBARCODE:
case CONST_CTRL_TYPE_INPUTNFC:
var obj = editRecordData[ctrlName + 'text'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
if(ret == ''){
obj = editRecordData[ctrlName + 'string'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
if(ret == ''){
obj = editRecordData[ctrlName];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
ret = ret.replace(/\n/g,' ');
if(ctrlPropreties.realType == CONST_CTRL_TYPE_INPUTAPPROVAL){
var arr = ret.split(' ');
switch(arr[0]){
case 'approved':
ret = 'approve un_date';
break;
case 'rejected':
ret = 'deny un_date';
break;
case 'deny':
ret = 'deny un_date';
break;
case 'approve':
ret = 'approve un_date';
break;
default:
ret = 'pending';
}
}
if(obj == undefined){ ret = obj; } // 26605
setCtrlPropretiesValue(ctrlPropreties, ret, true);
break;
case CONST_CTRL_TYPE_INPUTLOCATION:
setCtrlPropretiesValue(ctrlPropreties, '', true);
if(editRecordData[ctrlName + 'LATITUDE']){
ctrlPropreties.val += editRecordData[ctrlName + 'LATITUDE'].value;
}
ctrlPropreties.val += ' ';
if(editRecordData[ctrlName + 'LONGITUDE']){
ctrlPropreties.val += editRecordData[ctrlName + 'LONGITUDE'].value;
}
ctrlPropreties.val += ' ';
if(editRecordData[ctrlName + 'ALTITUDE']){
ctrlPropreties.val += editRecordData[ctrlName + 'ALTITUDE'].value;
}
ctrlPropreties.val += ' ';
if(editRecordData[ctrlName + 'ACCURACY']){
ctrlPropreties.val += editRecordData[ctrlName + 'ACCURACY'].value;
}
break;
case CONST_CTRL_TYPE_INPUTSKETCH:
case CONST_CTRL_TYPE_INPUTSIGNATURE:
case CONST_CTRL_TYPE_INPUTIMAGE:
case CONST_CTRL_TYPE_INPUTVIDEO:
case CONST_CTRL_TYPE_INPUTAUDIO:
case CONST_CTRL_TYPE_INPUTMEDIA:
case CONST_CTRL_TYPE_INPUTATTACHMENT:
if(!editRecordData[ctrlName]){
setCtrlPropretiesValue(ctrlPropreties, '', true);
}else if(editRecordData[ctrlName].value == ''){
setCtrlPropretiesValue(ctrlPropreties, '', true);
}else{
setCtrlPropretiesValue(ctrlPropreties, editRecordData[ctrlName].name, true);
ctrlPropreties.attrs = {
blobKey: editRecordData[ctrlName].value
}
ctrlPropreties.hintLink = '/imageViewer?blobKey=' + editRecordData[ctrlName].value;
}
break;
case CONST_CTRL_TYPE_INPUTCOUNTER:
if(!editRecordData[ctrlName]){
setCtrlPropretiesValue(ctrlPropreties, '', true);
}else{
setCtrlPropretiesValue(ctrlPropreties, editRecordData[ctrlName].value, true);
}
break;
case CONST_CTRL_TYPE_GROUP:
case CONST_CTRL_TYPE_CTRLTABLE:
case CONST_CTRL_TYPE_CTRLSCHEDULE:
case CONST_CTRL_TYPE_CTRLPOD:
case CONST_CTRL_TYPE_CTRLSCORETABLE:
case CONST_CTRL_TYPE_CTRLGRID:
break;
default:
if(!editRecordData[ctrlName]){
setCtrlPropretiesValue(ctrlPropreties, undefined, true);
}else{
setCtrlPropretiesValue(ctrlPropreties, editRecordData[ctrlName].value, true);
}
break;
}
return ret;
}
function getEditRecordData2(ctrlPropreties, editRecordData){
var ret = '';
if(editRecordData == undefined){
return ret;
}
var ctrlName = ctrlPropreties.name;
if(ctrlPropreties.parentKind){
switch (ctrlPropreties.parentKind) {
case 'grid':
case CONST_CTRL_TYPE_GROUP:
ctrlName += getParentIndexFromClassPath(ctrlPropreties.classPath);
break;
}
}
switch (ctrlPropreties.ctrlType) {
case CONST_CTRL_TYPE_INPUTPAYMENT:
break;
case CONST_CTRL_TYPE_INPUT_TEXT:
case CONST_CTRL_TYPE_INPUTLOOKUP:
case CONST_CTRL_TYPE_INPUTLFBLUETOOTH:
case CONST_CTRL_TYPE_INPUTEMAILREPORT:
case CONST_CTRL_TYPE_INPUTFAX:
case CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT:
case CONST_CTRL_TYPE_INPUTFORWARD:
case CONST_CTRL_TYPE_INPUTSECUREFORWARD:
case CONST_CTRL_TYPE_INPUTCALCULATE:
case CONST_CTRL_TYPE_INPUTNEWPAYMENT:
case CONST_CTRL_TYPE_INPUTACTION:
case CONST_CTRL_TYPE_INPUTSELECTONE:
case CONST_CTRL_TYPE_INPUTSELECTMANY:
case CONST_CTRL_TYPE_INPUTSCOREONE:
case CONST_CTRL_TYPE_INPUTBARCODE:
case CONST_CTRL_TYPE_INPUTNFC:
var obj = editRecordData[ctrlName + 'text'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
if(ret == ''){
obj = editRecordData[ctrlName + 'string'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
if(ctrlPropreties.ctrlType === CONST_CTRL_TYPE_INPUTSELECTMANY && ret != ''){
ret = ret.replace(/\n|\r/g,"<br>")
}
break;
case CONST_CTRL_TYPE_INPUTNUMBERING:
var obj = editRecordData[ctrlName + 'text'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
if(ret == ''){
obj = editRecordData[ctrlName + 'string'];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
if(ret == ''){
obj = editRecordData[ctrlName];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
}
if(obj == undefined){ ret = obj; } // 26605
break;
case CONST_CTRL_TYPE_INPUT_NUMERIC:
case CONST_CTRL_TYPE_INPUTTRENDS:
var obj = editRecordData[ctrlName];
if(obj){
if(obj && obj.value != ''){
ret = obj.value;
}
}
break;
case CONST_CTRL_TYPE_INPUTDATE:
var val = '';
var date;
try{
val = editRecordData[ctrlName].value;
date = new Date(val);
}catch(e){
}
if(date.toString() == 'Invalid Date'){
date = undefined;
}
if(date != undefined){
var kind = ctrlPropreties.kind;
if(!kind){
kind = CONST_VALUE_DATE_LOWERCASE;
}else{
kind = kind.toLowerCase();
}
switch(kind){
case CONST_VALUE_DATE_LOWERCASE:
if(val.indexOf(':') > 0){
ret = date.format('mm/dd/yyyy HH:MM:ss');
} else{
ret = date.format('mm/dd/yyyy');
}
break;
case CONST_VALUE_TIME_LOWERCASE:
var timeVal = date.format("HH:MM:ss");
// CO-1738: Military time ability to use 24:00 (01/02/1970 00:00:00)
if(date.format("yyyy-mm-dd'T'HH:MM:ss") == '1970-01-02T00:00:00'){
timeVal = CONS_MILITARY_24;
}
ret = timeVal;
break;
case 'date time':
ret = date.format('mm/dd/yyyy HH:MM:ss');
break;
}
}
break;
case CONST_CTRL_TYPE_INPUTLOCATION:
if(editRecordData[ctrlName + 'LATITUDE']){
ret += editRecordData[ctrlName + 'LATITUDE'].value;
}
ret += ' ';
if(editRecordData[ctrlName + 'LONGITUDE']){
ret += editRecordData[ctrlName + 'LONGITUDE'].value;
}
ret += ' ';
if(editRecordData[ctrlName + 'ALTITUDE']){
ret += editRecordData[ctrlName + 'ALTITUDE'].value;
}
ret += ' ';
if(editRecordData[ctrlName + 'ACCURACY']){
ret += editRecordData[ctrlName + 'ACCURACY'].value;
}
break;
//default:
// break;
}
return ret;
}
function getPODData(ctrlPropreties, editRecordData){
var podVal = undefined;
try{
var parentName = ctrlPropreties.parentName;
if(editRecordData['__POD__DATA'] != undefined
&& editRecordData['__POD__DATA'][parentName] != undefined){
var arrPOD = editRecordData['__POD__DATA'][parentName];
var podName = ctrlPropreties.name;
if(podName.indexOf('__') > 0){
podName = podName.replace(podName.split('__')[0], '');
}
if(ctrlPropreties.rowIndex < arrPOD.length
&& arrPOD[ctrlPropreties.rowIndex][podName] != undefined){
podVal = arrPOD[ctrlPropreties.rowIndex][podName];
}
}
} catch(e){}
return podVal;
};
/**
* Apply function HtmlEncode(s) only for Website
*/
function HtmlEncode4Website(s, usingCData)
{
if(s == null){
return '';
}else if(usingCData){
if(typeof s === 'string') {
return '/gi, ']]>') + ']]>';
} else {
return '';
}
}else{
var el = document.createElement("div");
el.innerText = el.textContent = s;
s = el.innerHTML;
delete el;
s = s.replace(/ /gi, '\r\n');
s = s.replace(/'/gi, ''');
s = s.replace(/"/gi, '"');
s = s.replace(/ /gi, ' ');
s = s.replace(//gi, '');
return s;
}
}
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) );
}
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
return stringToTrim.replace(/\s+$/, "");
}
function HtmlDecode(s)
{
var el = $('
' + s + '
');
s = el.text();
delete el;
return s;
}
/**
* Process validate field []Custom Weight for Grid/Table/Questionaire
*/
function validateCustomWeight4ContainerGeneralProperty(control, retObj) {
var finalErrorCode = -1;
var numChildren = 0;
if(control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){
if (control.children.length === undefined || control.children.length === null) {
return finalErrorCode;
}
numChildren = control.children.length;
}else{
numChildren = control.columns.length;
}
if(control.type !== 'ctrlBreakPointData'){
if(!isVersion(VERSION_GRID_TYPE_FUNCTION) || (control.type !== CONST_CTRL_TYPE_CTRLGRID && control.type !== CONST_CTRL_TYPE_CTRLTABLE && control.type !== CONST_CTRL_TYPE_CTRLSCHEDULE && control.type !== CONST_CTRL_TYPE_CTRLPOD && control.type !== CONST_CTRL_TYPE_CTRLSCORETABLE && control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY)){
// Do nothing because we don't check into []Custom weight
if (control.isColumnWeightCustom !== true) {
return finalErrorCode;
}
}else{
if (control.columnsSpaceType !== '2') {
return finalErrorCode;
}
}
}else{
if (control.reportColumnsSpaceType !== '2') {
return finalErrorCode;
}
}
// PCA-199 Build Forms for New Grid Type, change column weight spec for Questionnaire
// Special treating with Questionnaire
if (control.type === CONST_CTRL_TYPE_CTRLSCORETABLE) {
return validateCustomWeight4ContainerGPQuestionnaire(control, retObj);
}
var withFormat4ColumnWeight = control.withFormat4ColumnWeight;
if (control.withFormat4ColumnWeight === undefined
|| control.withFormat4ColumnWeight === null
|| control.withFormat4ColumnWeight === '') {
retObj.error = 13;
retObj.message = msg_bf_act_required;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
//requiredError = true;
finalErrorCode = 1; // errorCode = 1
return finalErrorCode;
}
// Validate content
var trimWithFormat4ColumnWeight = withFormat4ColumnWeight.trim();
var arrNumbers = trimWithFormat4ColumnWeight.split('|');
var checkColumns = arrNumbers.length;
// Default get number of fields (Table)
var containerCols = numChildren;
// If checked there will be an input box
// with the format [10 | 20 | 20 | 50]
//
// Or number of separated input box for each column
// It will be validated by :
// * total of values equals 100
// * number columns equals number fields in table
// * number columns equals number options in questionnaire
// * number columns equals number [Number Columns]
// Process Grid
var gridCenterPaddingTotal = 0;
if (control.type == CONST_CTRL_TYPE_CTRLGRID) {
containerCols = control.loop;
// Fwd: Column Weight Issue (07-Nov-2016)
// Special treating with value such as &&&21
if (containerCols && (containerCols + '').indexOf('&&&') === 0) {
try {
containerCols = (containerCols + '').replace('&&&', '');
} catch (e) {}
}
switch(control.gridType){
case CONST_GRID_TYPE_CENTER:
var isNumberValue = false;
var numberVal = 0;
try {
// Parse number value into float type
numberVal = parseFloat(control.leftPadding);
if (!isNaN(numberVal) && isFinite(control.leftPadding)) {
isNumberValue = true;
}
} catch (e) {
}
if (isNumberValue === true && numberVal >= 0) {
gridCenterPaddingTotal += numberVal;
}
try {
// Parse number value into float type
numberVal = parseFloat(control.rightPadding);
if (!isNaN(numberVal) && isFinite(control.rightPadding)) {
isNumberValue = true;
}
} catch (e) {
}
if (isNumberValue === true && numberVal >= 0) {
gridCenterPaddingTotal += numberVal;
}
break;
}
} else if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) {
// Get the first option
var firstOption = control.children[0];
if (firstOption !== undefined
&& firstOption.options !== undefined
&& firstOption.options.length != undefined) {
containerCols = firstOption.options.length;
// Check if we need append []Append comment column + 1 first header column
// The caption header
containerCols++;
if (control.appendComment === true) {
containerCols++;
}
}
}else if (control.type == CONST_CTRL_TYPE_CTRLPOD) {
//ignore status field and AutoID field
containerCols-=2;
}else if (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY) {
if (control.isRowCountDisplay === true) {
containerCols++;
}
}
writeToLogInfoRequired('Columns in FORMAT : ' + checkColumns + " >> containerCols : " + containerCols);
if (checkColumns != containerCols) {
retObj.error = 202;
retObj.message = msg_bf_column_weight_container_num_cols_invalid;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
finalErrorCode = 2;
return finalErrorCode;
}
// Check number value
var totalValue = 0;
for (var i = 0; i < arrNumbers.length; i++) {
var currentNumber = arrNumbers[i].trim();
var isNumberValue = false;
var numberVal = 0;
try {
// Parse number value into float type
numberVal = parseFloat(currentNumber);
if (!isNaN(numberVal) && isFinite(currentNumber)) {
isNumberValue = true;
}
} catch (e) {
}
// Do not accept negative value or equal 0
// Change request : accept value 0
// Email : Fwd: Re: bug in adjust column widths (27-Jan-2016 10:16 AM)
if (isNumberValue === true && numberVal >= 0) {
totalValue += numberVal;
continue;
}
else {
// Not number => Invalid
writeToLogInfoRequired('Not number => Invalid : ' + currentNumber);
retObj.error = 203;
retObj.message = msg_bf_column_weight_container_not_number_invalid;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
//requiredError = true;
finalErrorCode = 1; // errorCode = 1
return finalErrorCode;
}
// Setting the main object
withFormat4ColumnWeight = control.withFormat4ColumnWeight2;
// Validate Question/Answer/Comment
// The Question should be a number
var valQuestion = withFormat4ColumnWeight.withFormat4CWQuestion;
if (false === isNumberValueString(valQuestion)) {
// Is not a number
retObj.error = 13;
retObj.message = msg_bf_questionnaire_question_number_check;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
finalErrorCode = 1;
return finalErrorCode;
}
// Validate Answer
var valAnswer = withFormat4ColumnWeight.withFormat4CWAnswer;
if (false === isNumberValueString(valAnswer)) {
// Is not a number
retObj.error = 13;
retObj.message = msg_bf_questionnaire_answer_number_check;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
finalErrorCode = 1;
return finalErrorCode;
}
// Check the Comment
var valComment = withFormat4ColumnWeight.withFormat4CWComment;
if (control.appendComment === true) {
if (false === isNumberValueString(valComment)) {
// Is not a number
retObj.error = 13;
retObj.message = msg_bf_questionnaire_comment_number_check;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
finalErrorCode = 1;
return finalErrorCode;
}
}
var trimWithFormat4ColumnWeightSC = valAnswer.trim();
//var arrNumbers = trimWithFormat4ColumnWeightSC.split('|');
var arrNumbers = new Array();
var checkColumns = arrNumbers.length;
// If checked there will be an input box
// with the format [10 | 20 | 20 | 50]
//
// Or number of separated input box for each column
// It will be validated by :
// * total of values equals 100
// * number columns equals number fields in table
// * number columns equals number options in questionnaire
// * number columns equals number [Number Columns]
/*
// Process Grid
if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE && control.children.length > 0) {
// Get the first option
var firstOption = control.children[0];
if (firstOption !== undefined
&& firstOption.options !== undefined
&& firstOption.options.length != undefined) {
containerCols = firstOption.options.length;
}
//writeToLogInfoRequired('Columns in FORMAT : ' + checkColumns + " >> containerCols : " + containerCols);
if (checkColumns != containerCols) {
retObj.error = 202;
retObj.message = msg_bf_column_weight_container_num_cols_invalid;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
finalErrorCode = 2;
return finalErrorCode;
}
}
*/
// Check number value (in total 3 field : Question/Answer/Comment
// Check the header/comment column
arrNumbers.push(valQuestion);
arrNumbers.push(valAnswer);
// Check if we need append []Append comment column
if (control.appendComment === true) {
arrNumbers.push(valComment);
}
var totalValue = 0;
for (var i = 0; i < arrNumbers.length; i++) {
var currentNumber = arrNumbers[i].trim();
var isNumberValue = false;
var numberVal = 0;
try {
// Parse number value into float type
numberVal = parseFloat(currentNumber);
if (!isNaN(numberVal) && isFinite(currentNumber)) {
isNumberValue = true;
}
} catch (e) {
}
// Do not accept negative value or equal 0
if (isNumberValue === true && numberVal > 0) {
totalValue += numberVal;
continue;
}
else {
// Not number => Invalid
writeToLogInfoRequired('Not number => Invalid : ' + currentNumber);
retObj.error = 203;
retObj.message = msg_bf_questionnaire_answer_not_number_invalid_sc;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
errorCode = 1;
}
}
}
if(errorCode == 1){
return true;
}
return false;
}
/*
* error = 0 : success
* error = 1 : min/max are required.
* error = 2 : min > max
* error = 3 : The length of default value is not valid.
* error = 4 : The default value is not valid.
* error = 5 : Field minimum is not valid.
* error = 6 : Field maximum is not valid.
* error = 7 : The default value is not valid.
* error = 8 : Select control options not input.
* error = 9 : Option name/value not input.
* error = 9 : Control name not input.
* error = 9 : Category not input.
* error = 10 : Read Only/Required error.
* error = 11 : Control name is not valid.
* error = 12 : More than one option with same underlying value.
* error = 13 : Caption text is required.
* error = 14 : Required and zero length.
* error = 15 : Group with no control.
* error = 16 : Max Repeats must be between 1 and 20.
* error = 17 : All fields are required in skip conditions.
* error = 18 : All fields are required in relevance conditions.
* error = 19 : Please input min <= max <= 500.
* error = 20 : Data source is required.
* error = 21 : Lookup field is required.
* error = 22 : All fields are required in lookup control.
* error = 23 : The number must be between >= nin range and <= max range.
* error = 24 : data source different
* error = 25 : the first control in table is conditional LU
* error = 26 : Please select currency symbol
* error = 27 : cannot add date with date
* error = 28 : The answer options not the same
* error = 29 : Cannot choose required and "Hide field in website" or "Hide field in mobile app"
* error = 30 : Number of prior values is required
* error = 31 : Trending date is required
* error = 32 : Key field filter is required
* error = 33 : Number of prior is not valid
* error = 34 : Wrong specified question
* error = 97 : Control required error.
* error = 98 : No control error.
* error = 99 : Controls name are required.
* error = 101: Duplicate value between Separation Delimiter and End Delimiter ([]Parse of Barcode/NFC).
* error = 103: using key word ]]> in caption and hint
* error = 104: condition is required, condition compare control is required, jump control is required
*/
var checkControlData = function(control, lookupDatasourceArray, optionMap, controls, controlParrent, controlsOrg, useChecklistObjMap)
{
var retObj = {};
var errorCode = 0;
retObj.error = 0;
retObj.message = '';
retObj.ctrlName = control.name;
if(control.name && control.name.startsWith('AE__')){
return retObj;
}
var isAdvanceLocation = false;
if(isVersion(VERSION_GPS_GET_ADDRESS) && control.locationStype && control.locationStype == CONST_TYPE_ADVANCED){
isAdvanceLocation = true;
}
var kwError = keywordCheck(control);
if(kwError != null && kwError.error != undefined && kwError.error != 0){
retObj.error = kwError.error;
retObj.message = kwError.message;//msg_bf_cdata_kw_error;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
errorCode = 1;
requiredError = true;
}
//return retObj;
}
}
}
// Fix bug 0022155: Barcode-NFC Parsing : There is no warning message if Separation Delimiter and End Delimiter have the same value
// Check if the [x]Parse - Android ONLY, Separation Delimiter and End Delimiter
if (control.parse !== undefined
&& control.parse !== null
&& control.parse !== ''
&& control.parse !== false) {
var separatorDelimiter = control.parse.separation;
var startDelimiter = control.parse.start;
var endDelimiter = control.parse.end;
// check if delimiter has & symbol
if(containsString(startDelimiter, "&") || containsString(separatorDelimiter, "&") || containsString(endDelimiter, "&")){
retObj.error = 102;
retObj.message = msg_bf_barcode_nfc_parse_delimiter_error;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
errorCode = 1;
}
// Check duplicate value
// Fix bug 0025079: Barcode-NFC Parsing : There is no warning message if Start Delimiter and End Delimiter have the same value
if ((jQuery.trim(separatorDelimiter) !== '' && separatorDelimiter == endDelimiter)
|| (jQuery.trim(separatorDelimiter) !== '' && separatorDelimiter == startDelimiter)
|| (jQuery.trim(startDelimiter) !== '' && startDelimiter == endDelimiter)
) {
// error = 101: Duplicate value between Separation Delimiter and End Delimiter ([]Parse of Barcode/NFC).
retObj.error = 101;
retObj.message = msg_bf_barcode_nfc_enable_parse_error;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
errorCode = 1;
requiredError = true;
}
}
});
}else if(control.isUseActionButton){
// CO-675: NFC/Barcode Use Action Button
// When I select "Action button only" it allowed me to publish the form without selecting a destination field. The builder should not allow the publishing of a form without at least one destination field selected
retObj.error = 10;
retObj.message = msg_bf_destination_fields_required;
if(!requiredError){
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
errorCode = 1;
requiredError = true;
}
//return retObj;
}
}
}
// Fix bug 0022155: Barcode-NFC Parsing : There is no warning message if Separation Delimiter and End Delimiter have the same value
// Check if the [x]Parse - Android ONLY, Separation Delimiter and End Delimiter
if (control.parse !== undefined
&& control.parse !== null
&& control.parse !== ''
&& control.parse !== false) {
var separatorDelimiter = control.parse.separation;
var startDelimiter = control.parse.start;
var endDelimiter = control.parse.end;
// check if delimiter has & symbol
if(containsString(startDelimiter, "&") || containsString(separatorDelimiter, "&") || containsString(endDelimiter, "&")){
retObj.error = 102;
retObj.message = msg_bf_barcode_nfc_parse_delimiter_error;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
errorCode = 1;
}
// Check duplicate value
// Fix bug 0025079: Barcode-NFC Parsing : There is no warning message if Start Delimiter and End Delimiter have the same value
if ((jQuery.trim(separatorDelimiter) !== '' && separatorDelimiter == endDelimiter)
|| (jQuery.trim(separatorDelimiter) !== '' && separatorDelimiter == startDelimiter)
|| (jQuery.trim(startDelimiter) !== '' && startDelimiter == endDelimiter)
) {
// error = 101: Duplicate value between Separation Delimiter and End Delimiter ([]Parse of Barcode/NFC).
retObj.error = 101;
retObj.message = msg_bf_barcode_nfc_enable_parse_error;
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
errorCode = 1;
requiredError = true;
}
}
});
}else if(control.isUseActionButton){
// CO-675: NFC/Barcode Use Action Button
// When I select "Action button only" it allowed me to publish the form without selecting a destination field. The builder should not allow the publishing of a form without at least one destination field selected
retObj.error = 10;
retObj.message = msg_bf_destination_fields_required;
if(!requiredError){
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
errorCode = 1;
}
}else{
var min = Date.parse(control.reportDateRange.min);
var max = Date.parse(control.reportDateRange.max);
var days = Math.round((max-min)/(1000*60*60*24));
if(!(0 < days && days <= 31)){
retObj.error = 1;
retObj.message = err_report_data_range_invalid;
if(!requiredError){
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
');
requiredError = true;
errorCode = 1;
}
}else{
var $ctrlDataSource = controlsOrg[0];
if($ctrlDataSource && $ctrlDataSource.type == 'ctrlDataSource'){
// check Can’t select date/time in the past needs to be a future date/time when compared to the specified data dates.
if($ctrlDataSource.dataSourceDateFilter == '6' && $ctrlDataSource.reportDateRange && $ctrlDataSource.reportDateRange.useDateRange != false){
if($ctrlDataSource.reportDateRange.max != ''){
var max = Date.parse($ctrlDataSource.reportDateRange.max);
var curDate = Date.parse(control.reportFrequency.datefilter);
var days = Math.round((curDate-max)/(1000*60*60*24));
if(days < 0){
retObj.error = 1;
retObj.message = msg_error_select_past_date.replace('$1', $ctrlDataSource.reportDateRange.max);
if(!requiredError){
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
' + retObj.message + '
');
errorCode = 1;
}
}
}
}
if(errorCode != 1){
var curDate = new Date(control.reportFrequency.datefilter + ' ' + control.reportFrequency.timefilter);
var nowTime = getCurrentSettingTime(control.reportTimeZone, control.reportTimeZoneDst);
var days = (curDate-nowTime)/(1000*60*60*24);
if(days < 0){
retObj.error = 1;
retObj.message = msg_error_select_past_date.replace('$1', nowTime.format("mm/dd/yyyy HH:MM:ss"));
if(!requiredError){
$('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '