/** * 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( '
  • ' + retObj.message + '
  • '); finalErrorCode = 3; return finalErrorCode; } } totalValue += gridCenterPaddingTotal; writeToLogInfoRequired('TotalValue : ' + totalValue); if (totalValue != 100 && totalValue.toFixed(2) != '100.00') { retObj.error = 204; retObj.message = msg_bf_column_weight_container_total_percent_invalid; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); finalErrorCode = 4; return finalErrorCode; } return finalErrorCode; } /** * Process validate field []Custom Weight for Grid/Table/Questionaire */ function validateCustomWeight4ContainerGPQuestionnaire(control, retObj) { var finalErrorCode = -1; // Check required condition var isRequiredError = false; var withFormat4ColumnWeight = null; if (control.withFormat4ColumnWeight2 === undefined || control.withFormat4ColumnWeight2 === null) { isRequiredError = true; } if (isRequiredError === false) { // Check required condition (continued ... ) withFormat4ColumnWeight = control.withFormat4ColumnWeight2; if (withFormat4ColumnWeight.withFormat4CWQuestion === undefined || withFormat4ColumnWeight.withFormat4CWQuestion === null || withFormat4ColumnWeight.withFormat4CWQuestion === '' || withFormat4ColumnWeight.withFormat4CWAnswer === undefined || withFormat4ColumnWeight.withFormat4CWAnswer === null || withFormat4ColumnWeight.withFormat4CWAnswer === '' ) { isRequiredError = true; } if (control.appendComment === true) { // Check if [x]Append comment if (withFormat4ColumnWeight.withFormat4CWComment === undefined || withFormat4ColumnWeight.withFormat4CWComment === null || withFormat4ColumnWeight.withFormat4CWComment === '' ) { isRequiredError = true; } } } // Check required error if (isRequiredError === true) { 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; } // 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( '
  • ' + retObj.message + '
  • '); finalErrorCode = 3; return finalErrorCode; } } writeToLogInfoRequired('TotalValue : ' + totalValue); if (totalValue != 100 && totalValue.toFixed(2) != '100.00') { retObj.error = 204; retObj.message = msg_bf_questionnaire_total_percent_invalid_sc; if (control.appendComment === true) { retObj.message = msg_bf_questionnaire_total_percent_invalid_sc_cmt; } $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); finalErrorCode = 4; return finalErrorCode; } return finalErrorCode; } /** * Apply replacing SPACE into   in XML file based on []Replace space with HTML tag “ ” * (used for Grid/Table/Questionnaire */ function applyCheckingCustomControlLabel4XML(controlLabel, control, objParent) { // Check version for processing this feature if (currentVersion < VERSION_NEW_OPTION_CUSTOM_COLUMN_WEIGHT) { return controlLabel; } var isNeedAdjustValue = false; if (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID) { // PCA-270: Remove the replace space function // if (control.replaceSpaceWithHtmlTagNBSP === true) { // if (controlLabel.eng !== undefined) { // controlLabel.eng = controlLabel.eng.replace(/ /g, ' '); // } // } isNeedAdjustValue = true; } // Check parent object (if exists) else if (typeof objParent !== 'undefined') { if (objParent.type == CONST_CTRL_TYPE_CTRLTABLE || objParent.type == CONST_CTRL_TYPE_CTRLSCHEDULE || objParent.type == CONST_CTRL_TYPE_CTRLPOD || objParent.type == CONST_CTRL_TYPE_CTRLSCORETABLE || objParent.type == CONST_CTRL_TYPE_CTRLGRID) { // PCA-270: Remove the replace space function // if (objParent.replaceSpaceWithHtmlTagNBSP === true) { // if (controlLabel.eng !== undefined) { // controlLabel.eng = controlLabel.eng.replace(/ /g, ' '); // } // } isNeedAdjustValue = true; } } // PCA-270: Remove the replace space function if (isNeedAdjustValue === true) { if (controlLabel.eng !== undefined) { //controlLabel.eng = controlLabel.eng.replace(/ /g, ' '); // Change value as pattern : [ Sample caption ] // => become : [  Sample caption   ] var mainDataString = controlLabel.eng; var arrString = mainDataString.split(''); // Go from the first characters for (var t = 0; t < arrString.length; t++) { //writeToLogInfo('arrString[t] : [' + arrString[t] + ']'); if (arrString[t] === ' ') { arrString[t] = ' '; } else { break; } } // Go from the last characters for (var t = arrString.length-1; t >= 0; t--) { if (arrString[t] === ' ') { arrString[t] = ' '; } else { break; } } controlLabel.eng = arrString.join(''); } } return controlLabel; } var getControlById = function(controlId, controls) { if(controls){ return getControlFromArrayById(controls, controlId, false); }else{ var internal = odkmaker.data.extract(); return getControlFromArrayById(internal.controls, controlId, false); } }; var checkCtrlPosIsCorrected = function(controls, ctrlId1, ctrlId2) { return checkControlByIdCorrectPos(controls, ctrlId1, ctrlId2); }; var getControlFromArrayById = function(controls, controlId, isCtrlScoreTable) { var ret = null; _.each(controls, function(control){ if(ret != null){ return false; } if(('' + control.id) == ('' + controlId)){ ret = control; if(isCtrlScoreTable){ ret.isCtrlInScoreTable = true; }else{ ret.isCtrlInScoreTable = false; } return false; }else{ if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV) { ret = getControlFromArrayById(control.children, controlId, false); if(ret != null){ return false; } }else if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) { ret = getControlFromArrayById(control.children, controlId, true); if(ret != null){ return false; } }else if (control.type == CONST_CTRL_TYPE_CTRLGRID) { ret = getControlFromArrayById(control.children, controlId, false); if(ret != null){ return false; } } } }); return ret; }; var checkControlByIdCorrectPos = function(controls, controlId, controlId2) { var ret = null; _.each(controls, function(control){ if(ret != null){ return false; } if(control.id == controlId2){ ret = false return false; } if(control.id == controlId){ ret = false; _.each(controls, function(control1){ if(ret == true){ return false; } if(control1.id == controlId2){ ret = true return false; } }); return false; }else{ if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID) { var retChild = checkControlByIdCorrectPos(control.children, controlId, controlId2); if(retChild != null && retChild == true){ ret = true; } } } }); if(ret == null){ ret = false; } return ret; }; var isITEConditionTheSameKind = function(controls, ctrlId1, ctrlId2){ return isRelevanceConditionTheSameKind(controls, ctrlId1, ctrlId2); } var isRelevanceConditionTheSameKind = function(controls, ctrlId1, ctrlId2) { var ctrl1 = getControlFromArrayById(controls, ctrlId1, false); var ctrl2 = getControlFromArrayById(controls, ctrlId2, false); if(ctrl1 == undefined && ctrl2 == undefined){ return true; }else if(ctrl1 == undefined || ctrl2 == undefined){ return false; }else{ var type1 = ctrl1.type; var kind1 = ctrl1.kind || ''; var type2 = ctrl2.type; var kind2 = ctrl2.kind || ''; if(type1 == type2 && kind1 == kind2){ return true; }else if(isCtrlTextKind(type1, ctrl1) && isCtrlTextKind(type2, ctrl2)){ return true; }else if(isCtrlNumberKind(type1, kind1) && isCtrlNumberKind(type2, kind2)){ return true; }else{ switch(type1){ case CONST_CTRL_TYPE_INPUTDATE: if(type2 == CONST_CTRL_TYPE_INPUTCALCULATE && kind2 == CONST_VALUE_DATE){ return true; } break; case CONST_CTRL_TYPE_INPUTCALCULATE: if(kind1 == CONST_VALUE_DATE && type2 == CONST_CTRL_TYPE_INPUTDATE){ return true; } break; } return false; } } }; var checkInputSourcePosIsCorrected = function(controls, selectedCtrlId, inputSourceId, inputSourceType) { var inputSourceStack = []; var inputSourceStackCount = 0; var findInputSourceCtrlToNode = function(controls, selectedCtrlId, inputSource){ var addNode = false; var tmp = []; var i = 0; _.each(controls, function(control) { if(selectedCtrlId == control.id){ addNode = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findInputSourceCtrlToNode(control.children, selectedCtrlId, inputSource); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findInputSourceCtrlToNode(control.children, selectedCtrlId, inputSource); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findInputSourceCtrlToNode(control.children, selectedCtrlId, inputSource); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findInputSourceCtrlToNode(control.children, selectedCtrlId, inputSource); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ //addNode = findInputSourceCtrlToNode(control.children, selectedCtrlId, inputSource); _.each(control.children, function(controlGrd) { if(selectedCtrlId == controlGrd.id){ addNode = true; } if(addNode){ return false; } if(!isVersion(VERSION_GMAP_REMOVE_INPUT_SRC)){ if(inputSource == 'Text widget'){ if(controlGrd.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTCALCULATE && controlGrd.kind == 'String'){ tmp[i] = controlGrd.id; i++; } }else if(inputSource == 'Lookup widget'){ if(controlGrd.type == CONST_CTRL_TYPE_INPUTLOOKUP){ tmp[i] = controlGrd.id; i++; } }else if(inputSource == 'LFBluetooth widget'){ if(controlGrd.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ tmp[i] = controlGrd.id; i++; } }else if(inputSource == 'Location widget'){ if(controlGrd.type == CONST_CTRL_TYPE_INPUTLOCATION){ tmp[i] = controlGrd.id; i++; } } }else{ if(inputSource == 'Lat/Lon'){ if(controlGrd.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTCALCULATE && controlGrd.kind == 'String'){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTLOOKUP){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTLOCATION){ tmp[i] = controlGrd.id; i++; } }else{ if(controlGrd.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTCALCULATE && controlGrd.kind == 'String'){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTLOOKUP){ tmp[i] = controlGrd.id; i++; }else if(controlGrd.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ tmp[i] = controlGrd.id; i++; } } } }); }else { if(!isVersion(VERSION_GMAP_REMOVE_INPUT_SRC)){ if(inputSource == 'Text widget'){ if(control.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.kind == 'String'){ tmp[i] = control.id; i++; } }else if(inputSource == 'Lookup widget'){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ tmp[i] = control.id; i++; } }else if(inputSource == 'LFBluetooth widget'){ if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ tmp[i] = control.id; i++; } }else if(inputSource == 'Location widget'){ if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){ tmp[i] = control.id; i++; } } }else{ if(inputSource == 'Lat/Lon'){ if(control.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.kind == 'String'){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){ tmp[i] = control.id; i++; } }else{ if(control.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.kind == 'String'){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ tmp[i] = control.id; i++; } } } } }); if(addNode){ for(var j=i; j>0; j--){ inputSourceStack[inputSourceStackCount] = tmp[j-1]; inputSourceStackCount++; } } return addNode; } findInputSourceCtrlToNode(controls, selectedCtrlId, inputSourceType); for(var j=inputSourceStackCount; j>0; j--){ if(inputSourceStack[j-1] == inputSourceId){ return true; } } return false; } var checkCalculateCtrlPosIsCorrected = function(controls, controlType, controlId, conditionControlId, isPreviousCtrl) { var calStack = []; var calStackCount = 0; var calStackFields4Date = []; var calStackFields4DateCount = 0; var calStack4Date = []; var calStackCount4Date = 0; var findCalculateToNode = function(controls, controlType, endId, isGrid, isPreviousCtrl){ var addNode = false; var tmp = []; var tmp4Date = []; var tmpFields4Date = []; var i = 0; var k = 0; var l = 0; var addNodeToEndOfGroup = false; var addClass = ''; _.each(controls, function(control) { if(endId == control.id){ if(isPreviousCtrl && control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.parentCtrlType == CONST_CTRL_TYPE_GROUP){ addNodeToEndOfGroup = true; addClass = CONST_CLS_FOR_PREVIOUS_OPT; }else{ addNode = true; } } if(addNode){ return false; } if((control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')) && !addNodeToEndOfGroup){ addNode = findCalculateToNode(control.children, controlType, endId, false, isPreviousCtrl); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findCalculateToNode(control.children, controlType, endId, false, isPreviousCtrl); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findCalculateToNode(control.children, controlType, endId, false, isPreviousCtrl); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findCalculateToNode(control.children, controlType, endId, false, isPreviousCtrl); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ //addNode = findCalculateToNode(control.children, controlType, endId, true, isPreviousCtrl); _.each(control.children, function(controlInGrid) { if(endId == controlInGrid.id){ addNode = true; } if(addNode){ return false; } if((controlType == 'Number' || controlType == CONST_VALUE_DATE)){ if(controlInGrid.type == CONST_CTRL_TYPE_INPUT_NUMERIC || controlInGrid.type == CONST_CTRL_TYPE_INPUTTRENDS || controlInGrid.type == CONST_CTRL_TYPE_INPUTCOUNTER){ tmp[i] = controlInGrid.id; i++; tmp4Date[k] = controlInGrid.id; k++; } if(controlInGrid.type == CONST_CTRL_TYPE_INPUTCALCULATE && controlInGrid.kind != 'String'){ // not use String Cal for Num Cal expression tmp[i] = controlInGrid.id; i++; } if(controlInGrid.type == CONST_CTRL_TYPE_INPUTDATE){// && controlInGrid.kind != CONST_VALUE_TIME){ if(controlInGrid.kind == CONST_VALUE_TIME && !isVersion3_2()){ }else{ tmp4Date[k] = controlInGrid.id; k++; tmpFields4Date[l] = controlInGrid.id; l++; } } }else if(controlType == 'String'){ if(controlInGrid.type == CONST_CTRL_TYPE_INPUT_TEXT || controlInGrid.type == CONST_CTRL_TYPE_INPUT_NUMERIC || controlInGrid.type == CONST_CTRL_TYPE_INPUTCOUNTER || controlInGrid.type == CONST_CTRL_TYPE_INPUTLOOKUP || controlInGrid.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || controlInGrid.type == CONST_CTRL_TYPE_INPUTNUMBERING || controlInGrid.type == CONST_CTRL_TYPE_INPUTSELECTONE){ tmp[i] = controlInGrid.id; i++; tmp4Date[k] = controlInGrid.id; k++; } if(controlInGrid.type == CONST_CTRL_TYPE_INPUTCALCULATE){ tmp[i] = controlInGrid.id; i++; } if(controlInGrid.type == CONST_CTRL_TYPE_INPUTDATE){// && controlInGrid.kind != CONST_VALUE_TIME){ if(controlInGrid.kind == CONST_VALUE_TIME && !isVersion3_2()){ }else{ tmp4Date[k] = controlInGrid.id; k++; tmpFields4Date[l] = controlInGrid.id; l++; } } } }); }else if((controlType == 'Number' || controlType == CONST_VALUE_DATE)){ if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ tmp[i] = control.id; i++; tmp4Date[k] = control.id; k++; } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.kind != 'String'){ // not use String Cal for Num Cal expression if(control.kind == CONST_CTRL_KIND_NUMBER){ tmp4Date[k] = control.id; k++; } tmp[i] = control.id; i++; } if(control.type == CONST_CTRL_TYPE_INPUTDATE){// && control.kind != CONST_VALUE_TIME){ if(control.kind == CONST_VALUE_TIME && !isVersion3_2()){ }else{ tmp4Date[k] = control.id; k++; tmpFields4Date[l] = control.id; l++; } } }else if(controlType == 'String'){ if(control.type == CONST_CTRL_TYPE_INPUT_TEXT || control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTCOUNTER || control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type == CONST_CTRL_TYPE_INPUTNUMBERING || control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ tmp[i] = control.id; i++; tmp4Date[k] = control.id; k++; } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ tmp[i] = control.id; i++; } if(control.type == CONST_CTRL_TYPE_INPUTDATE){// && control.kind != CONST_VALUE_TIME){ if(control.kind == CONST_VALUE_TIME && !isVersion3_2()){ }else{ tmp4Date[k] = control.id; k++; tmpFields4Date[l] = control.id; l++; } } } }); if(addNodeToEndOfGroup){ addNode = true; } if(addNode || isGrid){ for(var j=i; j>0; j--){ calStack[calStackCount] = tmp[j-1]; calStackCount++; } if(controlType == 'String'){ for(var j=l; j>0; j--){ calStack[calStackCount] = tmpFields4Date[j-1]; calStackCount++; } } for(var j=l; j>0; j--){ calStackFields4Date[calStackFields4DateCount] = tmpFields4Date[j-1]; calStackFields4DateCount++; } for(var j=k; j>0; j--){ calStack4Date[calStackCount4Date] = tmp4Date[j-1]; calStackCount4Date++; } return addNode; }else{ return false; } } var end = findCalculateToNode(controls, controlType, controlId, undefined, isPreviousCtrl); if(end){ if(controlType == CONST_VALUE_DATE){ for(var j=calStackCount4Date; j>0; j--){ if(calStack4Date[j-1] == conditionControlId){ return true; } } }else{ for(var j=calStackCount; j>0; j--){ if(calStack[j-1] == conditionControlId){ return true; } } } } return false; } var checkCalculateSumCtrlPosIsCorrected = function(controls, controlType, endId, conditionControlId) { calStack = []; calStackCount = 0; var findCalculateSumToNode = function(controls, controlType, endId, canAddNode){ var addNode = false; var tmp = []; var i = 0; var canAddNodeThisLevel = false; if(!canAddNode){ _.each(controls, function(control) { if(endId == control.id){ canAddNodeThisLevel = true; }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(isVersion8_1){ _.each(control.children, function(controlGrd) { if(endId == controlGrd.id){ canAddNodeThisLevel = true; } if(canAddNodeThisLevel){ return false; } }); } } if(canAddNodeThisLevel){ return false; } }); }else{ canAddNodeThisLevel = true; } _.each(controls, function(control) { if(endId == control.id){ addNode = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findCalculateSumToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findCalculateSumToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findCalculateSumToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findCalculateSumToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ //addNode = findCalculateSumToNode(control.children, controlType, endId, canAddNodeThisLevel); if(isVersion8_1){ _.each(control.children, function(controlGrd) { if(endId == controlGrd.id){ addNode = true; } if(addNode){ return false; } if(controlType == 'Number' && (controlGrd.type == CONST_CTRL_TYPE_INPUT_NUMERIC || controlGrd.type == CONST_CTRL_TYPE_INPUTTRENDS || controlGrd.type == CONST_CTRL_TYPE_INPUTCALCULATE || controlGrd.type == CONST_CTRL_TYPE_INPUTCOUNTER)){ if(canAddNode){ tmp[i] = controlGrd.id; i++; } }else if(controlType == CONST_VALUE_DATE && controlGrd.type == CONST_CTRL_TYPE_INPUTDATE){ if(canAddNode){ tmp[i] = controlGrd.id; i++; } } }); } }else if(controlType == 'Number' && (control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCALCULATE || control.type == CONST_CTRL_TYPE_INPUTCOUNTER)){ if(canAddNode){ tmp[i] = control.id; i++; } }else if(controlType == CONST_VALUE_DATE && control.type == CONST_CTRL_TYPE_INPUTDATE){ if(canAddNode){ tmp[i] = control.id; i++; } } }); for(var j=i; j>0; j--){ calStack[calStackCount] = tmp[j-1]; calStackCount++; } if(addNode){ return true; }else{ return false; } } /*var findCalculate4UseCheckList = function(controls, ctrlId, isTable){ var tmp = []; var i = 0; if(isTable == true){ tmp = []; var ctrlInThisTable = false; _.each(controls, function(control) { if(ctrlId == control.id){ ctrlInThisTable = true; }else{ tmp[i] = control.id; i++; } }); if(ctrlInThisTable == true){ for(var j=i; j>0; j--){ calStack[calStackCount] = tmp[j-1]; calStackCount++; } } return; } _.each(controls, function(control) { if(ctrlId == control.id){ return false } if(calStackCount > 0){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP){ findCalculate4UseCheckList(control.children, ctrlId, false); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE){ findCalculate4UseCheckList(control.children, ctrlId, true); } }); }*/ calStack = []; calStackCount = 0; var end = findCalculateSumToNode(controls, controlType, endId, false); if(end){ for(var j=calStackCount; j>0; j--){ if(calStack[j-1] == conditionControlId){ return true; } } } /*calStack = []; calStackCount = 0; findCalculate4UseCheckList(controls, endId, false); if(calStackCount>0){ for(var j=calStackCount; j>0; j--){ if(calStack[j-1] == conditionControlId){ return true; } } }*/ if(conditionControlId && conditionControlId.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ return true; } return false; } var checkCalculateCountCtrlPosIsCorrected = function(controls, controlType, endId, conditionControlId) { calStack = []; calStackCount = 0; var findCalculateCountToNode = function(controls, controlType, endId, canAddNode){ var addNode = false; var tmp = []; var i = 0; var canAddNodeThisLevel = false; if(!canAddNode){ _.each(controls, function(control) { if(endId == control.id){ canAddNodeThisLevel = true; }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(isVersion8_1()){ _.each(control.children, function(controlGrd) { if(endId == controlGrd.id){ canAddNodeThisLevel = true; } if(canAddNodeThisLevel){ return false; } }); } } if(canAddNodeThisLevel){ return false; } }); }else{ canAddNodeThisLevel = true; } _.each(controls, function(control) { if(endId == control.id){ addNode = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findCalculateCountToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findCalculateCountToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findCalculateCountToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findCalculateCountToNode(control.children, controlType, endId, canAddNodeThisLevel); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ //addNode = findCalculateCountToNode(control.children, controlType, endId, canAddNodeThisLevel); if(isVersion8_1()){ _.each(control.children, function(controlGrd) { if(endId == controlGrd.id){ addNode = true; } if(addNode){ return false; } if(canAddNode){ tmp[i] = controlGrd.id; i++; } }); } }else if(control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ }else if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ }else if(control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ }else if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ }else if(control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ }else{ if(canAddNode){ tmp[i] = control.id; i++; } } }); for(var j=i; j>0; j--){ calStack[calStackCount] = tmp[j-1]; calStackCount++; } if(addNode){ return true; }else{ return false; } } var findCalculate4UseCheckList = function(controls, ctrlId, isTable){ var tmp = []; var i = 0; if(isTable == true){ tmp = []; var ctrlInThisTable = false; _.each(controls, function(control) { if(ctrlId == control.id){ ctrlInThisTable = true; }else{ tmp[i] = control.id; i++; } }); if(ctrlInThisTable == true){ for(var j=i; j>0; j--){ calStack[calStackCount] = tmp[j-1]; calStackCount++; } } return; } _.each(controls, function(control) { if(ctrlId == control.id){ return false } if(calStackCount > 0){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP){ findCalculate4UseCheckList(control.children, ctrlId, false); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE){ findCalculate4UseCheckList(control.children, ctrlId, true); } }); } calStack = []; calStackCount = 0; var end = findCalculateCountToNode(controls, controlType, endId, false); if(end){ for(var j=calStackCount; j>0; j--){ if(calStack[j-1] == conditionControlId){ return true; } } } calStack = []; calStackCount = 0; findCalculate4UseCheckList(controls, endId, false); if(calStackCount>0){ for(var j=calStackCount; j>0; j--){ if(calStack[j-1] == conditionControlId){ return true; } } } if(conditionControlId && conditionControlId.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ return true; } return false; } var checkLookupConditionAnsByIdCorrectPos = function(controls, controlId, conditionControlId) { var i =0; var conditionStack = []; var conditionStackCount = 0; var findConditionFieldToNode = function(controls, endId, level, isGridCtrl){ var addNode = false; var tmp = []; var i = 0; var sameLevel = false; _.each(controls, function(control) { if(endId == control.id){ addNode = true; sameLevel = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findConditionFieldToNode(control.children, endId, level + 1); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findConditionFieldToNode(control.children, endId, level + 1); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findConditionFieldToNode(control.children, endId, level + 1); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findConditionFieldToNode(control.children, endId, level + 1); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ addNode = findConditionFieldToNode(control.children, endId, level + 1, true); }else if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ tmp[i] = control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ tmp[i] = control.id; i++; }else if((control.type == 'inputFacingTable' || control.type == CONST_CTRL_TYPE_INPUT_TEXT || control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTNUMBERING || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTSELECTONE || control.type == CONST_CTRL_TYPE_INPUTCOUNTER || control.type == CONST_CTRL_TYPE_INPUTCALCULATE) && isVersion2_12()){ tmp[i] = control.id; i++; } }); if(isGridCtrl){ sameLevel = true; } if(addNode || isGridCtrl){ if(level == 0 || sameLevel){ for(var j=i; j>0; j--){ conditionStack[conditionStackCount] = tmp[j-1]; conditionStackCount++; } } return addNode; }else{ return false; } } var end = findConditionFieldToNode(controls, controlId, 0); if(end){ for(var j=conditionStackCount; j>0; j--){ if(conditionStack[j-1] == conditionControlId){ return true; } } } return false; } var checkControlSkipByIdCorrectPos = function(controls, controlId, skipToControlId) { var ret = false; var start = false; var skip = false; var endOfForm = true; _.each(controls, function(control) { if(skip){ return false; } if(!start){ if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ if(checkControlSkipByIdCorrectPos(control.children, controlId, skipToControlId)){ ret = true; skip = true; start = true; endOfForm = false; } }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(isVersion(VERSION_SKIP_IN_GRID)){ _.each(control.children, function(controlInGrid){ if(!skip){ if(start == false && controlInGrid.id == controlId){ start = true; }else{ if (start){ if(controlInGrid.type == 'inputPageBreak' || controlInGrid.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ }else{ if(controlInGrid.id == skipToControlId){ skip = true; ret = true return false; } } } } } }) }else{ if(checkControlSkipByIdCorrectPos(control.children, controlId, skipToControlId)){ ret = true; skip = true; start = true; endOfForm = false; } } } } if(!skip){ if(start == false && control.id == controlId){ start = true; }else{ if (start){ if(control.type == 'inputPageBreak' || control.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ }else{ if(control.id == skipToControlId){ skip = true; ret = true return false; } if(control.type == CONST_CTRL_TYPE_CTRLGRID){ _.each(control.children, function(control1){ if(skip){ return false; } if(control1.id == skipToControlId){ skip = true; ret = true return false; } }) } } } } } }); return ret; }; var checkControlInPOD = function(controls, ctrlPODId, controlInPODId) { var ret = false; _.each(controls, function(control) { if(ret){ return false; } if(ctrlPODId == control.id){ _.each(control.children, function(controlInPOD) { if(ret){ return false; } if(controlInPOD.id == controlInPODId){ ret = true; return false; } }); return false; } }); return ret; }; var checkLUDestinationByIdCorrectPos = function(controls, isRetrieveField, controlId, destinationControlId) { var lookupFillFieldStack = []; var findLookupFillField = function(controls, isRetrieveField, startControlId, level, isStart_forgrid, isStart_fortable, isStart_forgroup){ var start = false; if(isStart_forgrid || isStart_fortable || isStart_forgroup){ start = true; } if(isRetrieveField) { start = true; } var skip = false; var endOfForm = true; _.each(controls, function(control) { if(skip){ return false; } if(!start){ if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1)){ //skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1)){ //skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLPOD){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1)){ //skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1)){ //skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1)){ //skip = false; start = true; endOfForm = false; } } }else{ if(control.type == CONST_CTRL_TYPE_GROUP){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1, false, false, true)){ //skip = true; start = true; endOfForm = false; } }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1, true)){ //skip = false; start = true; endOfForm = false; } }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE){ if(findLookupFillField(control.children, isRetrieveField, startControlId, level + 1, false, true)){ //skip = false; start = true; endOfForm = false; } } } if(!skip){ if(start == false && control.id == startControlId){ start = true; }else{ if (start && control.type != CONST_CTRL_TYPE_GROUP && 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_CTRLGRID){ if (control.type == 'branch' || control.type == 'inputPageBreak' || control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY //|| control.type == CONST_CTRL_TYPE_INPUTNUMBERING //|| control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == 'inputInstruction' || control.type == CONST_CTRL_TYPE_INPUTCALCULATE // || control.type == CONST_CTRL_TYPE_INPUTLOOKUP // CO-3487 Add ability to use lookup control as destination field || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type == 'inputFacingTable' || control.type == 'inputLookupMulti' || control.type == CONST_CTRL_TYPE_INPUTAPPROVAL || control.type == 'inputSaveAndSend' || control.type == mdi_kind_inputImage || control.type == mdi_kind_inputAudio || control.type == mdi_kind_inputVideo || control.type == CONST_CTRL_TYPE_INPUTMEDIA || control.type == mdi_kind_inputSketch || control.type == mdi_kind_inputSignature || control.type == 'inputDraw' || control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ }else{ var addOpt = true; if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.imgAction != CONST_ACTION_LAUNCH_GOOGLE_MAP && control.imgAction != CONST_ACTION_LAUNCH_GARMIN_DIRECTIONS){ addOpt = false; } if(control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ addOpt = false; } if(addOpt){ lookupFillFieldStack[lookupFillFieldStack.length] = '' + control.id; } } } } } }); return start; }; lookupFillFieldStack = []; findLookupFillField(controls, isRetrieveField, controlId, 0); if(lookupFillFieldStack.indexOf('' + destinationControlId)>=0){ return true; } return false; }; var checkParseDestinationByIdCorrectPos = function(controls, controlId, destinationControlId){ return checkLUDestinationByIdCorrectPos(controls, false, controlId, destinationControlId); }; var checkTransactionResultParamByIdCorrectPos = function(controls, controlId, destinationControlId){ var transactionResultFieldStack = []; var findtransactionResultField = function(controls, startControlId, level, isStart_forgrid){ var start = false; if(isStart_forgrid){ start = true; } var skip = false; var endOfForm = true; _.each(controls, function(control) { if(skip){ return false; } if(!start){ if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ if(findtransactionResultField(control.children, startControlId, level + 1)){ skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ if(findtransactionResultField(control.children, startControlId, level + 1)){ skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLPOD){ if(findtransactionResultField(control.children, startControlId, level + 1)){ skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ if(findtransactionResultField(control.children, startControlId, level + 1)){ skip = true; start = true; endOfForm = false; } } if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(findtransactionResultField(control.children, startControlId, level + 1)){ skip = false; start = true; endOfForm = false; } } }else{ if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(findtransactionResultField(control.children, startControlId, level + 1, true)){ skip = false; start = true; endOfForm = false; } } } if(!skip){ if(start == false && control.id == startControlId){ start = true; }else{ if (start && control.type != CONST_CTRL_TYPE_GROUP && 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_CTRLGRID){ if (control.type == 'branch' || control.type == 'inputPageBreak' || control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY //|| control.type == CONST_CTRL_TYPE_INPUTNUMBERING //|| control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == 'inputInstruction' || control.type == CONST_CTRL_TYPE_INPUTCALCULATE || control.type == 'inputFacingTable' || control.type == 'inputLookupMulti' || control.type == CONST_CTRL_TYPE_INPUTAPPROVAL || control.type == 'inputSaveAndSend' || control.type == mdi_kind_inputImage || control.type == mdi_kind_inputAudio || control.type == mdi_kind_inputVideo || control.type == CONST_CTRL_TYPE_INPUTMEDIA || control.type == mdi_kind_inputSketch || control.type == mdi_kind_inputSignature || control.type == 'inputDraw' || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTPAYMENT || control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ }else{ transactionResultFieldStack[transactionResultFieldStack.length] = '' + control.id; } } } } }); return start; }; transactionResultFieldStack = []; findtransactionResultField(controls, controlId, 0); if(transactionResultFieldStack.indexOf('' + destinationControlId)>=0){ return true; } return false; }; var checkTransactionParamByIdCorrectPos = function(controls, controlId, destinationControlId, type) { transStack = []; var findTransCtrlToNode = function(controls, selectedCtrlId, type, isGrid){ var addNode = false; var tmp = []; var i = 0; _.each(controls, function(control) { if(selectedCtrlId == control.id){ addNode = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findTransCtrlToNode(control.children, selectedCtrlId, type); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findTransCtrlToNode(control.children, selectedCtrlId, type); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findTransCtrlToNode(control.children, selectedCtrlId, type); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findTransCtrlToNode(control.children, selectedCtrlId, type); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ addNode = findTransCtrlToNode(control.children, selectedCtrlId, type, true); }else { if(type == 'Amount'){ if(((control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && control.kind == 'Number') || (control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.kind != 'String' && control.kind != CONST_VALUE_DATE) || control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ tmp[i] = '' + control.id; i++; } }else if(type == 'Subtotal'){ if(((control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && control.kind == 'Number') || control.type == CONST_CTRL_TYPE_INPUTCALCULATE || control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ tmp[i] = '' + control.id; i++; } }else if(type == 'Tax'){ if(((control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && control.kind == 'Number') || control.type == CONST_CTRL_TYPE_INPUTCALCULATE || control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ tmp[i] = '' + control.id; i++; } }else if(type == 'Description'){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = '' + control.id; i++; } }else if(type == 'Memo'){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = '' + control.id; i++; } }else if(type == 'Name'){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type == CONST_CTRL_TYPE_INPUT_TEXT){ tmp[i] = '' + control.id; i++; } }else if(type == 'Phone'){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type == CONST_CTRL_TYPE_INPUT_TEXT || (control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.kind != CONST_CTRL_KIND_DATE) || (control.type == CONST_CTRL_TYPE_INPUT_NUMERIC && control.kind != 'Decimal')){ tmp[i] = '' + control.id; i++; } }else if(type == 'ReceiptEmail'){ if(((control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && control.kind != 'Number') || control.type == CONST_CTRL_TYPE_INPUT_TEXT || control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ tmp[i] = '' + control.id; i++; } }else if(type == 'Email'){ if(((control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && control.kind != 'Number') || control.type == CONST_CTRL_TYPE_INPUT_TEXT || control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ tmp[i] = '' + control.id; i++; } }else if(type == 'Invoice'){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type == CONST_CTRL_TYPE_INPUT_TEXT || control.type == CONST_CTRL_TYPE_INPUTCALCULATE || control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ tmp[i] = '' + control.id; i++; } } } }); if(addNode || isGrid){ for(var j=i; j>0; j--){ transStack[transStack.length] = tmp[j-1]; } } return addNode; } transStack = []; findTransCtrlToNode(controls, controlId, type); if(transStack.indexOf('' + destinationControlId)>=0){ return true; } return false; }; /** * In case of controlId2 not in group and checkControlByIdCorrectPos -> false */ var checkControlByIdCorrectPos2 = function(controls, controlId, controlId2, isRoot) { var ret = null; _.each(controls, function(control){ if(ret != null){ return false; } if(control.id == controlId2){ ret = false return false; } if(control.id == controlId && isRoot){ ret = true; return false; }else if(control.id == controlId){ if(hasControl2(controls, controlId2)){ ret = true; return false; }else{ ret = false return false; } }else{ if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV) { var retChild = checkControlByIdCorrectPos2(control.children, controlId, controlId2, false); if(retChild != null && retChild == true){ ret = true; } }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ _.each(control.children, function(control1){ if(ret != null){ return false; } if(control1.id == controlId2){ ret = false return false; } if(control1.id == controlId && isRoot){ ret = true; return false; }else if(control1.id == controlId){ if(hasControl2(controls, controlId2)){ ret = true; return false; }else{ ret = false return false; } }else{ } }); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ _.each(control.children, function(control1){ if(ret != null){ return false; } if(control1.id == controlId2){ ret = false return false; } if(control1.id == controlId && isRoot){ ret = true; return false; }else if(control1.id == controlId){ if(hasControl2(controls, controlId2)){ ret = true; return false; }else{ ret = false return false; } }else{ } }); } } }); if(ret == null && isRoot){ ret = false; } return ret; }; var checkAutoStampTriggerQuesIsCorrectPos = function(controls, autoStampControlId, triggerCtrlId, isPageTrigger) { if(1 == 1) return true; var stack = []; var stackPage = []; var stackCount = 0; var stackPageCount = 0; var findNode = function(controls, selectedCtrlId, isEndIfExist, isIgnoreLabel){ var addNode = false; var tmp = []; var i = 0; var tmpPage = []; var iPage = 0; _.each(controls, function(control) { if(selectedCtrlId == control.id){ if(isEndIfExist){ addNode = true; } return false; } if(isEndIfExist && addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findNode(control.children, selectedCtrlId, isEndIfExist, isIgnoreLabel); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findNode(control.children, selectedCtrlId, isEndIfExist); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findNode(control.children, selectedCtrlId, isEndIfExist); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findNode(control.children, selectedCtrlId, isEndIfExist); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ //addNode = findNode(control.children, selectedCtrlId, isEndIfExist); _.each(control.children, function(controlGrd) { if(selectedCtrlId == controlGrd.id){ if(isEndIfExist){ addNode = true; } return false; } if(isEndIfExist && addNode){ return false; } if(isIgnoreLabel && controlGrd.type == 'inputLabel'){ return; } tmp[i] = '' + controlGrd.id; i++; }); }else if(control.type == 'inputPageBreak'){ var pageName = iPage + 1; if(control.label.eng !== undefined && jQuery.trim(control.label.eng) !== ''){ pageName = pageName + ' (' + control.label.eng + ')'; } tmpPage[iPage] = '' + control.id; iPage++; }else{ if(isIgnoreLabel && control.type == 'inputLabel'){ }else{ tmp[i] = '' + control.id; i++; } } }); if(isEndIfExist){ if(addNode){ for(var j=i; j>0; j--){ stack[stackCount] = tmp[j-1]; stackCount++; } for(var j=iPage; j>0; j--){ stackPage[stackPageCount] = tmpPage[j-1]; stackPageCount++; } return true; }else{ return false; } }else{ for(var j=i; j>0; j--){ stack[stackCount] = tmp[j-1]; stackCount++; } for(var j=iPage; j>0; j--){ stackPage[stackPageCount] = tmpPage[j-1]; stackPageCount++; } return true; } } stack = []; stackPage = []; stackCount = 0; stackPageCount = 0; var end = findNode(controls, autoStampControlId, true, true); if(isPageTrigger){ if(stackPage.indexOf('' + triggerCtrlId)>=0){ return true; } return false; }else{ if(stack.indexOf('' + triggerCtrlId)>=0){ return true; } return false; } }; var checkOnClickDesPosIsCorrected = function(controls, actionProperties, desId) { var stack = []; var stackCount = 0; var findNodeForOnclick = function(controls, selectedCtrlId, path, parentPath, acceptCtrlList){ var tmp = []; var i = 0; if(!path){ path= '/data'; } _.each(controls, function(control) { if(selectedCtrlId == control.id){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP){ findNodeForOnclick(control.children, selectedCtrlId, path + '/' + control.name, parentPath, acceptCtrlList); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ findNodeForOnclick(control.children, selectedCtrlId, path + '/' + control.name, parentPath, acceptCtrlList); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ findNodeForOnclick(control.children, selectedCtrlId, path + '/' + control.name, parentPath, acceptCtrlList); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ findNodeForOnclick(control.children, selectedCtrlId, path + '/' + control.name, parentPath, acceptCtrlList); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ _.each(control.children, function(controlGrd) { if(selectedCtrlId == controlGrd.id){ return false; } if(acceptCtrlList && !acceptCtrlList[controlGrd.type]){ return; } if(parentPath == path){ tmp[i] = '' + control.id; i++; } }); }else{ if(acceptCtrlList && !acceptCtrlList[control.type]){ }else{ if(parentPath == path){ tmp[i] = '' + control.id; i++; } } } }); for(var j=i; j>0; j--){ stack[stackCount] = tmp[j-1]; stackCount++; } return true; } var selectedCtrlId = actionProperties.id; var path = '/data'; var itemPath = getControlXPath(controls, "/data/", selectedCtrlId); var parentPath = ''; var isInsideTheGrid = false; if($('.controlErrorMessage.ctrlId_' + selectedCtrlId).parents('.control.ctrlButtonGrid').length > 0 || $('.controlErrorMessage.ctrlId_' + selectedCtrlId).parents('.control.ctrlGrid').length > 0){ isInsideTheGrid = true; } if(isInsideTheGrid){ parentPath = '/data'; }else{ parentPath = itemPath.substr(0, itemPath.lastIndexOf("/")); } stack = []; stackCount = 0; findNodeForOnclick(controls, selectedCtrlId, path, parentPath, {inputText:true}); if(stack.indexOf('' + desId) >= 0){ return true; } return false; } var hasControl2 = function(controls, controlId2) { var ret = null; _.each(controls, function(control){ if(ret != null){ return false; } if(control.id == controlId2){ ret = true return false; } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID) { var retChild = hasControl2(control.children, controlId2); if(retChild != null && retChild == true){ ret = true; } } }); if(ret == null){ ret = false; } return ret; }; var checkRepValSourcePosIsCorrected = function(controls, selectedCtrlId, inputSourceId) { repeatSourceStack = []; var findRepeatSourceCtrlToNode = function(controls, selectedCtrlId, isGrid){ var addNode = false; var tmp = []; var i = 0; _.each(controls, function(control) { if(selectedCtrlId == control.id){ addNode = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findRepeatSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findRepeatSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findRepeatSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findRepeatSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ addNode = findRepeatSourceCtrlToNode(control.children, selectedCtrlId, true); }else { if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ tmp[i] = '' + control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(control.kind != undefined && control.kind == 'Number'){ tmp[i] = '' + control.id; i++; } } } }); if(addNode || isGrid){ for(var j=i; j>0; j--){ repeatSourceStack[repeatSourceStack.length] = tmp[j-1]; } } return addNode; } findRepeatSourceCtrlToNode(controls, selectedCtrlId); if(repeatSourceStack.indexOf('' + inputSourceId) >= 0){ return true; } return false; } var checkTrendsSourcePosIsCorrected = function(controls, selectedCtrlId, inputSourceId, isGetTrendsDate, ignoreCtlID, isForLastEnteredValue) { trendsSourceStack = []; var findTrendsSourceCtrlToNode = function(controls, selectedCtrlId, isGetTrendsDate, isGrid, ignoreCtlID, isForLastEnteredValue){ var addNode = false; var tmp = []; var i = 0; _.each(controls, function(control) { if(ignoreCtlID && ignoreCtlID == control.id){ return true; } if(selectedCtrlId == control.id){ addNode = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ if(!isGetTrendsDate){ addNode = findTrendsSourceCtrlToNode(control.children, selectedCtrlId, isGetTrendsDate, ignoreCtlID, isForLastEnteredValue); } }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ if(!isGetTrendsDate){ addNode = findTrendsSourceCtrlToNode(control.children, selectedCtrlId, isGetTrendsDate, ignoreCtlID, isForLastEnteredValue); } }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ if(!isGetTrendsDate){ addNode = findTrendsSourceCtrlToNode(control.children, selectedCtrlId, isGetTrendsDate, ignoreCtlID, isForLastEnteredValue); } }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ if(!isGetTrendsDate){ addNode = findTrendsSourceCtrlToNode(control.children, selectedCtrlId, isGetTrendsDate, ignoreCtlID, isForLastEnteredValue); } }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ addNode = findTrendsSourceCtrlToNode(control.children, selectedCtrlId, isGetTrendsDate, true, ignoreCtlID, isForLastEnteredValue); }else { if(isGetTrendsDate){ if(control.type == CONST_CTRL_TYPE_INPUTDATE){ tmp[i] = '' + control.id; i++; } }else if(isForLastEnteredValue){ switch(control.type){ case CONST_CTRL_TYPE_INPUT_NUMERIC: case CONST_CTRL_TYPE_INPUTCOUNTER: case CONST_CTRL_TYPE_INPUTTRENDS: tmp[i] = $('') .attr(CONST_VALUE, control.id) .text(control.name); i++; break; default: break; } }else{ switch(control.type){ case "inputPageBreak": case "inputLabel": case CONST_CTRL_TYPE_INPUTSCORESUMMARY: case CONST_CTRL_TYPE_INPUTMEDIA: case "inputDraw": case mdi_kind_inputImage: case mdi_kind_inputAudio: case mdi_kind_inputVideo: case mdi_kind_inputSketch: case mdi_kind_inputSignature: case CONST_CTRL_TYPE_CTRLTABLE: case CONST_CTRL_TYPE_CTRLSCHEDULE: case CONST_CTRL_TYPE_CTRLPOD: case CONST_CTRL_TYPE_CTRLSCORETABLE: case CONST_CTRL_TYPE_GROUP: case CONST_CTRL_TYPE_CTRLGRID: case CONST_CTRL_TYPE_INPUTAPPROVAL: case CONST_CTRL_TYPE_INPUTACTION: case CONST_CTRL_TYPE_INPUTPAYMENT: case CONST_CTRL_TYPE_INPUTNEWPAYMENT: case CONST_CTRL_TYPE_INPUTLOCATION: case CONST_CTRL_TYPE_IMAGE_VIEWER: break; default : tmp[i] = '' + control.id; i++; break; } } } }); if(selectedCtrlId == CONST_JUMP_EOF_VAL){ addNode = true; } if(addNode || isGrid){ for(var j=i; j>0; j--){ trendsSourceStack[trendsSourceStack.length] = tmp[j-1]; } } return addNode; } findTrendsSourceCtrlToNode(controls, selectedCtrlId, isGetTrendsDate, ignoreCtlID, isForLastEnteredValue); if(trendsSourceStack.indexOf('' + inputSourceId) >= 0){ return true; } return false; } var checkRowValSourcePosIsCorrected = function(controls, selectedCtrlId, inputSourceId) { rowSourceStack = []; var findRowSourceCtrlToNode = function(controls, selectedCtrlId, isGrid){ var addNode = false; var tmp = []; var i = 0; _.each(controls, function(control) { if(selectedCtrlId == control.id){ addNode = true; } if(addNode){ return false; } if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ addNode = findRowSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ addNode = findRowSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ addNode = findRowSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ addNode = findRowSourceCtrlToNode(control.children, selectedCtrlId); }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ addNode = findRowSourceCtrlToNode(control.children, selectedCtrlId, true); }else { if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ tmp[i] = '' + control.id; i++; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(control.kind != undefined && control.kind == 'Number'){ tmp[i] = '' + control.id; i++; } } } }); if(addNode || isGrid){ for(var j=i; j>0; j--){ rowSourceStack[rowSourceStack.length] = tmp[j-1]; } } return addNode; } findRowSourceCtrlToNode(controls, selectedCtrlId); if(rowSourceStack.indexOf('' + inputSourceId) >= 0){ return true; } return false; } var makeProPayPath = function(root, control){ var paramValue = 'amount='; var itemPath = ''; if((control.imgActionParamPP_Amount || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamPP_Amount, 'Amount')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamPP_Amount); } } paramValue += itemPath; paramValue += '¤cy=' + control.imgActionParamPP_Currency; if(control.paymentType == CONST_PAYMENT_TYPE_AUTOMATED){ paramValue += '&callback=http%3A//www.imobile3.com'; } switch(control.paymentType){ case CONST_PAYMENT_TYPE_SQUARE: break; case CONST_PAYMENT_MIPOS: if(control.imgActionParamMP_Tax && jQuery.trim(control.imgActionParamMP_Tax) !== ''){ paramValue += '&tax='; itemPath = ''; if((control.imgActionParamMP_Tax || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamMP_Tax, 'Tax')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamMP_Tax); } } paramValue += itemPath; } if(control.imgActionParamMP_IsTaxPercentage == true){ paramValue += '&taxPercentage=true'; } if(control.imgActionParamMP_Description && jQuery.trim(control.imgActionParamMP_Description) !== ''){ paramValue += '&description='; itemPath = ''; if((control.imgActionParamMP_Description || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamMP_Description, 'Description')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamMP_Description); } } paramValue += itemPath; } break; default: if(control.imgActionParamPP_Invoice && jQuery.trim(control.imgActionParamPP_Invoice) !== ''){ paramValue += '&invoice='; itemPath = ''; if((control.imgActionParamPP_Invoice || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamPP_Invoice, 'Invoice')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamPP_Invoice); } } paramValue += itemPath; } if(control.imgActionParamPP_Email && jQuery.trim(control.imgActionParamPP_Email) !== ''){ paramValue += '&email='; itemPath = ''; if((control.imgActionParamPP_Email || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamPP_Email, 'Email')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamPP_Email); } } paramValue += itemPath; } } return paramValue; } var getControlXPath = function(controls, xpath, controlId) { var retPath = ""; _.each(controls, function(control){ if(control.id == controlId){ retPath = xpath + control.name; return false; }else{ if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID) { var tmp = getControlXPath(control.children, xpath + control.name + '/', controlId); if(tmp != ""){ retPath = tmp; return false; } } } }); return retPath; }; var addTranslation = function(obj, itextPath, translations) { _.each(translations.children, function(translation) { translation.children.push({ name: 'text', attrs: { 'id': itextPath }, children: [ { name: CONST_VALUE, val: obj[translation.attrs.lang]==undefined?'':'' } ] }); }) }; ;(function($) { // gets just the pure data for any one control var getDataRepresentation = function($control) { var data = {}; _.each($control.data('odkControl-properties'), function(property, name) { if(property.type == 'emailReportDefault' && name == 'defaultValue'){ if(!property.isFaxWidget){ data[name] = property.value + '$$' + property.mailcontent; if(isVersion(VERSION_EMAIL_REPORT_NEW_DEFAULT)){ data[name+'_selectedCtrl'] = property.selectedCtrl; } if(data[name] == '$$'){ data[name] = ''; } }else{ data[name] = property.value; if(isVersion(VERSION_EMAIL_REPORT_NEW_DEFAULT)){ data[name+'_selectedCtrl'] = property.selectedCtrl; } } // Custom process for Email Report Setting Caption }else if(property.type == 'emailReportDefault' && name == 'reportEmail'){ data[name] = property.value + '$$' + property.mailcontent; if(data[name] == '$$'){ data[name] = ''; } }else if(name == 'reportSettingBuildForm' && property.type == 'report_setting_buildform'){ data[name] = property.value; // Put the caption Report Settings if (property.reportSettingBuildFormCaption !== undefined) { data['reportSettingBuildFormCaption'] = property.reportSettingBuildFormCaption; } // Apply changes : Email Report Changes REVIEW 02-17-15 MJ.PPTX, slide 08 // Put the caption Report Settings input value (if exists) if (property.reportSettingBuildFormCaptionInput !== undefined) { data['reportSettingBuildFormCaptionInput'] = property.reportSettingBuildFormCaptionInput; } }else{ if(property.value == undefined){ if(name == 'showAsTextMobile'){ property.value = false; }else if(name == 'mobileTextAlign'){ property.value = 'Left'; } } data[name] = property.value; if(property.iconColor != undefined){ // CO-4050 data['iconColor'] = property.iconColor; } } }); if(!data.useCurrentcySymbol && data.currency){ data.currency = 'None'; } data.type = $control.data('odkControl-type'); if (data.type == CONST_CTRL_TYPE_INPUTLOOKUP){ if(data.isRetrieve){ data.lookupfield = data.lookupfield4R; if(data.lookupConditionFields4R != undefined){ data.lookupConditionFields = data.lookupConditionFields4R.slice(); }else{ data.lookupConditionFields = undefined; } } } if(isVersion(VERSION_NEW_TOOL_LAYOUT)){ if(data){ if(data.isShowRelevanceCondition == false){ data.relevanceconds = []; } if(data.isShowSkipCondition == false){ data.skipconds = []; } } } return data; }; // gets the pure data tree for any workspace DOM node var extractRecurse = function($root, rootType, gridCols, gridEmptyCol, isScheduleWidget, isMessageWidget) { if(!rootType || rootType == ''){ resetUniqueIdForEmptyCell(); } var result = []; var isNewRow_Grid = true; var appendReplyFlag = false; $root.children('.control').each(function() { var $this = $(this); if(gridEmptyCol && isNewRow_Grid && ((result.length % gridCols) % gridEmptyCol) == (gridEmptyCol - 1)){ result.push(makeGridEmptyCell()); isNewRow_Grid = false; if((result.length % gridCols) == 0){ isNewRow_Grid = true; } } var data = getDataRepresentation($this); var _oriType = rootType; if(isScheduleWidget){ data.isScheduleWidget = true; } if(isMessageWidget){ data.isMessageWidget = true; } try{ // Reset gray caption in case of free from grid type if(rootType.indexOf('-') > 0){ var _gridType = rootType.split('-')[1]; _oriType = rootType.split('-')[0]; if(_gridType != '' && data.grayCaption != undefined){ data.grayCaption = false; } } } catch(e){} var dataExtSignatureForPOD = undefined; if(_oriType && _oriType != ''){ data.parentCtrlType = _oriType; if(isIgnoreRelevance(_oriType) && data.isShowRelevanceCondition == true){ data.isShowRelevanceCondition = false; } if(isIgnoreSkip(_oriType)){ data.isShowSkipCondition = false; } }else{ data.parentCtrlType = ''; } if (data.type == CONST_CTRL_TYPE_GROUP || (data.type == 'ctrlBreakPointData') || data.type == CONST_CTRL_TYPE_CTRLTABLE || data.type == CONST_CTRL_TYPE_CTRLSCHEDULE || data.type == CONST_CTRL_TYPE_CTRLPOD || data.type == CONST_CTRL_TYPE_CTRLINV || data.type == CONST_CTRL_TYPE_CTRLSCORETABLE || data.type == CONST_CTRL_TYPE_CTRLGRID) { var _suffix = ''; if(data.type == CONST_CTRL_TYPE_CTRLGRID){ _suffix = '-' + data.gridType; } if(data.type == CONST_CTRL_TYPE_CTRLGRID && data.isMakeEmptyColumn){ data.children = extractRecurse($this.children('.workspaceInnerWrapper').children('.workspaceInner'), data.type + _suffix, data.loop, data.emptyCol); }else{ data.children = extractRecurse($this.children('.workspaceInnerWrapper').children('.workspaceInner'), data.type + _suffix, undefined, undefined, data.isScheduleWidget, data.isMessageWidget); } if(data.type == CONST_CTRL_TYPE_CTRLPOD){ appendExternalForPOD(data.children, data); dataExtSignatureForPOD = createExternalSignatureForPOD(data); } if(data.type == CONST_CTRL_TYPE_CTRLINV){ appendExternalForINV(data.children, data); } if(data.children['replyToSender']){ if(!appendReplyFlag){ if(_oriType != ''){ result['replyToSender'] = []; appendReplyToSenderFlag(result['replyToSender']); appendReplyFlag = true; }else{ appendReplyToSenderFlag(result); appendReplyFlag = true; } } delete data.children['replyToSender']; } } else if (data.type == 'branch') { data.branches = []; $this.find('.workspaceInner').each(function() { var branch = {}; branch.conditions = $(this).data('odkmaker-branchConditions'); branch.children = extractRecurse($(this), data.type); data.branches.push(branch); }); } else if ((data.type == CONST_CTRL_TYPE_INPUTFORWARD || data.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD) && data.replyToSender && isVersion(VERSION_REPLY_TO_SENDER)) { if(!appendReplyFlag){ if(_oriType != ''){ result['replyToSender'] = []; appendReplyToSenderFlag(result['replyToSender']); appendReplyFlag = true; }else{ appendReplyToSenderFlag(result); appendReplyFlag = true; } } } result.push(data); if(dataExtSignatureForPOD){ data.signatureCtrlName = dataExtSignatureForPOD.name; result.push(dataExtSignatureForPOD); } if(!isNewRow_Grid && (result.length % gridCols) == 0){ isNewRow_Grid = true; } }); return result; }; var getUniqueIdForEmptyCell = function(){ currentEmptyCellId = currentEmptyCellId + 1; return currentEmptyCellId; } var resetUniqueIdForEmptyCell = function(){ currentEmptyCellId = 0; } var makeGridEmptyCell = function(){ var properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties['inputLabel']); properties.id.value = getUniqueIdForEmptyCell(); properties.name.value = 'AE__' + properties.id.value; var $ctrl = $('
    ').data('odkControl-properties', properties); dataTmp = getDataRepresentation($ctrl); dataTmp.type = 'inputLabel'; dataTmp.parentCtrlType = CONST_CTRL_TYPE_CTRLGRID; dataTmp.label.eng = ''; return dataTmp; } odkmaker.data.extract = function() { return { title: $('.builder:visible .header #renameFormField').val(), controls: extractRecurse($('.workspace:visible'), '') }; }; var appendReplyToSenderFlag = function(root){ //replay to sender flag var properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUT_TEXT]); properties.id.value = REPLY_TO_SENDER_FLAG_COL_ID; properties.name.value = '__reply_flag'; var $ctrl = $('
    ').data('odkControl-properties', properties); var dataTmp = getDataRepresentation($ctrl); dataTmp.type = CONST_CTRL_TYPE_INPUT_TEXT; dataTmp.textParse = false; dataTmp.label.eng = 'Reply flag'; dataTmp.hideViewEdit = true; dataTmp.hideDispatchNew = true; dataTmp.hideDispatchEdit = true; dataTmp.hideFillAndSend = true; dataTmp.hideInMobile = true; dataTmp.hideWebAppGrp = true; dataTmp.hideViewNew = true; dataTmp.hideDispatchToEmail = true; dataTmp.hideFillAndSendEdit = true; dataTmp.hideWebApp = true; dataTmp.hideEmbeddedForm = true; dataTmp.hideFormLinks = true; dataTmp.hideInPDF = true; dataTmp.hidePdfWeb = true; dataTmp.hideInWeb = true; dataTmp.hideForwarded = true; root.push(dataTmp); } var appendExternalForPOD = function(children, data){ //status column var properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUT_NUMERIC]); properties.id.value = POD_STATUS_COL_ID + data.id; properties.name.value = 'S' + data.id + '__Status'; var $ctrl = $('
    ').data('odkControl-properties', properties); var dataTmp = getDataRepresentation($ctrl); dataTmp.type = CONST_CTRL_TYPE_INPUT_NUMERIC; dataTmp.parentCtrlType = CONST_CTRL_TYPE_CTRLPOD; dataTmp.label.eng = 'Status'; dataTmp.hideViewEdit = true; dataTmp.hideDispatchNew = true; dataTmp.hideDispatchEdit = true; dataTmp.hideFillAndSend = true; dataTmp.hideInMobile = true; dataTmp.hideWebAppGrp = true; dataTmp.hideViewNew = true; dataTmp.hideDispatchToEmail = true; dataTmp.hideFillAndSendEdit = true; dataTmp.hideWebApp = true; dataTmp.hideEmbeddedForm = true; dataTmp.hideFormLinks = true; dataTmp.hideInPDF = true; dataTmp.hidePdfWeb = true; dataTmp.hideInWeb = true; children.push(dataTmp); //auto id column var properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUT_NUMERIC]); properties.id.value = POD_AUTO_ID_COL_ID + data.id; properties.name.value = 'S' + data.id + '__AutoID'; var $ctrl = $('
    ').data('odkControl-properties', properties); var dataTmp = getDataRepresentation($ctrl); dataTmp.type = CONST_CTRL_TYPE_INPUT_NUMERIC; dataTmp.parentCtrlType = CONST_CTRL_TYPE_CTRLPOD; dataTmp.label.eng = 'Auto Id'; dataTmp.hideViewEdit = true; dataTmp.hideDispatchNew = true; dataTmp.hideDispatchEdit = true; dataTmp.hideFillAndSend = true; dataTmp.hideInMobile = true; dataTmp.hideWebAppGrp = true; dataTmp.hideViewNew = true; dataTmp.hideDispatchToEmail = true; dataTmp.hideFillAndSendEdit = true; dataTmp.hideWebApp = true; dataTmp.hideEmbeddedForm = true; dataTmp.hideFormLinks = true; dataTmp.hideInPDF = true; dataTmp.hidePdfWeb = true; dataTmp.hideInWeb = true; children.push(dataTmp); } var appendExternalForINV = function(children, data){ } var createExternalSignatureForPOD = function(data){ if(!data.isRequiresSignature){ return; } if(!data.showSignatureCustomer && !data.showSignatureCarrier){ return; } //append layout grid var properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_CTRLGRID]); properties.id.value = POD_SIGN_GRID + data.id; properties.name.value = 'S' + data.id + '__Grid_Signature'; var $ctrl = $('
    ').data('odkControl-properties', properties); var gridData = getDataRepresentation($ctrl); gridData.type = CONST_CTRL_TYPE_CTRLGRID; gridData.parentCtrlType = CONST_CTRL_TYPE_CTRLPOD; gridData.label.eng = ''; gridData.podCtrlName = data.name; gridData.children = []; if(data.showSignatureCustomer){ //customer signature column var properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUTSIGNATURE]); removeUnsupportProperty(properties, CONST_CTRL_TYPE_INPUTSIGNATURE); removeUnuseVersion(properties); properties.id.value = POD_SIGN_CUSTOMER + data.id; properties.name.value = 'S' + data.id + '__Customer_Signature'; $ctrl = $('
    ').data('odkControl-properties', properties); var dataTmp = getDataRepresentation($ctrl); dataTmp.type = CONST_CTRL_TYPE_INPUTSIGNATURE; dataTmp.parentCtrlType = CONST_CTRL_TYPE_CTRLGRID; dataTmp.label.eng = 'Customer signature'; dataTmp.isAllowEditOption = false; if(data.signatureAllowEdit){ dataTmp.isAllowEditOptionDataView = true; } gridData.children.push(dataTmp); //customer signature time column properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUTDATE]); properties.id.value = POD_SIGN_CUSTOMER_TIME + data.id; properties.name.value = 'S' + data.id + '__Customer_Signature_DateTime'; $ctrl = $('
    ').data('odkControl-properties', properties); dataTmp = getDataRepresentation($ctrl); dataTmp.type = CONST_CTRL_TYPE_INPUTDATE; dataTmp.parentCtrlType = CONST_CTRL_TYPE_CTRLGRID; dataTmp.label.eng = 'Date/Time'; dataTmp.autoStamp = true; dataTmp.autoStampTrigger = '2'; dataTmp.autoStampTrigger2Ques = POD_SIGN_CUSTOMER + data.id; dataTmp.kind = CONST_VALUE_DATE_SPACE_TIME; dataTmp.readOnly = true; dataTmp.readOnlyDsp = true; dataTmp.isAllowEdit = false; gridData.children.push(dataTmp); } if(data.showSignatureCarrier){ //customer carrier column var properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUTSIGNATURE]); removeUnsupportProperty(properties, CONST_CTRL_TYPE_INPUTSIGNATURE); removeUnuseVersion(properties); properties.id.value = POD_SIGN_CARRIER + data.id; properties.name.value = 'S' + data.id + '__Customer_Carrier'; $ctrl = $('
    ').data('odkControl-properties', properties); var dataTmp = getDataRepresentation($ctrl); dataTmp.type = CONST_CTRL_TYPE_INPUTSIGNATURE; dataTmp.parentCtrlType = CONST_CTRL_TYPE_CTRLGRID; dataTmp.label.eng = 'Carrier signature'; dataTmp.isAllowEditOption = false; if(data.signatureAllowEdit){ dataTmp.isAllowEditOptionDataView = true; } gridData.children.push(dataTmp); //customer sifnature time column properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUTDATE]); properties.id.value = POD_SIGN_CARRIER_TIME + data.id; properties.name.value = 'S' + data.id + '__Customer_Carrier_DateTime'; $ctrl = $('
    ').data('odkControl-properties', properties); dataTmp = getDataRepresentation($ctrl); dataTmp.type = CONST_CTRL_TYPE_INPUTDATE; dataTmp.parentCtrlType = CONST_CTRL_TYPE_CTRLGRID; dataTmp.label.eng = 'Date/Time'; dataTmp.autoStamp = true; dataTmp.autoStampTrigger = '2'; dataTmp.autoStampTrigger2Ques = POD_SIGN_CARRIER + data.id; dataTmp.kind = CONST_VALUE_DATE_SPACE_TIME; dataTmp.readOnly = true; dataTmp.readOnlyDsp = true; dataTmp.isAllowEdit = false; gridData.children.push(dataTmp); } return gridData; } var loadRecurse = function($root, controls, duplicateDataTmp) { var loadReportPageSetting = function(pageSettingKey){ var ret = null; $.ajax({ url : '/pagesettings', dataType : 'json', type : 'POST', async:false, data : { action : 'getsettings' ,pageSettingKey : pageSettingKey }, cache : false, complete : function() { }, success : function(response, status) { ret = response.page_settings; }, error : function(request, status, error) { } }); return ret; } _.each(controls, function(control) { if(control.type == CONST_CTRL_TYPE_CTRLTABLE && control.isMessageWidget === true){ control.loop = 0; } if(control.name == '__reply_flag'){ return true; } control = convertHideIfCmpVal(control); fixButtonTypeForNFCBacodeInGridTable(control); fixHidePrintPDF(control); if(control.id && duplicateDataTmp[control.id]){ control.id = utils.seq.getUniqueId(); duplicateDataTmp[control.id] = true; }else{ duplicateDataTmp[control.id] = true; } if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLGRID){ if(control.name && control.name.startsWith('AE__')){ return true; } } if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLPOD){ /*var idInt = 0; try{ idInt = parseInt(control.id); if(idInt <= parseInt(POD_QTY_COL_ID)){ return true; } }catch(e){ }*/ if(control.name && control.name.indexOf('__Status') >= 0){ return true; } if(control.name && control.name.indexOf('__AutoID') >= 0){ return true; } if(control.name && control.name.indexOf('__Grid_Signature') >= 0){ return true; } } /* hqkhanh change control old to new here */ control = setDefaultITEFlagForOldForm(control); control = convertReadOnlyRequiredHide(control); switch(control.type){ case CONST_CTRL_TYPE_CTRLTABLE: case CONST_CTRL_TYPE_CTRLSCHEDULE: control = convertTableJustification(control); break; case CONST_CTRL_TYPE_CTRLGRID: control = convertGridJustification(control); break; case 'inputLabel': control = convertLabelJustification(control); break; case CONST_CTRL_TYPE_INPUTLOOKUP: control = convertRestrictOption(control); control = convertRetrieveDS(control); control = convertModifyOnly(control); control = convertLookupValue(control); break; case CONST_CTRL_TYPE_INPUTLFBLUETOOTH: control = convertRestrictOption(control); break; case 'inputSaveAndSend': control = convertInputSaveAndSendToInputAction(control); break; case 'ctrlDataSource': control.label.eng = lbl_report_data_source; break; case 'ctrlHeaderGrid': control.label.eng = lbl_report_header_grid; break; case 'ctrlReportBreakPoint': control.label.eng = lbl_report_break; break; case 'ctrlBreakPointData': control.label.eng = lbl_report_break_point_data; break; case 'ctrlFooterGrid': control.label.eng = lbl_report_footer_grid; break; case 'ctrlEmailSchedule': if(!control.reportFrequency){ control.reportFrequency = { frequency: '0', datefilter: '', timefilter: '', dayfilter: '', su: false, mn: false, te: false, wd: false, th: false, fa: false, sa: false, }; }else if(typeof control.reportFrequency != 'object'){ if(control.reportFrequency == '1'){ //if daily then convert to weekly control.reportFrequency = { frequency: '2', datefilter: '', timefilter: '', dayfilter: '', su: true, mn: true, te: true, wd: true, th: true, fa: true, sa: true, }; }else{ control.reportFrequency = { frequency: control.reportFrequency, datefilter: '', timefilter: '', dayfilter: '', su: false, mn: false, te: false, wd: false, th: false, fa: false, sa: false, }; } } /* cho phép user set time, timezone, DST để run report var reportTimezone = getReportTimeZone(); if(control.reportFrequency.timefilter != '' && reportTimezone != dataNS.currentReport.timezone){ try{ var reportDate = undefined; if(control.reportFrequency.datefilter != ''){ reportDate = (new Date(control.reportFrequency.datefilter + ' ' + control.reportFrequency.timefilter)).getTime(); reportDate = reportDate + reportTimezone - dataNS.currentReport.timezone; control.reportFrequency.datefilter = (new Date(reportDate)).format("mm/dd/yyyy"); control.reportFrequency.timefilter = (new Date(reportDate)).format("HH:MM"); }else{ reportDate = (new Date("1/1/2016 " + control.reportFrequency.timefilter)).getTime(); reportDate = reportDate + reportTimezone - dataNS.currentReport.timezone; control.reportFrequency.timefilter = (new Date(reportDate)).format("HH:MM"); } dataNS.currentReport.timezone = reportTimezone; }catch(e){ } }*/ break; case CONST_CTRL_TYPE_INPUTSIGNATURE: if(isVersion(VERSION_SIGNATURE_ADD_FUNC)){ if(control.isAllowEditOption == undefined){ if(control.isOneTimeSignatureCapture){ control.isAllowEditOption = false; }else{ control.isAllowEditOption = true; control.isOneTimeSignatureCapture = undefined; } } } if(!isAllowEditOption4Signature && control.isAllowEditOption == true){ isAllowEditOption4Signature = true; } break; case CONST_CTRL_TYPE_INPUTACTION: control = convertInputAction(control); break; case CONST_CTRL_TYPE_INPUTLOCATION: control = convertInputLocation(control) break; case CONST_CTRL_TYPE_INPUTIMAGE: control = convertInputImage(control); break; } if(isVersion(VERSION_MODIFY_ADD_FIELDS)){ control = setDefaultAddModifyFields(control); } if(isIgnoreRelevance(control.parentCtrlType) && control.isShowRelevanceCondition == true){ control.isShowRelevanceCondition = false; } if(isIgnoreSkip(control.parentCtrlType)){ control.isShowSkipCondition = false; } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(control.kind == CONST_STRING){ if(control.expression && control.expression.length > 0){ for(var index=0; index0){ var resultKind = getCalculateDateResultKind(control.expression[0], extractRecurse($root)); control.result = resultKind; } } } var properties = null; if ((control.type == CONST_CTRL_TYPE_GROUP) || (control.type == CONST_CTRL_TYPE_CTRLTABLE) || (control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) || (control.type == CONST_CTRL_TYPE_CTRLPOD) || (control.type == CONST_CTRL_TYPE_CTRLINV) || (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) || (control.type == CONST_CTRL_TYPE_CTRLGRID) || (control.type == 'branch') || (control.type == 'inputPageBreak') || (control.type == 'inputLabel') || (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY) || (control.type == CONST_CTRL_TYPE_INPUTNUMBERING) || (control.type == CONST_CTRL_TYPE_INPUTACTION) || (control.type == CONST_CTRL_TYPE_INPUTPAYMENT) || (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT) || (control.type == 'inputInstruction') || //(control.type == CONST_CTRL_TYPE_INPUTCALCULATE) || (control.type == CONST_CTRL_TYPE_INPUTLOOKUP) || (control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) || (control.type == 'inputFacingTable') || (control.type == 'inputLookupMulti') || (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTFAX) || (control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) || (control.type == 'inputSaveAndSend') || (control.type == 'ctrlDataSource') || (control.type == 'ctrlHeaderGrid') || (control.type == 'ctrlDataFilter') || (control.type == 'ctrlReportBreakPoint') || (control.type == 'ctrlBreakPointData') || (control.type == 'ctrlBreakPointDataElement') || (control.type == 'ctrlFooterGrid') || (control.type == 'ctrlEmailSchedule')){ if(control.relevanceconds == undefined){ control.relevanceconds = []; } properties = $.extend(true, {}, $.fn.odkControl.controlProperties[control.type]); }else{ properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[control.type]); removeUnsupportProperty(properties, control.type); } removeUnuseVersion(properties); if(control.isAttachFormWidget === true){ appendProperties4AttachFormWidget(properties); } if(properties.ctrlDesc){ properties.ctrlDesc.isInsideTheGrid = false; properties.ctrlDesc.isInsideTheButtonGrid = false; properties.ctrlDesc.isInsideTheTable = false; properties.ctrlDesc.isInsideTheRepeat = false; if(control.parentCtrlType){ switch(control.parentCtrlType){ case CONST_CTRL_TYPE_CTRLTABLE: properties.ctrlDesc.isInsideTheTable = true; break; case CONST_CTRL_TYPE_CTRLSCHEDULE: properties.ctrlDesc.isInsideTheTable = true; break; case CONST_CTRL_TYPE_GROUP: properties.ctrlDesc.isInsideTheRepeat = true; break; case CONST_CTRL_TYPE_CTRLGRID: properties.ctrlDesc.isInsideTheGrid = true; break; case CONST_CTRL_TYPE_CTRLBUTTONGRID: properties.ctrlDesc.isInsideTheButtonGrid = true; break; } } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(control.kind == CONST_VALUE_DATE){ control.useCurrentcySymbol = false; control.currency = 'None'; } } if(isVersion(VERSION_AUTONUMBER_PHASE2)){ if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ if(!control.autoNumberType){ control.autoNumberType = "Collected"; } } } if(isVersion(VERSION_NEW_EMAIL_REPORT_SETTING)){ if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ // Safety creating object in case of undefined value if(!control.reportSettingBuildForm_2){ control.reportSettingBuildForm_2 = {}; } // Fill content from OLD FORM into new STRUCTURE if(control.reportSettingBuildForm){ control.reportSettingBuildForm_2.reportSettingBuildFormKey2 = control.reportSettingBuildForm; var ps = loadReportPageSetting(control.reportSettingBuildForm); // Fill the excel templates + Report type from old report setting if(ps != null){ control.reportSettingBuildForm_2.reportSettingBuildFormExcelTemplateKey = ps.excel_template_key; if(ps.using_template_in_email_report == USING_TEMPLATE_EXCEL){ control.reportSettingBuildForm_2.reportSettingBuildFormReportType = "2"; }else{ if(ps.templateUseWhenCreatePdf == CREATE_PDF_BY_STANDARD_REPORT_TEMLATE){ control.reportSettingBuildForm_2.reportSettingBuildFormReportType = "1"; }else{ control.reportSettingBuildForm_2.reportSettingBuildFormReportType = "2"; } } } control.reportSettingBuildFormCaption = ""; control.reportSettingBuildForm = ""; } } } if(isVersion(VERSION_GRID_TYPE_FUNCTION)){ if(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_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ if(!control.columnsSpaceType){ control.columnsSpaceType = '1'; if(control.equallySpaceColumns){ control.columnsSpaceType = '0'; control.equallySpaceColumns = false; } if(control.isColumnWeightCustom){ control.columnsSpaceType = '2'; control.isColumnWeightCustom = false; } } } } if(isVersion(VERSION_PORTAL_SHADING)){ if(!control.apperance){ control.apperance = 'Default'; } if(!control.shadedHeadings){ if(control.type !== 'inputLabel'){ control.shadedHeadings = { isShadedHeadings: false, headingColor: '#E9E9E9', textColor: '#000000', isBorderAroundHeading: false }; } }else if(control.shadedHeadings.isBorderAroundHeading == undefined){ control.shadedHeadings.isBorderAroundHeading = false; } if(control.type !== 'inputLabel'){ if(!control.shadedHeadings){ control.shadedHeadings = { isShadedHeadings: false, headingColor: '#E9E9E9', textColor: '#000000', isBorderAroundHeading: false }; }else if(control.shadedHeadings.isBorderAroundHeading == undefined){ control.shadedHeadings.isBorderAroundHeading = false; } }else{ //input label } if(!control.shadedRow){ control.shadedRow = { isShadedRow: false, rowColor: '#E9E9E9', rowTextColor: '#000000' }; } if(!control.shadedButton){ control.shadedButton = { isShadedButton: false, btnSheadingColor: '#E9E9E9', btnTextColor: '#000000', activeBtnTextColor: '#000000', btnBorderColor: '#000000', btnRoundedCorners: false }; }else{ if(!control.shadedButton.activeBtnTextColor){ control.shadedButton.activeBtnTextColor = '#000000'; } if(!control.shadedButton.btnBorderColor){ control.shadedButton.btnBorderColor = '#000000'; } if(!control.shadedButton.btnRoundedCorners){ control.shadedButton.btnRoundedCorners = false; } } } if(isVersion(VERSION_DISPLAY_TYPE_FUNCTION)){ switch(control.type){ case CONST_CTRL_TYPE_INPUTSELECTONE: case CONST_CTRL_TYPE_INPUTSCOREONE: if(control.displayType == undefined){ if(control.showAsDropdown == undefined && control.parentCtrlType == CONST_CTRL_TYPE_CTRLGRID){ control.displayType = CONST_DROPDOWN; }else{ if(control.showAsDropdown){ control.displayType = CONST_DROPDOWN; }else{ control.displayType = CONST_DOWN; } } }else if(control.displayType == CONST_DROPDOWN){ control.showAsDropdown = true; } break; } } if(isVersion(VERSION_LOCATION_SHOW_HIDE_OPT)){ if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){ if(control.range && (control.range.min || '') != ''){ control.maxError = control.range.min; } control.range = false; } } if(isVersion(VERSION_NEW_TOOL_LAYOUT)){ if(control.isShowSkipCondition == undefined){ if(control.skipconds && control.skipconds.length > 0){ control.isShowSkipCondition = true; }else{ control.isShowSkipCondition = false; } } if(control.isShowRelevanceCondition == undefined){ if(control.relevanceconds && control.relevanceconds.length > 0){ control.isShowRelevanceCondition = true; }else{ control.isShowRelevanceCondition = false; } } } // // Fill data with Table/Grid/Questionaire // if(isVersion(VERSION_NEW_OPTION_CUSTOM_COLUMN_WEIGHT)){ // if(control.type == CONST_CTRL_TYPE_CTRLGRID){ // writeToLogInfo('option custom : GRID'); // } else if(control.type == CONST_CTRL_TYPE_CTRLTABLE) { // writeToLogInfo('option custom : Table'); // } else if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) { // writeToLogInfo('option custom : Questionaire'); // } // } if(control.type == CONST_CTRL_TYPE_INPUTLOCATION && isVersion(VERSION_PCA_43_44)){ if(control.showGPSInfo == undefined){ control.showGPSInfo = true; } } if(control.type == CONST_CTRL_TYPE_INPUTLOCATION && isVersion(VERSION_LOCATION_SHOW_HIDE_OPT)){ if(control.showGPSInfo){ if(control.showLat == undefined){ control.showLat = true; } if(control.showLon == undefined){ control.showLon = true; } if(control.showAcc == undefined){ control.showAcc = true; } if(control.showAlt == undefined){ control.showAlt = true; } } } if(isVersion(VERSION_ALLOW_EDIT_OPT)){ switch(control.type){ case CONST_CTRL_TYPE_INPUTDATE: case CONST_CTRL_TYPE_INPUTLOCATION: if(dataNS && dataNS.currentForm && dataNS.currentForm.formVersion && (parseFloat(dataNS.currentForm.formVersion) < parseFloat(FORM_VERSION))){ if(control.autoStamp){ if(control.isAllowEdit == undefined){ control.isAllowEdit = false; } }else{ control.isAllowEdit = true; } }else{ if(control.isAllowEdit == undefined){ control.isAllowEdit = true; } } break; } } if(isVersion(VERSION_ACTION_TYPE)){ if(control.kind == undefined){ if(control.useImage){ control.kind = 'Image'; }else{ control.kind = 'Button'; } } } // Prepare creating Questionnaire if (isVersion(VERSION_NEW_OPTION_CUSTOM_COLUMN_WEIGHT)) { if (control.type === CONST_CTRL_TYPE_CTRLSCORETABLE) { if (control.withFormat4ColumnWeight2 === undefined && control.withFormat4ColumnWeight !== undefined) { // Transfer data from old column weight into new column weight writeToLogInfo('Setting OLD control.withFormat4ColumnWeight into NEW withFormat4ColumnWeight2 : ' + control.withFormat4ColumnWeight); try { var arrDataCtrl = control.withFormat4ColumnWeight.split('|'); control.withFormat4ColumnWeight2 = {}; control.withFormat4ColumnWeight2.withFormat4CWQuestion = arrDataCtrl[0]; var answerData = 0; for (var t = 1; t < arrDataCtrl.length-1; t++) { try { // Parse number value into float type answerData += parseFloat(arrDataCtrl[t]); } catch (e) {} } if (control.appendComment === true) { control.withFormat4ColumnWeight2.withFormat4CWComment = arrDataCtrl[arrDataCtrl.length-1]; } else { try { answerData += parseFloat(arrDataCtrl[arrDataCtrl.length-1]); } catch (e) {} } // Validate number value //control.withFormat4ColumnWeight2.withFormat4CWAnswer = answerData + ''; if (isNumberValueString(answerData)) { control.withFormat4ColumnWeight2.withFormat4CWAnswer = answerData + ''; } else { control.withFormat4ColumnWeight2.withFormat4CWAnswer = ''; } } catch (ex) {} } } } if (isVersion(VERSION_TEXT_KEYBOARD_TYPE)) { if(!control.keyboardType && control.lockNumericKeyboard){ control.keyboardType = CONST_KB_TYPE_NO; } } properties.id.ctrlType = control.type; _.each(properties, function(property, key) { if(property.resetValue){ if(control[key]){ if(control[key] instanceof Array){ control[key] = []; }else if(control[key] instanceof Object){ control[key] = {}; }else{ property.value = ''; } } } if(isVersion(VERSION_STRICT_FORM_BUILDER)){ property.isOldCtrl = true; }else if(isFormOpenSpecial && (isVersion(VERSION_ADD_DEL_CTRL_OSP) || isVersion(VERSION_ADD_CTRL_OSP))){ property.isOldCtrl = true; } if((control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) && key == 'defaultValue'){ var value = control[key]; if(value != undefined){ var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ property.value = value.substring(0, contentStartPos); property.mailcontent = value.substring(contentStartPos + 2); }else{ property.value = value; } } if(isVersion(VERSION_EMAIL_REPORT_NEW_DEFAULT)){ property.selectedCtrl = control[key+'_selectedCtrl']; } }else if(control.type == 'ctrlEmailSchedule' && key == 'reportEmail'){ var value = control[key]; if(value != undefined){ var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ property.value = value.substring(0, contentStartPos); property.mailcontent = value.substring(contentStartPos + 2); }else{ property.value = value; } } }else if((control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) && key == 'reportSettingBuildForm'){ // Parse data when load form (Email Report Settings Caption) property.value = control[key]; property.reportSettingBuildFormCaption = control['reportSettingBuildFormCaption']; // Apply changes : Email Report Changes REVIEW 02-17-15 MJ.PPTX, slide 08 property.reportSettingBuildFormCaptionInput = control['reportSettingBuildFormCaptionInput']; }else{ if((control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV) && key == 'loop'){ if(control[key] > 20 && dataNS.currentForm && dataNS.currentForm.type == 2){ property.value = '&&&' + control[key]; }else{ property.value = control[key]; } }else{ property.value = control[key]; } if((control.type === CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTLOCATION || control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_RPT_HEADERGRID) && key === 'hintLink'){ // CO-4050 var iconColor = ''; if(control.iconColor){ iconColor = control.iconColor } property.iconColor = iconColor; } if(property.value == undefined && property.valueIfUndefined == 'parent'){ // CO-4827: Adding Text Justification To Image Button var parentProperty = $($root.parents('.control')[0]).data('odkControlProperties'); if(parentProperty != undefined){ if(property.valueIfUndefinedParentProperty != undefined){ if(parentProperty[property.valueIfUndefinedParentProperty] != undefined){ property.value = parentProperty[property.valueIfUndefinedParentProperty].value; } }else if(parentProperty[key] != undefined){ property.value = parentProperty[key].value; } } } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.iconColor){ property.applyScreenSize = control.applyScreenSize; property.buttonSize = control.buttonSize; property.ifScreenSmallerThan = control.ifScreenSmallerThan; property.ifScreenSmallerSize = control.ifScreenSmallerSize; } if(key == 'relevanceconds' && property.value != undefined){ _.each(property.value, function(relevanceCond){ if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == '' || relevanceCond.text[CONST_VALUE_CTRLTYPE] == undefined){ return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_TEXT || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTLOCATION || relevanceCond.text[CONST_VALUE_CTRLTYPE] == mdi_kind_inputImage || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTBARCODE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTNFC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSECUREFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSCOREONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTMANY || relevanceCond.text[CONST_VALUE_CTRLTYPE] == 'inputRIF'){ if(relevanceCond.text[CONST_VAL]){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_EQUAL: case CONST_VALUE_NOT_EQUAL: case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } }else{ relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } } }); }else if(key == 'lookupConditionFields' && property.value != undefined){ _.each(property.value, function(lookupConditionField){ if(lookupConditionField.text.valCond == undefined || jQuery.trim(lookupConditionField.text.valCond) == ''){ return false; } if(lookupConditionField.text.valCond == properties.lookupfield.value){ lookupConditionField.text.valCond = ''; } }); }else if(key == 'options' && property.value != undefined){ _.each(property.value, function(item){ if(item.val == undefined || jQuery.trim(item.val) == ''){ return false; } item.isOldCtrl = true; }); } } }); // if(control.type != 'inputPageBreak' && properties.label.value.eng != undefined){ // if(properties.name.valueinput == ""){ // var controlidTmp = replaceNonAlphaNumericChar(properties.label.value.eng); // if(properties.name.value != controlidTmp){ // properties.name.valueinput = properties.name.value; // } // } // // } // // Fix bug 0020311: Data name is changed into default name after user open form! // else if(control.type != 'inputPageBreak' && properties.label.value.eng == undefined){ // if(properties.name.value != undefined && !properties.name.value.match(/^untitled/) && properties.name.valueinput == ""){ // properties.name.valueinput = properties.name.value; // }else if(properties.name.value.match(/^untitled/) && !properties.name.value.match(/^untitled[0-9]+$/) ){ // properties.name.valueinput = properties.name.value; // } // } // Always set properties.name.valueinput = properties.name.value in loading data properties.name.valueinput = properties.name.value; //when edit form (Build Form > Open > Edit) => allow edit/delete control from component imported => set isOldCtrl = false if(undefined != control.isOldCtrl && false == control.isOldCtrl) { properties.name.isOldCtrl = false; } var typeTmp = control.type; if(isVersion(VERSION_NEW_GRID_BUTTON) && control.type == CONST_CTRL_TYPE_CTRLGRID && control.isButtonGrid){ typeTmp = 'ctrlButtonGrid'; }else if(isVersion(VERSION_SECURE_EMAIL) && control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT && control.isSecureEmail){ typeTmp = CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT; }else if(isVersion(VERSION_FAX_WIDGET) && control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT && control.isFaxWidget){ typeTmp = CONST_CTRL_TYPE_INPUTFAX; }else if(isVersion(VERSION_SECURE_FORWARD) && control.type == CONST_CTRL_TYPE_INPUTFORWARD && control.isSecureForward){ typeTmp = CONST_CTRL_TYPE_INPUTSECUREFORWARD; }else if(isVersion(VERSION_LOOKUP_RETRIEVE) && control.type == CONST_CTRL_TYPE_INPUTLOOKUP && control.isRetrieve){ typeTmp = CONST_CTRL_TYPE_INPUTLOOKUP_RETRIEVE; }else if(isVersion(VERSION_SCHEDULE_WIDGET) && control.type == CONST_CTRL_TYPE_CTRLTABLE && control.isScheduleWidget){ typeTmp = CONST_CTRL_TYPE_CTRLSCHEDULE; }else if(isVersion(VERSION_MESSAGE_WIDGET) && control.type == CONST_CTRL_TYPE_CTRLTABLE && control.isMessageWidget){ typeTmp = CONST_CTRL_TYPE_CTRLMESSAGE; }else if(isVersion(VERSION_ACTION_OPEN_FILE_WIDGET) && control.type == CONST_CTRL_TYPE_INPUTACTION && control.isOpenFileWidget){ typeTmp = CONST_CTRL_TYPE_INPUTOPENFILE; }else if(isVersion(VERSION_ATTACH_FORM) && control.type == CONST_CTRL_TYPE_INPUTACTION && control.isAttachFormWidget){ typeTmp = CONST_CTRL_TYPE_INPUTATTACHFORM; } var classExt = typeTmp; if($root && $root.parents('.ctrlPOD').length > 0){ if(properties && properties.id){ properties.id.isInPOD = true; } var idInt = 0; try{ idInt = parseInt(properties.id.value); if(isNaN(idInt)){ idInt = 0; } }catch(e){ idInt = 0; } if(idInt <= parseInt(POD_QTY_COL_ID)){ classExt += ' podSpecialCtrl ' + properties.name.value; } } if($root && $root.parents('.ctrlINV').length > 0){ if(properties && properties.id){ properties.id.isInINV = true; } var idInt = 0; try{ idInt = parseInt(properties.id.value); if(isNaN(idInt)){ idInt = 0; } }catch(e){ idInt = 0; } if(idInt <= parseInt(INV_ID_COL_ID)){ classExt += ' invSpecialCtrl ' + properties.name.value; } } if($root && $root.parents('.ctrlTable').length > 0){ if(properties && properties.id){ properties.id.isInSchedule = true; } var idInt = 0; try{ idInt = parseInt(properties.id.value); if(isNaN(idInt)){ idInt = 0; } }catch(e){ idInt = 0; } if(idInt <= parseInt(SCHEDULE_WIDGET_START_TIME_ID)){ classExt += ' scheduleSpecialCtrl ' + properties.name.value; } } var $control = $('#templates .control') .clone() .addClass(classExt) .odkControl(typeTmp, null, properties) .appendTo($root); if(typeTmp == 'ctrlBreakPointDataElement'){ var controlCount = $root.find('.ctrlBreakPointDataElement').length; $control.find('.reportColumnNumber').empty().append('' + controlCount); if(properties.inputType){ $control.addClass(properties.inputType.value); } } if(control.type == CONST_CTRL_TYPE_CTRLGRID && isVersion(VERSION_GRID_TYPE_FUNCTION) && control.gridType !== '1' && control.gridType !== '2'){ $control.addClass('gridTypeNormal'); } $control.find('.controlErrorMessage').addClass('ctrlId_' + control.id); if($root.children().length == 1){ $control.addClass('last-child'); }else if($($root.children()[$root.children().length - 2]).hasClass('last-child')){ $($root.children()[$root.children().length - 2]).removeClass('last-child'); $control.addClass('last-child'); } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID || control.type == 'ctrlBreakPointData'){ loadRecurse($control.find('.workspaceInner'), control.children, duplicateDataTmp); }else if(isVersion2_12()){ var ctrlId = 'ctrl_id_' + control.id; if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ lookupDataFieldArray[ctrlId] = control.lookupfield || ''; if(control.lookupConditionFields != undefined && control.lookupConditionFields.length > 0){ for(var i=0; i utils.seq.getCurrentId()){ utils.seq.resetUniqueId(controlId); } } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID) findNextCtrlId(control.children); }); }; odkmaker.data.load = function(formObj) { checkIsAllowEditOption4Signature(); // Apply replace Form Structure :   to SPACE with Table/Grid/Questionnaire //applyReplaceFormStructureWithNBSP(formObj.controls, true); //debugger //$("#formBuilder .workspace.workspaceScrollAreaContent:empty").css("background-image", "url(/img/formbuilder/bgTransparent.jpg)"); //$("div.workspace.workspaceScrollAreaContent").css("background-image", "url(/img/formbuilder/bgTransparent.jpg)"); $(".propertiesPaneQuick").addClass(CONST_CSS_CLASS_HIDE_SESSION); $("div#panVideo.propertiesPane").css("top", "40px"); $("div#panSampleForm.propertiesPane").css("top", "40px"); /* * START CO-671: no need to move search panel to left (it's always on left) * this code will be excuted if customers open form (load form) $(".searchHeader").css("right", "21em"); */ /* CO-671: this function checks visible of quicktip body * then hide it if customer click on build form link (look like initial) */ checkQuickTipShowMoreVisible(); lookupDataFieldArray = []; var title = formObj.title; var $textField = $('.header #renameFormField'); $textField.val(title); $('.formBuilder .header h1').attr('title', title); /*if(title.length > 20){ title = title.substring(0, 17) + '...'; }*/ $('.formBuilder .header h1').text(title); var $myWorkspace = $('.workspace:visible').empty(); //TODO // hqkhanh utils.seq.resetUniqueId(0); findNextCtrlId(formObj.controls); $myWorkspace.addClass(CONST_CSS_CLASS_HIDE_SESSION); var duplicateDataTmp = {}; isFormLoadding = true; loadRecurse($myWorkspace, formObj.controls, duplicateDataTmp); isFormLoadding = false; $myWorkspace.removeClass(CONST_CSS_CLASS_HIDE_SESSION); $myWorkspace.find('.control:first').trigger('odkControl-reloadProperties'); }; odkmaker.data.loadReport = function(reportObj) { lookupDataFieldArray = []; var title = reportObj.title; var $textField = $('.header #renameReportField'); $textField.val(title); $('.reportBuilder .header h1').attr('title', title); $('.reportBuilder .header h1').text(title); $('.workspace:visible').empty(); utils.seq.resetReportUniqueId(0); findNextCtrlId(reportObj.controls); var duplicateDataTmp = {}; loadRecurse($('.workspace:visible'), reportObj.controls, duplicateDataTmp); $('.workspace:visible .control:first').trigger('odkControl-reloadProperties'); }; odkmaker.data.loadFV = function(formObj, rootInputProperties){ $('body').addClass(CONST_CLS_FORM_LOADING); fvDataNS.isLoading = true; fvDataNS.isRefreshLayout = false; fvDataNS.isLoadedIncomplete = false; if(isVersion(VERSION_JUMP_WHEN_OPEN)){ fvDataNS.hasSkipConditionArray = []; } if(fvDataNS.isOpenInCompleteRecord || fvDataNS.isOpenCompleteRecord || (fvDataNS.currentForm && fvDataNS.currentForm.editRecordData)){ fvDataNS.isEditFormData = true; }else{ fvDataNS.isEditFormData = false; } // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { // Put flag for starting flow (default <=> true) fvDataNS.isNeedApplyIfThenElseCondition = true; if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ // We are in edit mode // => Do not process IfThenElse value fvDataNS.isNeedApplyIfThenElseCondition = false; } } // Apply skip if in WebApps GUI if (isVersion(VERSION_SKIP_IF)) { // Put flag for starting flow (default <=> true) fvDataNS.isNeedApplySkipIfCondition = true; if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ // We are in edit mode // => Do not process skip if value fvDataNS.isNeedApplySkipIfCondition = false; } } geofencesMap = {}; // CO-4372 geofencesValue = {}; odkmaker.data.loadFVNew(formObj, rootInputProperties); autoResizeTextarea(); clearAllCtrlChange(); releaseDirtyFlag(true); fvDataNS.incomplete = false; if(isTabletPreview){ initPreviewMenuIcon(); } showDisToEmailWarning(); //fix CO-4420:Passed Value Through Form Isn't Recognized //fillSendDataOfPreviousForm(); // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { // Put flag for ending flow (default <=> true) // Wait after 1s for allowing process If Then Else Condition // for make sure that for reserving edit data in Table/Grid/Questionnaire setTimeout(function() { fvDataNS.isNeedApplyIfThenElseCondition = true; console.log('fvDataNS.isNeedApplyIfThenElseCondition = TRUE after finishing loading form data ... '); }, 1000); } // Apply Skip if in WebApps GUI if (isVersion(VERSION_SKIP_IF)) { // Put flag for ending flow (default <=> true) // Wait after 1s for allowing process skip if Condition // for make sure that for reserving edit data in Table/Grid/Questionnaire setTimeout(function() { fvDataNS.isNeedApplySkipIfCondition = true; console.log('fvDataNS.isNeedApplySkipIfCondition = TRUE after finishing loading form data ... '); }, 1000); } var finishedLoading = function() { if(fvDataNS.isExecuteControlChangeRunning == true){ setTimeout(function(){ finishedLoading(); }, 1000); return; } $('body').removeClass(CONST_CLS_FORM_LOADING); if(fvDataNS.isPlusLoading){ // CO-4608 // data is still loading } else{ fvDataNS.isLoading = false; } runWaitForDataLoaded(); //fix CO-4420:Passed Value Through Form Isn't Recognized fillSendDataOfPreviousForm(); fillReturnDataOfPreviousForm(); var classPath = $(CONST_JQUERY_ID_FORMVIEW).attr(CONST_DATA_JUMP_CTRL); $(CONST_JQUERY_ID_FORMVIEW).removeAttr(CONST_DATA_JUMP_CTRL); if(classPath){ var ctrlProperties = fvDataNS.dataArray[classPath]; if(ctrlProperties){ jumpToCtrl(ctrlProperties, ctrlProperties.id, false, false); } } processChecklistCondition4Edit(); waitForDataLoading(false); /* hqkhanh fix bug 0025649: Edit mode - Table checklist - Values are not filled after changing value of LU condition add fvDataNS.currentForm.editRecordData = undefined; */ if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ fvDataNS.currentForm.editRecordData = undefined; if(fvDataNS.currentForm.retrieveControlDataChange){ _.each(fvDataNS.currentForm.retrieveControlDataChange, function(item){ var ctrlPropreties = item.ctrlPropreties; var $control = fvDataNS.ctrlArray[ctrlPropreties.classPath]; switch(item.type){ case 'clearOnRetrieve': if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTATTACHMENT){ $control.trigger('clearData'); }else{ //$control.trigger('setLookupValue', [item.value, false]); if($control.find('textarea').length > 0){ $control.find('textarea').trigger('setLookupValue', [item.value, true]); }else if($control.find('input').length > 0){ $control.find('input').trigger('setLookupValue', [item.value, true]); }else{ $control.trigger('clearData'); } } break; case 'calculate': if(ctrlPropreties.calculateExpression != undefined && ctrlPropreties.calculateExpression != ''){ var $parent = item.parentProperties; var isShowHHMM = $parent.showAsHM?$parent.showAsHM.value:undefined; var isShowHHMMSS = $parent.showAsHMS?$parent.showAsHMS.value:undefined; var decPlace = $parent.decPlace?$parent.decPlace.value:undefined; if(ctrlPropreties.usePercent == true){ if(decPlace){ decPlace = parseInt(decPlace) + 2; }else{ decPlace = 8; } } var calValue = calculateExpression(ctrlPropreties.calculateExpression, ctrlPropreties, fvDataNS.inputData, isShowHHMM, decPlace, isShowHHMMSS); if(calValue != ctrlPropreties.val){ $control.trigger('Calculate_Data_Change'); } break; } default: } }) setTimeout(function() { fvDataNS.currentForm.retrieveControlDataChange = undefined; }, 1000); } //render repeatable summary if(fvDataNS.repeatableRef && fvDataNS.repeatableRef.length>0){ _.each(fvDataNS.repeatableRef, function(element, key){ renderRepeatableSummary(element); }) } }else{ //new record //trigger autorun when a question is completed if(fvDataNS.autoStampTriggerMap['2']) { jQuery.each(fvDataNS.autoStampTriggerMap['2'], function(key, element) { var classPathArr = fvDataNS.ctrlIdMap[key]; var classPath = ''; if(classPathArr) { classPath = Object.keys(classPathArr)[0]; } var ctrlPropreties = fvDataNS.dataArray[classPath]; if(ctrlPropreties && getValueOrEmpty(ctrlPropreties.val) != '' && ctrlPropreties.val != ctrlPropreties.defaultValue){ //fvDataNS.listCtrlChange[classPath] = true; //executeControlChange(classPath, true); autostampTrigger(ctrlPropreties); } }); } } if(fvDataNS.sent != undefined){ fvDataNS.sent = false; } if(fvDataNS.autoStampTriggerMap['8']) { jQuery.each(fvDataNS.autoStampTriggerMap['8'], function(key, element) { //var listCtrl = fvDataNS.ctrlIdMap[id]; //var ctrlName = fvDataNS.ctrlMap[key]; var classPathArr = fvDataNS.ctrlIdMap[key]; var classPath = ''; if(classPathArr) { classPath = Object.keys(classPathArr)[0]; } var ctrlPropreties = fvDataNS.dataArray[classPath];//getControlsPropertyByName(ctrlName, classPath); var $control = fvDataNS.ctrlArray[classPath]; if(element && element.retrieveTrigger) { actionRetrieve(ctrlPropreties, $control); } if(element && element.modifyTrigger) { actionModify(ctrlPropreties, $control); } }); } processLoadNewDestination4ReloadOnRetrieve(); console.log('doforms-form-loaded'); top.postMessage({ eventType: 'doforms-form-loaded', shareId: shareId }, '*'); var observer = new MutationObserver(reportFormResized); $('.fvWorkspace.data > *').each(function (index, element) { observer.observe(element, {attributes: true, attributeFilter: ['style']}); }); reportFormResized(); setTimeout(function() { executeJumpWhenOpen(); }, 1000); } setTimeout(function() { finishedLoading(); }, 1000); } odkmaker.data.loadFVNew = function(formObj, rootInputProperties) { // Process update all information getting from server into global variables updateGlobalVariable4ShaddingAndButtonTextBuildForms(formObj); makeCtrlIdMap(formObj.controls, 'data', 0); var loadFormData = function(formObj, rootInputProperties){ waitForDataLoading(true); hasEncryptField = false; // reset default value rootDataCtrlWidth = 0; if(!isVersion(VERSION_SKETCH_BTN)){ $($('a.imgActBtn4Sketch').siblings('br')[0]).remove(); $('a.imgActBtn4Sketch').remove(); } if(!isVersion(VERSION_IMAGE_SKETCH_BTN)){ $('.VERSION_IMAGE_SKETCH_BTN').remove(); } var title = formObj.title; $('.formViewMain #menu_contain .header h1').attr('title', title); $('.formViewMain #menu_contain .header h1').text(title); var fvWorkspace = $('.formView .fvWorkspace').attr('style', ''); // === Check for Dispatch plus container var disPlusContainerFlg = false; if(isWADispatchPlus()){ if(fvWorkspace.find('.waDisTable').length == 0){ fvWorkspace.empty(); //$('
    ').appendTo(fvWorkspace); } else{ disPlusContainerFlg = true; $(".formView .fvWorkspace > *:not('.waDisTable, .waDisSendType, .sentToEmailBar, .sentToSMSBar, .waDisProjectForm, .waRootContainer')").remove(); } } else{ fvWorkspace.empty(); } setDirtyFlag(true); if(fvDataNS.incomplete){ $('#fvmain_menu .fvDeleteForm').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvPrintForm').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $('#fvmain_menu .fvDeleteForm').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvPrintForm').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } if(authNS && authNS.currentUser && authNS.currentUser.mb_header_color){ $('#fvmain_menu').attr('style', 'background-color: ' + authNS.currentUser.mb_header_color + ' !important'); }else{ if(doformHeaderColor) { $('#fvmain_menu').attr('style', 'background-color: ' + doformHeaderColor + '!important'); } } if(hideToolbar == true) { $('#fvmain_menu').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); } $('#fvmain_menu .mainMenuIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION); if(previewSubmit && !isWebAppDispatch() && !isWebAppDataview() && !isWebAppDataviewAddNew() && !(typeof previewEmbedLink != 'undefined' && previewEmbedLink) && !(typeof previewEmbedHtml != 'undefined' && previewEmbedHtml) && !formLinkDeviceMode){ var iconColor; if(doformIconColor){ iconColor = doformIconColor; }else{ iconColor = '#136792'; } if(authNS.currentUser && authNS.currentUser.mmbMenuIconColor){ iconColor = authNS.currentUser.mmbMenuIconColor; } //var fullScreenIconCanvas = document.getElementById("fvFullScreen"); //drawFVFullScreenIcon(fullScreenIconCanvas, iconColor); if(isFullScreen()){ $('#fvmain_menu li.liFvFullScreen .fvFullScreen').addClass('fullMode'); }else{ $('#fvmain_menu li.liFvFullScreen .fvFullScreen').removeClass('fullMode'); } $('#fvmain_menu li.liFvFullScreen').css('padding-top', '0px').removeClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $('#fvmain_menu li.liFvFullScreen').addClass(CONST_CSS_CLASS_HIDE_SESSION); showBackButton4Webclient(false); } if(!formLinkDeviceMode) { $('#fvmain_menu .mainMenuIcon .mainMenuIconText').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('#fvmain_menu .fvCancel').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvPrintForm').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); if(isWebClient){ if(authNS.currentUser.removeSaveOptionFromMenu == true){ $('#fvmain_menu .fvSaveCompleteLink').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvSaveContinueLink').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $('#fvmain_menu .fvSaveCompleteLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvSaveContinueLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } if(authNS.currentUser.removeSaveAndSendOptionFromMenu == true){ $('#fvmain_menu .fvSaveLink').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $('#fvmain_menu .fvSaveLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } if(authNS.currentUser.removePagesOptionFromMenu == true){ $('#fvmain_menu #pageMenuIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $('#fvmain_menu #pageMenuIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } }else{ $('#fvmain_menu .fvSaveCompleteLink').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvSaveLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvSaveContinueLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } else { // $('#fvmain_menu .mainMenuIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION); initMainMenuIconFormLinkDeviceMode(); $('#fvmain_menu .fvCancel').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); //$('#fvmain_menu .fvSaveLink').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .liFvSaveCompleteLink').remove(); $('#fvmain_menu .fvPrintForm').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('#fvmain_menu .fvPrint').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } /*if(isTabletPreview){ fvDataNS.hasShowLUTruncatWarning = false; }*/ fvDataNS.dontCallAutoStampTrigger = true; fvDataNS.lkData = undefined; fvDataNS.ctrlIndex = 0; fvDataNS.scoreData = {}; fvDataNS.scoreSum = {}; loadCtrlMap(formObj.controls, fvDataNS.ctrlMap, fvDataNS.saveAndSendCtrlMap); if(isVersion5_0()){ appendScoreSummary(fvWorkspace, rootInputProperties, fvDataNS.scoreSum); try { delete fvDataNS.scoreSum; // no need for this obj any more } catch (e) { } } // CO-2223 var fillAndSendInfo = undefined; try{ // CO-2223 if(!isFillAndSend // Not fill & send open link case && fvDataNS.currentForm.editRecordData && fvDataNS.currentForm.editRecordData['@SubmitByFun'].value == 'FillAndSend' // Not forward case && fvDataNS.currentForm.editRecordData['@FillAndSendEmail'] != undefined){ fillAndSendInfo = {}; fillAndSendInfo.email = fvDataNS.currentForm.editRecordData['@FillAndSendEmail'].value; fillAndSendInfo.subject = fvDataNS.currentForm.editRecordData['@FillAndSendEmailSubject'].value; fillAndSendInfo.message = fvDataNS.currentForm.editRecordData['@FillAndSendMessage'].value; } } catch(e){} var tmpFaS = ((typeof viewDataFillAndSend != 'undefined') ? viewDataFillAndSend : false) || fillAndSendInfo; var viewDataFillAndSendClass = ''; if(tmpFaS) { viewDataFillAndSendClass = ' viewDataFillAndSend'; } if(!disPlusContainerFlg){ if(webAppDispatch && !isDataViewCopying() || tmpFaS) { // && true == getParent().dispatchFlg try { var cssColRoot = ' style="width: 50%; vertical-align: top;"'; var rootContainer = $('
    ' + '' + '' + '' + '' + '' + '' + '
    ' + '
    ').appendTo(fvWorkspace); if (webAppDataView && !webAppDataViewAddNew) { $(rootContainer).addClass('hideItem'); } if(tmpFaS) { $(rootContainer).find('#tblWaRow1, #tblWaRow2, #tblWaRow3, #tblWaRow4').addClass('hideItem'); $(rootContainer).find('#tblWaRoot')[0].style.setProperty('border-bottom', 'none', 'important'); } var prjFormDiv = $('
    ').appendTo(fvWorkspace); if(!isInDispatchPlusTab) { $(prjFormDiv).addClass('hideItem'); } var cssCol0 = ' style="width: 98px;padding-top:5px!important;' + ' font-size: 14px; font-weight: bold;"'; var cssCol1 = ' style="padding-left: 5px!important;"'; var table5 = $('
    ' + '' + '' + '
    Send to:
    ').appendTo(fvWorkspace); var sendTo = []; if(!tmpFaS) { sendTo.push({val: 'Mobile', text: { eng: 'Mobile'}}); } sendTo.push({val: 'Email', text: { eng: 'Email'}}); if(!tmpFaS) { sendTo.push({val: 'Link', text: { eng: 'Link'}}); // CO-3080 } sendTo.push({val: 'SMS', text: { eng: 'SMS'}});//CO-5177 var ctrlType = CONST_CTRL_TYPE_INPUTSELECTONE; var _ctrlLabel = ''; var _ctrlName = 'sendTo'; var _ctrlId = 'dispatchTo'; var _ctrlPropreties = { name: _ctrlName, classPath: 'data ' + _ctrlName, id: _ctrlId, ctrlDataId: _ctrlId, label: _ctrlLabel, val: 'Mobile', children: [], isIgnoreAcross: false, displayType: CONST_ACROSS }; var _properties = { id: {value: _ctrlId}, showAsDropdown: {value: false}, label: {eng: _ctrlLabel, value: {eng: _ctrlLabel}}, hint: {eng: _ctrlLabel, value: {eng: ""}}, relevanceconds: {value: []}, skipconds: {}, defaultValue: {}, readOnly: {}, name: {}, options: { name: "Options", type: "optionsEditor", required: true, summary: false, value: sendTo } }; $('#formview_templates .' + ctrlType).first() .clone() .attr('id', 'fvCtrlID_' + _ctrlId) .addClass(ctrlType) .addClass('fvControl') .addClass('showAccross') .addClass('fvCtrlID_' + _ctrlId) .addClass('fvCtrlName_' + _ctrlName) .odkControlFV(ctrlType, null, _properties, _ctrlPropreties) .appendTo(table5.find('.col1')); $('.inpCtrlID_' + _ctrlId).css('float','left'); $('.inpCtrlID_dispatchTo input').click(function(){ if ('SMS' == $(this).val() && (!authNS.currentUser.enableSMS || !authNS.currentUser.customerSMSIsEnable)) { return false; } var mobileClass = '.waDisTable'; if(isWADispatchPlus()){ mobileClass = '.waMobile'; } //$(mobileClass).css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); $('.fvCtrlID_dispatchEmailOfSendTo').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); $('.sentToSMSBar').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('.waEmail_SMS_10').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('.waControls_10').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); //$('.waControls_01').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); //$('.waControls_11').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); //$('#tblWaRow2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); //$('#tblWaRow3').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); //$('#tblWaRow4').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); if('Mobile' == $(this).val()) { //$('.waControls_01').css(CONST_CSS_KEY_DISPLAY, ''); //$('.waControls_11').css(CONST_CSS_KEY_DISPLAY, ''); //$('#tblWaRow2').css(CONST_CSS_KEY_DISPLAY, ''); //$('#tblWaRow3').css(CONST_CSS_KEY_DISPLAY, ''); //$('#tblWaRow4').css(CONST_CSS_KEY_DISPLAY, ''); //$('.waDisTable.repeat').appendTo($('.waRootContainer').find('.colRoot21')); //$('#repeatDailyContainer').appendTo($('.waRootContainer').find('.colRoot31')); $('li.liFvSaveLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $('li.liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY,'inline-block'); if(!isWADispatchPlus()){ $('li.liFvSaveAndSchedule').css(CONST_CSS_KEY_DISPLAY,'inline-block'); } $('li.liFvSaveFormLink').css(CONST_CSS_KEY_DISPLAY,'none'); $('.fvCtrlID_dispatchMobileLink').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.fvCtrlID_dispatchSMSOfSendTo').css(CONST_CSS_KEY_DISPLAY,CONST_CSS_CLASS_HIDE_SESSION); //$(mobileClass).css(CONST_CSS_KEY_DISPLAY,''); $('.waControls_10').css(CONST_CSS_KEY_DISPLAY, ''); dispatchToEmail = false; $('.fvControl').trigger('checkAndSetRequired'); $('.fvControl .ctrlGrid_widgetHeader').trigger('checkAndSetRequired'); $('.fvControl').trigger('checkAndSetReadOnly'); $('.fvControl').trigger('checkAndSetHide'); $('.fvControl').trigger('checkAndSetRestrict'); } else if('Email' == $(this).val()) { //$('.waDisTable.repeat').appendTo($('.waRootContainer').find('.waEmail_SMS_11')); //$('#repeatDailyContainer').appendTo($('.waRootContainer').find('.waEmail_SMS_11')); if(viewDataFillAndSend || fillAndSendInfo) { $('.fvCtrlID_dispatchMobileLink').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.fvCtrlID_dispatchEmailOfSendTo').css(CONST_CSS_KEY_DISPLAY,''); $('.fvCtrlID_dispatchSMSOfSendTo').css(CONST_CSS_KEY_DISPLAY, CONST_CSS_CLASS_HIDE_SESSION); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY,''); $('.waEmail_SMS_10').css(CONST_CSS_KEY_DISPLAY, ''); } else { $('li.liFvSaveLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $('li.liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY,'inline-block'); if(!isWADispatchPlus()){ $('li.liFvSaveAndSchedule').css(CONST_CSS_KEY_DISPLAY,'inline-block'); } $('li.liFvSaveFormLink').css(CONST_CSS_KEY_DISPLAY,'none'); $('.fvCtrlID_dispatchMobileLink').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.fvCtrlID_dispatchEmailOfSendTo').css(CONST_CSS_KEY_DISPLAY,''); $('.fvCtrlID_dispatchSMSOfSendTo').css(CONST_CSS_KEY_DISPLAY, CONST_CSS_CLASS_HIDE_SESSION); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY,''); $('.waEmail_SMS_10').css(CONST_CSS_KEY_DISPLAY, ''); $('#dis_to_email_warrning_container #msg span').text('Dispatch to Email'); if(typeof authNS.currentUser != 'undefined' && (typeof authNS.currentUser.hide_branding == 'undefined' || !authNS.currentUser.hide_branding) && typeof authNS.currentUser.disToEmailWarningChargeCredits != 'undefined' && authNS.currentUser.disToEmailWarningChargeCredits == true //incase warning variable tell alert && previewRecordKey == ''//incase add new && (shareId == undefined || shareId == '' || shareId == 'null') ) { $('#dis_to_email_warrning_container').jqmShow(); } dispatchToEmail = true; $('.fvControl').trigger('checkAndSetRequired'); $('.fvControl .ctrlGrid_widgetHeader').trigger('checkAndSetRequired'); $('.fvControl').trigger('checkAndSetReadOnly'); $('.fvControl').trigger('checkAndSetHide'); $('.fvControl').trigger('checkAndSetRestrict'); } } else if('SMS' == $(this).val()) { //$('.waDisTable.repeat').appendTo($('.waRootContainer').find('.waEmail_SMS_11')); //$('#repeatDailyContainer').appendTo($('.waRootContainer').find('.waEmail_SMS_11')); if(viewDataFillAndSend || fillAndSendInfo) { $('.fvCtrlID_dispatchMobileLink').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.fvCtrlID_dispatchEmailOfSendTo').css(CONST_CSS_KEY_DISPLAY, CONST_CSS_CLASS_HIDE_SESSION); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY, CONST_CSS_CLASS_HIDE_SESSION); $('.sentToSMSBar').css(CONST_CSS_KEY_DISPLAY,''); $('.waEmail_SMS_10').css(CONST_CSS_KEY_DISPLAY, ''); } else { $('li.liFvSaveLink').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $('li.liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY,'inline-block'); if(!isWADispatchPlus()){ $('li.liFvSaveAndSchedule').css(CONST_CSS_KEY_DISPLAY,'inline-block'); } $('li.liFvSaveFormLink').css(CONST_CSS_KEY_DISPLAY,'none'); $('.fvCtrlID_dispatchMobileLink').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.fvCtrlID_dispatchEmailOfSendTo').css(CONST_CSS_KEY_DISPLAY, CONST_CSS_CLASS_HIDE_SESSION); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY, CONST_CSS_CLASS_HIDE_SESSION); $('.sentToSMSBar').css(CONST_CSS_KEY_DISPLAY,''); $('.waEmail_SMS_10').css(CONST_CSS_KEY_DISPLAY, ''); $('#dis_to_email_warrning_container #msg span').text('Dispatch to SMS'); if(typeof authNS.currentUser != 'undefined' && (typeof authNS.currentUser.hide_branding == 'undefined' || !authNS.currentUser.hide_branding) && typeof authNS.currentUser.disToEmailWarningChargeCredits != 'undefined' && authNS.currentUser.disToEmailWarningChargeCredits == true //incase warning variable tell alert && previewRecordKey == ''//incase add new && (shareId == undefined || shareId == '' || shareId == 'null') ) { $('#dis_to_email_warrning_container').jqmShow(); } dispatchToEmail = false; $('.fvControl').trigger('checkAndSetRequired'); $('.fvControl .ctrlGrid_widgetHeader').trigger('checkAndSetRequired'); $('.fvControl').trigger('checkAndSetReadOnly'); $('.fvControl').trigger('checkAndSetHide'); $('.fvControl').trigger('checkAndSetRestrict'); } } else if('Link' == $(this).val()) { $('li.liFvSaveLink').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('li.liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY,'none'); $('li.liFvSaveAndSchedule').css(CONST_CSS_KEY_DISPLAY,'none'); $('li.liFvSaveFormLink').css(CONST_CSS_KEY_DISPLAY,'inline-block'); if(fvDataNS.currentForm.editRecordKey == undefined){ // add new case $('li.liFvSaveFormLink').css('margin-right','7px'); } $('.fvCtrlID_dispatchMobileLink').removeClass('hideSession'); // CO-3080 } }); $('.waDisSendType').appendTo($('.waRootContainer').find('.colRoot00')); //add help icon for send to if(table5 != undefined){ table5.find('.col1').append(''); table5.find('a.sendToHelpIcon').click(function(){ if(tmpFaS) { showRightPanelHelp('/360045967434-Fill-Send'); } else { showRightPanelHelp('/200391935#send-to'); } }); } } catch (e) {} } if((webAppDispatch && !isDataViewCopying()) || viewDataFillAndSend || fillAndSendInfo) { try { var tmpFaS = (typeof viewDataFillAndSend != 'undefined') ? viewDataFillAndSend : false; var dispatchToEmail = 'dispatchToEmail'; if(tmpFaS) { dispatchToEmail = ''; } var table = $('').appendTo(fvWorkspace); // CO-2223 var emailAddress = ''; var emailSubject = ''; var emailMessage = ''; if (fillAndSendInfo) { emailAddress = fillAndSendInfo.email; emailSubject = fillAndSendInfo.subject; varEmailMsg = fillAndSendInfo.message; emailMessage = (varEmailMsg != undefined && varEmailMsg != '') ? varEmailMsg.replace(/
    ||
    |/g, '\n') : ''; } var ctrlType = CONST_CTRL_TYPE_INPUT_TEXT; var _ctrlLabel = 'Address'; // if(tmpFaS) { // _ctrlLabel = 'Email to'; // } var _ctrlName = 'emailOfSendTo'; var _ctrlId = 'dispatchEmailOfSendTo'; var _ctrlPropreties = { name: _ctrlName, classPath: 'data ' + _ctrlName, id: _ctrlId, ctrlDataId: _ctrlId, label: _ctrlLabel, val: emailAddress, children: [], isIgnoreAcross: false, hint: 'Send form to' }; var _properties = { id: {value: _ctrlId}, showAsDropdown: {value: false}, label: {eng: _ctrlLabel, value: {eng: _ctrlLabel}}, hint: {eng: _ctrlLabel, value: {eng: ""}}, relevanceconds: {value: []}, skipconds: {}, defaultValue: {}, readOnly: {}, name: {}, options: { name: "Options", type: "optionsEditor", required: true, summary: false, value: '' } }; $('#formview_templates .' + ctrlType).first() .clone() .attr('id', 'fvCtrlID_' + _ctrlId) .addClass(ctrlType) .addClass('fvControl') .addClass('fvCtrlID_' + _ctrlId) .addClass('fvCtrlName_' + _ctrlName) .odkControlFV(ctrlType, null, _properties, _ctrlPropreties) .appendTo(table.find('.sendToEmailControl')); //$('.inpCtrlID_' + _ctrlId).attr('placeholder','Send form to: '); ctrlType = CONST_CTRL_TYPE_INPUT_TEXT; _ctrlLabel = 'Subject'; // if(tmpFaS) { // _ctrlLabel = 'Email subject line'; // } _ctrlName = 'subjectOfSendTo'; _ctrlId = 'dispatchSubjectEmailOfSendTo'; var _ctrlPropreties = { name: _ctrlName, classPath: 'data ' + _ctrlName, id: _ctrlId, ctrlDataId: _ctrlId, label: _ctrlLabel, val: emailSubject, children: [], isIgnoreAcross: false, hint: 'Email subject line:' }; var _properties = { id: {value: _ctrlId}, showAsDropdown: {value: false}, label: {eng: _ctrlLabel, value: {eng: _ctrlLabel}}, hint: {eng: _ctrlLabel, value: {eng: ""}}, relevanceconds: {value: []}, skipconds: {}, defaultValue: {}, readOnly: {}, name: {}, options: { name: "Options", type: "optionsEditor", required: true, summary: false, value: '' } }; $('#formview_templates .' + ctrlType).first() .clone() .attr('id', 'fvCtrlID_' + _ctrlId) .addClass(ctrlType) .addClass('fvControl') .addClass('fvCtrlID_' + _ctrlId) .addClass('fvCtrlName_' + _ctrlName) .odkControlFV(ctrlType, null, _properties, _ctrlPropreties) .appendTo(table.find('.sendToSubjectEmailControl')); //$('.inpCtrlID_' + _ctrlId).attr('placeholder','Email subject line:'); ctrlType = CONST_CTRL_TYPE_INPUT_TEXT; _ctrlLabel = 'Message'; // if(tmpFaS) { // _ctrlLabel = 'Email body message'; // } _ctrlName = 'messageOfSendTo'; _ctrlId = 'dispatchMessageEmailOfSendTo'; var _ctrlPropreties = { name: _ctrlName, classPath: 'data ' + _ctrlName, id: _ctrlId, ctrlDataId: _ctrlId, label: _ctrlLabel, val: emailMessage, children: [], isIgnoreAcross: false, hint: 'Email body message' }; var _properties = { id: {value: _ctrlId}, showAsDropdown: {value: false}, label: {eng: _ctrlLabel, value: {eng: _ctrlLabel}}, hint: {eng: _ctrlLabel, value: {eng: ""}}, relevanceconds: {value: []}, skipconds: {}, defaultValue: {}, readOnly: {}, name: {}, options: { name: "Options", type: "optionsEditor", required: true, summary: false, value: '' } }; $('#formview_templates .' + ctrlType).first() .clone() .attr('id', 'fvCtrlID_' + _ctrlId) .addClass(ctrlType) .addClass('fvControl') .addClass('fvCtrlID_' + _ctrlId) .addClass('fvCtrlName_' + _ctrlName) .odkControlFV(ctrlType, null, _properties, _ctrlPropreties) .appendTo(table.find('.sendToEmailMessageControl')); $('.inpCtrlID_' + _ctrlId) //.attr('placeholder','Email body message') .css('overflow-y', 'scroll'); loadDisToEmailSetting(table, fillAndSendInfo); //SMS to number var tableSMS = $('' + '
    ').appendTo(fvWorkspace); // SMS Message var ctrlType = CONST_CTRL_TYPE_INPUT_TEXT; var _ctrlLabel = 'Number'; var _ctrlName = 'smsOfSendTo'; var _ctrlId = 'dispatchSMSOfSendTo'; var dispatchToSMSNumber = ''; var _ctrlPropreties = { name: _ctrlName, classPath: 'data ' + _ctrlName, id: _ctrlId, ctrlDataId: _ctrlId, label: _ctrlLabel, val: dispatchToSMSNumber, children: [], isIgnoreAcross: false, hint: '' }; var _properties = { id: {value: _ctrlId}, showAsDropdown: {value: false}, label: {eng: _ctrlLabel, value: {eng: _ctrlLabel}}, hint: {eng: _ctrlLabel, value: {eng: ""}}, relevanceconds: {value: []}, skipconds: {}, defaultValue: {}, readOnly: {}, name: {}, options: { name: "Options", type: "optionsEditor", required: true, summary: false, value: '' } }; $('#formview_templates .' + ctrlType).first() .clone() .attr('id', 'fvCtrlID_' + _ctrlId) .addClass(ctrlType) .addClass('fvControl') .addClass('fvCtrlID_' + _ctrlId) .addClass('fvCtrlName_' + _ctrlName) .odkControlFV(ctrlType, null, _properties, _ctrlPropreties) .appendTo(tableSMS.find('.sendToSMSControl')); $('.inpCtrlID_' + _ctrlId).attr('placeholder','').attr('maxlength', '20'); tableSMS.find('.inpCtrlID_' + _ctrlId).keypress(function(event){ return onlyMobileNumber(this, event); }); // SMS Message ctrlType = CONST_CTRL_TYPE_INPUT_TEXT; _ctrlLabel = 'Message'; _ctrlName = 'smsMessageOfSendTo'; _ctrlId = 'dispatchMessageSMSOfSendTo'; var dispatchToSMSMessage = ''; var _ctrlPropreties = { name: _ctrlName, classPath: 'data ' + _ctrlName, id: _ctrlId, ctrlDataId: _ctrlId, label: _ctrlLabel, val: dispatchToSMSMessage, children: [], isIgnoreAcross: false, hint: '' }; var _properties = { id: {value: _ctrlId}, showAsDropdown: {value: false}, label: {eng: _ctrlLabel, value: {eng: _ctrlLabel}}, hint: {eng: _ctrlLabel, value: {eng: ""}}, relevanceconds: {value: []}, skipconds: {}, defaultValue: {}, readOnly: {}, name: {}, options: { name: "Options", type: "optionsEditor", required: true, summary: false, value: '' } }; $('#formview_templates .' + ctrlType).first() .clone() .attr('id', 'fvCtrlID_' + _ctrlId) .addClass(ctrlType) .addClass('fvControl') .addClass('fvCtrlID_' + _ctrlId) .addClass('fvCtrlName_' + _ctrlName) .odkControlFV(ctrlType, null, _properties, _ctrlPropreties) .appendTo(tableSMS.find('.sendToSMSMessageControl')); $('.inpCtrlID_' + _ctrlId).attr('placeholder','').attr('maxlength', '290').css('overflow-y', 'scroll'); loadDisToSMSSetting(tableSMS, _ctrlPropreties); //$('.fvCtrlID_' + _ctrlId).css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); if(fillAndSendInfo){ // CO-2223 // do nothing } else if(viewDataFillAndSend) { $('.inpCtrlID_dispatchTo input.radio_Email').prop('checked',true); //show Fill and Send button $('#fvmain_menu li.liFvFillAndSend').css(CONST_CSS_KEY_DISPLAY,'block'); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY, ''); } else { $('.fvCtrlID_dispatchEmailOfSendTo').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); } // $('.inpCtrlID_dispatchSubjectEmailOfSendTo').prop('disabled', true); // $('.inpCtrlID_dispatchMessageEmailOfSendTo').prop('disabled', true); } catch (e) { } } } var waDisPlus = isWADispatchPlus(); if(waDisPlus){ fvDataNS.isPlusLoading = true; // CO-4608 if(!disPlusContainerFlg){ // if not exist => generate html appendDispatchPlusUnitsNew(fvWorkspace); } if(getParent().dispatchTab == true){ initEmailButton(); } } else{ initWebAppDispatch(fvWorkspace); initEmailButton(); } /*if(fvDataNS.currentForm.editRecordKey && fvDataNS.currentForm.editRecordKey != ''){ fvDataNS.openFormRunning = true; setDontCallTrigger(); loadRecurseFV(fvWorkspace, formObj.controls, '', rootInputProperties); fvDataNS.dontCallTrigger = false; fvDataNS.openFormRunning = false; }else{ fvDataNS.openFormRunning = false; loadRecurseFV(fvWorkspace, formObj.controls, '', rootInputProperties); }*/ loadRecurseFV(fvWorkspace, formObj.controls, '', rootInputProperties); // CO-1125: Calculate root data control width var cssMarginLeft = 0; if(true == getParent().dispatchFlg || isDispatchPlus || canSchedule){ cssMarginLeft = 10; } var rootWidth = fvDataNS.ctrlWidth; if(rootDataCtrlWidth > 0){ var scrollBarWidth = 18; if(navigator.userAgent.indexOf('Mozilla') >= 0) { scrollBarWidth = 24; } rootWidth = rootDataCtrlWidth - scrollBarWidth - cssMarginLeft; // CO-1930: Scroll Bar Affecting Field Screen % } if(webAppDispatch || isDispatchPlus || canSchedule){ $('div.fvCtrlID_dispatchMobileLink').css('width', rootWidth + "px"); //$('div.waDisTable').not('.schedule,.project,.form').css('width', rootWidth + "px"); $('div.waDisTable').not('.schedule,.repeat,.scheduleAction,.project,.form').css({'margin-left': cssMarginLeft + 'px'}); } // CO-1174: Extra horizontal scrollbar in dispatch add/edit //$('div.waDisSendType').css('width', rootWidth + "px"); addToCtrlIdRefForRelevanceInQueue(fvDataNS.relUndQueue); if(!fvDataNS.incomplete && !(fvDataNS.currentForm.editRecordKey && fvDataNS.currentForm.editRecordKey != '')){ setDontCallTrigger(); notIncompleteInit(fvDataNS.inputData); resetDontCallTrigger(); }else{ if(fvDataNS.currentForm.editRecordKey && fvDataNS.currentForm.editRecordKey != ''){ setDontCallTrigger(); notIncompleteEditRecordInit(fvDataNS.inputData); resetDontCallTrigger(); } fvDataNS.groupChangeList = []; showHidePageBreak(); } if(isVersion5_0() && !jQuery.isEmptyObject(fvDataNS.scoreData)){ var inputScoreSummaryCtrl = fvWorkspace.find('.inputScoreSummary.forAllCategory'); if(inputScoreSummaryCtrl.length <= 0){ if(isVersion(VERSION_SUMMARY_FOR_CATEGORY) && fvWorkspace.find('.inputScoreSummary').length > 0){ $('.formView .scoreSummary').removeClass(CONST_CSS_CLASS_HIDE_SESSION).addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ if(parseFloat(fvDataNS.currentForm.formVersion) >= 3.0){ $('.formView .scoreSummary').remove(); }else{ var fvPageWorkspace = fvWorkspace.find('.fvPageWorkspace'); if(fvPageWorkspace.length > 0){ $(fvPageWorkspace[fvPageWorkspace.length - 1]).append($('.formView .scoreSummary')); }else{ fvWorkspace.append($('.formView .scoreSummary')); } } } }else{ //$(inputScoreSummaryCtrl).replaceWith($('.formView .scoreSummary')); $(inputScoreSummaryCtrl).addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $('.formView .scoreSummary').insertAfter($(inputScoreSummaryCtrl)); } $('.formView .scoreSummary').removeClass('scoreSummaryLoadding'); }else{ $('.formView .scoreSummary').remove(); } loadCounter(); initCtrlWidth(); /*fvWorkspace.append($('.fvfooterForWA #fvfooter').clone());*/ defineNewFunction(); //var coreQuestionMap = getScoreQuestionMap(fvDataNS.inputData); $('.fvWorkspaceScrollArea').scrollTop(0); fvDataNS.dontCallAutoStampTrigger = false; $('.formView').find('.groupFooterButton').trigger('showHideAddBtn'); try { if(isWebAppDispatch()){ // 21820 //$('.ctrlHref .controlLabel .required').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); $('.ctrlHref .controlInfMsg').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); //$('.hideOnMobileApp').css(CONST_CSS_KEY_DISPLAY,'block'); } } catch (e) { } // check if Plus record is sent var plusReadOnlyFlg = false; if(waDisPlus && fvDataNS.currentForm.editRecordData != undefined && !isDispatchCopying()){ // CO-4421 // true != getParent().plusRowCopy var curStatus = ''; if(undefined != fvDataNS.currentForm.editRecordData['@Status']){ curStatus = fvDataNS.currentForm.editRecordData['@Status'].value; if('Scheduled' == curStatus){ // CO-1857 $('#fvmain_menu .liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); } else if('Sent' == curStatus || 'Emailed' == curStatus || CONST_DISPATCH_STATUS_SMS == curStatus){ $('#fvmain_menu .liFvSaveLink').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#fvmain_menu .liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); plusReadOnlyFlg = true; } /*else if('Emailed' == curStatus || 'Scheduled' == curStatus){ $('#fvmain_menu .liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); }*/ } else{ $('#fvmain_menu .liFvSaveLink').css(CONST_CSS_KEY_DISPLAY, ''); $('#fvmain_menu .liFvSaveAndSend').css(CONST_CSS_KEY_DISPLAY, ''); $('.inpCtrlID_dispatchUTime').prop('disabled', false); $('.inpCtrlID_dispatchUTime2').prop('disabled', false); $('.inpCtrlID_dispatchUTime3').prop('disabled', false); // CO-3478: Allow edit of dispatch scheduler fields $('.inpCtrlID_dispatchMobileGroup').prop('disabled', false); $('.inpCtrlID_dispatchUID').prop('disabled', false); $('.inpCtrlID_dispatchUName').prop('disabled', false); $('.inpCtrlID_dispatchUDate').prop('disabled', false); $('.inpCtrlID_dispatchUDura').prop('disabled', false); $('.inpCtrlID_dispatchUDuraMin').prop('disabled', false); } if(!(getParent().dispatchTab == true)){ $('#fvmain_menu .liFvEmail').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); } } if(isWebAppDataview() && fvDataNS && fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ $('#fvmain_menu li.liFvSaveLink').removeClass('dispatchFormView'); } // CO-1867 var cssDispatchSubmit = CONST_VALUE_NONE; try{ // CO-4421 ??? if(isDispatchSubmitVersion() && '' == getParent().dispatchCOPYId // Not dispatch copy && fvDataNS.currentForm.editRecordData != undefined && 'Pending' === fvDataNS.currentForm.editRecordData['@Status'].value){ cssDispatchSubmit = ''; } }catch(e){} $('#fvmain_menu .liFvSubmit').css(CONST_CSS_KEY_DISPLAY, cssDispatchSubmit); // Refresh layout after finishing load GUI WebApps fvDataNS.isRefreshLayout = true; reArrangeLayoutOfChooseOneWithShadingWALastAction(); if(formObj.controls && formObj.controls.length > 0 && formObj.controls[0].type == 'inputPageBreak'){ $('#pageMenuIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $('.liFvPageIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION); // CO-2051 hide page icon $('.pageMenuIconText').removeClass(CONST_CSS_CLASS_HIDE_SESSION); var pages = $('.fvWorkspaceScrollArea .inputPageBreak').length; /*var hidePage = ($('.fvWorkspaceScrollArea .inputPageBreak.hideOnMobileApp').length + $('.fvWorkspaceScrollArea .inputPageBreak.hideSession').length);*/ var hidePage = $('.fvWorkspaceScrollArea .inputPageBreak.' + CONST_CSS_CLASS_HIDE_SESSION).length; var hideOnMobileAppPage = $('.fvWorkspaceScrollArea .inputPageBreak.hideOnMobileApp').length; var hideOnMobileAppAndRelevancePage = $('.fvWorkspaceScrollArea .inputPageBreak.hideOnMobileApp.' + CONST_CSS_CLASS_HIDE_SESSION).length; var hidePageCount = hidePage + hideOnMobileAppPage - hideOnMobileAppAndRelevancePage; $('.pageMenuIconText').empty().append('Pages(' + (pages - hidePageCount) + ')'); if((pages - hidePageCount) <= 1 ){ $('#pageMenuIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.liFvPageIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION); // CO-2051 hide page icon $('.pageMenuIconText').addClass(CONST_CSS_CLASS_HIDE_SESSION); } hideShowDetailBtnClick($('.page-active')); }else{ $('#pageMenuIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.liFvPageIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION); // CO-2051 hide page icon $('.pageMenuIconText').addClass(CONST_CSS_CLASS_HIDE_SESSION); } // CO-552: Encryption var disableCtrls = false; try { if(true == authNS.currentUser.isDisplayEncryptedFormat && fvDataNS.currentForm.editRecordKey != undefined && fvDataNS.currentForm.editRecordKey != '' //&& true != getParent().plusRowCopy && !isDispatchCopying() ){ // CO-4421 disableCtrls = true; plusReadOnlyFlg = true; } } catch (e) {} try { if(isDispatchCopying()){ // CO-4421 // true == getParent().plusRowCopy // do nothing } else if (waDisPlus || (disableCtrls && 'true' != fSecureFlg)) { // Process mode OnlyView in WebAppGUI processModeOnlyView4DPWebAppGUI(plusReadOnlyFlg); } } catch (e) {} try{ if(true == hasEncryptField){ // $('#ctrlDataId_dispatchTo .email_sendTo').css('display', 'none'); $('.inpCtrlID_dispatchMessageEmailOfSendTo').val(lbl_secure_email_body_default); } else{ // $('#ctrlDataId_dispatchTo .email_sendTo').css('display', ''); } } catch(e){} // CO-1132: Show/hide encryption banner message when form locked // CO-1714: Forward Secure if(disableCtrls && 'true' != fSecureFlg){ $('#encryptBanner').attr('style', 'width:' + rootWidth + 'px'); $('.fvWorkspaceScrollArea').attr('style', 'top: 3em;'); // padding: 10px; try{ // Check for Webclient case if(authNS.currentUser.MobileKey != undefined && authNS.currentUser.MobileKey != '' && authNS.currentUser.MobileKey != 'All'){ $('#encryptBanner').css('margin-top', '3px'); } } catch(e){} } else{ $('#encryptBanner').attr('style', 'display: none;'); $('.fvWorkspaceScrollArea').attr('style', ''); } // CO-2223 if(fillAndSendInfo){ $('.fvCtrlID_dispatchEmailOfSendTo').css(CONST_CSS_KEY_DISPLAY,''); $('.sentToEmailBar').css(CONST_CSS_KEY_DISPLAY,''); $('.inpCtrlID_dispatchEmailOfSendTo').prop('disabled', true); $('.inpCtrlID_dispatchSubjectEmailOfSendTo').prop('disabled', true); $('.inpCtrlID_dispatchMessageEmailOfSendTo').prop('disabled', true); } try{ // CO-4372: init geofence api if(geofencesMap != undefined && Object.keys(geofencesMap).length > 0){ //if(document.getElementById('maps_javaScript_api') == undefined){ // script not exists // loadGoogleMapScript(); //} else{ initGeofencesFirstValue(); //} } } catch(e){} try{ // Check browser Geolocation support if(fvDataNS.googleRouteMap){ if (navigator.geolocation) { var geoSuccess = function(position) { console.log('location: ' + position.coords.latitude + '/' + position.coords.longitude); fvDataNS.geolocation = position; }; navigator.geolocation.getCurrentPosition(geoSuccess); } } } catch(e){} // CO-3355: new setting: OnDevice setAutoStampForAll(undefined, undefined, '8'); if(!fvDataNS.currentForm.editRecordData){ setAutoStampForAll(undefined, undefined, '2'); } waitForDataLoading(false); } /* hqkhanh fix I want this message removed tonight. I get this message and the form loads two seconds after. if(!isTabletPreview){ if(fvDataNS.currentForm.LookupTables != undefined){ var strLookups = generateLookupList( fvDataNS.currentForm.controls , fvDataNS.currentForm.LookupTables); $.ajax({ url: '/client/lookupXml?ct=count&isUsingGZip=true' + '&id=' + encodeURIComponent(GZip(strLookups)), data : {}, dataType: 'json', type: 'Get', cache: false, async: false, complete: function() { }, success: function(response, status) { try { if(isWebAppDispatch() && waLookupDS != undefined){ loadFormData(formObj, rootInputProperties); return; } } catch (e) { } if(getLookupsRecordCount(response) >= MAX_LOOKUP_RECORD_COUNT_WARNING){ $.alerts.okButton = 'Load'; jConfirm(msg_max_lookup_record_count_warning,lbl_warning,function(result){ $.alerts.okButton = CUSTOM_OK_BUTTON_LABEL; if(!result){ if(!isWebClient){ parent.$.fancybox.close(); }else{ showMainScreen(true); } return; } waitForDataLoading(true); setTimeout(function(){ loadFormData(formObj, rootInputProperties); }, 500); }); }else{ loadFormData(formObj, rootInputProperties); } }, error: function(request, status, error) { loadFormData(formObj, rootInputProperties); } }); if($('.page-active').length > 0){ hideShowDetailBtnClick($('.page-active'), true); } return; } }*/ loadFormData(formObj, rootInputProperties); /* hqkhanh fix bug 0025355: Preview - Auto-Stamp not work when page is opend by open form in case use "Trigger when a specified page is displayed" */ if($('.page-active').length > 0){ hideShowDetailBtnClick($('.page-active'), true); } //if record save by dispatch to email, check to email if(isWebAppDispatch() && fvDataNS.currentForm.editRecordKey && fvDataNS.currentForm.editRecordKey != '' && typeof formObj.editRecordData != 'undefined' && typeof formObj.editRecordData["@SubmitByFun"] != 'undefined' && formObj.editRecordData["@SubmitByFun"].value == 'DispatchToEmail') { //setTimeout(function(){ $('.inpCtrlID_dispatchTo input.radio_Email').click(); //}, 1000); if(typeof formObj.editRecordData["@FillAndSendEmail"] != 'undefined' && typeof formObj.editRecordData["@FillAndSendEmail"].value != 'undefined') { $('.inpCtrlID_dispatchEmailOfSendTo').val(formObj.editRecordData["@FillAndSendEmail"].value); } if(typeof formObj.editRecordData["@FillAndSendEmailSubject"] != 'undefined' && typeof formObj.editRecordData["@FillAndSendEmailSubject"].value != 'undefined') { $('.inpCtrlID_dispatchSubjectEmailOfSendTo').val(formObj.editRecordData["@FillAndSendEmailSubject"].value); } if(typeof formObj.editRecordData["@FillAndSendMessage"] != 'undefined' && typeof formObj.editRecordData["@FillAndSendMessage"].value != 'undefined') { $('.inpCtrlID_dispatchMessageEmailOfSendTo').val(formObj.editRecordData["@FillAndSendMessage"].value); } } if(isWebAppDispatch() && fvDataNS.currentForm.editRecordKey && fvDataNS.currentForm.editRecordKey != '' && typeof formObj.editRecordData != 'undefined' && typeof formObj.editRecordData["@SubmitByFun"] != 'undefined' && formObj.editRecordData["@SubmitByFun"].value == DISPATCH_TO_SMS_SUBMIT_BY_FUN) { $('.inpCtrlID_dispatchTo input.radio_SMS').click(); if(typeof formObj.editRecordData[DISPATCH_TO_SMS_NUMBER] != 'undefined' && typeof formObj.editRecordData[DISPATCH_TO_SMS_NUMBER].value != 'undefined') { $('.inpCtrlID_dispatchSMSOfSendTo').val(formObj.editRecordData[DISPATCH_TO_SMS_NUMBER].value); } if(typeof formObj.editRecordData[DISPATCH_TO_SMS_MESSAGE] != 'undefined' && typeof formObj.editRecordData[DISPATCH_TO_SMS_MESSAGE].value != 'undefined') { $('.inpCtrlID_dispatchMessageSMSOfSendTo').val(formObj.editRecordData[DISPATCH_TO_SMS_MESSAGE].value); } } $('#fvCtrlID_dispatchEmailOfSendTo, #fvCtrlID_dispatchSubjectEmailOfSendTo' + ', #fvCtrlID_dispatchMessageEmailOfSendTo').off('keydown').keydown(function(objEvent){ var keyCode = objEvent.keyCode || objEvent.which; if (keyCode == 9 || keyCode == 13) { //tab pressed // var ret = toNextCtrl(this, objEvent, ctrlPropreties); // objEvent.preventDefault(); // return ret; if($(this).attr('id') == 'fvCtrlID_dispatchEmailOfSendTo') { if(keyCode == 9) { $('#fvCtrlID_dispatchSubjectEmailOfSendTo').focus(); } else if(keyCode == 13) { objEvent.preventDefault(); $('#fvCtrlID_dispatchSubjectEmailOfSendTo textarea').focus(); } } else if($(this).attr('id') == 'fvCtrlID_dispatchSubjectEmailOfSendTo') { if(keyCode == 9) { $('#fvCtrlID_dispatchMessageEmailOfSendTo').focus(); } else if(keyCode == 13) { objEvent.preventDefault(); $('#fvCtrlID_dispatchMessageEmailOfSendTo textarea').focus(); } } else if(keyCode != 13) { $('#fvCtrlID_1').focus(); } } }); $('#fvCtrlID_dispatchSMSOfSendTo, #fvCtrlID_dispatchMessageSMSOfSendTo').off('keydown').keydown(function(objEvent){ var keyCode = objEvent.keyCode || objEvent.which; if (keyCode == 9 || keyCode == 13) { //tab pressed if($(this).attr('id') == 'fvCtrlID_dispatchSMSOfSendTo') { if(keyCode == 9) { $('#fvCtrlID_dispatchMessageSMSOfSendTo').focus(); } else if(keyCode == 13) { objEvent.preventDefault(); $('#fvCtrlID_dispatchMessageSMSOfSendTo textarea').focus(); } } else if(keyCode != 13) { $('#fvCtrlID_1').focus(); } } }); }; // massages the output JSON into a structure representing an XForm var controlTypes = { inputText: 'input', inputNumeric: 'input', inputTrends: 'input', inputDate: 'input', inputSelectOne: 'select1', inputScoreOne: 'select1', inputSelectMany: 'select', inputLocation: 'input', inputImage: 'upload', inputAudio: 'upload', inputVideo: 'upload', inputMedia: 'upload', inputSketch: 'upload', inputSignature: 'upload', inputDraw: 'upload', inputBarcode: 'input', inputNFC: 'input', inputForward: 'input', inputSecureForward: 'input', inputCounter: 'input', //inputRIF: 'input' inputPageBreak: 'input', inputLabel: 'input', inputScoreSummary: 'input', inputNumbering: 'input', inputAction: 'input', inputPayment: 'input', inputNewPayment: 'input', inputInstruction: 'input', inputEmailReport: 'input', inputFaxWidget: 'input', inputSecureEmailReport: 'input', inputApproval: 'input', inputCalculate: 'input', inputLookup: 'input', inputLFBluetooth: 'input', inputFacingTable: 'input', inputLookupMulti: 'input', inputSaveAndSend: 'input', inputGeofence: 'input', inputShipping: 'input', inputImageViewer: 'upload', inputAttachment: 'upload' }; /** * convert MM/dd/yyyyy to yyyy-mm-dd */ var mmddyyyyToyyyymmdd = function(mmddyyyy){ var dateElement = mmddyyyy.split('/'); return dateElement[2] + '-' + dateElement[0] + '-' + dateElement[1]; }; var toJavaRosaFormat = function(strValue, type){ if(type == CONST_VALUE_TIME){ if(strValue.indexOf('/')>=0){ }else{ strValue = '01/01/2011 ' + strValue; } } var date = new Date(strValue); if(type == CONST_VALUE_TIME){ var timeStr = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); if(timeStr == '0:0:0' && date.getDate()>1){ timeStr = '24:0:0' } return timeStr; }else if(type == CONST_VALUE_DATE_SPACE_TIME){ return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + 'T' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); }else{ return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate(); } }; var parseControl = function(control, xpath, relpath, instance, translations, model, body, relevance, root, nextCtrlName, parentType, objParent) { /*if(control.hideInPreview){ return; }*/ // groups are special if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')) { if ((control.loop === undefined) || (control.loop === '') || (control.loop === '0')){ control.loop = '10'; } var instanceTag = { name: control.name, attrs: { 'jr:template': "" }, children: [] }; if ((control.loop !== undefined) && (control.loop !== '') && (control.loop !== '0')) { var repeatCount = { name: 'repeat_count', val: toLooupCountValue(control.loop) }; //repeatCount.children = [control.loop]; instanceTag.children.push(repeatCount); }; instance.children.push(instanceTag); var bodyTag = { name: CONST_CTRL_TYPE_GROUP, children: [] }; body.children.push(bodyTag); if ((control.label !== undefined) && (control.label !== '')) { bodyTag.children.push({ name: 'label', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":label')" } }); //addTranslation(control.label, xpath + control.name + ':label', translations); // Check if we need parse from SPACE into   var customControlLabel = new Object(); if (control.label.eng !== undefined) { customControlLabel.eng = control.label.eng; } else { customControlLabel.eng = ''; } customControlLabel = applyCheckingCustomControlLabel4XML(customControlLabel, control, objParent); addTranslation(customControlLabel, xpath + control.name + ':label', translations); } // Repeat Transition Text if ((control.repeatTransitionText !== undefined) && (control.repeatTransitionText !== '')) { bodyTag.children.push({ name: 'repeatTransitionText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":repeatTransitionText')" } }); addTranslation(control.repeatTransitionText, xpath + control.name + ':repeatTransitionText', translations); } if ((control.loop !== undefined) && (control.loop !== '') && (control.loop !== '0')) { // binding var binding = { name: 'bind', attrs: { 'nodeset': xpath + control.name } } if(isVersion(VERSION_TOOL_NEW_JUSTIFICATION)){ var justification = getJustification(control); if(justification != ''){ binding.attrs.justification = justification; } } model.children.push(binding); var bindingRepeatCount = { name: 'bind', attrs: { 'nodeset': xpath + control.name + '/repeat_count', 'type': 'int' } } model.children.push(bindingRepeatCount); if(isVersion(VERSION_REMOVE_SPACE)) { if (control.removeSpaceAbove !== undefined && control.removeSpaceAbove === true){ binding.attrs.removeSpaceAbove = CONST_XML_FUNCTION_TRUE; } if (control.removeSpaceBelow !== undefined && control.removeSpaceBelow === true){ binding.attrs.removeSpaceBelow = CONST_XML_FUNCTION_TRUE; } } // PCA-646: Email widget > Send report as a web link (for large pdfs) // Apply link of Convert PDF file with size > 10MB if (isVersion(VERSION_LINK_CONVERT_PDF_OVER_LIMIT_SIZE)) { if (control.sendReportAsWebLink !== undefined && control.sendReportAsWebLink === true){ binding.attrs.removeSpaceAbove = CONST_XML_FUNCTION_TRUE; } else { binding.attrs.removeSpaceAbove = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_REPEAT_TYPE_FUNCTION)) { if (control.repeatableType !== undefined){ binding.attrs.repeatableType = control.repeatableType; } } if(isVersion5_0()){ if(control.isVariableRepeats){ binding.attrs.isVariableRepeats = CONST_XML_FUNCTION_TRUE; if(control.isAllRepRequired){ binding.attrs.isAllRepRequired = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isAllRepRequired = CONST_XML_FUNCTION_FALSE; } if(control.isRepCountDisplay){ binding.attrs.isRepCountDisplay = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isRepCountDisplay = CONST_XML_FUNCTION_FALSE; } if(isVersion(VERSION_CLEAR_REPEAT_WHEN_CHANGE)){ if(control.isDeleteWhenVarChange){ binding.attrs.isDeleteWhenVarChange = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isDeleteWhenVarChange = CONST_XML_FUNCTION_FALSE; } } // add calculate attribute var itemPath = getControlXPath(root, "/data/", control.repValSource); bindingRepeatCount.attrs.calculate = '(' + itemPath + ')'; }else{ binding.attrs.isVariableRepeats = CONST_XML_FUNCTION_FALSE; } // CO-1322: set HeaderWith value for ctrlProperties if(control.isReplaceRepeatableHeader){ binding.attrs.isReplaceRepeatableHeader = CONST_XML_FUNCTION_TRUE; binding.attrs.replaceRepeatableHeaderWith = getControlXPath(root, "/data/", control.replaceRepeatableHeaderWith);; }else{ binding.attrs.isReplaceRepeatableHeader = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_AUTO_COLLAPSE_REPEAT)){ // CO-2745 Auto collapse repeat - new setting if(control.isAutoCollapseRepeat){ binding.attrs.isAutoCollapseRepeat = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isAutoCollapseRepeat = CONST_XML_FUNCTION_FALSE; } } if (isVersion(VERSION_REQUIRED_REPEAT) && control.requiredRows !== undefined && control.requiredRows === true){ binding.attrs.requiredRows = CONST_XML_FUNCTION_TRUE; if(control.requiredOptionsGroup && !jQuery.isEmptyObject(control.requiredOptionsGroup)){ var requiredRowFields = ''; var tmp = ''; _.each(control.requiredOptionsGroup, function(item, key){ if(item == true){ var fieldPath = getControlXPath(root, "/data/", key); requiredRowFields += tmp + fieldPath; if(tmp == '') { tmp = ','; } } }); binding.attrs.requiredRowFields = requiredRowFields; } } if(isVersion(VERSION_READ_ONLY_GROUP)){ // CO-3672 Read Only - Repeatable if (control.readOnly === true){ binding.attrs.isReadonlyAddNew = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_REPEAT_ALLOW_DELETE)){ if(control.isAllowDelete == false){ binding.attrs.isAllowDelete = CONST_XML_FUNCTION_FALSE; } } var repeatBodyTag = { name: 'repeat', attrs: { 'nodeset': xpath + control.name, 'jr:count': xpath + control.name + '/repeat_count' }, children: [] }; bodyTag.children.push(repeatBodyTag); _.each(control.children, function(child) { child.parentCtrlType = control.type; if(isIgnoreRelevance(control.parentCtrlType) && child.isShowRelevanceCondition == true){ child.isShowRelevanceCondition = false; } if(isIgnoreSkip(control.type)){ child.isShowSkipCondition = false; } var nextCtrlInd = control.children.indexOf(child); nextCtrlInd += 1; if((child.type == CONST_CTRL_TYPE_GROUP || (child.type == 'ctrlBreakPointData') || child.type == CONST_CTRL_TYPE_CTRLSCORETABLE) && nextCtrlInd < control.children.length){ var nextCtrlNameNew = CONST_JUMP_EOF_TEXT; nextCtrlNameNew = control.children[nextCtrlInd].name; parseControl(child, xpath + control.name + '/', '', instanceTag, translations, model, repeatBodyTag, relevance, root, nextCtrlNameNew, control.type, control); }else{ parseControl(child, xpath + control.name + '/', '', instanceTag, translations, model, repeatBodyTag, relevance, root, nextCtrlName, control.type, control); } }); }else{ _.each(control.children, function(child) { child.parentCtrlType = control.type; if(isIgnoreRelevance(control.parentCtrlType) && child.isShowRelevanceCondition == true){ child.isShowRelevanceCondition = false; } if(isIgnoreSkip(control.type)){ child.isShowSkipCondition = false; } var nextCtrlInd = control.children.indexOf(child); nextCtrlInd += 1; if((child.type == CONST_CTRL_TYPE_GROUP || (child.type == 'ctrlBreakPointData') || child.type == CONST_CTRL_TYPE_CTRLSCORETABLE) && nextCtrlInd < control.children.length){ var nextCtrlNameNew = CONST_JUMP_EOF_TEXT; nextCtrlNameNew = control.children[nextCtrlInd].name; parseControl(child, xpath + control.name + '/', relpath + control.name + '/', instanceTag, translations, model, bodyTag, relevance, root, nextCtrlNameNew, control.type, control); }else{ parseControl(child, xpath + control.name + '/', relpath + control.name + '/', instanceTag, translations, model, bodyTag, relevance, root, nextCtrlName, control.type, control); } }); } if(isVersion(VERSION_PORTAL_SHADING)){ if(control.apperance == 'Custom'){ if(control.shadedHeadings){ if(isVersion(VERSION_APPEARANCE_ACTIVE_TEXT)){ if(control.shadedHeadings.isShadedHeadings){ binding.attrs.customShading = 'true|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading + '|' + control.shadedHeadings.activeTextColor; }else{ binding.attrs.customShading = 'false|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading + '|' + control.shadedHeadings.activeTextColor; } }else{ if(control.shadedHeadings.isShadedHeadings){ binding.attrs.customShading = 'true|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading; }else{ binding.attrs.customShading = 'false|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading; } } } if(control.answerColor){ if(control.answerColor.isAnswerColor){ binding.attrs.answerColor = control.answerColor.answerTextColor; if(isVersion(VERSION_ANSWER_BACKGROUND_COLOR)){ if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLTABLE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLSCHEDULE){ binding.attrs.answerBGColor = control.answerColor.answerBGColor; } } } } if(control.shadedRow){ if(control.type !== CONST_CTRL_TYPE_CTRLTABLE && control.type !== CONST_CTRL_TYPE_CTRLSCHEDULE && control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && control.shadedKind && (control.shadedKind == '2' || control.shadedKind == '3')){ }else{ if(control.shadedRow.isShadedRow){ binding.attrs.customRow = 'true|' + control.shadedRow.rowColor + '|' + control.shadedRow.rowTextColor; }else{ binding.attrs.customRow = 'false|' + control.shadedRow.rowColor + '|' + control.shadedRow.rowTextColor; } } } if(control.shadedButton){ if(control.shadedButton.isShadedButton){ binding.attrs.customButtonShading = 'true|' + control.shadedButton.btnSheadingColor + '|' + control.shadedButton.btnTextColor + '|' + control.shadedButton.activeBtnTextColor + '|' + control.shadedButton.btnBorderColor + '|' + control.shadedButton.btnRoundedCorners; }else{ binding.attrs.customButtonShading = 'false|' + control.shadedButton.btnSheadingColor + '|' + control.shadedButton.btnTextColor + '|' + control.shadedButton.activeBtnTextColor + '|' + control.shadedButton.btnBorderColor + '|' + control.shadedButton.btnRoundedCorners; } } } } if(isVersion(VERSION_REMOVE_ANSW_BORDER) && control.apperance == 'Custom'){ if(control.removeAnswerBorder){ binding.attrs.removeAnswerBorder = CONST_XML_FUNCTION_TRUE; } } return; }else if (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID || control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY) { // binding var binding = { name: 'bind', attrs: { 'nodeset': xpath + control.name } } if(isVersion(VERSION_TOOL_NEW_JUSTIFICATION)){ var justification = getJustification(control); if(justification != ''){ binding.attrs.justification = justification; } } model.children.push(binding); if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ control.loop = 1; }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(isVersion(VERSION_HIDE_4_GRID)){ createXmlHideProperty4Mobile(root, control, binding, bodyTag); } }else{ if ((control.loop === undefined) || (control.loop === '') || (control.loop === '0')){ control.loop = '10'; } } var bodyTag; if(control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ var instanceTag = { name: control.name, attrs: { 'jr:template': "" }, children: [] }; if ((control.loop !== undefined) && (control.loop !== '') && (control.loop !== '0') && (control.type != CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY)) { var repeatCount = { name: 'repeat_count', val: toLooupCountValue(control.loop) }; if(control.type == CONST_CTRL_TYPE_CTRLGRID){ repeatCount.val = 1; } //repeatCount.children = [control.loop]; instanceTag.children.push(repeatCount); }; instance.children.push(instanceTag); bodyTag = { name: 'table', children: [] }; }else{ var instanceTag = { name: control.name }; instance.children.push(instanceTag); bodyTag = { name: 'input', attrs: { 'ref': control.destination || (relpath + control.name) }, children: [] }; } body.children.push(bodyTag); if (control.type == CONST_CTRL_TYPE_CTRLPOD){ if ((control.scannedNotFoundMsg !== undefined) && (control.scannedNotFoundMsg !== '')) { bodyTag.children.push({ name: 'scannedNotFoundMsg', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":scannedNotFoundMsg')" } }); addTranslation(control.scannedNotFoundMsg, xpath + control.name + ':scannedNotFoundMsg', translations); } bodyTag.children.push({ name: 'manifest', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":manifest')" } }); var manifestValue = ''; switch(control.podDataSource){ case 'inter form': manifestValue = getControlXPath(root, "/data/", control.podInterForm); addTranslation({'eng': manifestValue}, xpath + control.name + ':manifest', translations); break; case 'form': manifestValue = control.podDSProject; manifestValue += '|' + control.podDSForm; manifestValue += '|' + control.podDSID; manifestValue += '|' + control.podDSPOD; addTranslation({'eng': manifestValue}, xpath + control.name + ':manifest', translations); odkmaker.data.lookupTablesArr[manifestValue] = manifestValue; break; case CONST_VALUE_NONE: break; default: //manifest manifestValue = CONST_VALUE_TRUE_STR; manifestValue += '|' + control.manifest.withDate; manifestValue += '|' + control.manifest.prefix; addTranslation({'eng': manifestValue}, xpath + control.name + ':manifest', translations); odkmaker.data.lookupTablesArr[manifestValue] = manifestValue; } } if ((control.label !== undefined) && (control.label !== '')) { bodyTag.children.push({ name: 'label', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":label')" } }); //addTranslation(control.label, xpath + control.name + ':label', translations); // Check if we need parse from SPACE into   var customControlLabel = new Object(); if (control.label.eng !== undefined) { customControlLabel.eng = control.label.eng; } else { customControlLabel.eng = ''; } customControlLabel = applyCheckingCustomControlLabel4XML(customControlLabel, control, objParent); addTranslation(customControlLabel, xpath + control.name + ':label', translations); } if ((control.loop !== undefined) && (control.loop !== '') && (control.loop !== '0') || control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY) { if(control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ binding.attrs.type = CONST_REPEATABLE_SUMMARY; var fieldPath = getControlXPath(root, "/data/", control.repeatable); binding.attrs.repeatable = fieldPath; var columns = ''; var tmp = ''; _.each(control.columns, function(item, key){ var fieldPath = getControlXPath(root, "/data/", item.text.val); columns += tmp + fieldPath; if(tmp == '') { tmp = ','; } }); binding.attrs.repeatableSummaryColumns = columns; if(control.hideOnRetrieve === true){ binding.attrs.hideOnRetrieve = CONST_XML_FUNCTION_TRUE; } if (control.hideInMobile !== undefined && control.hideInMobile === true){ binding.attrs.hideinmobile = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_HIDE_PDF_WEB)){ if(control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } }else{ if(control.hideWebAppGrp == true && control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } } if (control.hideForwarded !== undefined && control.hideForwarded === true){ binding.attrs.hideForwarded = CONST_XML_FUNCTION_TRUE; } }else{ binding.attrs.type = 'table'; } if(isVersion(VERSION_REMOVE_SPACE)) { if (control.removeSpaceAbove !== undefined && control.removeSpaceAbove === true){ binding.attrs.removeSpaceAbove = CONST_XML_FUNCTION_TRUE; } if (control.removeSpaceBelow !== undefined && control.removeSpaceBelow === true){ binding.attrs.removeSpaceBelow = CONST_XML_FUNCTION_TRUE; } } if (control.requiredRows !== undefined && control.requiredRows === true){ binding.attrs.requiredRows = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_TABLE_REQUIRED_ROW_OPTION) && control.requiredOptionsGroup && !jQuery.isEmptyObject(control.requiredOptionsGroup)){ var requiredRowFields = ''; var tmp = ''; _.each(control.requiredOptionsGroup, function(item, key){ if(item == true){ var fieldPath = getControlXPath(root, "/data/", key); requiredRowFields += tmp + fieldPath; if(tmp == '') { tmp = ','; } } }); binding.attrs.requiredRowFields = requiredRowFields; } } if(isVersion(VERSION_TABLE_AUTO_ADD_ROW)){ if (control.autoAddNewRow === true){ binding.attrs.autoAddNewRow = CONST_XML_FUNCTION_TRUE; if(control.maxLoop != undefined && true == control.maxLoop.useMaxLoop){ // CO-4565 var maxLoop = control.maxLoop.val; if(maxLoop == undefined || maxLoop == ''){ maxLoop = '0'; } binding.attrs.maxRowNum = ('' + maxLoop).replace('&&&', ''); // CO-4978: ZD #97668: Form publishing } } if (control.allowDeleteRow === true){ binding.attrs.allowDeleteRow = CONST_XML_FUNCTION_TRUE; } } if(control.usechecklist === true){ if(control.children[0].type != CONST_CTRL_TYPE_INPUTLOOKUP && control.children[0].type != CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ control.usechecklist = false; } } if (!control.isVariableNumberRow && control.usechecklist !== undefined && control.usechecklist === true){ binding.attrs.usechecklist = CONST_XML_FUNCTION_TRUE; processChecklistFilters(binding, control, root); if (control.hideRows !== undefined && control.hideRows === true){ binding.attrs.hideRows = CONST_XML_FUNCTION_TRUE; if (control.hideFlag !== undefined && jQuery.trim(control.hideFlag.eng) !== ''){ binding.attrs.hideFlag = control.hideFlag.eng; } } if (control.jumpOverChkLst !== undefined && control.jumpOverChkLst === true && isVersion3_6()){ binding.attrs.jumpOverChkLst = CONST_XML_FUNCTION_TRUE; } if (control.isShowAllWhenFilterQuesBlank !== undefined && control.isShowAllWhenFilterQuesBlank === true && isVersion(VERSION_TABLE_SHOW_DUPLICATE_VALUE)){ binding.attrs.isShowAllWhenFilterQuesBlank = CONST_XML_FUNCTION_TRUE; } if (control.isShowDuplicateValue !== undefined && control.isShowDuplicateValue === true && isVersion(VERSION_TABLE_SHOW_DUPLICATE_VALUE)){ binding.attrs.isShowDuplicateValue = CONST_XML_FUNCTION_TRUE; } /*if (control.dispChkLstCol !== undefined && control.dispChkLstCol === true && isVersion3_6()){ binding.attrs.dispChkLstCol = CONST_XML_FUNCTION_TRUE; }*/ if (isVersion3_6()){ control.dispChkLstCol = true; binding.attrs.dispChkLstCol = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_LOCK_HEADER)){ var lock = ''; if(control.lockFirstRow){ lock = CONST_XML_FUNCTION_TRUE; }else{ lock = CONST_XML_FUNCTION_FALSE; } if(control.lockFirstColumn){ lock += '|true()'; }else{ lock += '|false()'; } binding.attrs.lock = lock; } if(!isVersion(VERSION_GRID_TYPE_FUNCTION) || control.type !== CONST_CTRL_TYPE_CTRLGRID){ if (control.equallySpaceColumns !== undefined && control.equallySpaceColumns === true){ binding.attrs.equallySpaceColumns = CONST_XML_FUNCTION_TRUE; }else if (control.equallySpaceColumns !== undefined){ binding.attrs.equallySpaceColumns = CONST_XML_FUNCTION_FALSE; }/*else{ if (control.isUtilizingFullScr !== undefined && control.isUtilizingFullScr === true){ binding.attrs.isUtilizingFullScr = CONST_XML_FUNCTION_TRUE; }else if (control.isUtilizingFullScr !== undefined){ binding.attrs.isUtilizingFullScr = CONST_XML_FUNCTION_FALSE; } }*/ } if (control.isUtilizingFullScr !== undefined && control.isUtilizingFullScr === true){ binding.attrs.isUtilizingFullScr = CONST_XML_FUNCTION_TRUE; }else if (control.isUtilizingFullScr !== undefined){ binding.attrs.isUtilizingFullScr = CONST_XML_FUNCTION_FALSE; } // CO-1948 if (control.isUseVerticalCaption !== undefined && control.isUseVerticalCaption === true){ binding.attrs.isUseVerticalCaption = CONST_XML_FUNCTION_TRUE; }else if (control.isUseVerticalCaption !== undefined){ binding.attrs.isUseVerticalCaption = CONST_XML_FUNCTION_FALSE; } // CO-2816 Duplicate validation setting for table if(isVersion(VERSION_VERIFY_DUPLICATE)){ if (control.isVerifyDuplicate === true){ binding.attrs.verifyDuplicate = CONST_XML_FUNCTION_TRUE; binding.attrs.verifyDuplicate += '|' if(control.isAllowDuplicate === true){ binding.attrs.verifyDuplicate += CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.verifyDuplicate += CONST_XML_FUNCTION_FALSE; } binding.attrs.verifyDuplicate += '|' var tmp = ''; Object.keys(control.duplicateColumnsGroup).forEach(function(k){ console.log(k + ' - ' + control.duplicateColumnsGroup[k]); if(control.duplicateColumnsGroup[k] == true){ _.each(control.children, function(item){ if(item.id == k){ var itemPath = getControlXPath(root, "/data/", k); binding.attrs.verifyDuplicate += tmp + itemPath; tmp = ','; return false; } }) } }); }else{ binding.attrs.verifyDuplicate = CONST_XML_FUNCTION_FALSE; } } // CO-2816 end binding.attrs.captionHeight = binding.attrs.captionHeigh || 1; if (control.captionHeight !== undefined){ binding.attrs.captionHeight = control.captionHeight; } // CO-1948 // PCA-270: Remove the replace space function // // []Replace space with HTML tag “ ” // if (control.replaceSpaceWithHtmlTagNBSP !== undefined && control.replaceSpaceWithHtmlTagNBSP === true){ // binding.attrs.replaceSpaceWithHtmlTagNBSP = CONST_XML_FUNCTION_TRUE; // }else if (control.replaceSpaceWithHtmlTagNBSP !== undefined){ // binding.attrs.replaceSpaceWithHtmlTagNBSP = CONST_XML_FUNCTION_FALSE; // } if(isVersion(VERSION_ADJUST_WIDTH_IF_SMALLER)){ if(control.isUtilizingFullScr && control.adjustWidthNormal){ binding.attrs.adjustWidthNormal = control.adjustWidthNormal; } if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(control.isIgnoreGrid && (!control.stackedExpand || control.stackedExpand == 'expand') && control.adjustWidth){ binding.attrs.adjustWidth = control.adjustWidth; } }else{ /*if(control.columnsSpaceType == '2' && control.adjustWidth && control.isApplyForScreen){ binding.attrs.adjustWidth = control.adjustWidth; }*/ if(control.adjustWidth && control.isApplyForScreen){ binding.attrs.adjustWidth = control.adjustWidth; } } }else{ if(isVersion(VERSION_ADJUST_WIDTH_PERCEN)){ if(control.columnsSpaceType == '2' && control.adjustWidth){ binding.attrs.adjustWidth = control.adjustWidth; } } } 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)){ // [] Column weight if (control.isColumnWeightCustom !== undefined && control.isColumnWeightCustom === true){ binding.attrs.isColumnWeightCustom = CONST_XML_FUNCTION_TRUE; // Make the attribute equallySpaceColumns = false, isUtilizingFullScr = false binding.attrs.equallySpaceColumns = CONST_XML_FUNCTION_FALSE; binding.attrs.isUtilizingFullScr = CONST_XML_FUNCTION_FALSE; // Column weight >> custom format if (control.withFormat4ColumnWeight !== undefined){ binding.attrs.withFormat4ColumnWeight = control.withFormat4ColumnWeight; } }else if (control.isColumnWeightCustom !== undefined){ binding.attrs.isColumnWeightCustom = CONST_XML_FUNCTION_FALSE; } }else{ if (control.columnsSpaceType == '2') { //Adjust column width binding.attrs.isColumnWeightCustom = CONST_XML_FUNCTION_TRUE; // Make the attribute equallySpaceColumns = false binding.attrs.equallySpaceColumns = CONST_XML_FUNCTION_FALSE; if(control.isUtilizingFullScr){ binding.attrs.isUtilizingFullScr = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isUtilizingFullScr = CONST_XML_FUNCTION_FALSE; } // Column weight >> custom format if (control.withFormat4ColumnWeight !== undefined){ binding.attrs.withFormat4ColumnWeight = control.withFormat4ColumnWeight; } // Special treating with Questionnaire // PCA-199 Build Forms for New Grid Type, change column weight spec for Questionnaire if (control.type === CONST_CTRL_TYPE_CTRLSCORETABLE) { if (control.withFormat4ColumnWeight2 !== undefined) { // Combine 3 data of Question/Answer/Comment var wF4ColWSC = control.withFormat4ColumnWeight2; var wF4ColVal = ''; // Question if (wF4ColWSC.withFormat4CWQuestion !== undefined) { wF4ColVal += wF4ColWSC.withFormat4CWQuestion; } // Parse Answer into fragments if (wF4ColWSC.withFormat4CWAnswer !== undefined) { var numOptions = 1; if (control.children !== undefined && control.children.length > 0) { var firstOption = control.children[0]; if (firstOption !== undefined && firstOption.options !== undefined && firstOption.options.length != undefined) { numOptions = firstOption.options.length; // Fix bug 0026903: Adjust column width Questionnaire (has comment field) works incorrectly var countActualOptions = 0; for (var tm = 0; tm < numOptions; tm++) { var itemOpt = firstOption.options[tm]; if (itemOpt.text !== undefined && itemOpt.val !== undefined) { countActualOptions++; } } if (countActualOptions !== 0) { numOptions = countActualOptions; } } } try { writeToLogInfo('numoptions : ' + numOptions); if (numOptions <= 1) { wF4ColVal += '|' + wF4ColWSC.withFormat4CWAnswer; } else { var totalVal = parseFloat(wF4ColWSC.withFormat4CWAnswer); var intVal = (totalVal / numOptions); writeToLogInfo('intVal : ' + intVal); for (var k = 0; k < numOptions-1; k++) { wF4ColVal += '|' + intVal; totalVal -= intVal; } wF4ColVal += '|' + totalVal; } } catch (e) { // TODO: handle exception } //wF4ColVal += '|' + wF4ColWSC.withFormat4CWAnswer; } // Comment if (control.appendComment === true && wF4ColWSC.withFormat4CWComment !== undefined) { wF4ColVal += '|' + wF4ColWSC.withFormat4CWComment; } // Binding value into XML structure binding.attrs.withFormat4ColumnWeight = wF4ColVal; } } }else{ binding.attrs.isColumnWeightCustom = CONST_XML_FUNCTION_FALSE; if (control.columnsSpaceType == '0') { binding.attrs.equallySpaceColumns = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.equallySpaceColumns = CONST_XML_FUNCTION_FALSE; } } } if (control.type == CONST_CTRL_TYPE_CTRLPOD){ binding.attrs.isPOD = CONST_XML_FUNCTION_TRUE; binding.attrs.kind = control.manifestType; if(control.manifestType == 'delivery'){ if(control.isAllowDelivery){ binding.attrs.isAllowDelivery = CONST_XML_FUNCTION_TRUE; } }else{ if(control.isAllowPickup){ binding.attrs.isAllowPickup = CONST_XML_FUNCTION_TRUE; } } if(control.isSort && control.sortColumn != ''){ binding.attrs.sortColumn = control.sortColumn; } if(control.stopType){ binding.attrs.stopType = control.stopType; } if(control.podDataSource){ binding.attrs.podDataSource = control.podDataSource; } if(control.itemPerRow){ binding.attrs.itemPerRow = control.itemPerRow; if(control.itemPerRow == 'single'){ var singleAllowOption = ''; if(control.allowDamagedOption){ singleAllowOption = CONST_VALUE_TRUE_STR; }else{ singleAllowOption = CONST_VALUE_FALSE_STR; } if(control.allowDamagedDelivery){ singleAllowOption += '|true'; }else{ singleAllowOption += '|false'; } if(control.allowRejectedOption){ singleAllowOption += '|true'; }else{ singleAllowOption += '|false'; } binding.attrs.singleAllowOption = singleAllowOption; } } binding.attrs.method = control.manifestMethod; binding.attrs.showOptions = ''; var showCommentIfCheck = false; if(control.showDamaged){ showCommentIfCheck = true; binding.attrs.showOptions = CONST_VALUE_TRUE_STR; }else{ binding.attrs.showOptions = CONST_VALUE_FALSE_STR; } if(control.showReject){ showCommentIfCheck = true; binding.attrs.showOptions += '|true'; }else{ binding.attrs.showOptions += '|false'; } if(control.stopType == 'multi'){ binding.attrs.showOptions += '|true'; if(control.stopFilterQues && control.stopFilterQues != ''){ var ctrlFilterPath = getControlXPath(root, "/data/", control.stopFilterQues); binding.attrs.stopFilter = ctrlFilterPath; } if(control.stopFilterColumn && control.stopFilterColumn != ''){ var ctrlFilterColumnPath = getControlXPath(root, "/data/", control.stopFilterColumn); if(ctrlFilterColumnPath != ''){ binding.attrs.stopFilterColumn = ctrlFilterColumnPath; } } }else{ binding.attrs.showOptions += '|false'; } if(control.showOSDReport){ binding.attrs.showOptions += '|true'; }else{ binding.attrs.showOptions += '|false'; } if(control.showDeliveredPickupReport){ binding.attrs.showOptions += '|true'; if(control.dprAllowEdit == false){ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_FALSE; } }else{ binding.attrs.showOptions += '|false'; } if(showCommentIfCheck && control.showComment){ binding.attrs.showOptions += '|true'; }else{ binding.attrs.showOptions += '|false'; } if(control.showOSDReportType){ binding.attrs.showOptions += '|' + control.showOSDReportType; }else{ binding.attrs.showOptions += '|down' } if(control.isRequiresSignature){ var podSignatureName = 'S' + control.id + '__Grid_Signature'; binding.attrs.signature = CONST_VALUE_TRUE_STR; if(control.showSignatureCustomer){ binding.attrs.signature += '|true'; }else{ binding.attrs.signature += '|false'; } if(control.showSignatureCarrier){ binding.attrs.signature += '|true'; }else{ binding.attrs.signature += '|false'; } if(control.signatureAllowEdit){ binding.attrs.signature += '|true'; }else{ binding.attrs.signature += '|false'; } binding.attrs.signature += '|' + podSignatureName; }else{ binding.attrs.signature = 'false|false|false|false|'; } if(isVersion(VERSION_NFC_BAR_PARSE_POD)){ if ((control.parse !== undefined) && (control.parse !== false)){ binding.attrs.allowParsing = CONST_XML_FUNCTION_TRUE; binding.attrs.parsingStartDelimeter = control.parse.start || ''; binding.attrs.parsingSeperationDelimeter = control.parse.separation || ''; binding.attrs.parsingEndDelimeter = control.parse.end || ''; }else{ binding.attrs.allowParsing = CONST_XML_FUNCTION_FALSE; } } /*binding.attrs.lookuptable = control.datasource;*/ } if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ binding.attrs.isScoreTable = CONST_XML_FUNCTION_TRUE; if(control.appendComment != undefined && control.appendComment == true){ binding.attrs.appendComment = CONST_XML_FUNCTION_TRUE; } } if (control.type == CONST_CTRL_TYPE_CTRLGRID){ if(control.isButtonGrid){ binding.attrs.isButtonGrid = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isGrid = CONST_XML_FUNCTION_TRUE; } if(control.loop == undefined || jQuery.trim(control.loop) == ''){ binding.attrs.columns = 5 }else{ binding.attrs.columns = ('' + control.loop).replace('&&&', ''); } } if(control.type != CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ var bindingRepeatCount = { name: 'bind', attrs: { 'nodeset': xpath + control.name + '/repeat_count', 'type': 'int' } } model.children.push(bindingRepeatCount); } if(isVersion(VERSION_TABLE_TEXT_SIZE) && (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE)){ if (control.textSize != undefined){ binding.attrs.textSize = control.textSize; } } if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV){ if(isVersion5_0()){ if(control.isVariableNumberRow){ binding.attrs.isVariableNumberRow = CONST_XML_FUNCTION_TRUE; if(control.isAllRowRequired){ binding.attrs.isAllRowRequired = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isAllRowRequired = CONST_XML_FUNCTION_FALSE; } // add calculate attribute var itemPath = getControlXPath(root, "/data/", control.rowValSource); bindingRepeatCount.attrs.calculate = '(' + itemPath + ')'; }/*else{ binding.attrs.isVariableNumberRow = CONST_XML_FUNCTION_FALSE; }*/ if(control.isRowCountDisplay){ binding.attrs.isRowCountDisplay = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isRowCountDisplay = CONST_XML_FUNCTION_FALSE; } } }else if(control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ if(control.isRowCountDisplay){ binding.attrs.isRowCountDisplay = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isRowCountDisplay = CONST_XML_FUNCTION_FALSE; } } if(control.type != CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ var repeatBodyTag = { name: 'repeat', attrs: { 'nodeset': xpath + control.name, 'jr:count': xpath + control.name + '/repeat_count' }, children: [] }; bodyTag.children.push(repeatBodyTag); _.each(control.children, function(child) { child.parentCtrlType = control.type; if(isIgnoreRelevance(control.parentCtrlType) && child.isShowRelevanceCondition == true){ child.isShowRelevanceCondition = false; } if(isIgnoreSkip(control.type)){ child.isShowSkipCondition = false; } if(control.gridType != undefined && control.gridType != '' // free form grid && child.grayCaption != ''){ child.grayCaption = false; } var nextCtrlInd = control.children.indexOf(child); nextCtrlInd += 1; if((child.type == CONST_CTRL_TYPE_GROUP || (child.type == 'ctrlBreakPointData') || child.type == CONST_CTRL_TYPE_CTRLSCORETABLE) && nextCtrlInd < control.children.length){ var nextCtrlNameNew = CONST_JUMP_EOF_TEXT; nextCtrlNameNew = control.children[nextCtrlInd].name; parseControl(child, xpath + control.name + '/', '', instanceTag, translations, model, repeatBodyTag, relevance, root, nextCtrlNameNew, control.type, control); }else{ parseControl(child, xpath + control.name + '/', '', instanceTag, translations, model, repeatBodyTag, relevance, root, nextCtrlName, control.type, control); } if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE && control.appendComment != undefined && control.appendComment == true){ var childAdd = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUT_TEXT]); copyProperties(child, childAdd); childAdd.type = CONST_CTRL_TYPE_INPUT_TEXT; childAdd.name = '' + child.name + '__comment'; childAdd.length = false; childAdd.textParse = false; var labelVal = ''; if(control.commentLabel != undefined){ labelVal = control.commentLabel; } childAdd.label.eng = labelVal; childAdd.hint.eng = ''; childAdd.options = undefined; childAdd.defaultValue = ''; childAdd.required = false; childAdd.duplicateCheck = false; parseControl(childAdd, xpath + control.name + '/', '', instanceTag, translations, model, repeatBodyTag, relevance, root, nextCtrlName, control.type, control); }else if (control.type == CONST_CTRL_TYPE_CTRLGRID){ } }); } }else{ _.each(control.children, function(child) { child.parentCtrlType = control.type; if(isIgnoreRelevance(control.parentCtrlType) && child.isShowRelevanceCondition == true){ child.isShowRelevanceCondition = false; } if(isIgnoreSkip(control.type)){ child.isShowSkipCondition = false; } var nextCtrlInd = control.children.indexOf(child); nextCtrlInd += 1; if((child.type == CONST_CTRL_TYPE_GROUP || (child.type == 'ctrlBreakPointData') || child.type == CONST_CTRL_TYPE_CTRLSCORETABLE) && nextCtrlInd < control.children.length){ var nextCtrlNameNew = CONST_JUMP_EOF_TEXT; nextCtrlNameNew = control.children[nextCtrlInd].name; parseControl(child, xpath + control.name + '/', relpath + control.name + '/', instanceTag, translations, model, bodyTag, relevance, root, nextCtrlNameNew, control.type, control); }else{ parseControl(child, xpath + control.name + '/', relpath + control.name + '/', instanceTag, translations, model, bodyTag, relevance, root, nextCtrlName, control.type, control); } }); } if(isVersion(VERSION_GRID_TABLE_SHADING)){ if(control.shadedKind && control.shadedKind != ''){ if(isVersion(VERSION_GRID_TYPE_FUNCTION) && control.gridType && control.gridType != ''){ }else{ binding.attrs.shadedKind = control.shadedKind; } } } if(isVersion(VERSION_PORTAL_SHADING)){ if(control.apperance == 'Custom'){ if(control.shadedHeadings){ if(isVersion(VERSION_APPEARANCE_ACTIVE_TEXT)){ if(control.shadedHeadings.isShadedHeadings){ binding.attrs.customShading = 'true|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading + '|' + control.shadedHeadings.activeTextColor; }else{ binding.attrs.customShading = 'false|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading + '|' + control.shadedHeadings.activeTextColor; } }else{ if(control.shadedHeadings.isShadedHeadings){ binding.attrs.customShading = 'true|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading; }else{ binding.attrs.customShading = 'false|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading; } } } if(control.answerColor){ if(control.answerColor.isAnswerColor){ binding.attrs.answerColor = control.answerColor.answerTextColor; if(isVersion(VERSION_ANSWER_BACKGROUND_COLOR)){ if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLTABLE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLSCHEDULE){ binding.attrs.answerBGColor = control.answerColor.answerBGColor; } } } } if(control.shadedRow){ if(control.type !== CONST_CTRL_TYPE_CTRLTABLE && control.type !== CONST_CTRL_TYPE_CTRLSCHEDULE && control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && control.shadedKind && (control.shadedKind == '2' || control.shadedKind == '3')){ }else{ if(control.shadedRow.isShadedRow){ binding.attrs.customRow = 'true|' + control.shadedRow.rowColor + '|' + control.shadedRow.rowTextColor; }else{ binding.attrs.customRow = 'false|' + control.shadedRow.rowColor + '|' + control.shadedRow.rowTextColor; } } } if(control.shadedButton){ if(control.shadedButton.isShadedButton){ binding.attrs.customButtonShading = 'true|' + control.shadedButton.btnSheadingColor + '|' + control.shadedButton.btnTextColor + '|' + control.shadedButton.activeBtnTextColor + '|' + control.shadedButton.btnBorderColor + '|' + control.shadedButton.btnRoundedCorners; }else{ binding.attrs.customButtonShading = 'false|' + control.shadedButton.btnSheadingColor + '|' + control.shadedButton.btnTextColor + '|' + control.shadedButton.activeBtnTextColor + '|' + control.shadedButton.btnBorderColor + '|' + control.shadedButton.btnRoundedCorners; } } } } if(isVersion(VERSION_REMOVE_ANSW_BORDER) && control.apperance == 'Custom'){ if(control.removeAnswerBorder){ binding.attrs.removeAnswerBorder = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_GRID_TYPE_FUNCTION)){ if(isVersion(VERSION_STACKED_EXP_FREE_FORM)){ if(control.gridType && control.gridType != ''){ binding.attrs.gridType = control.gridType; } if(control.isIgnoreGrid){ binding.attrs.ignoreGrid = 'true()|' + control.ignoreScreenSize; binding.attrs.ignoreGrid += '|true()'; } }else{ if(control.gridType && control.gridType != ''){ binding.attrs.gridType = control.gridType; if(control.isIgnoreGrid){ binding.attrs.ignoreGrid = 'true()|' + control.ignoreScreenSize; binding.attrs.ignoreGrid += '|true()'; } } } if(isVersion(VERSION_GRID_TYPE_CENTER)){ if(control.gridType == CONST_GRID_TYPE_CENTER){ var padding = ''; if(control.leftPadding && control.leftPadding != ''){ padding += control.leftPadding; }else{ padding += CONST_GRID_TYPE_CENTER_DEFAULT_PADDING; } padding += '|'; if(control.rightPadding && control.rightPadding != ''){ padding += control.rightPadding; }else{ padding += CONST_GRID_TYPE_CENTER_DEFAULT_PADDING; } binding.attrs.padding = padding; if(control.noCaptions == true){ binding.attrs.noCaptions = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.noCaptions = CONST_XML_FUNCTION_FALSE; } } } } if(isVersion(VERSION_NEW_GRID_BUTTON)){ if(control.isApplyForScreen){ binding.attrs.isApplyForScreen = 'true()|' + control.applyScreenSize; } } if(control.podCtrlName){ binding.attrs.podCtrlName = control.podCtrlName; } if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.type == CONST_CTRL_TYPE_CTRLTABLE){ if(control.clearOnRetrieve === true){ binding.attrs.clearOnRetrieve = CONST_XML_FUNCTION_TRUE; } } return; } var instanceTag = { name: control.name }; instance.children.push(instanceTag); // control markup var ctrlType = controlTypes[control.type]; var bodyTag = { name: ctrlType, attrs: { 'ref': control.destination || (relpath + control.name) }, children: [] }; body.children.push(bodyTag); // binding var binding = { name: 'bind', attrs: { 'nodeset': control.destination || (xpath + control.name) } } if(isVersion(VERSION_TOOL_NEW_JUSTIFICATION)){ var justification = getJustification(control); if(justification != ''){ binding.attrs.justification = justification; } } if(isVersion(VERSION_CTRL_SHOW_ADVANCED_TOOLBAR)){ if(control.type == CONST_CTRL_TYPE_INPUTSKETCH || control.type == CONST_CTRL_TYPE_INPUTIMAGE){ if(control.isShowAdvanceToolbar == false){ binding.attrs.isShowAdvanceToolbar = CONST_XML_FUNCTION_FALSE; } } } if(isVersion(VERSION_ALLOW_REPLACE_CLEAR)){ if(control.type == CONST_CTRL_TYPE_INPUTSKETCH){ if(control.isAllowReplace == false){ binding.attrs.isAllowReplace = CONST_XML_FUNCTION_FALSE; } if(control.isAllowClear == false){ binding.attrs.isAllowClear = CONST_XML_FUNCTION_FALSE; } } } if(isVersion(VERSION_ALLOW_EDIT_SKETCH_IMG)){ if(control.type == CONST_CTRL_TYPE_INPUTIMAGE){ if(control.isAllowEdit == false){ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_FALSE; } if(control.isAllowSketch == false){ binding.attrs.isAllowSketch = CONST_XML_FUNCTION_FALSE; }else{ if(isVersion(VERSION_AUTO_START_SKETCH) && control.isAutoStartSketch){ binding.attrs.isAutoStartSketch = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_AUTO_STAMP_IMG) && control.isAllowAutoStampImage){ var autoStampImage = CONST_XML_FUNCTION_TRUE; autoStampImage += '|'; if(control.stampGPSLocation == true){ autoStampImage += CONST_XML_FUNCTION_TRUE; }else{ autoStampImage += CONST_XML_FUNCTION_FALSE; } autoStampImage += '|'; if(isVersion(VERSION_AUTO_STAMP_IMG_DIR) && control.stampDirection == true){ autoStampImage += CONST_XML_FUNCTION_TRUE; }else{ autoStampImage += CONST_XML_FUNCTION_FALSE; } autoStampImage += '|'; if(control.stampDateNTime == true){ autoStampImage += CONST_XML_FUNCTION_TRUE; }else{ autoStampImage += CONST_XML_FUNCTION_FALSE; } autoStampImage += '|'; if(control.stampDescription == true){ autoStampImage += CONST_XML_FUNCTION_TRUE; }else{ autoStampImage += CONST_XML_FUNCTION_FALSE; } autoStampImage += '|'; if(control.stampDescField && control.stampDescField != ''){ var itemPath = getControlXPath(root, "/data/", control.stampDescField); autoStampImage += itemPath; } if(isVersion(VERSION_AUTO_STAMP_ALT)){ autoStampImage += '|'; if(control.stampAltitude == true){ autoStampImage += CONST_XML_FUNCTION_TRUE; }else{ autoStampImage += CONST_XML_FUNCTION_FALSE; } } binding.attrs.isAllowAutoStampImage = autoStampImage; } } } if(isVersion(VERSION_IMG_CAMERA_APP)){ if(control.type == CONST_CTRL_TYPE_INPUTIMAGE){ var cameraAppParamObj = {}; if(isVersion(VERSION_ANDROID_APP)){ var androidApp = {}; androidApp.eng = control.androidApp; bodyTag.children.push({ name: 'androidApp', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":androidApp')" } }); addTranslation(androidApp, xpath + control.name + ':androidApp', translations); var found = false; _.each(android_app, function(app){ var arr = app.split('$$'); if(arr[0] == control.androidApp){ found = true; if(arr.length >= 2){ cameraAppParamObj.eng = arr[1]; }else{ cameraAppParamObj.eng = arr[0]; } return false; } }) if(!found){ cameraAppParamObj.eng = control.androidApp; } }else{ cameraAppParamObj.eng = control.androidCameraApp; } bodyTag.children.push({ name: 'cameraApp', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":cameraApp')" } }); addTranslation(cameraAppParamObj, xpath + control.name + ':cameraApp', translations); } } if(isVersion(VERSION_PAYMENT_TYPE)){ if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ if(control.paymentType == CONST_PAYMENT_TYPE_AUTOMATED || control.paymentType == CONST_PAYMENT_TYPE_SQUARE || control.paymentType == CONST_PAYMENT_MIPOS){ //binding.attrs.paymenttype = CONST_PAYMENT_TYPE_AUTOMATED; if(control.propay || control.propay == undefined){ //ProPay //binding.attrs.vendor = CONST_ACTION_PROPAY; binding.attrs.type = 'action'; //binding.attrs.imageJustification = 'Center'; binding.attrs.checkUpdates = CONST_XML_FUNCTION_FALSE; if(control.paymentType == CONST_PAYMENT_TYPE_SQUARE){ binding.attrs.action = CONST_ACTION_ID_SQUARE; if((control.totalAmountPaid || '') != ''){ binding.attrs.totalAmountPaid = getControlXPath(root, "/data/", control.totalAmountPaid); } if((control.transactionClientId || '') != ''){ binding.attrs.transactionClientId = getControlXPath(root, "/data/", control.transactionClientId); } }else if(control.paymentType == CONST_PAYMENT_MIPOS){ binding.attrs.action = CONST_ACTION_ID_MIPOD; var miposReturn = ''; if((control.totalAmountPaid || '') != ''){ miposReturn = getControlXPath(root, "/data/", control.totalAmountPaid); } miposReturn += ','; if((control.cardholderName || '') != ''){ miposReturn += getControlXPath(root, "/data/", control.cardholderName); } miposReturn += ','; if((control.cardNumber || '') != ''){ miposReturn += getControlXPath(root, "/data/", control.cardNumber); } miposReturn += ','; if((control.authorizatioCode || '') != ''){ miposReturn += getControlXPath(root, "/data/", control.authorizatioCode); } miposReturn += ','; if((control.paymentMethod || '') != ''){ miposReturn += getControlXPath(root, "/data/", control.paymentMethod); } miposReturn += ','; if((control.referenceNumber || '') != ''){ miposReturn += getControlXPath(root, "/data/", control.referenceNumber); } binding.attrs.miposReturn = miposReturn; }else{ binding.attrs.action = CONST_ACTION_ID_PROPAY; } //binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; /*bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; actionBtnTextObj.eng = control.label.eng; addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations);*/ var actionParamObj = {}; actionParamObj.eng = makeProPayPath(root, control); bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); } }else{ //binding.attrs.paymenttype = 'manual'; } } } model.children.push(binding); if(model.ctrlLastEnteredValueMap && model.ctrlLastEnteredValueMap[control.id]){ binding.attrs.calculate = model.ctrlLastEnteredValueMap[control.id]; } if(!model.ctrlMap){ model.ctrlMap = {}; } model.ctrlMap[control.id] = model.children.length - 1; // relevance string if (relevance === undefined) relevance = []; // constraint string var constraint = []; /*// constraint message string var constraintmessage = '';*/ if(isVersion(VERSION_SIGNATURE_ADD_FUNC)) { if(control.type == mdi_kind_inputSignature){ if(control.isAllowEditOption != undefined){ if(!control.isAllowEditOption){ binding.attrs.isAllowEditOption = CONST_XML_FUNCTION_FALSE; } }else{ if(control.isOneTimeSignatureCapture == false){ binding.attrs.isOneTimeSignatureCapture = CONST_XML_FUNCTION_FALSE; } } } if(control.type == mdi_kind_inputSignature && (control.parentCtrlType == CONST_CTRL_TYPE_CTRLTABLE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLSCHEDULE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLPOD || control.parentCtrlType == CONST_CTRL_TYPE_CTRLGRID)){ if(control.sizeOptions == 'Large'){ binding.attrs.isLargeSize = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_BULK_SIGNATURE)) { if(control.isBulkSignature){ binding.attrs.isBulkSignature = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_GRAY_CAPTION_TEXT)) { if(control.grayCaption){ binding.attrs.grayCaption = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_DATE_TIME_CALENDAR_VIEW)) { if(control.useCalendarView){ binding.attrs.useCalendarView = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_NFC_ALLOW_EDIT)) { if(control.type == CONST_CTRL_TYPE_INPUTNFC){ if(control.isAllowEditOption != undefined){ if(!control.isAllowEditOption){ binding.attrs.isAllowEditOption = CONST_XML_FUNCTION_FALSE; } } } } if(isVersion(VERSION_ALLOW_EDIT_NFC_BARCODE)) { if(control.type == CONST_CTRL_TYPE_INPUTNFC || control.type == CONST_CTRL_TYPE_INPUTBARCODE){ if(control.isAllowManualEntry != undefined){ if(!control.isAllowManualEntry){ binding.attrs.isAllowManualEntry = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_AUTO_START_SCAN_OPTION) && control.type == CONST_CTRL_TYPE_INPUTBARCODE){ if (control.autoStartScan === true){ binding.attrs.autoStartScan = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.autoStartScan = CONST_XML_FUNCTION_FALSE; } } } if(control.type == CONST_CTRL_TYPE_INPUTBARCODE){ if(control.isAllowEditOption != undefined){ if(!control.isAllowEditOption){ binding.attrs.isAllowEditOption = CONST_XML_FUNCTION_FALSE; } } } } if(control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && isVersion(VERSION_REMOVE_SPACE)) { if (control.removeSpaceAbove !== undefined && control.removeSpaceAbove === true){ binding.attrs.removeSpaceAbove = CONST_XML_FUNCTION_TRUE; } if (control.removeSpaceBelow !== undefined && control.removeSpaceBelow === true){ binding.attrs.removeSpaceBelow = CONST_XML_FUNCTION_TRUE; } } if(control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(isVersion(VERSION_CHOOSE_ONE_SLIDER) && control.optionKind == CONST_CHOOSE_ONE_SWITCH) { binding.attrs.showAsSwitch = CONST_XML_FUNCTION_TRUE; if(control.sliderColor && control.sliderColor.isSliderColor){ if(control.sliderColor.sliderActiveColor){ binding.attrs.sliderActiveColor = control.sliderColor.sliderActiveColor; } } }else{ if(isVersion(VERSION_DISPLAY_TYPE_FUNCTION)) { if (control.displayType !== undefined){ binding.attrs.displayType = control.displayType; if(control.displayType == CONST_DROPDOWN){ binding.attrs.showAsDropdown = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.showAsDropdown = CONST_XML_FUNCTION_FALSE; if(isVersion(VERSION_IGNORE_ACROSS)){ if(control.displayType == CONST_ACROSS){ if(control.isIgnoreAcross){ binding.attrs.ignoreAcross = 'true()|' + control.ignoreAcrossScreenSize; } } } } }else{ if (control.showAsDropdown != undefined){ if(control.showAsDropdown === true && parentType != CONST_CTRL_TYPE_CTRLSCORETABLE){ binding.attrs.showAsDropdown = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.showAsDropdown = CONST_XML_FUNCTION_FALSE; } } } }else{ if (control.showAsDropdown != undefined){ if(control.showAsDropdown === true && parentType != CONST_CTRL_TYPE_CTRLSCORETABLE){ binding.attrs.showAsDropdown = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.showAsDropdown = CONST_XML_FUNCTION_FALSE; } } } if(isVersion(VERSION_ALLOW_UNCHECK) && control.isAllowUncheck){ binding.attrs.isAllowUncheck = CONST_XML_FUNCTION_TRUE; } } }else{ if(isVersion(VERSION_DISPLAY_TYPE_FUNCTION)) { if (control.displayType !== undefined){ binding.attrs.displayType = control.displayType; if(isVersion(VERSION_IGNORE_ACROSS)){ if(control.displayType == CONST_ACROSS){ if(control.isIgnoreAcross){ binding.attrs.ignoreAcross = 'true()|' + control.ignoreAcrossScreenSize; } } } if(isVersion(VERSION_DROPDOWN_SCORE_ONE)){ if(control.displayType == CONST_DROPDOWN){ binding.attrs.showAsDropdown = CONST_XML_FUNCTION_TRUE; } } } } } if(isVersion(VERSION_HIDE_ANSWER_ON_CHECKBOX) && control.isHideAnswer){ binding.attrs.isHideAnswer = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_TURN_OFF_SELECTION_OUTLINE) && control.apperance == 'Custom') { if (control.turnOffSelectionOutline){ binding.attrs.turnOffSelectionOutline = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.turnOffSelectionOutline = CONST_XML_FUNCTION_FALSE; } } if (isVersion(VERSION_TEXT_SECURITY)) { var currentUser = authNS.currentUser; if(currentUser && currentUser[CONST_FIELDENCRYPTION]){ if(control.encryptField != undefined && (control.encryptField == true || control.encryptField.value == true)){ binding.attrs.encrypt = CONST_XML_FUNCTION_TRUE; } } } // deal with input type: if (control.type == CONST_CTRL_TYPE_INPUT_TEXT){ binding.attrs.type = 'string'; if(control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && control.numberOfLine){ var numberOfLine = control.numberOfLine; if(numberOfLine == ''){ numberOfLine = '1'; } binding.attrs.numberOfLine = numberOfLine; } if(isVersion(VERSION_TEXT_FORMAT_OPTION)){ if(control.socialSecurityFormat){ binding.attrs.format = 'social|'; }else if(control.phoneNoFormat){ binding.attrs.format = 'phone|' + (control.phoneFormatKind | 0); }else if(control.isCustomFormat){ // CO-2251 - Export xml data // binding.attrs.format = 'custom|' + (control.txtCustomFormatVal || ''); // New update 2018.11.08 - stop prevent character, user could input anything bodyTag.children.push({ name: 'customformat', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":customformat')" } }); var formatCustomObj = { eng: '' }; formatCustomObj.eng = control.txtCustomFormatVal; addTranslation(formatCustomObj, xpath + control.name + ':customformat', translations); // START CO-2680 binding.attrs.isShowCustomFormat = CONST_XML_FUNCTION_FALSE; if(control.isShowCustomFormat){ binding.attrs.isShowCustomFormat = CONST_XML_FUNCTION_TRUE; } if(control.customFormatTextChar != undefined && control.customFormatTextChar != ''){ binding.attrs.customFormatTextChar = control.customFormatTextChar; } if(control.customFormatNumChar != undefined && control.customFormatNumChar != ''){ binding.attrs.customFormatNumChar = control.customFormatNumChar; } // END CO-2680 // CO-2680 Change custom format for text fields (r55573) //binding.attrs.encrypt = CONST_XML_FUNCTION_TRUE; // END CO-2680 } } if(isVersion(VERSION_TEXT_KEYBOARD_TYPE)){ if(control.keyboardType == CONST_KB_TYPE_NO){ binding.attrs.lockNumericKeyboard = CONST_XML_FUNCTION_TRUE; }else if(control.keyboardType == CONST_KB_TYPE_NONE){ binding.attrs.isHideKeyboard = 'true()'; } }else{ if(isVersion(VERSION_LOCK_MUMERIC_KB_OPTION)){ if(control.lockNumericKeyboard){ binding.attrs.lockNumericKeyboard = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_LOCK_SCREEN)){ if(control.lockScreen == true){ binding.attrs.lockScreen = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_SHOW_SYMBOLS)){ if(control.showSymbols){ binding.attrs.showSymbols = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_UPPERCASE_LOCK)){ if(control.uppercaseLock){ binding.attrs.uppercaseLock = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_SUPPRESS_KEYBOARD)){ // CO-2559:Suppress keyboard setting - Text Field if(control.suppressKeyboard){ binding.attrs.suppressKeyboard = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_TEXT_PARSE)){ if(control.textParse){ var parseDestinationFieldString = ''; _.each(control.textParseDestinationFields, function(item){ var len = item.text.len || ''; var val = item.text.val || ''; if(len == '' || val == ''){ return true; } var parseDestinationFieldControl = getControlById(item.text.val, root); if(parseDestinationFieldControl == undefined){ return true; } var parseDestinationFieldPath = getControlXPath(root, "/data/", item.text.val); parseDestinationFieldString += '|' + len + ',' + parseDestinationFieldPath; if(item.text.isTable == true){ parseDestinationFieldString += ','; var parseDestinationFieldTableControl = getControlById(item.text.tablefield, root); if(parseDestinationFieldTableControl == undefined){ return true; } var parseDestinationFieldTablePath = getControlXPath(root, "/data/", item.text.tablefield); parseDestinationFieldString += parseDestinationFieldTablePath; } i++; }); binding.attrs.parse = CONST_XML_FUNCTION_TRUE + parseDestinationFieldString; if(control.hideAfterParse){ binding.attrs.hideAfterParse = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_DUPLICAT_CHECK)){ if(control.duplicateCheck){ var duplicateCheckFieldControlPath = getControlXPath(root, "/data/", control.duplicateCheckField); binding.attrs.duplicateCheck = CONST_XML_FUNCTION_TRUE + '|' + duplicateCheckFieldControlPath; } } }else if (control.type == CONST_CTRL_TYPE_INPUT_NUMERIC) { if (control.kind == 'Integer') binding.attrs.type = 'int'; else if (control.kind == 'Decimal') binding.attrs.type = 'decimal'; else if (control.kind == 'Percent'){ binding.attrs.type = 'decimal'; binding.attrs.isPercent = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_LOCK_SCREEN)){ if(control.lockScreen == true){ binding.attrs.lockScreen = CONST_XML_FUNCTION_TRUE; } } } else if (control.type == CONST_CTRL_TYPE_INPUTTRENDS) { if (control.kind == 'Integer') binding.attrs.type = 'int'; else if (control.kind == 'Decimal') binding.attrs.type = 'decimal'; binding.attrs.isTrands = CONST_XML_FUNCTION_TRUE; binding.attrs.numberOfPrior = control.numberOfPrior; if(control.trendingDate == lbl_trending_date_default){ binding.attrs.trendingDate = lbl_trending_date_default; }else{ var trendingDatePath = getControlXPath(root, "/data/", control.trendingDate); binding.attrs.trendingDate = trendingDatePath; } if(isVersion(VERSION_LAST_ENTERED_VALUE)){ if(control.lastEnteredValue){ var lastEnteredValuePath = getControlXPath(root, "/data/", control.id); if(model.ctrlMap[control.lastEnteredValue]){ var lastEnteredBinding = model.children[model.ctrlMap[control.lastEnteredValue]]; lastEnteredBinding.attrs.calculate= 'trend(' + lastEnteredValuePath + ')'; }else{ if(!model.ctrlLastEnteredValueMap){ model.ctrlLastEnteredValueMap = {}; } model.ctrlLastEnteredValueMap[control.lastEnteredValue] = 'trend(' + lastEnteredValuePath + ')'; } } } if(control.keyFieldFilter != undefined && control.keyFieldFilter != '' && control.keyFieldFilter != lbl_sel_question){ if(checkTrendsSourcePosIsCorrected(root, control.id, control.keyFieldFilter, false, false, false)){ var keyFieldFilterPath = getControlXPath(root, "/data/", control.keyFieldFilter); binding.attrs.keyFieldFilter = keyFieldFilterPath; } } } else if (control.type == CONST_CTRL_TYPE_INPUTDATE) { if (control.kind == CONST_VALUE_DATE) binding.attrs.type = CONST_VALUE_DATE_LOWERCASE; else if (control.kind == CONST_VALUE_TIME) binding.attrs.type = CONST_VALUE_TIME_LOWERCASE; else if (control.kind == CONST_VALUE_DATE_SPACE_TIME) binding.attrs.type = 'dateTime'; else binding.attrs.type = CONST_VALUE_DATE_LOWERCASE; } else if (control.type == CONST_CTRL_TYPE_INPUTLOCATION){ binding.attrs.type = 'geopoint'; }else if (control.type == mdi_kind_inputImage){ binding.attrs.type = 'binary'; }else if (control.type == mdi_kind_inputAudio){ binding.attrs.type = 'binary'; }else if (control.type == mdi_kind_inputVideo){ binding.attrs.type = 'binary'; }else if (control.type == CONST_CTRL_TYPE_INPUTMEDIA){ binding.attrs.type = 'binary'; }else if (control.type == mdi_kind_inputSketch){ binding.attrs.type = 'binary'; }else if (control.type == mdi_kind_inputSignature){ binding.attrs.type = 'binary'; }else if (control.type == 'inputDraw'){ binding.attrs.type = 'binary'; }else if (control.type == CONST_CTRL_TYPE_INPUTBARCODE){ binding.attrs.type = 'barcode'; if (control.kind !== 'Number') binding.attrs.inputType = 'string'; else binding.attrs.inputType = 'int'; }else if (control.type == CONST_CTRL_TYPE_INPUTNFC){ binding.attrs.type = 'nfc'; }else if (control.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ binding.attrs.type = 'string'; if(isVersion(VERSION_FW_TO_EMAIL)){ binding.attrs.inputType = 'forward'; }else{ binding.attrs.inputType = 'int'; } }else if (control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ binding.attrs.type = 'counter'; }else if (control.type == 'inputPageBreak'){ binding.attrs.type = 'pageBreak'; }else if (control.type == 'inputLabel'){ binding.attrs.type = 'label'; }else if (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ binding.attrs.type = 'string'; }else if (control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ binding.attrs.type = 'int'; binding.attrs.autoNumber = CONST_XML_FUNCTION_TRUE; }else if (control.type == CONST_CTRL_TYPE_INPUTACTION){ binding.attrs.type = 'action'; }else if (control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ binding.attrs.type = 'action'; }else if (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ if(binding.attrs.type !== 'action'){ binding.attrs.type = 'payment'; } }else if (control.type == 'inputInstruction') binding.attrs.type = 'label'; else if (control.type == 'inputSaveAndSend') binding.attrs.type = 'saveandsend'; else if (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(control.isFaxWidget == true){ binding.attrs.type = 'string'; }else{ binding.attrs.type = 'emailreport'; } if(isVersion(VERSION_ATTACHMENT)){ if(control.includeAttachments == true){ binding.attrs.includeAttachments = CONST_XML_FUNCTION_TRUE; } } }else if (control.type == CONST_CTRL_TYPE_INPUTFAX) binding.attrs.type = 'string'; else if (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) binding.attrs.type = 'approval'; else if (control.type == CONST_CTRL_TYPE_INPUTCALCULATE) binding.attrs.type = 'string'; else if (control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) { //START CO-1736 Add Lookup Keyboard Section if(isVersion(VERSION_SHOW_LK_SYMBOLS)){ if(control.showSymbols){ binding.attrs.showSymbols = CONST_XML_FUNCTION_TRUE; } if(control.keyboardType.toLowerCase() == 'numeric'){ binding.attrs.lockNumericKeyboard = CONST_XML_FUNCTION_TRUE; } } //END CO-1736 Add Lookup Keyboard Section binding.attrs.type = 'string'; if (control.kind !== 'Number') binding.attrs.inputType = 'string'; else binding.attrs.inputType = 'int'; }else if (control.type == 'inputFacingTable') { binding.attrs.type = 'string'; if (control.kind !== 'Number') binding.attrs.inputType = 'string'; else binding.attrs.inputType = 'int'; }else if (control.type == 'inputLookupMulti') { binding.attrs.type = 'string'; if (control.kind !== 'Number') binding.attrs.inputType = 'string'; else binding.attrs.inputType = 'int'; }else if (control.type == CONST_CTRL_TYPE_INPUTGEOFENCE){ binding.attrs.type = 'geofence'; }else if (control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ binding.attrs.type = 'shipping'; }else if (control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ binding.attrs.type = 'binary'; }else if (control.type == CONST_CTRL_TYPE_INPUTATTACHMENT){ binding.attrs.type = 'binary'; } /* else if (control.type == 'inputRIF') binding.attrs.type = 'rif';*/ // deal with properties: // label if ((control.label !== undefined) && (control.label !== '')) { bodyTag.children.push({ name: 'label', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":label')" } }); //addTranslation(control.label, xpath + control.name + ':label', translations); // Check if we need parse from SPACE into   var customControlLabel = new Object(); if((control.type == CONST_CTRL_TYPE_INPUTACTION && control.isAttachFormWidget !== true) || control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ customControlLabel.eng = ''; }else{ if (control.label.eng !== undefined) { customControlLabel.eng = control.label.eng; } else { customControlLabel.eng = ''; } customControlLabel = applyCheckingCustomControlLabel4XML(customControlLabel, control, objParent); } addTranslation(customControlLabel, xpath + control.name + ':label', translations); } // hint if ((control.hint !== undefined) && (control.hint !== '')) { bodyTag.children.push({ name: 'hint', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":hint')" } }); if((control.type == CONST_CTRL_TYPE_INPUTACTION && control.isAttachFormWidget !== true) || control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ var customControlHint = new Object(); customControlHint.eng = ''; addTranslation(customControlHint, xpath + control.name + ':hint', translations); }else{ addTranslation(control.hint, xpath + control.name + ':hint', translations); } } // default value if ((control.defaultValue !== undefined) && (control.defaultValue !== '')){ if (control.type == CONST_CTRL_TYPE_INPUTDATE){ if(control.defaultValue === 'today'){ instanceTag.val = 'today'; }else{ instanceTag.val = toJavaRosaFormat(control.defaultValue, control.kind); } }else{ instanceTag.val = ''; } } if(control.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if ((control.scoreCategory !== undefined) && (control.scoreCategory !== '')){ binding.attrs.category = HtmlEncode(control.scoreCategory, true); } } if(control.type == 'inputPageBreak'){ } if(isVersion(VERSION_NUMERIC_NEGATIVE_OPT)){ if(control.negativeBrackets){ binding.attrs.negativeFormat = 'Brackets'; } if(control.negativeRedText){ if(binding.attrs.negativeFormat){ binding.attrs.negativeFormat += '/RedText'; }else{ binding.attrs.negativeFormat = 'RedText'; } } } if(control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ if(control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ if(!isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION)){ if (control.dispMobile == undefined || control.dispMobile === true){ binding.attrs.dispMobile = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispMobile = CONST_XML_FUNCTION_FALSE; } } if (control.dispReport == undefined || control.dispReport === true){ binding.attrs.dispReport = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispReport = CONST_XML_FUNCTION_FALSE; } } if (control.imgJustify != undefined){ binding.attrs.imageJustification = control.imgJustify; } // START CO-4827 if(isVersion(VERSION_IMAGE_CAPTION_JUSTIFY) && control.type == CONST_CTRL_TYPE_INPUTACTION && control.kind == CONST_TYPE_IMAGE){ if (control.justificationCaption != undefined){ binding.attrs.imageCaptionJustification = control.justificationCaption; } } // END CO-4827 // START CO-2725 if(control.type == 'inputLabel' && control.justificationImage != undefined) { var imgAlignment = 'Center'; if(control.justificationImage == '0') { imgAlignment = 'Left'; } else if(control.justificationImage == '2') { imgAlignment = 'Right'; } binding.attrs.imageJustification = imgAlignment; } // END CO-2725 if (isVersion(ACTION_CHECK_UPDATES) && !isVersion(VERSION_REMOVE_CHECK_FOR_UPDATE) && control.checkUpdates != undefined){ switch(control.imgAction){ case CONST_ACTION_SAVE_AND_LOAD_FORM: case CONST_ACTION_CLOSE_AND_OPEN_FORM: /*case CONST_ACTION_OPEN_FORM:*/ case CONST_ACTION_SEND_AND_CONTINUE: case CONST_ACTION_SAVE_AND_SEND: case CONST_ACTION_SAVE_AS_COMPLETE: case CONST_ACTION_EXIT_WITHOUT_CONF: case CONST_ACTION_CLOSE_AND_RELOAD: if(control.checkUpdates){ binding.attrs.checkUpdates = CONST_XML_FUNCTION_TRUE; } else{ binding.attrs.checkUpdates = CONST_XML_FUNCTION_FALSE; } break; } } if (isVersion(VERSION_IGNORE_REQ_FORWARD) && control.ignoreRequiredForward != undefined){ switch(control.imgAction){ case CONST_ACTION_SAVE_AND_LOAD_FORM: case CONST_ACTION_CLOSE_AND_OPEN_FORM: /*case CONST_ACTION_OPEN_FORM:*/ case CONST_ACTION_SEND_AND_CONTINUE: case CONST_ACTION_SAVE_AND_SEND: case CONST_ACTION_SAVE_AS_COMPLETE: if(control.ignoreRequiredForward){ binding.attrs.ignoreRequiredForward = CONST_XML_FUNCTION_TRUE; } else{ binding.attrs.ignoreRequiredForward = CONST_XML_FUNCTION_FALSE; } break; } } // CO-2744 Action button close without saving or sending - New Setting if (isVersion(VERSION_ACTION_DEL_FORM_JOB_LIST) && control.isDeleteFormJobList != undefined){ switch(control.imgAction){ case CONST_ACTION_EXIT_WITHOUT_CONF: if(control.isDeleteFormJobList){ binding.attrs.isDeleteFormJobList = CONST_XML_FUNCTION_TRUE; } else{ binding.attrs.isDeleteFormJobList = CONST_XML_FUNCTION_FALSE; } break; } } // CO-2254 export xml data if (control.actionKind != CONST_TYPE_BUTTON_LOWERCASE && control.autoActionStampTrigger != undefined && control.autoActionStampTrigger != '' && control.autoActionStampTrigger != lbl_action_select_a_trigger){ binding.attrs.autostamp = "false()"; binding.attrs.autoStampTriggerQues = ''; if(control.autoActionStampTrigger != '' && control.autoActionStampTrigger != lbl_sel_question) { binding.attrs.autostamp = "true()"; if(control.autoActionStampTrigger == '2') { binding.attrs.autoStampTrigger = 2; }else{ if(isVersion(VERSION_AUTO_RUN_WHEN_RETRIEVE)){ if(control.autoActionStampTrigger == CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_DATA || control.autoActionStampTrigger == CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_NO_DATA) { binding.attrs.autoStampTrigger = control.autoActionStampTrigger; } } } } if(binding.attrs.autostamp == "true()") { var itemPath = getControlXPath(root, "/data/", control.autoActionStampQuestionTrigger); binding.attrs.autoStampTriggerQues = itemPath; } } var isCloseNSaveAction = false; // END CO-2254 if (control.imgAction != undefined){ var actionValue = CONST_ACTION_ID_JUMP; if(control.imgAction === CONST_ACTION_PLAY_VIDEO){ actionValue = CONST_ACTION_ID_PLAY_VIDEO; }else if(control.imgAction === CONST_ACTION_OPEN_WEB_PAGE){ actionValue = CONST_ACTION_ID_OPEN_WEB_PAGE; }else if(control.imgAction === CONST_ACTION_LANCH_PROGRAM){ actionValue = CONST_ACTION_ID_LAUNCH_PROGRAM; }else if(control.imgAction === CONST_ACTION_SEND_STATUS){ actionValue = CONST_ACTION_ID_SEND_STATUS; }else if(control.imgAction === CONST_ACTION_JUMP_TO_PAGE){ actionValue = CONST_ACTION_ID_JUMP_TO_PAGE; }else if(control.imgAction === CONST_ACTION_SAVE_AND_SEND){ actionValue = CONST_ACTION_ID_SAVE_AND_SEND; }else if(control.imgAction === CONST_ACTION_LAUNCH_GOOGLE_MAP){ actionValue = CONST_ACTION_ID_LAUNCH_GOOGLE_MAPS; }else if(control.imgAction === CONST_ACTION_LAUNCH_GARMIN_DIRECTIONS){ actionValue = CONST_ACTION_ID_LAUNCH_GARMIN_DIRECTIONS; }else if(control.imgAction === 'Credit Card Payment'){ actionValue = CONST_ACTION_ID_CREDIT_CARD_PAYMENT; }else if(control.imgAction === CONST_ACTION_SEND_AND_CONTINUE){ actionValue = CONST_ACTION_ID_SEND_AND_CONTINUE; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_FLINT_APP){ actionValue = CONST_ACTION_ID_FLINT_APP; }else if(control.imgAction === CONST_ACTION_EXIT_WITHOUT_CONF){ actionValue = CONST_ACTION_ID_EXIT_WITHOUT_CONFIRM; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_SAVE_AND_EXIT){ actionValue = CONST_ACTION_ID_SAVE_AND_EXIT; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_SAVE_AND_LOAD_FORM){ actionValue = CONST_ACTION_ID_SAVE_AND_LOAD_FORM; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_OPEN_FORM){ actionValue = CONST_ACTION_ID_PARAM_OPEN_FORM; }else if(control.imgAction === CONST_ACTION_OPEN_REVIEW){ actionValue = CONST_ACTION_ID_PARAM_OPEN_FORM_FROM_REVIEW; }else if(control.imgAction === CONST_ACTION_PRINT){ actionValue = CONST_ACTION_ID_PRINT; }else if(control.imgAction === CONST_ACTION_PRINT_MOBILE){ actionValue = CONST_ACTION_ID_PRINT_MOBILE; }else if(control.imgAction === CONST_ACTION_ZEBRA_PRINT){ actionValue = CONST_ACTION_ID_ZEBRA_PRINT; }else if(control.imgAction === CONST_ACTION_SAVE_FORM){ actionValue = CONST_ACTION_ID_SAVE_FORM; isCloseNSaveAction = true; }else if(control.imgAction === 'Deliver'){ actionValue = CONST_ACTION_ID_DELIVER_PICKUP; }else if(control.imgAction === 'Pickup'){ actionValue = CONST_ACTION_ID_DELIVER_PICKUP; }else if(control.imgAction === CONST_ACTION_SAVE_AS_COMPLETE){ actionValue = CONST_ACTION_ID_SAVE_COMPLETE; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_CALL){ actionValue = CONST_ACTION_ID_CALL; }else if(control.imgAction === CONST_ACTION_PROPAY){ actionValue = CONST_ACTION_ID_PROPAY; }else if(control.imgAction === CONST_ACTION_SQUARE){ actionValue = CONST_ACTION_ID_SQUARE; }else if(control.imgAction === CONST_ACTION_ONCLICK){ actionValue = CONST_ACTION_ID_ONCLICK; }else if(control.imgAction === CONST_ACTION_INCOMPLETE_STATUS){ actionValue = CONST_ACTION_ID_INCOMPLETESTATUS; }else if(control.imgAction === CONST_ACTION_SET_DESTINATION_FIELDS){ actionValue = CONST_ACTION_ID_SET_DESTINATION_FIELDS; }else if(control.imgAction === CONST_ACTION_OPEN_FILE){ actionValue = CONST_ACTION_ID_OPEN_FILE; }else if(control.imgAction === CONST_ACTION_CLOSE_AND_RELOAD){ actionValue = CONST_ACTION_ID_CLOSE_AND_RELOAD; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_CLOSE_AND_OPEN_FORM){ actionValue = CONST_ACTION_ID_CLOSE_AND_OPEN_FORM; isCloseNSaveAction = true; }else if(control.imgAction === CONST_SET_STATUS_TO_GPS){ actionValue = CONST_ACTION_ID_SET_STATUS_TO_GPS; }else if(control.imgAction === CONST_ACTION_AUDIT){ actionValue = CONST_ACTION_ID_AUDIT; }else if(control.imgAction === CONST_ACTION_MIPOD){ actionValue = CONST_ACTION_ID_MIPOD; }else if(control.imgAction === CONST_ACTION_CLOSE_AND_RETRIEVE){ actionValue = CONST_ACTION_ID_CLOSE_AND_RETRIEVE; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_SEND_AND_RETRIEVE){ actionValue = CONST_ACTION_ID_SEND_AND_RETRIEVE; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_ATTACH_FORM){ actionValue = CONST_ACTION_ID_ATTACH_FORM; isCloseNSaveAction = true; }else if(control.imgAction === CONST_ACTION_GET_GEOTAB_DATA){ actionValue = CONST_ACTION_ID_GET_GEOTAB_DATA; }else if(control.imgAction === CONST_ACTION_SEND_TEXT_MESSAGE){ actionValue = CONST_ACTION_ID_SEND_TEXT_MESSAGE; } binding.attrs.action = actionValue; processButtonSize(binding, control); var actionParamObj = {}; var iOSActionParamObj = {}; if(actionValue === CONST_ACTION_ID_SEND_AND_CONTINUE){ if(isVersion(VERSION_OFE_SEND_DATA)){ if(control.imgActionParam_isSendValues === true){ binding.attrs.isSendValues = CONST_XML_FUNCTION_TRUE; if(control.imgActionParam_sendValues && control.imgActionParam_sendValues.length>0){ var sendData = ''; _.each(control.imgActionParam_sendValues, function(sendValuesItem){ var newFormFieldName = sendValuesItem.text.new_form_field; var currentFieldPath = getControlXPath(root, "/data/", sendValuesItem.text.current_field); if(sendData == ''){ sendData = currentFieldPath + ',' + newFormFieldName; }else{ sendData = sendData + ';' + currentFieldPath + ',' + newFormFieldName; } }); actionParamObj.eng = sendData; bodyTag.children.push({ name: 'actionParam_sendValues', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam_sendValues')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam_sendValues', translations); } } } }else if(actionValue === CONST_ACTION_ID_PLAY_VIDEO || actionValue === CONST_ACTION_ID_OPEN_WEB_PAGE || actionValue === CONST_ACTION_ID_LAUNCH_PROGRAM || actionValue === CONST_ACTION_ID_SEND_STATUS){ if((isVersion(VERSION_CONSISTENCE_DROPDOWN) && control.imgOpenWebPageParamType == CONST_VALUE_OTHER)){ // add calculate attribute var itemPath = getControlXPath(root, "/data/", control.imgOpenWebPageQues); binding.attrs.calculate = '(' + itemPath + ')'; }else if(!isVersion(VERSION_CONSISTENCE_DROPDOWN) && actionValue === CONST_ACTION_ID_OPEN_WEB_PAGE && control.imgOpenWebPageQues != undefined && control.imgOpenWebPageQues !== '__Constant__' && isVersion(VERSION_OPEN_WEB_PAGE_NEW)){ // add calculate attribute var itemPath = getControlXPath(root, "/data/", control.imgOpenWebPageQues); binding.attrs.calculate = '(' + itemPath + ')'; }else{ if(isVersion(VERSION_ACTION_SEND_STATUS_NEW_OPT) && actionValue === CONST_ACTION_ID_SEND_STATUS){ if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(valueOrEmpty(control.imgActionParamType) == CONST_VALUE_OTHER){ actionParamObj.eng = ''; var actionStatusParamObj = {}; var itemPath = getControlXPath(root, "/data/", control.imgActionStatusCtrl); actionStatusParamObj.eng = itemPath; bodyTag.children.push({ name: 'actionParamQuestion', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParamQuestion')" } }); addTranslation(actionStatusParamObj, xpath + control.name + ':actionParamQuestion', translations); }else{ actionParamObj.eng = control.imgActionParam; } }else{ if(valueOrEmpty(control.imgActionStatusCtrl) != ''){ actionParamObj.eng = ''; var actionStatusParamObj = {}; var itemPath = getControlXPath(root, "/data/", control.imgActionStatusCtrl); actionStatusParamObj.eng = itemPath; bodyTag.children.push({ name: 'actionParamQuestion', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParamQuestion')" } }); addTranslation(actionStatusParamObj, xpath + control.name + ':actionParamQuestion', translations); }else{ actionParamObj.eng = control.imgActionParam; } } }else{ if(isVersion(VERSION_ANDROID_APP) && actionValue === CONST_ACTION_ID_LAUNCH_PROGRAM){ var androidApp = {}; androidApp.eng = control.androidApp; bodyTag.children.push({ name: 'androidApp', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":androidApp')" } }); addTranslation(androidApp, xpath + control.name + ':androidApp', translations); var found = false; _.each(android_app, function(app){ var arr = app.split('$$'); if(arr[0] == control.androidApp){ found = true; if(arr.length >= 2){ actionParamObj.eng = arr[1]; }else{ actionParamObj.eng = arr[0]; } return false; } }) if(!found){ actionParamObj.eng = control.androidApp; } }else{ actionParamObj.eng = control.imgActionParam; } } bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); } if(actionValue === CONST_ACTION_ID_LAUNCH_PROGRAM){ if(!isVersion(VERSION_IOS_APP_SELECT_OPTION)){ iOSActionParamObj.eng = control.imgiOSActionParam; }else{ if(!control.iOSApp || control.iOSApp == CONS_OPTION_CONSTANT_VALUE){ iOSActionParamObj.eng = control.imgiOSActionParam; }else{ if(control.iOSApp == '' || control.iOSApp == lbl_sel_question){ iOSActionParamObj.eng = ''; }else{ var itemPath = getControlXPath(root, "/data/", control.iOSApp); iOSActionParamObj.eng = itemPath; } } } bodyTag.children.push({ name: 'iOSActionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":iOSActionParam')" } }); addTranslation(iOSActionParamObj, xpath + control.name + ':iOSActionParam', translations); } }else if(actionValue === CONST_ACTION_ID_JUMP){ var destinationControl = getControlById(control.imgActionParamDesQues, root); if(destinationControl != undefined){ //binding.attrs.actionParam = destinationControl.name; actionParamObj.eng = destinationControl.name; bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); } if (control.imgActionParamDesQuesFlg == undefined || control.imgActionParamDesQuesFlg === true){ binding.attrs.actionParamAutostamp = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.actionParamAutostamp = CONST_XML_FUNCTION_FALSE; } }else if(actionValue === CONST_ACTION_ID_JUMP_TO_PAGE){ switch(control.imgActionParamDesPage){ case 'top': case 'previous': case 'next': case 'bottom': case 'first': case 'last': actionParamObj.eng = control.imgActionParamDesPage; bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); break; default: var destinationControl = getControlById(control.imgActionParamDesPage, root); if(destinationControl != undefined){ //binding.attrs.actionParam = destinationControl.name; actionParamObj.eng = destinationControl.name; bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); } } }else if(actionValue === CONST_ACTION_ID_LAUNCH_GOOGLE_MAPS || actionValue === CONST_ACTION_ID_LAUNCH_GARMIN_DIRECTIONS){ // Launch Google Maps var addressType = '0'; var hasRelevant = true; //if(control.imgActionParamMap == 'Address' || control.imgActionParamMap == 'Lat/Lon'){ if(control.imgActionParamMap == 'Address'){ addressType = '0'; }else if(control.imgActionParamMap == 'Lat/Lon'){ addressType = '1'; }else{ addressType = '2'; } if(control.mapActionGroup == CONST_MAP_ACTION_GROUP_ROUTE){ addressType = '2'; } var mapAction = '0'; if(control.imgActionParamMapAdd == 'Center map on address'){ mapAction = '0'; }else if(control.imgActionParamMapAdd == 'Get directions from current position to address'){ mapAction = '1'; }else{ //if(isVersion(VERSION_GOOGLE_MAP_ROUTES)){ if(control.mapActionGroup == CONST_MAP_ACTION_GROUP_ROUTE){ var route = ''; var itemPath = ''; switch(control.imgActionParamMapAdd){ case CONST_ACTION_OPEN_MFR: mapAction = '2'; route = control.routeType; route += '|' + toRouteString(root, control.route); route += '|||'; if(isVersion(VERSION_GOOGLE_MAP_ROUTES_ARRIVAL_TIME)){ route += '|'; } hasRelevant = false; break; case CONST_ACTION_RS: mapAction = '3'; route = control.routeType; route += '|' + toRouteString(root, control.route); route += '|' + control.routeDistance + ','; itemPath = getControlXPath(root, "/data/", control.routeDistanceField); route += itemPath; route += '|' + control.routeTravelTime + ','; itemPath = getControlXPath(root, "/data/", control.routeTravelTimeField); route += itemPath; route += '|'; itemPath = getControlXPath(root, "/data/", control.routeMap); route += itemPath; if(isVersion(VERSION_GOOGLE_MAP_ROUTES_ARRIVAL_TIME)){ route += '|'; itemPath = getControlXPath(root, "/data/", control.arrivalTime); route += itemPath; } hasRelevant = false; break; case CONST_ACTION_OPEN_MFR_N_RS: mapAction = '4'; /*route = control.routeType; route += '|' + toRouteString(root, control.route); route += '|' + control.distanceUnit; route += '|' + control.travelTimeFormat; route += '|';*/ route = control.routeType; route += '|' + toRouteString(root, control.route); route += '|' + control.routeDistance + ','; itemPath = getControlXPath(root, "/data/", control.routeDistanceField); route += itemPath; route += '|' + control.routeTravelTime + ','; itemPath = getControlXPath(root, "/data/", control.routeTravelTimeField); route += itemPath; route += '|'; itemPath = getControlXPath(root, "/data/", control.routeMap); route += itemPath; if(isVersion(VERSION_GOOGLE_MAP_ROUTES_ARRIVAL_TIME)){ route += '|'; itemPath = getControlXPath(root, "/data/", control.arrivalTime); route += itemPath; } hasRelevant = false; break; default: mapAction = '4'; route = control.routeType; route += '|' + toRouteString(root, control.route); route += '|' + control.routeDistance + ','; itemPath = getControlXPath(root, "/data/", control.routeDistanceField); route += itemPath; route += '|' + control.routeTravelTime + ','; itemPath = getControlXPath(root, "/data/", control.routeTravelTimeField); route += itemPath; route += '|'; itemPath = getControlXPath(root, "/data/", control.routeMap); route += itemPath; if(isVersion(VERSION_GOOGLE_MAP_ROUTES_ARRIVAL_TIME)){ route += '|'; itemPath = getControlXPath(root, "/data/", control.arrivalTime); route += itemPath; } hasRelevant = false; break; } if(route != ''){ binding.attrs.route = route; } } } binding.attrs.mapAction = mapAction; //} /*else if(control.imgActionParamMap == 'Lat/Lon'){ addressType = '1'; var mapAction = '0'; if(control.imgActionParamMapLatLong == 'Center map on lat/lon'){ mapAction = '0'; }else if(control.imgActionParamMapLatLong == 'Get directions from current position to lat/lon'){ mapAction = '1'; } binding.attrs.mapAction = mapAction; }*/ var inputSource = 0; if(!isVersion(VERSION_GMAP_REMOVE_INPUT_SRC)){ if(control.imgActionParamMapInputSourceParam == 'Lookup widget'){ inputSource = '0'; }else if(control.imgActionParamMapInputSourceParam == 'Text widget'){ inputSource = '1'; }else if(control.imgActionParamMapInputSourceParam == 'Location widget'){ inputSource = '2'; } }else{ inputSource = '3'; } binding.attrs.inputSource = inputSource; if(hasRelevant){ // add calculate attribute var itemPath = getControlXPath(root, "/data/", control.imgActionParamMapLatLongParam); //var destinationControl = getControlById(control.imgActionParamMapLatLongParam, root); binding.attrs.calculate = '(' + itemPath + ')'; } binding.attrs.addressType = addressType; }else if(actionValue === CONST_ACTION_ID_CREDIT_CARD_PAYMENT){ // Credit Card Payment // add calculate attribute var itemPath = getControlXPath(root, "/data/", control.imgActionParamCCP_TransAmount); binding.attrs.calculate = "creditCard(" + itemPath; if((control.imgActionParamCCP_TransDesc || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamCCP_TransDesc, 'Description')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamCCP_TransDesc); } } binding.attrs.calculate += "," + itemPath; binding.attrs.calculate += ",'" + (control.imgActionParamCCP_Currency || '') + "'"; if((control.imgActionParamCCP_ReceiptEmail || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamCCP_ReceiptEmail, 'ReceiptEmail')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamCCP_ReceiptEmail); } } binding.attrs.calculate += "," + itemPath; binding.attrs.calculate += ')'; }else if(actionValue === CONST_ACTION_ID_FLINT_APP){ // Flint app // add calculate attribute var flintParam = ''; var itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_TransSubtotal); flintParam = 'flintIn(' + itemPath; binding.attrs.flintIn = itemPath; if((control.imgActionParamFA_Tax || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamFA_Tax, 'Tax')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_Tax); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.imgActionParamFA_TransMemo || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamFA_TransMemo, 'Memo')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_TransMemo); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.imgActionParamFA_ReceiptEmail || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamFA_ReceiptEmail, 'ReceiptEmail')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_ReceiptEmail); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.imgActionParamFA_Name || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamFA_Name, 'Name')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_Name); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.imgActionParamFA_Phone || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionParamFA_Phone, 'Phone')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_Phone); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.imgActionParamFA_Trxid || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionResultParamByIdCorrectPos(root, control.id, control.imgActionParamFA_Trxid, 'Trxid')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_Trxid); } } flintParam += '); flintOut(' + itemPath; binding.attrs.flintOut = itemPath; if((control.imgActionParamFA_Result_Amount || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionResultParamByIdCorrectPos(root, control.id, control.imgActionParamFA_Result_Amount, 'Amount')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionParamFA_Result_Amount); } } flintParam += "," + itemPath; flintParam += ')'; binding.attrs.flintOut += "," + itemPath; actionParamObj.eng = flintParam; bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); }else if(actionValue === CONST_ACTION_ID_SAVE_AND_LOAD_FORM || actionValue === CONST_ACTION_ID_CLOSE_AND_OPEN_FORM){ if(isVersion(VERSION_ADD_PROJECT_SELECTOR)){ actionParamObj.eng = control.imgActionParam_SaveAndLoadProject; bodyTag.children.push({ name: 'actionParam_Project', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam_Project')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam_Project', translations); } actionParamObj.eng = control.imgActionParam_SaveAndLoadForm; bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); if(isVersion(VERSION_OFE_SEND_DATA)){ if(control.imgActionParam_isSendValues === true){ binding.attrs.isSendValues = CONST_XML_FUNCTION_TRUE; if(control.imgActionParam_sendValues && control.imgActionParam_sendValues.length>0){ var sendData = ''; _.each(control.imgActionParam_sendValues, function(sendValuesItem){ var newFormFieldName = sendValuesItem.text.new_form_field; var currentFieldPath = getControlXPath(root, "/data/", sendValuesItem.text.current_field); if(sendData == ''){ sendData = currentFieldPath + ',' + newFormFieldName; }else{ sendData = sendData + ';' + currentFieldPath + ',' + newFormFieldName; } }); actionParamObj.eng = sendData; bodyTag.children.push({ name: 'actionParam_sendValues', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam_sendValues')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam_sendValues', translations); } } } }else if(actionValue === CONST_ACTION_ID_PARAM_OPEN_FORM){ actionParamObj.eng = control.imgActionParam_OpenForm; bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); if(isVersion(VERSION_ACTION_OPEN_FORM_PROJECT)){ actionParamObj.eng = control.imgActionParam_OpenFormProject; bodyTag.children.push({ name: 'actionParam_Project', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam_Project')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam_Project', translations); } if(isVersion(VERSION_OFE_SEND_DATA)){ if(control.imgActionParam_isSendValues === true){ binding.attrs.isSendValues = CONST_XML_FUNCTION_TRUE; if(control.imgActionParam_sendValues && control.imgActionParam_sendValues.length>0){ var sendData = ''; _.each(control.imgActionParam_sendValues, function(sendValuesItem){ var newFormFieldName = sendValuesItem.text.new_form_field; var currentFieldPath = getControlXPath(root, "/data/", sendValuesItem.text.current_field); if(sendData == ''){ sendData = currentFieldPath + ',' + newFormFieldName; }else{ sendData = sendData + ';' + currentFieldPath + ',' + newFormFieldName; } }); actionParamObj.eng = sendData; bodyTag.children.push({ name: 'actionParam_sendValues', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam_sendValues')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam_sendValues', translations); } } } if(isVersion(VERSION_SAVE_AS_INCOMPLETE)){ if(control.imgActionParam_isSaveAsIncomplete === false){ binding.attrs.isSaveAsIncomplete = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_OFE_RETURN_DATA)){ if(control.imgActionParam_isReturnValues === true){ binding.attrs.isReturnValues = CONST_XML_FUNCTION_TRUE; if(control.imgActionParam_returnValues && control.imgActionParam_returnValues.length>0){ var returnData = ''; _.each(control.imgActionParam_returnValues, function(returnValuesItem){ var newFormFieldName = returnValuesItem.text.new_form_field; var currentFieldPath = getControlXPath(root, "/data/", returnValuesItem.text.current_field); if(returnData == ''){ returnData = currentFieldPath + ',' + newFormFieldName; }else{ returnData = returnData + ';' + currentFieldPath + ',' + newFormFieldName; } }); actionParamObj.eng = returnData; bodyTag.children.push({ name: 'actionParam_returnValues', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam_returnValues')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam_returnValues', translations); } } } }else if(actionValue === CONST_ACTION_ID_PARAM_OPEN_FORM_FROM_REVIEW){ if(isVersion(VERSION_ACTION_OPEN_REVIEW)){ var openFromReview = ''; if(control.fromIncompleteNone){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromIncompleteAA){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromIncompleteNP){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromIncompleteNS){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromIncompleteNQA){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_VERTICAL_BAR; if(control.fromCompleteNone){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromCompleteAA){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromCompleteNP){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromCompleteNS){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_COMMA; if(control.fromCompleteNQA){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } openFromReview += CONST_VERTICAL_BAR; if(control.fromSent){ openFromReview += CONST_VALUE_TRUE_STR }else{ openFromReview += CONST_VALUE_FALSE_STR } binding.attrs.openFromReview = openFromReview; } }else if(actionValue === CONST_ACTION_ID_SAVE_FORM){ // Save form }else if(actionValue === CONST_ACTION_ID_DELIVER_PICKUP){ // Deliver }else if(actionValue === CONST_ACTION_ID_CALL){ // call if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(control.imgActionMobileNumberParamType == CONST_VALUE_OTHER){ var itemPath = ''; if((control.imgActionMobileNumberCtrl || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionMobileNumberCtrl, 'Phone')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionMobileNumberCtrl); } } actionParamObj.eng = itemPath; }else{ actionParamObj.eng = control.imgActionMobileNumber; } }else{ if(control.imgActionMobileNumberCtrl && control.imgActionMobileNumberCtrl != ''){ var itemPath = ''; if((control.imgActionMobileNumberCtrl || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionMobileNumberCtrl, 'Phone')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionMobileNumberCtrl); } } actionParamObj.eng = itemPath; }else{ actionParamObj.eng = control.imgActionMobileNumber; } } bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); }else if(actionValue === CONST_ACTION_ID_SEND_TEXT_MESSAGE){ if(isVersion(VERSION_SEND_TEXT_MESSAGE)){ if(control.imgActionMobileNumberParamType == CONST_VALUE_OTHER){ var itemPath = ''; if((control.imgActionMobileNumberCtrl || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionMobileNumberCtrl, 'Phone')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionMobileNumberCtrl); } } actionParamObj.eng = itemPath; }else{ actionParamObj.eng = control.imgActionMobileNumber; } bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); if(control.imgActionMessageType == CONST_VALUE_OTHER){ var itemPath = ''; if((control.imgActionMessageCtrl || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.imgActionMessageCtrl, 'Phone')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.imgActionMessageCtrl); } } actionParamObj.eng = itemPath; }else{ actionParamObj.eng = control.imgActionMessage; } bodyTag.children.push({ name: 'actionMessage', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionMessage')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionMessage', translations); } }else if(actionValue === CONST_ACTION_ID_PROPAY || actionValue === CONST_ACTION_ID_SQUARE || actionValue === CONST_ACTION_ID_MIPOD){ //paypro actionParamObj.eng = makeProPayPath(root, control); bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); }else if(actionValue === CONST_ACTION_ID_ONCLICK){ //OnClick var desQuesItemPath = getControlXPath(root, "/data/", control.imgActionParamDesQues); actionParamObj.eng = desQuesItemPath; bodyTag.children.push({ name: 'actionParamQuestion', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParamQuestion')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParamQuestion', translations); actionParamObj.eng = control.imgActionParam; bodyTag.children.push({ name: 'actionParamValue', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParamValue')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParamValue', translations); }else if(actionValue === CONST_ACTION_ID_INCOMPLETESTATUS || actionValue === CONST_ACTION_ID_SAVE_AND_EXIT || actionValue === CONST_ACTION_ID_SAVE_COMPLETE ){ // save as incomplete Status if(control.imgActionIncompleteStatus != ''){ actionParamObj.eng = control.imgActionIncompleteStatus; bodyTag.children.push({ name: 'actionParamValue', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParamValue')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParamValue', translations); } }else if(actionValue === CONST_ACTION_ID_PRINT_MOBILE){ if(isVersion(VERSION_ACTION_PRINTER)){ switch(control.imgActionParamPrinter){ case CONST_PRN_ZEBRA: binding.attrs.printType = CONST_PRN_ZEBRA; if(control.imgActionParamPrintFields && control.imgActionParamPrintFields.length > 0){ var printControls = ''; var tmp = ''; for(var i=0;i 0){ for(var i=0;i 0){ var printColumn1 = ''; var printColumn2 = ''; var printAdjustColumnWidth = ''; var tmp = ''; for(var i=0;i 0){ var tmp = ''; var printFiles = ''; for(var i=0;i 0){ if(isVersion(VERSION_TRIGGER_ACTION_N_LOGIC) && isCloseNSaveAction){ if(control.triggerActionNLogic == false){ binding.attrs.triggerActionNLogic = CONST_XML_FUNCTION_FALSE; } } var destinationFillString = ''; var i = 0; _.each(control.actionDestinationData, function(item){ if(item.text.val == ''){ return true; } // CO-4086 Add user variables as destination field targets start var fillFieldPath; var fillFieldType; if(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldPath = item.text.val; fillFieldType = CONST_STRING; }else{ var fillControl = getControlById(item.text.val, root); if(fillControl == undefined){ return true; } fillFieldPath = getControlXPath(root, "/data/", item.text.val); fillFieldType = getFieldType(fillControl) } // CO-4086 Add user variables as destination field targets end if(i != 0){ destinationFillString = destinationFillString + ', '; } var fillFieldValue = ''; if(item.value.val === 'Other value'){ if(item.value.other_value == undefined){ item.value.other_value = ''; } switch(fillFieldType){ case CONST_STRING: fillFieldValue = "'" + item.value.other_value + "'"; fillFieldValue = fillFieldValue.replace(/&/gi, '&').replace(//gi, '>'); break; default: fillFieldValue = item.value.other_value; } }else if(item.value.val.startsWith('Other')){ var otherControl = getControlById(item.value.other_ctrl_id, root); if(otherControl == undefined){ return true; } var otherControlPath = getControlXPath(root, "/data/", item.value.other_ctrl_id); switch(item.value.val){ case CONST_OTHER_DAY_OF_MONTH: fillFieldValue = 'dayofmonth(' + otherControlPath + ')'; break; case CONST_OTHER_WEEK_NUMBER: fillFieldValue = 'weeknumber(' + otherControlPath + ')'; break; case CONST_OTHER_MONTH_NUMBER: fillFieldValue = 'monthnumber(' + otherControlPath + ')'; break; case CONST_OTHER_YEAR_NUMBER: fillFieldValue = 'yearnumber(' + otherControlPath + ')'; break; case CONST_OTHER_DAY_NAME: fillFieldValue = 'dayofweek(' + otherControlPath + ')'; break; case CONST_OTHER_WEEK_NAME: fillFieldValue = 'weekname(' + otherControlPath + ')'; break; case CONST_OTHER_MONTH_NAME: fillFieldValue = 'monthname(' + otherControlPath + ')'; break; case CONST_OTHER_YEAR_NAME: fillFieldValue = 'yearname(' + otherControlPath + ')'; break; default: fillFieldValue = otherControlPath; } }else if(item.value.val.indexOf('()')>0){ fillFieldValue = item.value.val; }else if(item.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldValue = item.value.val; }else{ var otherControl = getControlById(item.value.val, root); if(otherControl == undefined){ return true; } var otherControlPath = getControlXPath(root, "/data/", item.value.val); fillFieldValue = otherControlPath; } if(fillFieldValue == ''){ fillFieldValue = "''"; } destinationFillString = destinationFillString + fillFieldPath + " = " + fillFieldValue; i++; }); var actionParamObj = {}; actionParamObj.eng = destinationFillString; bodyTag.children.push({ name: 'destination', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":destination')" } }); addTranslation(actionParamObj, xpath + control.name + ':destination', translations); } }else if(isVersion(VERSION_ACTION_SET_DESTINATION_FIELD)){ if(control.actionDestinationData4SDF != undefined && control.actionDestinationData4SDF.length > 0){ var destinationFillString = ''; var i = 0; _.each(control.actionDestinationData4SDF, function(item){ if(item.text.val == ''){ return true; } // CO-4086 Add user variables as destination field targets start var fillFieldPath; var fillFieldType; if(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldPath = item.text.val; fillFieldType = CONST_STRING; }else{ var fillControl = getControlById(item.text.val, root); if(fillControl == undefined){ return true; } fillFieldPath = getControlXPath(root, "/data/", item.text.val); fillFieldType = getFieldType(fillControl) } // CO-4086 Add user variables as destination field targets end if(i != 0){ destinationFillString = destinationFillString + ', '; } var fillFieldValue = ''; if(item.value.val === 'Other value'){ if(item.value.other_value == undefined){ item.value.other_value = ''; } switch(fillFieldType){ case CONST_STRING: fillFieldValue = "'" + item.value.other_value + "'"; fillFieldValue = fillFieldValue.replace(/&/gi, '&').replace(//gi, '>'); break; default: fillFieldValue = item.value.other_value; } }else if(item.value.val.startsWith('Other')){ var otherControl = getControlById(item.value.other_ctrl_id, root); if(otherControl == undefined){ return true; } var otherControlPath = getControlXPath(root, "/data/", item.value.other_ctrl_id); switch(item.value.val){ case CONST_OTHER_DAY_OF_MONTH: fillFieldValue = 'dayofmonth(' + otherControlPath + ')'; break; case CONST_OTHER_WEEK_NUMBER: fillFieldValue = 'weeknumber(' + otherControlPath + ')'; break; case CONST_OTHER_MONTH_NUMBER: fillFieldValue = 'monthnumber(' + otherControlPath + ')'; break; case CONST_OTHER_YEAR_NUMBER: fillFieldValue = 'yearnumber(' + otherControlPath + ')'; break; case CONST_OTHER_DAY_NAME: fillFieldValue = 'dayofweek(' + otherControlPath + ')'; break; case CONST_OTHER_WEEK_NAME: fillFieldValue = 'weekname(' + otherControlPath + ')'; break; case CONST_OTHER_MONTH_NAME: fillFieldValue = 'monthname(' + otherControlPath + ')'; break; case CONST_OTHER_YEAR_NAME: fillFieldValue = 'yearname(' + otherControlPath + ')'; break; default: fillFieldValue = otherControlPath; } }else if(item.value.val.indexOf('()')>0){ fillFieldValue = item.value.val; }else if(item.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldValue = item.value.val; }else{ var otherControl = getControlById(item.value.val, root); if(otherControl == undefined){ return true; } var otherControlPath = getControlXPath(root, "/data/", item.value.val); fillFieldValue = otherControlPath; } if(fillFieldValue == ''){ fillFieldValue = "''"; } destinationFillString = destinationFillString + fillFieldPath + " = " + fillFieldValue; i++; }); var actionParamObj = {}; actionParamObj.eng = destinationFillString; bodyTag.children.push({ name: 'destination', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":destination')" } }); addTranslation(actionParamObj, xpath + control.name + ':destination', translations); } } } } if(isVersion(VERSION_GET_GEOTAB_DATA) && control.type == CONST_CTRL_TYPE_INPUTACTION){ if(control.imgAction == CONST_ACTION_GET_GEOTAB_DATA){ binding.attrs.actionGeoTabVehicle = control.actionGeoTabVehicle; } } if(control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ if (control.imgJustify != undefined){ binding.attrs.imageJustification = control.imgJustify; } var actionValue = CONST_ACTION_ID_FLINT_APP; binding.attrs.action = actionValue; var actionParamObj = {}; var iOSActionParamObj = {}; // add calculate attribute var flintParam = ''; var itemPath = getControlXPath(root, "/data/", control.payment_TransSubtotal); flintParam = 'flintIn(' + itemPath; binding.attrs.flintIn = itemPath; if((control.payment_Tax || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.payment_Tax, 'Tax')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.payment_Tax); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.payment_TransMemo || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.payment_TransMemo, 'Memo')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.payment_TransMemo); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.payment_ReceiptEmail || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.payment_ReceiptEmail, 'ReceiptEmail')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.payment_ReceiptEmail); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.payment_Name || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.payment_Name, 'Name')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.payment_Name); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.payment_Phone || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionParamByIdCorrectPos(root, control.id, control.payment_Phone, 'Phone')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.payment_Phone); } } flintParam += "," + itemPath; binding.attrs.flintIn += "," + itemPath; if((control.payment_Trxid || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionResultParamByIdCorrectPos(root, control.id, control.payment_Trxid, 'Trxid')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.payment_Trxid); } } flintParam += '); flintOut(' + itemPath; binding.attrs.flintOut = itemPath; if((control.payment_Result_Amount || '') == ''){ itemPath = "''"; }else{ if(!checkTransactionResultParamByIdCorrectPos(root, control.id, control.payment_Result_Amount, 'Amount')){ itemPath = "''"; }else{ itemPath = getControlXPath(root, "/data/", control.payment_Result_Amount); } } flintParam += "," + itemPath; flintParam += ')'; binding.attrs.flintOut += "," + itemPath; actionParamObj.eng = flintParam; bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); } if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ if(control.propay == false || control.paymentType == 'manual'){ constraint.push('string-length(decrypt(.)) >= ' + CREDIT_MINLENGTH); } } if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ } if(control.type == 'inputPageBreak' || control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || control.type == CONST_CTRL_TYPE_INPUTPAYMENT || control.type == 'inputInstruction' || control.type == 'inputSaveAndSend' || control.type == CONST_CTRL_TYPE_INPUT_SHIPPING || control.type == CONST_CTRL_TYPE_INPUTLOCATION){ var isAttachFormWidget = false; if(isVersion(VERSION_ATTACH_FORM) && control.isAttachFormWidget === true){ isAttachFormWidget = true; } if(!(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || control.type == CONST_CTRL_TYPE_INPUTLOCATION) && !isAttachFormWidget){ binding.attrs.readonly = CONST_XML_FUNCTION_TRUE; } /*if(isVersion(VERSION_CTRL_PROPERTY_DSP_READ_ONLY)){ binding.attrs.readOnlyDsp = CONST_XML_FUNCTION_TRUE; }*/ if(control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUT_SHIPPING || control.type == CONST_CTRL_TYPE_INPUTLOCATION){ var isAutoRun = false; if(isVersion(VERSION_GROUP_FUNCTION)){ if(control.actionKind == CONST_TYPE_AUTO_RUN){ isAutoRun = true; } } if(!isAutoRun || control.type == CONST_CTRL_TYPE_INPUTACTION){ if(isVersion(VERSION_ACTION_TYPE) && control.kind != undefined){ if(control.kind === 'Image'){ if(control.type !== CONST_CTRL_TYPE_INPUTLOCATION){ // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(control.imageText === undefined || jQuery.trim(control.imageText) === ''){ control.imageText = lbl_enter_image_text; } bodyTag.children.push({ name: 'imageText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":imageText')" } }); var imageTextObj = {}; imageTextObj.eng = control.imageText; addTranslation(imageTextObj, xpath + control.name + ':imageText', translations); } if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); var isWhiteColor = false; var isUsedCanvas = false; if((FILIB_ICON_IMAGE_CANVAS && binding.attrs.hintlink.indexOf('img/filib/') >= 0) || (FILIBBUTTON_ICON_IMAGE_CANVAS && binding.attrs.hintlink.indexOf('img/filibbutton/') >= 0)) { isUsedCanvas = true; } if(arr[0].indexOf('ffffff') > 0 && !isUsedCanvas) { isWhiteColor = true; } binding.attrs.hintlink = arr[0].replace('transparent','ffffff'); if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } if(control.iconColor != undefined){ var _hintLink = binding.attrs.hintlink; if(_hintLink == undefined || _hintLink == '' || _hintLink.indexOf('imageViewer?blobKey=') > 0){ // image uploaded binding.attrs.iconColor = ''; // CO-4811 } else if(isWhiteColor && CONST_FILIB_WHITE_BACKGROUND_COLOR == control.iconColor) { binding.attrs.iconColor = '#ffffff'; } else{ binding.attrs.iconColor = '#'+control.iconColor; // CO-4050 } } } } }else if(control.type !== CONST_CTRL_TYPE_INPUTLOCATION){ // button binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } //binding.attrs.actionBtnText = control.actionBtnText; bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; if(isVersion(VERSION_ATTACH_FORM) && control.isAttachFormWidget === true){ actionBtnTextObj.eng = lbl_action_attach_form_btn; }else{ actionBtnTextObj.eng = control.actionBtnText; } addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); if(isVersion(VERSION_SHOW_IMAGE_ICON_IN_STANDARD_BTN) && control.type == CONST_CTRL_TYPE_INPUTACTION){ if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); var isWhiteColor = false; var isUsedCanvas = false; if((FILIB_ICON_IMAGE_CANVAS && binding.attrs.hintlink.indexOf('img/filib/') >= 0) || (FILIBBUTTON_ICON_IMAGE_CANVAS && binding.attrs.hintlink.indexOf('img/filibbutton/') >= 0)) { isUsedCanvas = true; } if(arr[0].indexOf('ffffff') > 0 && !isUsedCanvas) { isWhiteColor = true; } binding.attrs.hintlink = arr[0].replace('transparent','ffffff'); if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } if(control.iconColor != undefined){ var _hintLink = binding.attrs.hintlink; if(_hintLink == undefined || _hintLink == '' || _hintLink.indexOf('imageViewer?blobKey=') > 0){ // image uploaded binding.attrs.iconColor = ''; // CO-4811 } else if(isWhiteColor && CONST_FILIB_WHITE_BACKGROUND_COLOR == control.iconColor) { binding.attrs.iconColor = '#ffffff'; } else{ binding.attrs.iconColor = '#'+control.iconColor; // CO-4050 } } binding.attrs.showImageIcon = CONST_XML_FUNCTION_TRUE; } } } } }else if(control.type !== CONST_CTRL_TYPE_INPUTLOCATION){ if(control.useImage !== undefined && control.useImage === false){ // ignore hintlink binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } //binding.attrs.actionBtnText = control.actionBtnText; bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; if(isVersion(VERSION_ATTACH_FORM) && control.isAttachFormWidget === true){ actionBtnTextObj.eng = lbl_action_attach_form_btn; }else{ actionBtnTextObj.eng = control.actionBtnText; } addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); }else if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); binding.attrs.hintlink = arr[0]; if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } } } } if(isVersion(VERSION_ACTION_IMAGE_SIZE_BY) && control.kind === 'Image'){ if(control.imageSize == 'ImageSize'){ binding.attrs.fitToContainer = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_GROUP_FUNCTION) && control.hideButtonAfterClick == true){ binding.attrs.hideButtonAfterClick = CONST_XML_FUNCTION_TRUE; } }else{ if(control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ binding.attrs.autostamp = CONST_XML_FUNCTION_TRUE; if(control.autoRunTrigger != '' && control.autoRunTrigger != lbl_sel_question) { if(control.autoRunTrigger == '2') { binding.attrs.autoStampTrigger = 2; }else{ if(isVersion(VERSION_AUTO_RUN_WHEN_RETRIEVE)){ if(control.autoRunTrigger == CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_DATA || control.autoRunTrigger == CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_NO_DATA) { binding.attrs.autoStampTrigger = control.autoRunTrigger; } } } } var itemPath = getControlXPath(root, "/data/", control.autoRunQuestionTrigger); binding.attrs.autoStampTriggerQues = itemPath; } } }else if(control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ if(isVersion(VERSION_ACTION_TYPE) && control.kind != undefined){ if(control.kind === 'Image'){ // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(control.imageText === undefined || jQuery.trim(control.imageText) === ''){ control.imageText = lbl_enter_image_text; } bodyTag.children.push({ name: 'imageText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":imageText')" } }); var imageTextObj = {}; imageTextObj.eng = control.imageText; addTranslation(imageTextObj, xpath + control.name + ':imageText', translations); if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); binding.attrs.hintlink = arr[0]; if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } } } }else{ // button binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } //binding.attrs.actionBtnText = control.actionBtnText; bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; actionBtnTextObj.eng = control.actionBtnText; addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); } }else{ if(control.useImage !== undefined && control.useImage === false){ // ignore hintlink binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } //binding.attrs.actionBtnText = control.actionBtnText; bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; actionBtnTextObj.eng = control.actionBtnText; addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); }else if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); binding.attrs.hintlink = arr[0]; if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } } } } }else if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ if(isVersion(VERSION_PAYMENT_TYPE) && (control.paymentType == CONST_PAYMENT_TYPE_AUTOMATED || control.paymentType == CONST_PAYMENT_TYPE_SQUARE || control.paymentType == CONST_PAYMENT_MIPOS)){ delete binding.attrs.justification; if(control.kind === 'Image'){ binding.attrs.imageJustification = 'Center'; // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(control.imageText === undefined || jQuery.trim(control.imageText) === ''){ control.imageText = lbl_enter_image_text; } bodyTag.children.push({ name: 'imageText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":imageText')" } }); var imageTextObj = {}; imageTextObj.eng = control.imageText; addTranslation(imageTextObj, xpath + control.name + ':imageText', translations); if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); binding.attrs.hintlink = arr[0]; if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } } } }else{ if (control.imgJustify != undefined){ binding.attrs.imageJustification = control.imgJustify; } // button binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } if(control.displayCCIcon){ binding.attrs.displayCCIcon = CONST_XML_FUNCTION_TRUE; } //binding.attrs.actionBtnText = control.actionBtnText; bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; actionBtnTextObj.eng = control.actionBtnText; addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); } } }else if(control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ binding.attrs.isScoreSummary = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_SUMMARY_FOR_CATEGORY)){ var summaryCategory = valueOrEmpty(control.summaryCategory); if( summaryCategory != ''){ binding.attrs.summaryCategory = HtmlEncode(summaryCategory, true); } } }else if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); binding.attrs.hintlink = arr[0]; if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } } } } // CO-4022: Hide if start if(isVersion(VERSION_HIDE_IF)){ if(control.isHideIfClick == true || control.isHideIfChecked == true || control.isHideIfCmpVal == true){ var hideIfString = CONST_XML_FUNCTION_TRUE + '|'; var hideIfCmpValString = ''; var hideIfCmpVal = ''; if(control.isHideIfCmpVal == true){ if(control.hideIfCmpVal){ var condString = control.hideIfCmpVal.condition; if(condString == CONST_VALUE_EQUAL){ condString = "="; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = "!="; }else if(condString == CONST_VALUE_LESS_THAN){ condString = "<"; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = "<="; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = ">"; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = ">="; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = "="; } }else{ condString = "="; } } hideIfCmpValString = condString + '|'; var cmpType = control.hideIfCmpVal.cmpType; if( cmpType == CONST_VALUE_OTHER){ hideIfCmpValString += cmpType; //hideIfCmpVal = getControlXPath(root, "/data/", control.hideIfCmpVal.val); }else{ hideIfCmpValString += CONS_RETRIVE_ACTION_CONSTANT_VALUE; //hideIfCmpVal = control.hideIfCmpVal.val; } hideIfCmpVal = createHideIfCondition(root, control); } hideIfString += hideIfCmpValString + '|'; } if(control.hideIfFields && control.hideIfFields.length>0){ var i = 0; _.each(control.hideIfFields, function(item){ if(item.text.val == ''){ return true; } var ItemControl = getControlById(item.text.val, root); if(ItemControl == undefined){ return true; } var hideIfFieldPath = getControlXPath(root, "/data/", item.text.val); if(i != 0){ hideIfString = hideIfString + ', '; } hideIfString = hideIfString + hideIfFieldPath; i++; }); if(control.isHideIfClick == true){ binding.attrs.isHideIfClick = hideIfString; }else if(control.isHideIfChecked == true){ binding.attrs.isHideIfChecked = hideIfString; }else if(control.isHideIfCmpVal == true){ bodyTag.children.push({ name: 'hideIfCmpVal', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":hideIfCmpVal')" } }); var actionParamObj = {}; actionParamObj.eng = hideIfCmpVal; addTranslation(actionParamObj, xpath + control.name + ':hideIfCmpVal', translations); binding.attrs.isHideIfCmpVal = hideIfString; } } } } // CO-4022: Hide if end if(isVersion(VERSION_SHOW_ICON_BUTTON) || isVersion(VERSION_SHOW_ICON_BUTTON_DATE_IN_GRID_TABLE)){ //CO-895 Add the Button type setting for Date/Time fields in Grid/Table if(isVersion(VERSION_SHOW_ICON_BUTTON_DATE_IN_GRID_TABLE)){ if(control.btnType === 'Image'){ // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_ICON_ACTION_DATE_TIME) && control.iconAction == CONST_PICKER){ binding.attrs.iconAction = CONST_PICKER; } } }else{ if(control.btnType === 'Image' && control.parentCtrlType != CONST_CTRL_TYPE_CTRLTABLE && control.parentCtrlType != CONST_CTRL_TYPE_CTRLSCHEDULE && control.parentCtrlType != CONST_CTRL_TYPE_CTRLGRID){ // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_ICON_ACTION_DATE_TIME) && control.iconAction == CONST_PICKER){ binding.attrs.iconAction = CONST_PICKER; } } } } if(isVersion(VERSION_PORTAL_SHADING)){ if(control.apperance == 'Custom'){ if(control.type == 'inputLabel' && control.parentCtrlType != CONST_CTRL_TYPE_CTRLGRID){ //ignore shadedHeadings if inputLabel not inside grid }else{ if(control.shadedHeadings){ if(isVersion(VERSION_APPEARANCE_ACTIVE_TEXT)){ if(control.shadedHeadings.isShadedHeadings){ binding.attrs.customShading = 'true|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading + '|' + control.shadedHeadings.activeTextColor; }else{ binding.attrs.customShading = 'false|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading + '|' + control.shadedHeadings.activeTextColor; } }else{ if(control.shadedHeadings.isShadedHeadings){ binding.attrs.customShading = 'true|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading; }else{ binding.attrs.customShading = 'false|' + control.shadedHeadings.headingColor + '|' + control.shadedHeadings.textColor + '|' + control.shadedHeadings.isBorderAroundHeading; } } } } if(control.answerColor){ if(control.answerColor.isAnswerColor){ //binding.attrs.answerColor = 'true|' + control.answerColor.answerBGColor + '|' + control.answerColor.answerTextColor; binding.attrs.answerColor = control.answerColor.answerTextColor; if(isVersion(VERSION_ANSWER_BACKGROUND_COLOR)){ if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLTABLE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLSCHEDULE){ binding.attrs.answerBGColor = control.answerColor.answerBGColor; } } } } if(control.shadedRow){ if(control.shadedRow.isShadedRow){ binding.attrs.customRow = 'true|' + control.shadedRow.rowColor + '|' + control.shadedRow.rowTextColor; }else{ binding.attrs.customRow = 'false|' + control.shadedRow.rowColor + '|' + control.shadedRow.rowTextColor; } } if(control.shadedButton){ if(control.shadedButton.isShadedButton){ binding.attrs.customButtonShading = 'true|' + control.shadedButton.btnSheadingColor + '|' + control.shadedButton.btnTextColor + '|' + control.shadedButton.activeBtnTextColor + '|' + control.shadedButton.btnBorderColor + '|' + control.shadedButton.btnRoundedCorners; }else{ binding.attrs.customButtonShading = 'false|' + control.shadedButton.btnSheadingColor + '|' + control.shadedButton.btnTextColor + '|' + control.shadedButton.activeBtnTextColor + '|' + control.shadedButton.btnBorderColor + '|' + control.shadedButton.btnRoundedCorners; } } } } if(isVersion(VERSION_REMOVE_ANSW_BORDER) && control.apperance == 'Custom'){ if(control.removeAnswerBorder){ binding.attrs.removeAnswerBorder = CONST_XML_FUNCTION_TRUE; } } if(control.type == 'inputLabel' && control.parentCtrlType != CONST_CTRL_TYPE_CTRLGRID){ // execute if inputLabel not inside grid if(isVersion(VERSION_LABEL_FIT_SCREEN)){ if(control.isFitToScreen){ binding.attrs.imgFitToScreen = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_LABEL_ADD_AS_SPACE)){ if(control.addAsSpace){ binding.attrs.addAsSpace = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_LABEL_SHADING)){ if(control.apperance == undefined || control.apperance == 'Custom'){ if(control.labelShading == '1'){ //lines //binding.attrs.labelShading = "1|" + (control.linesTextColor || LBL_DEFAULT_TEXT_COLOR) + "|" + (control.linesLineColor || LBL_DEFAULT_LINE_COLOR) + "| | | " ; binding.attrs.labelShading = "1| |" + (control.linesTextColor || LBL_DEFAULT_TEXT_COLOR) + "|" + (control.linesLineColor || LBL_DEFAULT_LINE_COLOR); }else if(control.labelShading == '2'){ //shaded /*if(isVersion(VERSION_PORTAL_SHADING)){ binding.attrs.labelShading = "2| | |" + (control.shadedHeadings.headingColor || LBL_DEFAULT_SHADE_COLOR) + "|" + (control.shadedHeadings.textColor || LBL_DEFAULT_TEXT_COLOR) + "| "; }else{ binding.attrs.labelShading = "2|" + (control.shadedColor || LBL_DEFAULT_SHADE_COLOR) + "|" + (control.shadedTextColor || LBL_DEFAULT_TEXT_COLOR) + "| "; }*/ //binding.attrs.labelShading = "2| | |" + (control.shadedColor || LBL_DEFAULT_SHADE_COLOR) + "|" + (control.shadedTextColor || LBL_DEFAULT_TEXT_COLOR) + "| "; binding.attrs.labelShading = "2|" + (control.shadedColor || LBL_DEFAULT_SHADE_COLOR) + "|" + (control.shadedTextColor || LBL_DEFAULT_TEXT_COLOR) + "| "; }else if(control.labelShading == '3'){ //no lines or shading //binding.attrs.labelShading = "3| | | | |" + (control.nolinesTextColor || LBL_DEFAULT_TEXT_COLOR); binding.attrs.labelShading = "3| |" + (control.nolinesTextColor || LBL_DEFAULT_TEXT_COLOR) + "| "; }else{ } }else{ binding.attrs.labelShading = "-1| | | "; } } } if(control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ if(control.imageUrl){ var itemPath = getControlXPath(root, "/data/", control.imageUrl); binding.attrs.imageUrl = itemPath; } if(control.isFitToScreen === true){ binding.attrs.imgFitToScreen = CONST_XML_FUNCTION_TRUE; } if(control.addAsSpace === true){ binding.attrs.addAsSpace = CONST_XML_FUNCTION_TRUE; } } //if then else condition binding = generateIfThenElseCondition(control, binding, root); if(isVersion(VERSION_SKIP_IF)){ //sip if condition binding = generateSkipIfCondition(control, binding, root); } if(isVersion5_0()){ if(!isFreeAccount()){ if(control.skipconds != undefined && control.skipconds[0] != undefined && control.skipconds[0].text['eng'] != undefined){ showSkipWrning = true; var fieldPath = getControlXPath(root, "/data/", control.id); var skipCondString = ""; var skipToField = control.skipconds[0].text['eng']; var i = 0; var condString = ""; var condValue = ""; var space = " "; _.each(control.skipconds, function(skipCond){ condString = skipCond.text[CONST_VAL]; condValue = skipCond.value[CONST_VAL]; if(condValue == undefined){ condValue = ''; } condValue = HtmlEncode(condValue, true); if(i != 0){ var joinString = skipCond.text['eng']; if(joinString == undefined || joinString != CONST_VALUE_OR_LOWERCASE){ joinString = CONST_VALUE_AND_LOWERCASE; } skipCondString = skipCondString + space + joinString + space; } var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } if(isNewEmptyType){ skipCondString = skipCondString + condString + '(' + fieldPath + ')'; }else if(control.type == CONST_CTRL_TYPE_INPUT_TEXT){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } skipCondString = skipCondString + fieldPath + condString + condValue; }else if(control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } skipCondString = skipCondString + fieldPath + condString + condValue; }else if(control.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(control.kind == CONST_VALUE_TIME){ skipCondString = skipCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ skipCondString = skipCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); }else{ skipCondString = skipCondString + fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); } }else if(control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTSCOREONE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(condString == ' = '){ skipCondString = skipCondString + 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ skipCondString = skipCondString + 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } }else if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputImage){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputAudio){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputVideo){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTMEDIA){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputSketch){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputSignature){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputDraw'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTBARCODE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTNFC){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputPageBreak' || control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTPAYMENT || control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || control.type == 'inputInstruction' || control.type == 'inputSaveAndSend'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputFacingTable'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputLookupMulti'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }/*else if (control.type == 'inputRIF'){ }*/ else if(control.type == CONST_CTRL_TYPE_INPUTATTACHMENT){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; } i++; }); //skipCondString = "false()=(" + skipCondString + ")"; binding.attrs.skip = skipCondString; binding.attrs.action = CONST_ACTION_ID_JUMP; var actionParamObj = {}; if(skipToField != CONST_JUMP_EOF_VAL){ var destinationControl = getControlById(skipToField, root); if(destinationControl != undefined){ actionParamObj.eng = destinationControl.name; }else{ actionParamObj.eng = ''; } }else{ //actionParamObj.eng = CONST_JUMP_EOF_TEXT; actionParamObj.eng = nextCtrlName; } bodyTag.children.push({ name: 'actionParam', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionParam')" } }); addTranslation(actionParamObj, xpath + control.name + ':actionParam', translations); } } } if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ if(isVersion(VERSION_AUTONUMBER_PHASE2)){ if (control.autoNumberType == 'Received'){ binding.attrs.typePrefix = 'Received'; binding.attrs.start = control.startValue; if(control.isResetNumbering){ binding.attrs.isResetNumbering = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isResetNumbering = CONST_XML_FUNCTION_FALSE; } }else if (control.autoNumberType == CONST_AUTO_TYPE_ON_DEVCE){ binding.attrs.typePrefix = CONST_AUTO_TYPE_ON_DEVCE; binding.attrs.start = control.startValue; if(control.isResetNumbering){ binding.attrs.isResetNumbering = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isResetNumbering = CONST_XML_FUNCTION_FALSE; } if(control.isEnableAsCollect){ binding.attrs.isEnableAsCollect = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isEnableAsCollect = CONST_XML_FUNCTION_FALSE; } if(control.autoNumberTriggerType && control.autoNumberTriggerType != ''){ binding.attrs.autoNumberTriggerType = control.autoNumberTriggerType; var itemPath = ''; switch(control.autoNumberTriggerType){ case '2': itemPath = getControlXPath(root, "/data/", control.autoNumTriggerQues); binding.attrs.autoNumTriggerQues = itemPath; break; case '4': itemPath = getControlXPath(root, "/data/", control.autoNumTriggerPages); binding.attrs.autoNumTriggerPages = itemPath; break; } } }else{ //Collected binding.attrs.typePrefix = 'Collected'; } bodyTag.children.push({ name: 'prefix', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":prefix')" } }); var actionParamObj = {}; actionParamObj.eng = control.prefix; addTranslation(actionParamObj, xpath + control.name + ':prefix', translations); } } if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(isVersion(VERSION_EMAIL_REPORT_NEW_DEFAULT) && control.defaultValue_selectedCtrl && control.defaultValue_selectedCtrl != '') { var itemPath = getControlXPath(root, "/data/", control.defaultValue_selectedCtrl); if(isVersion(VERSION_FAX_WIDGET) && control.isFaxWidget == true){ if(binding.attrs.calculate == undefined || binding.attrs.calculate == ''){ binding.attrs.calculate = itemPath; }else{ binding.attrs.calculate = 'if(isEmpty(.),' + itemPath + ',' + binding.attrs.calculate + ')'; } }else{ binding.attrs.calculate = 'email(' + itemPath + ')'; } } if(isVersion(VERSION_FAX_WIDGET) && control.isFaxWidget == true){ binding.attrs.isFaxWidget = CONST_XML_FUNCTION_TRUE; if(control.phoneNoFormat){ binding.attrs.format = 'phone|' + (control.phoneFormatKind | 0); } } } if(isVersion(VERSION_LOOKUP_RETRIEVE) && control.isRetrieve) { binding.attrs.isRetrieve = CONST_XML_FUNCTION_TRUE; var lookupValue; if(!jQuery.isPlainObject(control.lookupValue)){ lookupValue = control.lookupValue; }else{ lookupValue = control.lookupValue.val; } var itemPath = getControlXPath(root, "/data/", lookupValue); binding.attrs.lookupValue = itemPath; if(control.retrieveKind != "autoRun"){ if(control.btnKind === 'Image'){ // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(control.imageText === undefined || jQuery.trim(control.imageText) === ''){ control.imageText = lbl_enter_image_text; } bodyTag.children.push({ name: 'imageText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":imageText')" } }); var imageTextObj = {}; imageTextObj.eng = control.imageText; addTranslation(imageTextObj, xpath + control.name + ':imageText', translations); if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); // binding.attrs.hintlink = arr[0]; // if(arr[1]){ // binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); // } var isWhiteColor = false; var isUsedCanvas = false; if((typeof FILIB_ICON_IMAGE_CANVAS != 'undefined' && FILIB_ICON_IMAGE_CANVAS && binding.attrs.hintlink.indexOf('img/filib/') >= 0) || (typeof FILIBBUTTON_ICON_IMAGE_CANVAS != 'undefined' && FILIBBUTTON_ICON_IMAGE_CANVAS && binding.attrs.hintlink.indexOf('img/filibbutton/') >= 0)) { isUsedCanvas = true; } if(arr[0].indexOf('ffffff') > 0 && !isUsedCanvas) { isWhiteColor = true; } binding.attrs.hintlink = arr[0].replace('transparent','ffffff'); if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } if(typeof CONST_FILIB_WHITE_BACKGROUND_COLOR == 'undefined') { CONST_FILIB_WHITE_BACKGROUND_COLOR = '000000'; } if(control.iconColor != undefined){ var _hintLink = binding.attrs.hintlink; if(_hintLink == undefined || _hintLink == '' || _hintLink.indexOf('imageViewer?blobKey=') > 0){ // image uploaded binding.attrs.iconColor = ''; // CO-4811 } else if(isWhiteColor && CONST_FILIB_WHITE_BACKGROUND_COLOR == control.iconColor) { binding.attrs.iconColor = '#ffffff'; } else{ binding.attrs.iconColor = '#'+control.iconColor; // CO-4050 } } } } }else{ // button binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } //binding.attrs.actionBtnText = control.actionBtnText; bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; actionBtnTextObj.eng = control.actionBtnText; addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); } } // CO-1739 binding.attrs.imageJustification = 'Center'; if (control.imgJustify != undefined){ binding.attrs.imageJustification = control.imgJustify; } } if(isVersion(VERSION_RETRIEVE_MODIFY_SET_DESTINATION_FIELD) && control.isRetrieve){ if(control.actionDestinationData4SDF != undefined && control.actionDestinationData4SDF.length > 0){ var destinationFillString = ''; var i = 0; _.each(control.actionDestinationData4SDF, function(item){ if(item.text.val == ''){ return true; } // CO-4086 Add user variables as destination field targets start var fillFieldPath; var fillFieldType; if(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldPath = item.text.val; fillFieldType = CONST_STRING; }else{ var fillControl = getControlById(item.text.val, root); if(fillControl == undefined){ return true; } fillFieldPath = getControlXPath(root, "/data/", item.text.val); fillFieldType = getFieldType(fillControl) } // CO-4086 Add user variables as destination field targets end if(i != 0){ destinationFillString = destinationFillString + ', '; } var fillFieldValue = ''; if(item.value.val === 'Other value'){ if(item.value.other_value == undefined){ item.value.other_value = ''; } switch(fillFieldType){ case CONST_STRING: fillFieldValue = "'" + item.value.other_value + "'"; fillFieldValue = fillFieldValue.replace(/&/gi, '&').replace(//gi, '>'); break; default: fillFieldValue = item.value.other_value; } }else if(item.value.val.startsWith('Other')){ var otherControl = getControlById(item.value.other_ctrl_id, root); if(otherControl == undefined){ return true; } var otherControlPath = getControlXPath(root, "/data/", item.value.other_ctrl_id); switch(item.value.val){ case CONST_OTHER_DAY_OF_MONTH: fillFieldValue = 'dayofmonth(' + otherControlPath + ')'; break; case CONST_OTHER_WEEK_NUMBER: fillFieldValue = 'weeknumber(' + otherControlPath + ')'; break; case CONST_OTHER_MONTH_NUMBER: fillFieldValue = 'monthnumber(' + otherControlPath + ')'; break; case CONST_OTHER_YEAR_NUMBER: fillFieldValue = 'yearnumber(' + otherControlPath + ')'; break; case CONST_OTHER_DAY_NAME: fillFieldValue = 'dayofweek(' + otherControlPath + ')'; break; case CONST_OTHER_WEEK_NAME: fillFieldValue = 'weekname(' + otherControlPath + ')'; break; case CONST_OTHER_MONTH_NAME: fillFieldValue = 'monthname(' + otherControlPath + ')'; break; case CONST_OTHER_YEAR_NAME: fillFieldValue = 'yearname(' + otherControlPath + ')'; break; default: fillFieldValue = otherControlPath; } }else if(item.value.val.indexOf('()')>0){ fillFieldValue = item.value.val; }else if(item.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldValue = item.value.val; }else{ var otherControl = getControlById(item.value.val, root); if(otherControl == undefined){ return true; } var otherControlPath = getControlXPath(root, "/data/", item.value.val); fillFieldValue = otherControlPath; } if(fillFieldValue == ''){ fillFieldValue = "''"; } destinationFillString = destinationFillString + fillFieldPath + " = " + fillFieldValue; i++; }); var actionParamObj = {}; actionParamObj.eng = destinationFillString; bodyTag.children.push({ name: 'setDestinationFields', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":setDestinationFields')" } }); addTranslation(actionParamObj, xpath + control.name + ':setDestinationFields', translations); } } if(isVersion(VERSION_MODIFY_ADD_FIELDS) && control.isRetrieve){ //modifyAddFields="/data/cond_num = col5, /data/Date1 = col6" if(control.isModifyAdd == true && control.modifyAddFields != undefined){ var modifyAddFieldsString = ''; var i = 0; _.each(control.modifyAddFields, function(item){ if(item.text.val == ''){ return true; } var fillFieldPath = ''; if(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldPath = item.text.val; }else{ var fillControl = getControlById(item.text.val, root); if(fillControl == undefined){ return true; } fillFieldPath = getControlXPath(root, "/data/", item.text.val); } var lookupField = item.value.val; if(lookupField == undefined){ return true; } if(i != 0){ modifyAddFieldsString = modifyAddFieldsString + ', '; } modifyAddFieldsString = modifyAddFieldsString + fillFieldPath + " = " + lookupField; i++; }); binding.attrs.modifyAddFields = modifyAddFieldsString; } } if(isVersion(VERSION_SECURE_EMAIL) && control.isSecureEmail) { binding.attrs.isSecure = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_SECURE_FORWARD) && control.isSecureForward) { binding.attrs.isSecure = CONST_XML_FUNCTION_TRUE; } if(control.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ relevance.push(CONST_XML_FUNCTION_FALSE); } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ binding.attrs.readonly = CONST_XML_FUNCTION_TRUE; /*if(isVersion(VERSION_CTRL_PROPERTY_DSP_READ_ONLY)){ binding.attrs.readOnlyDsp = CONST_XML_FUNCTION_TRUE; }*/ /*if (control.showAsHM != true && (control.decPlace !== undefined) && (control.decPlace !== '')){ binding.attrs.decPlace = control.decPlace; }*/ switch(control.kind){ //case CONST_CTRL_KIND_DATE: case CONST_CTRL_KIND_STRING: break; default: if ((control.decPlace !== undefined) && (control.decPlace !== '')){ binding.attrs.decPlace = control.decPlace; } if ((control.round !== undefined) && (control.round !== 'Up')){ binding.attrs.roundDown = CONST_XML_FUNCTION_TRUE; } } if (control.showAsTextMobile != undefined && control.mobileTextAlign != undefined){ if(control.showAsTextMobile){ binding.attrs.showAsTextMobile = CONST_XML_FUNCTION_TRUE; } binding.attrs.mobileTextAlign = control.mobileTextAlign; } } if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC && control.kind == CONST_CTRL_KIND_DECIMAL){ if ((control.decPlace !== undefined) && (control.decPlace !== '')){ binding.attrs.decPlace = control.decPlace; } } if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ var isKindNumber = true; if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ switch(control.kind){ case CONST_CTRL_KIND_STRING: case CONST_CTRL_KIND_DATE: isKindNumber = false; break; } } if (isKindNumber && control.useCurrentcySymbol !== undefined && control.useCurrentcySymbol === true){ binding.attrs.useCurrentcySymbol = CONST_XML_FUNCTION_TRUE; if (control.currency !== undefined && control.currency !== '' && control.currency !== 'None'){ binding.attrs.currency = control.currency; } }else{ binding.attrs.useCurrentcySymbol = CONST_XML_FUNCTION_FALSE; if(isKindNumber && isVersion(VERSION_CALCULATE_PERCENT) && control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(control.usePercent == true){ binding.attrs.isPercent = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_SUPPRESS_KEYBOARD)){ // CO-2560:Suppress keyboard setting - Number Field if(control.suppressKeyboard){ binding.attrs.suppressKeyboard = CONST_XML_FUNCTION_TRUE; } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(isVersion(VERSION_CAL_SHOW_COMMA)){ if(control.kind == CONST_CTRL_KIND_NUMBER){ if(control.isShowComma){ binding.attrs.isShowComma = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isShowComma = CONST_XML_FUNCTION_FALSE; } } } }else{ if(isVersion(VERSION_NUM_SHOW_COMMA)){ if(control.isShowComma){ binding.attrs.isShowComma = CONST_XML_FUNCTION_TRUE; } } } } if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ if (control.limitToList !== undefined && control.limitToList === true){ binding.attrs.limitToList = CONST_XML_FUNCTION_TRUE; } if (control.dispMobile == undefined || control.dispMobile === true){ binding.attrs.dispMobile = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_AUTO_START_SCAN_OPTION)){ if (control.autoStartScan === true){ binding.attrs.autoStartScan = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.autoStartScan = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_DISPLAY_FIRST_MATCHING_SCAN)){ if (control.isDisplayFirstMatchingScanBC === true){ binding.attrs.isDisplayFirstMatchingScanBC = CONST_XML_FUNCTION_TRUE; } } }else{ binding.attrs.dispMobile = CONST_XML_FUNCTION_FALSE; } if (control.dispNFCBtn == undefined || control.dispNFCBtn === true){ binding.attrs.dispNFCBtn = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispNFCBtn = CONST_XML_FUNCTION_FALSE; } if (control.dispKBPortrait != undefined){ if(control.dispKBPortrait === true){ binding.attrs.dispKBPortrait = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispKBPortrait = CONST_XML_FUNCTION_FALSE; } } if (control.dispKBLandscape != undefined){ if(control.dispKBLandscape === true){ binding.attrs.dispKBLandscape = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispKBLandscape = CONST_XML_FUNCTION_FALSE; } } if (control.dispKBFirst != undefined){ if(control.dispKBFirst){ binding.attrs.dispKBFirst = 'true()|' + control.ignoreScreenSize; }else{ binding.attrs.dispKBFirst = 'false()|'; } } if (isVersion(VERSION_ON_CLEAR_CHK) && control.onClear != undefined){ if(control.onClear){ binding.attrs.onClear = CONST_XML_FUNCTION_TRUE; } } if (isVersion(VERSION_LU_KEYBOARD)){ var keyboardOption = ''; if(control.kbIconPortrait){ keyboardOption = CONST_XML_FUNCTION_TRUE; }else{ keyboardOption = CONST_XML_FUNCTION_FALSE; } if(control.kbIconLanscape){ keyboardOption += '|true()'; }else{ keyboardOption += '|false()'; } if(control.openKBPortrait){ keyboardOption += '|true()'; }else{ keyboardOption += '|false()'; } if(control.openKBLanscape){ keyboardOption += '|true()'; }else{ keyboardOption += '|false()'; } binding.attrs.keyboardOption = keyboardOption; } if (control.isWrapText != undefined){ if(control.isWrapText === true){ binding.attrs.isWrapText = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isWrapText = CONST_XML_FUNCTION_FALSE; } } if (control.textSize != undefined){ binding.attrs.textSize = control.textSize; } if (control.isSearchUndValue == undefined || control.isSearchUndValue === true){ binding.attrs.isSearchUndValue = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isSearchUndValue = CONST_XML_FUNCTION_FALSE; } if (control.isUseCondLookup == undefined || control.isUseCondLookup === false){ binding.attrs.isUseCondLookup = CONST_XML_FUNCTION_FALSE; }else{ binding.attrs.isUseCondLookup = CONST_XML_FUNCTION_TRUE; } if (control.isSortLookupList == undefined || control.isSortLookupList === false){ binding.attrs.isSortLookupList = CONST_XML_FUNCTION_FALSE; }else{ binding.attrs.isSortLookupList = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_LOAD_IMMEDIATELY)){ if (control.isLoadImmediately == true){ binding.attrs.isLoadImmediately = CONST_XML_FUNCTION_TRUE; } } if (control.sortType === 'desc'){ binding.attrs.sortType = 'desc'; }else{ binding.attrs.sortType = 'asc'; } if (control.isAcceptNull == undefined || control.isAcceptNull === false){ binding.attrs.isAcceptNull = CONST_XML_FUNCTION_FALSE; }else{ binding.attrs.isAcceptNull = CONST_XML_FUNCTION_TRUE; } if (control.isEvaluateERT == undefined || control.isEvaluateERT === false){ binding.attrs.isEvaluateERT = CONST_XML_FUNCTION_FALSE; }else{ binding.attrs.isEvaluateERT = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_DISPLAY_FIRST_MATCHING)){ if (control.isDisplayFirstMatching === true){ binding.attrs.isDisplayFirstMatching = CONST_XML_FUNCTION_TRUE; if (control.isAllowEdit === true){ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_DISPLAY_LIST_MATCHING)){ // CO-2741 if (control.isShowListMatching === true){ binding.attrs.isShowListMatching = CONST_XML_FUNCTION_TRUE; if (control.isAllowEdit2 === true){ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_CHOOSE_ONE_LU_FIELD)){ if(control.isRetrieve){ if(control.lookupValue && control.lookupValue.usingUnderlyValue != undefined){ if(control.lookupValue.usingUnderlyValue === true){ binding.attrs.isChooseOneField = CONST_XML_FUNCTION_TRUE; } }else{ if (control.isChooseOneField === true){ binding.attrs.isChooseOneField = CONST_XML_FUNCTION_TRUE; } } }else{ if (control.isChooseOneField === true){ binding.attrs.isChooseOneField = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_RETRIEVE_MODIFY_ONLY)){ if (control.isModifyOnly === true){ binding.attrs.isModifyOnly = CONST_XML_FUNCTION_TRUE; } } // CO-3852 if(control.isRetrieveDS == true){ binding.attrs.isRetrieveDS = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_RETRIEVE_RECORD_TYPE)){ if(control.retrieveRecordKind != undefined){ binding.attrs.retrieveRecordKind = control.retrieveRecordKind; switch(control.retrieveRecordKind){ case 'oldest': binding.attrs.isRetrieveOldestRecord = CONST_XML_FUNCTION_TRUE; break; } } }else{ if(control.isRetrieveOldestRecord && isVersion(VERSION_RETRIEVE_OLDEST_RECORD)){ binding.attrs.isRetrieveOldestRecord = CONST_XML_FUNCTION_TRUE; } } }else if(control.isRetrieveDS == false){ binding.attrs.isRetrieveDS = CONST_XML_FUNCTION_FALSE; } if(control.isRetrieve && isVersion(VERSION_CASE_SENSITIVE_MATCHING)){ if(control.isCaseSensitiveCmp == true){ binding.attrs.isCaseSensitiveCmp = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isCaseSensitiveCmp = CONST_XML_FUNCTION_FALSE; } } //if(!control.isRetrieve){ odkmaker.data.lookupTablesArr[control.datasource] = control.datasource; //} if(isVersion(VERSION_LOW_FREQUENCY_BLUETOOTH)){ if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ binding.attrs.isLFBluetooth = CONST_XML_FUNCTION_TRUE; /*var lookupkeyPath = getControlXPath(root, "/data/", control.lookupkey); var bluetoothkeyPath = getControlXPath(root, "/data/", control.bluetoothkey); binding.attrs.bluetoothInf = lookupkeyPath + ',' + bluetoothkeyPath;*/ //binding.attrs.bluetoothInf = control.bluetoothkey + ',' + control.lookupkey; binding.attrs.lookupkey = control.lookupkey; if(control.parsing == CONST_PARSING_CUSTOM){ binding.attrs.parsing = CONST_PARSING_CUSTOM; }else{ binding.attrs.parsing = CONST_PARSING_OEM; } var parsingInfo = ''; if(control.parsingInfo){ var parsingInfoTmp = cloneJSON(control.parsingInfo, root); parsingInfo = JSON.stringify(parsingInfoTmp); }else{ parsingInfo = '{}'; } bodyTag.children.push({ name: 'parsingInfo', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":parsingInfo')" } }); var parsingInfoObj = new Object(); parsingInfoObj = {eng: parsingInfo}; addTranslation(parsingInfoObj, xpath + control.name + ':parsingInfo', translations); if(control.showDeviceListType){ binding.attrs.showDeviceListType = control.showDeviceListType; }else{ binding.attrs.showDeviceListType = CONST_DEVICE_LIST_TYPE_ONE; } } } if(isVersion(VERSION_RESTRICT_OPTION)){ if(control.restMobile === true){ binding.attrs.isUseDispOnly = CONST_XML_FUNCTION_TRUE; binding.attrs.isUseMobileOnly = "false()"; }else{ binding.attrs.isUseMobileOnly = "true()"; odkmaker.data.lookupTablesUseInMobileArr[control.datasource] = control.datasource; } }else if(!isVersion(VERSION_LU_USE_MOBILE_ONLY)){ if(control.isUseDispOnly == undefined || control.isUseDispOnly === false){ odkmaker.data.lookupTablesUseInMobileArr[control.datasource] = control.datasource; }else if(control.isUseDispOnly === true){ binding.attrs.isUseDispOnly = CONST_XML_FUNCTION_TRUE; } }else{ if(control.isUseDispOnly || control.isNotUseDispatchTab || control.isUseViewdataOnly){ if(control.isUseDispOnly == undefined || control.isUseDispOnly === false){ }else if(control.isUseDispOnly === true){ binding.attrs.isUseDispOnly = CONST_XML_FUNCTION_TRUE; } if(control.isNotUseDispatchTab == undefined){ if((control.isUseDispOnly == undefined || control.isUseDispOnly === false ) && (control.isUseViewdataOnly == undefined || control.isUseViewdataOnly === false )){ binding.attrs.isUseMobileOnly = "true()"; }else{ binding.attrs.isUseMobileOnly = "false()"; } }else if(control.isNotUseDispatchTab === false){ binding.attrs.isUseMobileOnly = "false()"; }else{ binding.attrs.isUseMobileOnly = "true()"; } if(!binding.attrs.isUseMobileOnly || binding.attrs.isUseMobileOnly == "false()"){ odkmaker.data.lookupTablesUseInMobileArr[control.datasource] = control.datasource; } }else{ odkmaker.data.lookupTablesUseInMobileArr[control.datasource] = control.datasource; } } binding.attrs.lookuptable = control.datasource; binding.attrs.lookupfield = control.lookupfield; if(control.maxRows != undefined){ binding.attrs.maxRows = control.maxRows; } // CO-3852: New Retrieve Setting - Auto Run if(control.isRetrieveDS == true && control.retrieveKind != 'button' && control.autoActionStampTriggerRetrieve != undefined && (control.autoActionStampTriggerRetrieve == '2' // specific question || control.autoActionStampTriggerRetrieve == '8') // open form ){ //binding.attrs.autoActionStampTriggerRetrieve = control.autoActionStampTriggerRetrieve; //binding.attrs.autoActionStampQuestionTriggerRetrieve = control.autoActionStampQuestionTriggerRetrieve; binding.attrs.autostamp = CONST_XML_FUNCTION_TRUE; binding.attrs.autoStampTrigger = control.autoActionStampTriggerRetrieve; //binding.attrs.autoStampTriggerQues = ''; if(control.autoActionStampTriggerRetrieve == '2'){ var itemPath = getControlXPath(root, "/data/", control.autoActionStampQuestionTriggerRetrieve); binding.attrs.autoStampTriggerQues = itemPath; } if(true == control.hideRetrieveButtonAuto){ binding.attrs.hideRetrieveButtonAuto = CONST_XML_FUNCTION_TRUE; } else{ binding.attrs.hideRetrieveButtonAuto = CONST_XML_FUNCTION_FALSE; } } // CO-3853 if(isVersion(VERSION_AUTO_RUN_MODIFY)){ if(control.modifyKind == CONST_TYPE_AUTO_RUN){ if(control.autoActionStampTriggerModify){ binding.attrs.modifyAutoTrigger = control.autoActionStampTriggerModify; } if(control.autoActionStampTriggerModify == '2'){ var itemPath = getControlXPath(root, "/data/", control.autoActionStampQuestionTriggerModify); binding.attrs.autoModifyTriggerQues = itemPath; } } } if(control.hideRetrieveButton && control.hideRetrieveButton == true){ binding.attrs.hideRetrieveButton = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_RETRIEVE_MODIFY_ONLY)){ if(control.notDisplayRecNotFound && control.notDisplayRecNotFound == true){ binding.attrs.notDisplayRecNotFound = CONST_XML_FUNCTION_TRUE; } } } if(control.type == 'inputFacingTable'){ if (control.dispMobile == undefined || control.dispMobile === true){ binding.attrs.dispMobile = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispMobile = CONST_XML_FUNCTION_FALSE; } if (control.dispNFCBtn == undefined || control.dispNFCBtn === true){ binding.attrs.dispNFCBtn = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispNFCBtn = CONST_XML_FUNCTION_FALSE; } if (control.isSearchUndValue == undefined || control.isSearchUndValue === true){ binding.attrs.isSearchUndValue = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isSearchUndValue = CONST_XML_FUNCTION_FALSE; } odkmaker.data.lookupTablesArr[control.datasource + '&facings=true'] = control.datasource; if(control.isUseDispOnly == undefined || control.isUseDispOnly === false){ odkmaker.data.lookupTablesUseInMobileArr[control.datasource + '&facings=true'] = control.datasource; } binding.attrs.lookuptable = control.datasource; binding.attrs.lookupfield = control.storeid; binding.attrs.aislecolumn = control.aislecolumn binding.attrs.aislevalue = control.aislevalue; } if(control.type == 'inputLookupMulti'){ if (control.dispMobile == undefined || control.dispMobile === true){ binding.attrs.dispMobile = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispMobile = CONST_XML_FUNCTION_FALSE; } if (control.dispNFCBtn == undefined || control.dispNFCBtn === true){ binding.attrs.dispNFCBtn = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.dispNFCBtn = CONST_XML_FUNCTION_FALSE; } if (control.isSearchUndValue == undefined || control.isSearchUndValue === true){ binding.attrs.isSearchUndValue = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isSearchUndValue = CONST_XML_FUNCTION_FALSE; } odkmaker.data.lookupTablesArr[control.datasource] = control.datasource; if(!isVersion(VERSION_RESTRICT_OPTION)){ if(control.isUseDispOnly == undefined || control.isUseDispOnly === false){ odkmaker.data.lookupTablesUseInMobileArr[control.datasource] = control.datasource; } }else{ if(!control.restMobile){ odkmaker.data.lookupTablesUseInMobileArr[control.datasource] = control.datasource; } } binding.attrs.lookuptable = control.datasource; //binding.attrs.lookupfield = control.lookupfield; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ binding.attrs.hideOnRetrieve = CONST_XML_FUNCTION_TRUE; } if(control.readOnlyOnRetrieve === true){ binding.attrs.readOnlyOnRetrieve = CONST_XML_FUNCTION_TRUE; } if(control.requiredOnRetrieve === true){ binding.attrs.requiredOnRetrieve = CONST_XML_FUNCTION_TRUE; } if(control.clearOnRetrieve === true){ binding.attrs.clearOnRetrieve = CONST_XML_FUNCTION_TRUE; } } // read only if (control.readOnly === true){ binding.attrs.readonly = CONST_XML_FUNCTION_TRUE; }else{ if(isVersion(VERSION_REPLY_TO_SENDER)) { if((control.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD) && control.replyToSender){ binding.attrs.readonly = "/data/__reply_flag = '" + CONST_VALUE_TRUE_STR + "'"; } } } /*if(isVersion(VERSION_CTRL_PROPERTY_DSP_READ_ONLY)){ if (control.readOnlyDsp === true) binding.attrs.readOnlyDsp = CONST_XML_FUNCTION_TRUE; }*/ // auto return if (control.autoReturn != undefined && control.autoReturn === true) binding.attrs.autoReturn = CONST_XML_FUNCTION_TRUE; // auto display page break in Web App if(control.type == 'inputPageBreak'){ if (control.displayPageBreakWA == undefined || control.displayPageBreakWA === true){ binding.attrs.displayPageBreakWA = CONST_XML_FUNCTION_TRUE; // auto Expand page in Web App if (control.autoExpandPageWA != undefined && control.autoExpandPageWA === true) binding.attrs.autoExpandPageWA = CONST_XML_FUNCTION_TRUE; } } // required if (control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && control.required === true) binding.attrs.required = CONST_XML_FUNCTION_TRUE; if(control.type == CONST_CTRL_TYPE_INPUTLOCATION && isVersion(VERSION_PCA_43_44)){ // showGPSInfo if (control.showGPSInfo === false){ binding.attrs.showGPSInfo = CONST_XML_FUNCTION_FALSE; }else{ binding.attrs.showGPSInfo = CONST_XML_FUNCTION_TRUE; } } if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){ if(isVersion(VERSION_GPS_VERIFY_ADDRESS)){ if (control.isVerifyAddress === true){ var compareField = getControlXPath(root, "/data/", control.compareField); var destinationField = getControlXPath(root, "/data/", control.destinationField); var displayDistanceAs = control.displayDistanceAs if(displayDistanceAs == undefined){ displayDistanceAs = CONST_VALUE_METERS; } var verifyAddress = CONST_XML_FUNCTION_TRUE; verifyAddress += '|' + compareField; verifyAddress += '|' + destinationField; verifyAddress += '|' + displayDistanceAs; binding.attrs.verifyAddress = verifyAddress; }else{ binding.attrs.isVerifyAddress = CONST_XML_FUNCTION_FALSE + '|||'; } } // CO-6049: Implement Small, Medium Large image size options for GPS Location if(isVersion(VERSION_GPS_BUTTON_SIZE)){ if(control.locationStype === CONST_TYPE_ADVANCED && control.actionKind !== CONST_TYPE_AUTO_RUN){ if(control.kind != undefined){ if(control.kind === CONST_TYPE_IMAGE && control.buttonSize != undefined){ binding.attrs.buttonSize = control.buttonSize || CONST_SIZE_SMALL; } } } } // CO-4087: Add Get address option to GPS location start if(isVersion(VERSION_GPS_GET_ADDRESS)){ if (control.isGetAddress === true){ /*var destinationField4GetAddress = getControlXPath(root, "/data/", control.destinationField4GetAddress); var addressType = ''; if(control.addressType != undefined){ addressType = control.addressType; }*/ var addressData = ''; if(control.addressData && control.addressData.length>0){ for(var i = 0; i< control.addressData.length; i++){ var address = control.addressData[i]; addressData += '|'; if(!address.text || !address.text.val || address.text.val === ''){ addressData += '|'; }else{ if(address.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ addressData += address.text.val + '|'; }else{ var path = getControlXPath(root, "/data/", address.text.val); addressData += path + '|'; } } if(!address.value || !address.value.val || address.value.val === ''){ }else{ addressData += address.value.val; } } } binding.attrs.isGetAddress = CONST_XML_FUNCTION_TRUE + addressData; }else{ binding.attrs.isGetAddress = CONST_XML_FUNCTION_FALSE; } var isAdvanceLocation = false; if(control.locationStype && control.locationStype == CONST_TYPE_ADVANCED){ isAdvanceLocation = true; binding.attrs.isAdvanced = CONST_XML_FUNCTION_TRUE; } if(isAdvanceLocation){ var destinationData = ''; if(control.destinationdata && control.destinationdata.length>0){ for(var i = 0; i< control.destinationdata.length; i++){ var destination = control.destinationdata[i]; if(destinationData != ''){ destinationData += '|'; } if(!destination.text || !destination.text.val || destination.text.val === ''){ destinationData += '|'; }else{ if(destination.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ destinationData += destination.text.val + '|'; }else{ var path = getControlXPath(root, "/data/", destination.text.val); destinationData += path + '|'; } } if(!destination.value || !destination.value.val || destination.value.val === ''){ }else{ destinationData += destination.value.val; } } } if(destinationData != ''){ binding.attrs.destination = destinationData; } var isAutoRun = false; if(control.actionKind == CONST_TYPE_AUTO_RUN){ isAutoRun = true; } if(!isAutoRun){ if(control.kind != undefined){ if(control.kind === 'Image'){ // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(control.imageText === undefined || jQuery.trim(control.imageText) === ''){ control.imageText = lbl_enter_image_text; } bodyTag.children.push({ name: 'imageText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":imageText')" } }); var imageTextObj = {}; imageTextObj.eng = control.imageText; addTranslation(imageTextObj, xpath + control.name + ':imageText', translations); if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); binding.attrs.hintlink = arr[0].replace('transparent','ffffff'); if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } } } }else{ // button binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; actionBtnTextObj.eng = control.actionBtnText; addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); } } if(isVersion(VERSION_GROUP_FUNCTION) && control.hideButtonAfterClick == true){ binding.attrs.hideButtonAfterClick = CONST_XML_FUNCTION_TRUE; } }else{ binding.attrs.autostamp = CONST_XML_FUNCTION_TRUE; if(control.autoRunTrigger != '' && control.autoRunTrigger != lbl_sel_question) { if(control.autoRunTrigger == '2') { binding.attrs.autoStampTrigger = 2; }else{ if(isVersion(VERSION_AUTO_RUN_WHEN_RETRIEVE)){ if(control.autoRunTrigger == CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_DATA || control.autoRunTrigger == CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_NO_DATA) { binding.attrs.autoStampTrigger = control.autoRunTrigger; } } } } var itemPath = getControlXPath(root, "/data/", control.autoRunQuestionTrigger); binding.attrs.autoStampTriggerQues = itemPath; } } } // CO-4087: Add Get address option to GPS location end // CO-2736 if(isVersion(VERSION_GPS_VERIFY_ADDRESS) && control.zoomLevel){ binding.attrs.zoomLevel = control.zoomLevel; } // CO-2737 if(isVersion(VERSION_GPS_DISPLAY_MAP)){ if (false == control.dispMapInMobile){ binding.attrs.dispMapInMobile = CONST_XML_FUNCTION_FALSE; }else{ binding.attrs.dispMapInMobile = CONST_XML_FUNCTION_TRUE; } } } if(control.type == CONST_CTRL_TYPE_INPUTDATE && control.kind == CONST_VALUE_TIME && isVersion(VERSION_TIME_VERIFY)){ if (control.isVerifyTime === true){ var compareField = getControlXPath(root, "/data/", control.compareField); var destinationField = getControlXPath(root, "/data/", control.destinationField); /*var verifyMinRange = control.verifyMinRange; var verifyMaxRange = control.verifyMaxRange; var isVerifyTime = CONST_XML_FUNCTION_TRUE; var isDisplayLabel = CONST_XML_FUNCTION_TRUE; if(!control.isDisplayLabel){ isDisplayLabel = CONST_XML_FUNCTION_FALSE; }else{ bodyTag.children.push({ name: 'displayLabel', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":displayLabel')" } }); var displayLabel = new Object(); if (control.displayLabel) { displayLabel.eng = control.displayLabel; } else { displayLabel.eng = ''; } addTranslation(displayLabel, xpath + control.name + ':displayLabel', translations); } isVerifyTime += '|' + compareField; isVerifyTime += '|' + destinationField; isVerifyTime += '|' + verifyMinRange; isVerifyTime += '|' + verifyMaxRange; isVerifyTime += '|' + isDisplayLabel;*/ var isVerifyTime = CONST_XML_FUNCTION_TRUE; isVerifyTime += '|' + compareField; isVerifyTime += '|' + destinationField; binding.attrs.isVerifyTime = isVerifyTime; }else{ /*binding.attrs.isVerifyTime = CONST_XML_FUNCTION_FALSE + '|||||';*/ binding.attrs.isVerifyTime = CONST_XML_FUNCTION_FALSE + '||'; } } if(control.type == CONST_CTRL_TYPE_INPUTLOCATION && isVersion(VERSION_GPS_SHOW_DECIMAL)){ if(control.showAsDecimal == true){ binding.attrs.showAsDecimal = CONST_XML_FUNCTION_TRUE; } } if(control.type == CONST_CTRL_TYPE_INPUTLOCATION && isVersion(VERSION_LOCATION_SHOW_HIDE_OPT)){ //Name: gpsSetting //Format: Longitude(TRUE/FALSE)|Latitude(TRUE/FALSE)|Accuracy(TRUE/FALSE)|Altitude(TRUE/FALSE)|Maximum error(100)|Promt User After(5) binding.attrs.gpsSetting = ""; // show Longitude if (control.showGPSInfo && control.showLon){ binding.attrs.gpsSetting += "TRUE"; }else{ binding.attrs.gpsSetting += "FALSE"; } // show Latitude if (control.showGPSInfo && control.showLat){ binding.attrs.gpsSetting += "|TRUE"; }else{ binding.attrs.gpsSetting += "|FALSE"; } // show Accuracy if (control.showGPSInfo && control.showAcc){ binding.attrs.gpsSetting += "|TRUE"; }else{ binding.attrs.gpsSetting += "|FALSE"; } // show Altitude if (control.showGPSInfo && control.showAlt){ binding.attrs.gpsSetting += "|TRUE"; }else{ binding.attrs.gpsSetting += "|FALSE"; } // Maximum error if (control.maxError){ binding.attrs.gpsSetting += "|" + control.maxError; }else{ binding.attrs.gpsSetting += "| "; } // Promt User After if (control.promtAfter){ binding.attrs.gpsSetting += "|" + control.promtAfter; }else{ binding.attrs.gpsSetting += "| "; } } // don't show now button if(isVersion(VERSION_DATE_SHOW_NOW_BTN)){ if(control.showNowBtn != undefined && control.showNowBtn == false){ binding.attrs.showNowBtn = CONST_XML_FUNCTION_FALSE; } } // don't show Seconds if(isVersion(VERSION_SHOW_SECONDS_COLOR_ANSWER)){ if(control.showSeconds != undefined && control.showSeconds == false){ binding.attrs.showSeconds = CONST_XML_FUNCTION_FALSE; } } // auto stamp if (control.autoStamp !== undefined && control.autoStamp === true){ binding.attrs.autostamp = CONST_XML_FUNCTION_TRUE; var autoStampTrigger = 0; if(!isVersion5_0()){ if (control.autoStampTrigger1 !== undefined && control.autoStampTrigger1 === true){ autoStampTrigger += 1; } }else{ if (control.autoStampTrigger !== undefined && control.autoStampTrigger != '' && control.autoStampTrigger != lbl_auto_stamp_select_opt){ autoStampTrigger = control.autoStampTrigger; } } if(!isVersion5_0()){ if (control.autoStampTrigger2 !== undefined && control.autoStampTrigger2 === true){ autoStampTrigger += 2; var itemPath = getControlXPath(root, "/data/", control.autoStampTrigger2Ques); binding.attrs.autoStampTriggerQues = itemPath; } }else{ if (control.autoStampTrigger == '2'){ var itemPath = getControlXPath(root, "/data/", control.autoStampTrigger2Ques); binding.attrs.autoStampTriggerQues = itemPath; } } if(!isVersion5_0()){ if (control.autoStampTrigger4 !== undefined && control.autoStampTrigger4 === true){ autoStampTrigger += 4; var itemPath = getControlXPath(root, "/data/", control.autoStampTrigger4Ques); binding.attrs.autoStampTriggerPage = itemPath; } }else{ if (control.autoStampTrigger == '4'){ var itemPath = getControlXPath(root, "/data/", control.autoStampTrigger4Ques); binding.attrs.autoStampTriggerPage = itemPath; } } if(!isVersion5_0()){ if (control.autoStampTrigger8 !== undefined && control.autoStampTrigger8 === true){ autoStampTrigger += 8; } if (control.autoStampTrigger16 !== undefined && control.autoStampTrigger16 === true){ autoStampTrigger += 16; } } binding.attrs.autoStampTrigger = autoStampTrigger; } //CO-4273: Week Ending Date - New Date Field Setting start if(isVersion(VERSION_SET_WEEK_ENDING_DATE)){ if(control.kind != CONST_VALUE_TIME && control.isSetWeekEndingDate == true){ var endDay = control.endDay; if(!endDay || endDay == ''){ endDay = CONST_SUNDAY; } var weekEndingDateType = control.weekEndingDateType; if(!weekEndingDateType || weekEndingDateType == ''){ weekEndingDateType = CONST_CURRENT; } switch(weekEndingDateType){ case CONST_VALUE_OTHER: var weekEndingDateField = getControlXPath(root, "/data/", control.weekEndingDateField); binding.attrs.setWeekEndingDate = CONST_XML_FUNCTION_TRUE + '|' + endDay + '|' + weekEndingDateType + '|' + weekEndingDateField; break; default: binding.attrs.setWeekEndingDate = CONST_XML_FUNCTION_TRUE + '|' + endDay + '|' + weekEndingDateType; } } } //CO-4273: Week Ending Date - New Date Field Setting end //CO-6354: Date Field Month Ending Option start if(isVersion(VERSION_SET_MONTH_ENDING_DATE)){ if(control.kind != CONST_VALUE_TIME && control.isSetMonthEndingDate == true){ var monthEndingDateType = control.monthEndingDateType; if(!monthEndingDateType || monthEndingDateType == ''){ monthEndingDateType = CONST_CURRENT; } switch(monthEndingDateType){ case CONST_VALUE_OTHER: var monthEndingDateField = getControlXPath(root, "/data/", control.monthEndingDateField); binding.attrs.setMonthEndingDate = CONST_XML_FUNCTION_TRUE + '|' + monthEndingDateType + '|' + monthEndingDateField; break; default: binding.attrs.setMonthEndingDate = CONST_XML_FUNCTION_TRUE + '|' + monthEndingDateType; } } } //CO-6354: Date Field Month Ending Option end /* hqkhanh delete 12/02/2015 Auto-Stamp currently has a sub option: Allow edit option. a. Default to always be shown (do not hide this when auto-stamp is checked) b. Default to checked input location only */ if((isVersion(VERSION_ALLOW_EDIT_OPT) && control.type == CONST_CTRL_TYPE_INPUTLOCATION) || (isVersion(VERSION_ATTACHMENT) && control.type == CONST_CTRL_TYPE_INPUTATTACHMENT) ){ if(control.isAllowEdit){ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_USE_INTERVAL)){ if(control.useInterval == undefined || control.useInterval){ if(control.minuteInterval != undefined){ binding.attrs.minuteInterval = control.minuteInterval; } if(control.rounding != undefined){ binding.attrs.rounding = control.rounding; } if(isVersion(VERSION_LIMIT_TO_INTERVAL_VALUE)){ if(control.limitUserToIntervalValue == true){ binding.attrs.limitUserToIntervalValue = CONST_XML_FUNCTION_TRUE; } } } }else if(isVersion(VERSION_OPTION_MINUTE_INTERVAL)){ if(control.minuteInterval != undefined){ binding.attrs.minuteInterval = control.minuteInterval; } } /* hqkhanh delete 12/02/2015 Auto-Stamp currently has a sub option: Allow edit option. a. Default to always be shown (do not hide this when auto-stamp is checked) b. Default to checked move out check auto stamp */ if(isVersion(VERSION_ALLOW_EDIT_OPT) && control.type == CONST_CTRL_TYPE_INPUTDATE ){ if(control.isAllowEdit){ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.isAllowEdit = CONST_XML_FUNCTION_FALSE; } } if(isVersion(VERSION_FW_RESET_TO_NULL)) { if (control.resetToNull !== undefined){ if(control.resetToNull === true){ binding.attrs.resetToNull = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.resetToNull = CONST_XML_FUNCTION_FALSE; } } } if(isVersion(VERSION_FW_CUSTOM_EMAIL) && (control.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD)) { var customEmail = ''; if (control.hasCustomEmailSubject == true){ customEmail = 'true|'; bodyTag.children.push({ name: 'customEmailSubject', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":customEmailSubject')" } }); var customEmailSubject = new Object(); if (control.customEmailSubject) { customEmailSubject.eng = control.customEmailSubject; } else { customEmailSubject.eng = ''; } addTranslation(customEmailSubject, xpath + control.name + ':customEmailSubject', translations); }else{ customEmail = 'false|'; } if (control.hasCustomEmailBody == true){ customEmail += CONST_VALUE_TRUE_STR; bodyTag.children.push({ name: 'customEmailBody', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":customEmailBody')" } }); var customEmailBody = new Object(); if (control.customEmailBody) { customEmailBody.eng = control.customEmailBody; } else { customEmailBody.eng = ''; } addTranslation(customEmailBody, xpath + control.name + ':customEmailBody', translations); }else{ customEmail += CONST_VALUE_FALSE_STR; } binding.attrs.customEmail = customEmail; } if(isVersion(VERSION_LU_SEARCH_WILD_CARD)) { if (control.isSearchWildCard !== undefined){ if(control.isSearchWildCard === true){ binding.attrs.searchWildCard = CONST_XML_FUNCTION_TRUE; }else{ binding.attrs.searchWildCard = CONST_XML_FUNCTION_FALSE; } } } if(isVersion(VERSION_TRACK_AS_RELATED_RECORD)) { if (control.trackAsRelatedRecord !== undefined){ if(control.trackAsRelatedRecord === true){ binding.attrs.trackAsRelatedRecord = CONST_XML_FUNCTION_TRUE; } } } if(isVersion(VERSION_SCORE_SHOW_DECIMAL_VALUE)) { if (control.showDecimalValue !== undefined && control.showDecimalValue === false){ binding.attrs.showDecimalValue = CONST_XML_FUNCTION_FALSE; } } if (control.hideInWeb !== undefined && control.hideInWeb === true) binding.attrs.hideinweb = CONST_XML_FUNCTION_TRUE; if(!isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION)){ if (control.hideInMobile !== undefined && control.hideInMobile === true) binding.attrs.hideinmobile = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_HIDE_IN_PDF_4MOBILE)){ //co-5516 if(isVersion(VERSION_HIDE_PDF_WEB)){ if(control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } }else{ if(control.hideWebAppGrp == true && control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } } } }else{ if (control.hideInMobile !== undefined && control.hideInMobile === true){ switch(control.type){ case 'inputLabel': case CONST_CTRL_TYPE_INPUTSCORESUMMARY: binding.attrs.dispMobile = CONST_XML_FUNCTION_FALSE; break; default: binding.attrs.hideinmobile = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_HIDE_IN_PDF_4MOBILE)){ //co-5516 if(isVersion(VERSION_HIDE_PDF_WEB)){ if(control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } }else{ if(control.hideWebAppGrp == true && control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } } } } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_FORWARDED)){ if (control.hideForwarded !== undefined && control.hideForwarded === true){ binding.attrs.hideForwarded = CONST_XML_FUNCTION_TRUE; } if (control.requiredForwarded !== undefined && control.requiredForwarded === true){ binding.attrs.requiredForwarded = CONST_XML_FUNCTION_TRUE; } if (control.readOnlyForwarded !== undefined && control.readOnlyForwarded === true){ binding.attrs.readOnlyForwarded = CONST_XML_FUNCTION_TRUE; } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE && control.kind == CONST_CTRL_KIND_DATE){ if(isVersion(VERSION_CALCULATE_RESULT)){ if(control.result && control.result != ''){ binding.attrs.result = control.result; } } if (control.showAsHM !== undefined && control.showAsHM === true){ binding.attrs.showAsHM = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_SHOW_AS_HHMMSS)){ if (control.showAsHMS !== undefined && control.showAsHMS === true){ binding.attrs.showAsHMS = CONST_XML_FUNCTION_TRUE; } if (control.showDateOnly !== undefined && control.showDateOnly === true){ binding.attrs.showDateOnly = CONST_XML_FUNCTION_TRUE; } } } if (control.allowImgSel !== undefined && control.allowImgSel === true) binding.attrs.allowImgSel = CONST_XML_FUNCTION_TRUE; if(isVersion(VERSION_SHOW_BTN_IMG)){ if (control.isShowBtn !== undefined && control.isShowBtn === true) binding.attrs.isShowBtn = CONST_XML_FUNCTION_TRUE; } if (isVersion(VERSION_IMAGE_CLEAR_BTN) && control.dispClearBtn !== undefined && control.dispClearBtn === true) binding.attrs.dispClearBtn = CONST_XML_FUNCTION_TRUE; if (control.disTrendsBtn !== undefined && control.disTrendsBtn === false) binding.attrs.isDisplayTrendButtons = CONST_XML_FUNCTION_FALSE; if(control.type == CONST_CTRL_TYPE_INPUTDATE && control.kind !=CONST_VALUE_DATE){ if (control.militaryTime !== undefined && control.militaryTime === false){ binding.attrs.militaryTime = CONST_XML_FUNCTION_FALSE; }else{ binding.attrs.militaryTime = CONST_XML_FUNCTION_TRUE; } } if(control.type == CONST_CTRL_TYPE_INPUTDATE && control.advancedFormat) { var advancedFormat = {}; advancedFormat.eng = control.advancedFormat.format; bodyTag.children.push({ name: 'advancedFormat', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":advancedFormat')" } }); addTranslation(advancedFormat, xpath + control.name + ':advancedFormat', translations); } var ignoreRangeContraint = false; if(control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(isVersion(VERSION_COUNTER_STAR_SLIDER) && !(valueOrEmpty(control.counterFormat) == '' || control.counterFormat == CONST_TYPE_ARROWS)){ binding.attrs.counterType = control.counterFormat; switch(control.counterFormat){ case CONST_TYPE_STARS: binding.attrs.stars = control.range.stars; if(control.fitImageToScreen){ binding.attrs.fitImageToScreen = CONST_XML_FUNCTION_TRUE; } ignoreRangeContraint = true; break; case CONST_TYPE_SLIDER: if(control.range.min != ''){ binding.attrs.start = control.range.min; } if(control.range.max != ''){ binding.attrs.end = control.range.max; } break; } }else{ if((control.spinStep !== undefined) && (control.spinStep !== '')){ binding.attrs.step = control.spinStep; }else{ binding.attrs.step = '1'; } if ((control.range !== undefined) && (control.range !== false)){ if(control.range.min != ''){ binding.attrs.start = control.range.min; } if(control.range.max != ''){ binding.attrs.end = control.range.max; } } } } // Fix bug 0022156: Barcode-NFC Parsing : Pls hiding Parse checkbox of NFC //if(isVersion(VERSION_NFC_BAR_PARSE) && (control.type == CONST_CTRL_TYPE_INPUTBARCODE || control.type == CONST_CTRL_TYPE_INPUTNFC)){ if( (isVersion(VERSION_NFC_BAR_PARSE) && control.type == CONST_CTRL_TYPE_INPUTBARCODE) || ( isVersion(VERSION_NFC_PARSE_ONLY) && control.type == CONST_CTRL_TYPE_INPUTNFC) ){ if ((control.parse !== undefined) && (control.parse !== false)){ binding.attrs.allowParsing = CONST_XML_FUNCTION_TRUE; binding.attrs.parsingStartDelimeter = control.parse.start || ''; binding.attrs.parsingSeperationDelimeter = control.parse.separation || ''; binding.attrs.parsingEndDelimeter = control.parse.end || ''; }else{ binding.attrs.allowParsing = CONST_XML_FUNCTION_FALSE; } } if( (isVersion(VERSION_BC_LENGTH_PARSE) && control.type == CONST_CTRL_TYPE_INPUTBARCODE) || (isVersion(VERSION_NFC_LENGTH_PARSE) && control.type == CONST_CTRL_TYPE_INPUTNFC)){ if(control.textParse){ binding.attrs.allowParsing = CONST_XML_FUNCTION_TRUE; var parseDestinationFieldString = ''; _.each(control.textParseDestinationFields, function(item){ var len = item.text.len || ''; var val = item.text.val || ''; if(len == '' || val == ''){ return true; } var parseDestinationFieldControl = getControlById(item.text.val, root); if(parseDestinationFieldControl == undefined){ return true; } var parseDestinationFieldPath = getControlXPath(root, "/data/", item.text.val); parseDestinationFieldString += '|' + len + ',' + parseDestinationFieldPath; if(item.text.isTable == true){ parseDestinationFieldString += ','; var parseDestinationFieldTableControl = getControlById(item.text.tablefield, root); if(parseDestinationFieldTableControl == undefined){ return true; } var parseDestinationFieldTablePath = getControlXPath(root, "/data/", item.text.tablefield); parseDestinationFieldString += parseDestinationFieldTablePath; } i++; }); binding.attrs.parse = CONST_XML_FUNCTION_TRUE + parseDestinationFieldString; if(control.hideAfterParse){ binding.attrs.hideAfterParse = CONST_XML_FUNCTION_TRUE; } } } if( (isVersion(VERSION_DISPLAY_IMAGE_OPTION) && control.type == CONST_CTRL_TYPE_INPUTBARCODE && control.displayImage == true) ){ binding.attrs.displayImage = CONST_XML_FUNCTION_TRUE + '|' + control.barcodeType + '|' + (control.hideScanValue?CONST_XML_FUNCTION_TRUE:CONST_XML_FUNCTION_FALSE); } if(isVersion(VERSION_JUMP_ACTION) && control.type == CONST_CTRL_TYPE_INPUTBARCODE){ if(parentType == CONST_CTRL_TYPE_CTRLTABLE || parentType == CONST_CTRL_TYPE_CTRLSCHEDULE || parentType == CONST_CTRL_TYPE_CTRLGRID){ if(control.jumpAfterScan == true){ if(control.jumpAfterScanOption == CONST_ONE){ binding.attrs.actionJump = CONST_ACTION_JUMP_DOWN; }else{ binding.attrs.actionJump = CONST_ACTION_JUMP_RIGHT; } } }else{ if(control.jumpNextAfterScan == true){ binding.attrs.actionJump = CONST_ACTION_JUMP_NEXT; } } } if(isVersion(VERSION_TEXT_JUMP_ACTION) && (control.type == CONST_CTRL_TYPE_INPUT_TEXT || control.type == CONST_CTRL_TYPE_INPUTLOOKUP)){ if(parentType == CONST_CTRL_TYPE_CTRLTABLE || parentType == CONST_CTRL_TYPE_CTRLSCHEDULE || parentType == CONST_CTRL_TYPE_CTRLGRID){ if(control.jumpAfterScan == true){ if(control.jumpAfterScanOption == CONST_ONE){ binding.attrs.actionJump = CONST_ACTION_JUMP_DOWN; }else{ binding.attrs.actionJump = CONST_ACTION_JUMP_RIGHT; } } } } if(isVersion(VERSION_JUMP_WHEN_NOT_EMPTY) && control.type == CONST_CTRL_TYPE_INPUTBARCODE){ if(control.jumpWhenNotEmpty == true){ binding.attrs.jumpWhenNotEmpty = CONST_XML_FUNCTION_TRUE; } } if(isVersion(VERSION_NB_USE_ACTION_BTN)){ if(control.type == CONST_CTRL_TYPE_INPUTBARCODE || control.type == CONST_CTRL_TYPE_INPUTNFC){ if(false && (control.parentCtrlType == CONST_CTRL_TYPE_CTRLTABLE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLSCHEDULE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLGRID)){ // ignore isUseActionButton }else{ if ((((control.parse !== undefined) && (control.parse !== false)) || ((control.textParse !== undefined) && (control.textParse !== false))) && control.isUseActionButton){ binding.attrs.isUseActionButton = CONST_XML_FUNCTION_TRUE; if(control.btnKind === 'Image'){ // image binding.attrs.useImage = CONST_XML_FUNCTION_TRUE; if(control.imageText === undefined || jQuery.trim(control.imageText) === ''){ control.imageText = lbl_enter_image_text; } bodyTag.children.push({ name: 'imageText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":imageText')" } }); var imageTextObj = {}; imageTextObj.eng = control.imageText; addTranslation(imageTextObj, xpath + control.name + ':imageText', translations); if ((control.hintLink !== undefined) && (control.hintLink !== '')){ binding.attrs.hintlink = control.hintLink; if(binding.attrs.hintlink){ var arr = binding.attrs.hintlink.split('&fileName='); binding.attrs.hintlink = arr[0]; if(arr[1]){ binding.attrs.hintlink += "&fileName=" + encodeXmlFileName(arr[1]); } } } }else{ // button binding.attrs.useImage = CONST_XML_FUNCTION_FALSE; if(control.actionBtnText === undefined || jQuery.trim(control.actionBtnText) === ''){ control.actionBtnText = lbl_enter_button_text; } //binding.attrs.actionBtnText = control.actionBtnText; bodyTag.children.push({ name: 'actionBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":actionBtnText')" } }); var actionBtnTextObj = {}; actionBtnTextObj.eng = control.actionBtnText; addTranslation(actionBtnTextObj, xpath + control.name + ':actionBtnText', translations); } } } } } // text length if ((control.type != 'inputShipping') && (control.length !== undefined) && (control.length !== false)){ if(control.length.min == ''){ if(control.type === CONST_CTRL_TYPE_INPUT_TEXT || control.type === CONST_CTRL_TYPE_INPUTBARCODE || control.type === CONST_CTRL_TYPE_INPUTNFC || control.type === CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD || control.type === CONST_CTRL_TYPE_INPUTLOOKUP || control.type === CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type === 'inputFacingTable' || control.type === 'inputLookupMulti'){ constraint.push('string-length(.) <= ' + control.length.max); }else if(control.type === CONST_CTRL_TYPE_INPUTDATE){ //constraint.push('. <= ' + (control.length.max==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.length.max) + '\')'))); if(control.kind == CONST_VALUE_TIME){ constraint.push('. <= ' + (control.length.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.max, control.kind) + '\')'))); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ constraint.push('. <= ' + (control.length.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.max, control.kind) + '\')'))); }else{ constraint.push('. <= ' + (control.length.max==='today'?'today()':('date(\'' + toJavaRosaFormat(control.length.max, control.kind) + '\')'))); } }else if(control.type === CONST_CTRL_TYPE_INPUTLOCATION){ binding.attrs.gpsmaxerror = control.length.max; }else{ constraint.push('. <= ' + control.length.max); } }else if(control.length.max == ''){ if(control.type === CONST_CTRL_TYPE_INPUT_TEXT || control.type === CONST_CTRL_TYPE_INPUTBARCODE || control.type === CONST_CTRL_TYPE_INPUTNFC || control.type === CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD || control.type === CONST_CTRL_TYPE_INPUTLOOKUP || control.type === CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type === 'inputFacingTable' || control.type === 'inputLookupMulti'){ constraint.push('string-length(.) >= ' + control.length.min); }else if(control.type === CONST_CTRL_TYPE_INPUTDATE){ //constraint.push('. >= ' + (control.length.min==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.length.min) + '\')'))); if(control.kind == CONST_VALUE_TIME){ constraint.push('. >= ' + (control.length.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.min, control.kind) + '\')'))); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ constraint.push('. >= ' + (control.length.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.min, control.kind) + '\')'))); }else{ constraint.push('. >= ' + (control.length.min==='today'?'today()':('date(\'' + toJavaRosaFormat(control.length.min, control.kind) + '\')'))); } }else if(control.type === CONST_CTRL_TYPE_INPUTLOCATION){ binding.attrs.gpsminerror = control.length.min; }else{ constraint.push('. >= ' + control.length.min); } }else{ if(control.type === CONST_CTRL_TYPE_INPUT_TEXT || control.type === CONST_CTRL_TYPE_INPUTBARCODE || control.type === CONST_CTRL_TYPE_INPUTNFC || control.type === CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD || control.type === CONST_CTRL_TYPE_INPUTLOOKUP || control.type === CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type === 'inputFacingTable' || control.type === 'inputLookupMulti'){ constraint.push('string-length(.) >= ' + control.length.min + ' and string-length(.) <= ' + control.length.max); }else if(control.type === CONST_CTRL_TYPE_INPUTDATE){ //constraint.push('. >= ' + (control.length.min==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.length.min) + '\')')) + ' and . <= ' + (control.length.max==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.length.max) + '\')'))); if(control.kind == CONST_VALUE_TIME){ constraint.push('. >= ' + (control.length.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.min, control.kind) + '\')')) + ' and . <= ' + (control.length.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.max, control.kind) + '\')'))); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ constraint.push('. >= ' + (control.length.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.min, control.kind) + '\')')) + ' and . <= ' + (control.length.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.length.max, control.kind) + '\')'))); }else{ constraint.push('. >= ' + (control.length.min==='today'?'today()':('date(\'' + toJavaRosaFormat(control.length.min, control.kind) + '\')')) + ' and . <= ' + (control.length.max==='today'?'today()':('date(\'' + toJavaRosaFormat(control.length.max, control.kind) + '\')'))); } }else if(control.type === CONST_CTRL_TYPE_INPUTLOCATION){ binding.attrs.gpsminerror = control.length.min; binding.attrs.gpsmaxerror = control.length.max; }else{ constraint.push('. >= ' + control.length.min + ' and . <= ' + control.length.max); } } if(isVersion(VERSION_CANNOT_EXCEED_MAX) && control.length.cannotExceedMaximum){ binding.attrs.cannotExceedMaximum = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_IGNORE_SCAN_IF) && control.length.ignoreScanIf){ binding.attrs.ignoreScanIf = CONST_XML_FUNCTION_TRUE; if(control.length.ignoreScanIfTimeOut){ binding.attrs.ignoreScanIfTimeOut = control.length.ignoreScanIfTimeOut; } } } // numeric range if (!ignoreRangeContraint && (control.range !== undefined) && (control.range !== false)){ if(control.range.min == ''){ if(control.type === CONST_CTRL_TYPE_INPUT_TEXT || control.type === CONST_CTRL_TYPE_INPUTBARCODE || control.type === CONST_CTRL_TYPE_INPUTNFC || control.type === CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD || control.type === CONST_CTRL_TYPE_INPUTLOOKUP || control.type === CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type === 'inputFacingTable'|| control.type === 'inputLookupMulti'){ constraint.push('string-length(.) <= ' + control.range.max); }else if(control.type === CONST_CTRL_TYPE_INPUTDATE){ //constraint.push('. <= ' + (control.range.max==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.range.max) + '\')'))); if(control.kind == CONST_VALUE_TIME){ constraint.push('. <= ' + (control.range.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.max, control.kind) + '\')'))); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ constraint.push('. <= ' + (control.range.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.max, control.kind) + '\')'))); }else{ constraint.push('. <= ' + (control.range.max==='today'?'today()':('date(\'' + toJavaRosaFormat(control.range.max, control.kind) + '\')'))); } }else if(control.type === CONST_CTRL_TYPE_INPUTLOCATION){ binding.attrs.gpsmaxerror = control.range.max; }else{ constraint.push('. <= ' + control.range.max); } }else if(control.range.max == ''){ if(control.type === CONST_CTRL_TYPE_INPUT_TEXT || control.type === CONST_CTRL_TYPE_INPUTBARCODE || control.type === CONST_CTRL_TYPE_INPUTNFC || control.type === CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD || control.type === CONST_CTRL_TYPE_INPUTLOOKUP || control.type === CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type === 'inputFacingTable' || control.type === 'inputLookupMulti'){ constraint.push('string-length(.) >= ' + control.range.min); }else if(control.type === CONST_CTRL_TYPE_INPUTDATE){ //constraint.push('. >= ' + (control.range.min==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.range.min) + '\')'))); if(control.kind == CONST_VALUE_TIME){ constraint.push('. >= ' + (control.range.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.min, control.kind) + '\')'))); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ constraint.push('. >= ' + (control.range.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.min, control.kind) + '\')'))); }else{ constraint.push('. >= ' + (control.range.min==='today'?'today()':('date(\'' + toJavaRosaFormat(control.range.min, control.kind) + '\')'))); } }else if(control.type === CONST_CTRL_TYPE_INPUTLOCATION){ binding.attrs.gpsminerror = control.range.min; }else{ constraint.push('. >= ' + control.range.min); } }else{ if(control.type === CONST_CTRL_TYPE_INPUT_TEXT || control.type === CONST_CTRL_TYPE_INPUTBARCODE || control.type === CONST_CTRL_TYPE_INPUTNFC || control.type === CONST_CTRL_TYPE_INPUTFORWARD || control.type === CONST_CTRL_TYPE_INPUTSECUREFORWARD || control.type === CONST_CTRL_TYPE_INPUTLOOKUP || control.type === CONST_CTRL_TYPE_INPUTLFBLUETOOTH || control.type === 'inputFacingTable' || control.type === 'inputLookupMulti'){ constraint.push('string-length(.) >= ' + control.range.min + ' and string-length(.) <= ' + control.range.max); }else if(control.type === CONST_CTRL_TYPE_INPUTDATE){ //constraint.push('. >= ' + (control.range.min==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.range.min) + '\')')) + ' and . <= ' + (control.range.max==='today'?'today()':('date(\'' + mmddyyyyToyyyymmdd(control.range.max) + '\')'))); if(control.kind == CONST_VALUE_TIME){ constraint.push('. >= ' + (control.range.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.min, control.kind) + '\')')) + ' and . <= ' + (control.range.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.max, control.kind) + '\')'))); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ constraint.push('. >= ' + (control.range.min==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.min, control.kind) + '\')')) + ' and . <= ' + (control.range.max==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(control.range.max, control.kind) + '\')'))); }else{ constraint.push('. >= ' + (control.range.min==='today'?'today()':('date(\'' + toJavaRosaFormat(control.range.min, control.kind) + '\')')) + ' and . <= ' + (control.range.max==='today'?'today()':('date(\'' + toJavaRosaFormat(control.range.max, control.kind) + '\')'))); } }else if(control.type === CONST_CTRL_TYPE_INPUTLOCATION){ binding.attrs.gpsminerror = control.range.min; binding.attrs.gpsmaxerror = control.range.max; }else{ constraint.push('. >= ' + control.range.min + ' and . <= ' + control.range.max); } } if(isVersion(VERSION_CANNOT_EXCEED_MAX)){ if(control.range.cannotExceedMaximum){ binding.attrs.cannotExceedMaximum = CONST_XML_FUNCTION_TRUE; } if(control.range.customErrorMessageChk){ binding.attrs.customErrorMessage = CONST_XML_FUNCTION_TRUE; if(control.range.customErrorMessage && control.range.customErrorMessage != ''){ bodyTag.children.push({ name: 'customErrorMessage', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":customErrorMessage')" } }); var customErrorMessageObj = {}; customErrorMessageObj.eng = control.range.customErrorMessage; addTranslation(customErrorMessageObj, xpath + control.name + ':customErrorMessage', translations); } } } }else if(isVersion(VERSION_VALIDATE_VALUE) && control.validateValue){ var itemPath = getControlXPath(root, "/data/", control.validateValue.field); constraint.push('. ' + HtmlEncode(control.validateValue.condition) + ' ' + itemPath); } if(isVersion(VERSION_SKETCH_DEFAULT_IMAGE)){ if (control.defaultImage && control.defaultImage != ''){ var arr = control.defaultImage.split('&'); binding.attrs.defaultImage = arr[0]; } } // media kind if (control.type == mdi_kind_inputImage){ bodyTag.attrs.mediatype = 'image/*'; } if (control.type == mdi_kind_inputAudio){ bodyTag.attrs.mediatype = 'audio/*'; } if (control.type == mdi_kind_inputVideo){ bodyTag.attrs.mediatype = 'video/*'; } if (control.type == CONST_CTRL_TYPE_INPUTMEDIA){ bodyTag.attrs.mediatype = control.kind.toLowerCase() + '/*'; } if (control.type == mdi_kind_inputSketch) bodyTag.attrs.mediatype = 'sketch/*'; if (control.type == mdi_kind_inputSignature) bodyTag.attrs.mediatype = 'signature/*'; // media kind if (control.type == 'inputDraw') bodyTag.attrs.mediatype = control.kind.toLowerCase() + '/*'; if (control.type == CONST_CTRL_TYPE_INPUTATTACHMENT) bodyTag.attrs.mediatype = 'attachment/*'; // options if(isVersion(VERSION_CHOOSE_ONE_SLIDER) && control.type == CONST_CTRL_TYPE_INPUTSELECTONE && control.optionKind == CONST_CHOOSE_ONE_SWITCH) { var valTrue = CONST_SWITCH_1; var textTrue = {'eng': CONST_SWITCH_1}; var valFalse = CONST_SWITCH_0; var textFalse = {'eng': CONST_SWITCH_0}; switch(control.switchOption){ case CONST_SWITCH_ON_OFF: textTrue = {'eng': CONST_SWITCH_ON}; textFalse = {'eng': CONST_SWITCH_OFF}; valTrue = CONST_SWITCH_ON; valFalse = CONST_SWITCH_OFF; break; case CONST_SWITCH_YES_NO: textTrue = {'eng': CONST_SWITCH_YES}; textFalse = {'eng': CONST_SWITCH_NO}; valTrue = CONST_SWITCH_YES; valFalse = CONST_SWITCH_NO; break; case CONST_SWITCH_1_0: textTrue = {'eng': CONST_SWITCH_1}; textFalse = {'eng': CONST_SWITCH_0}; valTrue = CONST_SWITCH_1; valFalse = CONST_SWITCH_0; break; case CONST_SWITCH_CUSTOM: textTrue = {'eng': control.switchCustomOn}; textFalse = {'eng': control.switchCustomOff}; valTrue = control.switchCustomOn; valFalse = control.switchCustomOff; break; } var i = 0; var itextPath = xpath + control.name + ':option' + i; addTranslation(textTrue, itextPath, translations); bodyTag.children.push({ name: 'item', children: [ { name: 'label', attrs: { 'ref': "jr:itext('" + itextPath + "')" } }, { name: CONST_VALUE, val: valTrue } ] }); i = 1; itextPath = xpath + control.name + ':option' + i; addTranslation(textFalse, itextPath, translations); bodyTag.children.push({ name: 'item', children: [ { name: 'label', attrs: { 'ref': "jr:itext('" + itextPath + "')" } }, { name: CONST_VALUE, val: valFalse} ] }); }else{ if (control.options !== undefined){ _.each(control.options, function(option, i) { if (option.isShowUnderlying !== undefined){ return true; } var itextPath = xpath + control.name + ':option' + i; addTranslation(option.text, itextPath, translations); if(isVersion(VERSION_OPTION_IMAGE) && option.image && option.image != ''){ var imageItextPath = xpath + control.name + ':optionImage' + i; var objectImg = { eng: option.image.replace('transparent','ffffff') }; addTranslation(objectImg, imageItextPath, translations); var iconColorPath = xpath + control.name + ':optionIconColor' + i; var objectIconColor = { eng: '#' + option.iconColor }; addTranslation(objectIconColor, iconColorPath, translations); var showAnswerText = false; if(isVersion(VERSION_SHOW_ANSWER_TEXT) && option.showAnswerText){ showAnswerText = true; } var showAnswerTextPath = xpath + control.name + ':showAnswerText' + i; var objectShowAnswerText = { eng: showAnswerText }; addTranslation(objectShowAnswerText, showAnswerTextPath, translations); if(control.type == CONST_CTRL_TYPE_INPUTSCOREONE){ bodyTag.children.push({ name: 'item', children: [ { name: 'label', attrs: { 'ref': "jr:itext('" + itextPath + "')" } }, { name: CONST_VALUE, val: option.val }, { name: 'score', val: option.val }, { name: 'optionImage', attrs: { 'ref': "jr:itext('" + imageItextPath + "')" } }, { name: 'optionIconColor', attrs: { 'ref': "jr:itext('" + iconColorPath + "')" } }, { name: 'showAnswerText', attrs: { 'ref': "jr:itext('" + showAnswerTextPath + "')" } } ] }); }else{ bodyTag.children.push({ name: 'item', children: [ { name: 'label', attrs: { 'ref': "jr:itext('" + itextPath + "')" } }, { name: CONST_VALUE, val: option.val }, { name: 'optionImage', attrs: { 'ref': "jr:itext('" + imageItextPath + "')" } }, { name: 'optionIconColor', attrs: { 'ref': "jr:itext('" + iconColorPath + "')" } }, { name: 'showAnswerText', attrs: { 'ref': "jr:itext('" + showAnswerTextPath + "')" } } ] }); } }else{ if(control.type == CONST_CTRL_TYPE_INPUTSCOREONE){ bodyTag.children.push({ name: 'item', children: [ { name: 'label', attrs: { 'ref': "jr:itext('" + itextPath + "')" } }, { name: CONST_VALUE, val: option.val }, { name: 'score', val: option.val } //val: option.score } ] }); }else{ bodyTag.children.push({ name: 'item', children: [ { name: 'label', attrs: { 'ref': "jr:itext('" + itextPath + "')" } }, { name: CONST_VALUE, val: option.val } ] }); } } }); } } // advanced relevance if (control.relevance != undefined && control.relevance !== '') relevance.push(control.relevance); /*// advanced constraint if (control.constraint !== '') constraint.push(control.constraint);*/ /*// advanced constraint message if (control.constraintmessage !== '') constraintmessage = control.constraintmessage;*/ /*if (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT){ constraint.push("regex(., '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}')"); }*/ if (control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && relevance != undefined && relevance.length > 0){ if(relevance.length == 1){ binding.attrs.relevant = relevance.join(''); }else{ binding.attrs.relevant = '(' + relevance.join(') and (') + ')'; } } if (control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && constraint != undefined && constraint.length > 0){ if(constraint.length == 1){ binding.attrs.constraint = constraint.join(''); }else{ binding.attrs.constraint = '(' + constraint.join(') and (') + ')'; } } if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLPOD){ var qtyId = POD_QTY_COL_ID + objParent.id; if(control.name && control.name.indexOf('__Damaged') >= 0 || control.name && control.name.indexOf('__Rejected') >= 0){ if(control.type != CONST_CTRL_TYPE_INPUTSELECTMANY){ var itemQtyPath = getControlXPath(root, "/data/", qtyId); binding.attrs.constraint = '. >= 1'; if(itemQtyPath && itemQtyPath != ''){ binding.attrs.constraint += ' and . <= ' + itemQtyPath; } } }else if(control.name && control.name.indexOf('__Actual') >= 0){ binding.attrs.constraint = '. >= 0'; } } if(isVersion(VERSION_GEOFENCE_WIDGET) && control.type == CONST_CTRL_TYPE_INPUTGEOFENCE){ var itemPath = getControlXPath(root, "/data/", control.descriptionQuestion); var geofenceInfo = ''; geofenceInfo += (itemPath || '') + '|'; geofenceInfo += control.inputType + '|'; itemPath = getControlXPath(root, "/data/", control.addressQuestion); geofenceInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.latQuestion); geofenceInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.lonQuestion); geofenceInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.arrivedTimeDes); geofenceInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.departedTimeDes); geofenceInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.durationMinutesDes); geofenceInfo += (itemPath || ''); binding.attrs.info = geofenceInfo; if(control.radius != undefined && control.radius != ''){ binding.attrs.radius = control.radius; } if(control.isHoldingUntilDepart == true){ var holdingUntilDepart = CONST_XML_FUNCTION_TRUE; var sendDispatchAfter = CONST_SEND_DISPATCH_AFTER_DEFAULT; if(control.sendDispatchAfter != undefined && control.sendDispatchAfter != ''){ sendDispatchAfter = control.sendDispatchAfter; } binding.attrs.holdingUntilDepart = holdingUntilDepart + '|' + sendDispatchAfter; } } /*if (constraintmessage !== '') binding.attrs.message = constraintmessage;*/ if(isVersion(VERSION_INPUT_SHIPPING) && control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ createXmlPropertyShipping(root, control, binding, bodyTag); var purchaseBtnText = ''; if(control.purchaseBtnText != undefined && control.purchaseBtnText != ''){ purchaseBtnText = control.purchaseBtnText; }else{ purchaseBtnText = lbl_purchase; } bodyTag.children.push({ name: 'purchaseBtnText', attrs: { 'ref': "jr:itext('" + xpath + control.name + ":purchaseBtnText')" } }); addTranslation({'eng': purchaseBtnText}, xpath + control.name + ':purchaseBtnText', translations); } }; var makePreloadElement = function(xpath, elementName, type, preload, preloadParams, instance, model){ var instanceTag = { name: elementName }; instance.children.push(instanceTag); // binding var binding = { name: 'bind', attrs: { 'nodeset': xpath + elementName, 'type': type, 'jr:preload': preload, 'jr:preloadParams': preloadParams } } model.children.push(binding); }; var makeHideElement = function(xpath, elementName, value, type, instance, model){ var instanceTag = { name: elementName, val: value }; instance.children.push(instanceTag); // binding var binding = { name: 'bind', attrs: { 'nodeset': xpath + elementName, 'type': type } } model.children.push(binding); }; var makePreloadData = function(xpath, instanceHead, model){ makePreloadElement(xpath, 'start', 'dateTime', 'timestamp', 'start', instanceHead, model); makePreloadElement(xpath, 'end', 'dateTime', 'timestamp', 'end', instanceHead, model); makePreloadElement(xpath, 'today', CONST_VALUE_DATE_LOWERCASE, CONST_VALUE_DATE_LOWERCASE, 'today', instanceHead, model); makePreloadElement(xpath, 'deviceid', 'string', 'property', 'deviceid', instanceHead, model); makePreloadElement(xpath, 'subscriberid', 'string', 'property', 'subscriberid', instanceHead, model); makePreloadElement(xpath, 'simid', 'string', 'property', 'simserial', instanceHead, model); makePreloadElement(xpath, 'phonenumber', 'string', 'property', 'phonenumber', instanceHead, model); makePreloadElement(xpath, 'mobilekey', 'string', 'property', 'mobilekey', instanceHead, model); makePreloadElement(xpath, 'projectkey', 'string', 'property', 'projectkey', instanceHead, model); makePreloadElement(xpath, 'score-data', 'string', 'property', 'score-data', instanceHead, model); makeHideElement(xpath, 'recordid', '', 'string', instanceHead, model); }; var internalToXForm = function(internal) { // basic structure // TODO: user-config of instanceHead var instanceHead = { name: 'data', children: [] }; if(isVersion5_0()){ instanceHead.attrs = {version: FORM_VERSION}; } if(isVersion(VERSION_OPENING_VIEW)){ var openingView = odkmaker.data.formSettings.openingView || 'Form View'; if(openingView == 'Question View'){ if(odkmaker.data.formSettings.allowReturnToFromView){ instanceHead.attrs = {version: FORM_VERSION, opening_view: openingView, allowReturnToFV: CONST_XML_FUNCTION_TRUE}; }else{ instanceHead.attrs = {version: FORM_VERSION, opening_view: openingView, allowReturnToFV: CONST_XML_FUNCTION_FALSE}; } }else{ instanceHead.attrs = {version: FORM_VERSION, opening_view: openingView}; } } var instance = { name: 'instance', children: [ instanceHead ] }; var translations = { name: 'itext', children: [] }; var model = { name: 'model', children: [ instance, translations ] }; var body = { name: 'h:body', children: [] }; var root = { name: 'h:html', attrs: { 'xmlns': 'http://www.w3.org/2002/xforms', 'xmlns:h': 'http://www.w3.org/1999/xhtml', 'xmlns:ev': 'http://www.w3.org/2001/xml-events', 'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema', 'xmlns:jr': 'http://openrosa.org/javarosa' }, children: [ { name: 'h:head', children: [ { name: 'h:title', val: '' }, model ] }, body ] }; _.each(odkmaker.i18n.activeLanguages(), function(language) { translations.children.push({ name: 'translation', attrs: { 'lang': language }, children: [] }); }); makePreloadData('/data/', instanceHead, model); _.each(internal.controls, function(control) { /*var nextCtrlInd = internal.controls.indexOf(control); var nextCtrlName = CONST_JUMP_EOF_TEXT; nextCtrlInd += 1; if((control.type == CONST_CTRL_TYPE_GROUP || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) && nextCtrlInd < internal.controls.length){ nextCtrlName = internal.controls[nextCtrlInd].name; }*/ var nextCtrlName = CONST_JUMP_EOF_TEXT; if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ nextCtrlName = CONST_JUMP_EOG_TEXT; } parseControl(control, '/data/', '', instanceHead, translations, model, body, undefined, internal.controls, nextCtrlName, ""); if (control.type == CONST_CTRL_TYPE_INPUTACTION && control.imgAction === CONST_ACTION_AUDIT){ var childAdd = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[CONST_CTRL_TYPE_INPUT_TEXT]); childAdd.type = CONST_CTRL_TYPE_INPUT_TEXT; childAdd.name = '' + control.name + '__addInfo'; childAdd.length = false; childAdd.textParse = false; childAdd.label.eng = ''; childAdd.hint.eng = ''; childAdd.options = undefined; //childAdd.defaultValue = {foundItems:[], notFoundItems:[]}; childAdd.required = false; childAdd.hideInMobile = true; childAdd.justificationCaption = undefined; childAdd.justificationHint = undefined; childAdd.justificationAnswer = undefined; childAdd.numberOfLine = undefined; childAdd.grayCaption = undefined; childAdd.socialSecurityFormat = undefined; childAdd.phoneNoFormat = undefined; childAdd.isCustomFormat = undefined; childAdd.showSymbols = undefined; childAdd.uppercaseLock = undefined; childAdd.suppressKeyboard = undefined; childAdd.duplicateCheck = undefined; childAdd.relevance = undefined; childAdd.isShowITE = undefined; childAdd.iteConditions = undefined; parseControl(childAdd, '/data/', '', instanceHead, translations, model, body, undefined, internal.controls, nextCtrlName, ""); } }); modelTmp = model; return root; }; // XML serializer var generateIndent = function(indentLevel) { var result = ''; for (var i = 0; i < indentLevel; i++) result += ' '; return result; }; var JSONtoXML = function(obj, encode, indentLevel) { if (indentLevel === undefined) indentLevel = 0; var result = generateIndent(indentLevel); if (_.isString(obj)) return result + obj + '\n'; if(isControlHidden(obj)){ return ''; } if(obj.ctrlType == CONST_CTRL_TYPE_CTRLTABLE || obj.ctrlType == CONST_CTRL_TYPE_CTRLSCHEDULE || obj.ctrlType == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ var parentProperty = fvDataNS.dataArray['data ' + obj.name]; if(isControlHidden(parentProperty)){ return ''; } } if(obj.ctrlType == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ if(!obj.classPath.endsWith('_loop_1')){ return ''; }else{ result += '<' + obj.name + '> \n'; return result; } } if(obj.parentPageBreak != undefined // CO-4008 && $('.formView .fvCtrlID_' + obj.parentPageBreak).hasClass(CONST_CSS_CLASS_HIDE_SESSION)){ return ''; } var isIgnoreGroupItem = false; if(obj.ctrlType != undefined && obj.ctrlType == CONST_CTRL_TYPE_GROUP && obj.inputRepeatCount != undefined){ isIgnoreGroupItem = true; result = ''; }else{ result += '<' + obj.name; if(obj.ctrlType == CONST_CTRL_TYPE_CTRLPOD && !fvDataNS.inputData.PODDataHasGenTOJSon[obj.name]){ fvDataNS.inputData.PODDataHasGenTOJSon[obj.name] = true; try { if(fvDataNS.inputData && fvDataNS.inputData.PODData[obj.name]){ var tmp = fvDataNS.inputData.PODData[obj.name]; result += ' Qty="' + (tmp.Qty | 0) + '"'; result += ' Damaged="' + (tmp.Damaged | 0) + '"'; result += ' Over="' + (tmp.Over | 0) + '"'; } }catch (e) { } } // CO-4372 else if(obj.ctrlType == CONST_CTRL_TYPE_INPUTGEOFENCE){ try{ var geoVal = geofencesValue['geo__' + obj.name]; if(geoVal != undefined){ // address obj.val = (geoVal.address != undefined ? geoVal.address : ''); // radius var radius = 100; // default try{ radius = geofencesMap['geo__' + obj.name].radius; if(radius == undefined){ radius = 100; } } catch(e2){} obj.val += '$' + radius; // lat lng var latVal = (geoVal.lat != undefined ? geoVal.lat : ''); var lngVal = (geoVal.lng != undefined ? geoVal.lng : ''); obj.val += '$'; if(latVal != '' && lngVal != ''){ obj.val += latVal + ',' + lngVal; } obj.val += '$' + (geoVal.description != undefined ? geoVal.description : ''); } } catch(e){} } else if(obj.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ //track as record //CO-5405 if(obj.trackAsRelatedRecord && obj.lookupRecordKeyVal) { result += ' recordkey="' + obj.lookupRecordKeyVal + '"'; } } try { var objParent = getParent(); if(obj.name == 'mobilekey' && authNS.currentUser.Username != undefined && (1 == previewEmbedHtml // CO-1095: embed cases || (fvDataNS.currentForm['&frmLinkCopyToken'] && fvDataNS.currentForm.editRecordKey) // CO-3370 || objParent.dispatchCOPYId != undefined || 'true' == viewCopy)){ // CO-3396 result += ' username="' + authNS.currentUser.Username .replace(/&/g, '&') .replace(/"/g, '"') .replace(//g,">")+ '"'; } if((objParent.dispatchCOPYId != undefined && objParent.dispatchCOPYId != '') || true == objParent.plusRowCopy){ result += ' cloneMedia="1"'; } } catch (e) { } } if (obj.attrs !== undefined){ _.each(obj.attrs, function(value, key) { result += ' ' + key + '="' + value + '"'; }); } if (obj.val !== undefined || obj.submitValue !== undefined) { if(obj.name == '__reply_flag'){ var valueTmp = obj.val==''?CONST_VALUE_TRUE_STR:''; if (encode){ result += '>' + HtmlEncode4Website(valueTmp, isVersion(VERSION_USING_CDATA)) + '\n'; }else{ result += '>' + valueTmp + '\n'; } }else{ var objValue = ''; if(obj.submitValue){ objValue = obj.submitValue; }else{ objValue = obj.val; } if (encode){ result += '>' + HtmlEncode4Website(objValue, isVersion(VERSION_USING_CDATA)) + '\n'; }else{ result += '>' + objValue + '\n'; } } } else if (obj.children !== undefined) { var level = indentLevel; if(!isIgnoreGroupItem){ result += '>\n'; level += 1; } var podName = ''; var replyToSenderFlag = false; var replyToSenderChild = undefined; _.each(obj.children, function(child) { if(!child){ return false; } if(child.isMessageWidget){ return true; } if(child.name == '__reply_flag' && child.val == ''){ replyToSenderChild = child; return true; } if(podName == ''){ if(child.ctrlType == CONST_CTRL_TYPE_CTRLPOD){ podName = child.name; } }else{ if(podName != child.name){ if(fvDataNS.inputData.PODExtData && fvDataNS.inputData.PODExtData[podName]){ _.each(fvDataNS.inputData.PODExtData[podName], function(podExtChild){ result += JSONtoXML(podExtChild, encode, level); }); } if(child.ctrlType == CONST_CTRL_TYPE_CTRLPOD){ podName = child.name; }else{ podName = ''; } } } if(!replyToSenderFlag && (child.ctrlType == CONST_CTRL_TYPE_INPUTFORWARD || child.ctrlType == CONST_CTRL_TYPE_INPUTSECUREFORWARD)){ if(child.replyToSender && child.val != ''){ replyToSenderFlag = true; } } result += JSONtoXML(child, encode, level); }); if(replyToSenderChild){ if(replyToSenderFlag){ replyToSenderChild.val = ''; }else{ // reset flag replyToSenderChild.val = CONST_VALUE_TRUE_STR; } result += JSONtoXML(replyToSenderChild, encode, level); } if(podName != ''){ if(fvDataNS.inputData.PODExtData && fvDataNS.inputData.PODExtData[podName]){ _.each(fvDataNS.inputData.PODExtData[podName], function(podExtChild){ result += JSONtoXML(podExtChild, encode, level); }); } } if(!isIgnoreGroupItem){ result += generateIndent(indentLevel) + '\n'; } } else { result += '/>\n'; } result += addAddInfo4Audit(obj, encode, indentLevel); return result; }; var addAddInfo4Audit = function(obj, encode, indentLevel){ if(!isVersion(VERSION_ACTION_AUDIT)){ return ''; } if(obj.ctrlType == CONST_CTRL_TYPE_INPUTACTION && obj.imgAction === CONST_ACTION_AUDIT){ if(fvDataNS.auditDataInfo[obj.classPath] == undefined){ fvDataNS.auditDataInfo[obj.classPath] = {}; } addInfoObj = { name: obj.name + '__addInfo', ctrlType: CONST_CTRL_TYPE_INPUT_TEXT, val: JSON.stringify(fvDataNS.auditDataInfo[obj.classPath]) } return JSONtoXML(addInfoObj, encode, indentLevel); }else{ return ''; } } var getBindingObject = function(json, itemPath){ var model = json.children[0].children[1]; var bindingRet = null; var nodeSet; _.each(model.children, function(binding){ if(binding.name == 'bind'){ nodeSet = binding.attrs['nodeset']; if(itemPath == nodeSet){ bindingRet = binding; return false; } } }); return bindingRet; }; var addSkipLogic = function(root, controls, json) { var bRet = true; _.each(controls, function(control) { if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addSkipLogic(root, control.children, json); } if(control.skipconds != undefined && control.skipconds[0] != undefined && control.skipconds[0].text['eng'] != undefined){ var fieldPath = getControlXPath(root, "/data/", control.id); var skipCondString = ""; var skipToField = control.skipconds[0].text['eng']; var i = 0; var condString = ""; var condValue = ""; var space = " "; _.each(control.skipconds, function(skipCond){ condString = skipCond.text[CONST_VAL]; condValue = skipCond.value[CONST_VAL]; if(condValue == undefined){ condValue = ''; } condValue = HtmlEncode(condValue, true); if(i != 0){ var joinString = skipCond.text['eng']; if(joinString == undefined || joinString != CONST_VALUE_OR_LOWERCASE){ joinString = CONST_VALUE_AND_LOWERCASE; } skipCondString = skipCondString + space + joinString + space; } var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } if(isNewEmptyType){ skipCondString = skipCondString + condString + '(' + fieldPath + ')'; }else if(control.type == CONST_CTRL_TYPE_INPUT_TEXT){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } skipCondString = skipCondString + fieldPath + condString + condValue; }else if(control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } skipCondString = skipCondString + fieldPath + condString + condValue; }else if(control.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(control.kind == CONST_VALUE_TIME){ skipCondString = skipCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ skipCondString = skipCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); }else{ skipCondString = skipCondString + fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); } }else if(control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTSCOREONE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(condString == ' = '){ skipCondString = skipCondString + 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ skipCondString = skipCondString + 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } }else if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputImage){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputAudio){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputVideo){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTMEDIA){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputSketch){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputSignature){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputDraw'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTBARCODE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTNFC){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputPageBreak' || control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTPAYMENT || control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || control.type == 'inputInstruction' || control.type == 'inputSaveAndSend'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputFacingTable'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputLookupMulti'){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; }/*else if (control.type == 'inputRIF'){ }*/ else if(control.type == CONST_CTRL_TYPE_INPUTATTACHMENT){ skipCondString = skipCondString + fieldPath + condString + "'" + condValue + "'"; } i++; }); skipCondString = "false()=(" + skipCondString + ")"; if(!isVersion5_0()){ var bStart = false; _.each(controls, function(item) { if(item.id == control.id){ bStart = true; }else{ if(skipToField != CONST_JUMP_EOF_VAL){ if(item.id == skipToField){ bStart = false; return bStart; } } if(bStart){ var itemPath = getControlXPath(root, "/data/", item.id); var binding = getBindingObject(json, itemPath); if(binding != null){ if(binding.attrs.relevant == undefined || binding.attrs.relevant == ''){ binding.attrs.relevant = skipCondString; //binding.attrs.action="hide"; }else{ binding.attrs.relevant = binding.attrs.relevant + ' and ' + skipCondString; } } } } }); }else{ var binding = getBindingObject(json, fieldPath); if(binding != null){ binding.attrs.skip = skipCondString; binding.attrs.action = CONST_ACTION_ID_JUMP; if(skipToField != CONST_JUMP_EOF_VAL){ var itemPath = getControlXPath(root, "/data/", skipToField); binding.attrs.actionParam = itemPath; }else{ binding.attrs.actionParam = CONST_JUMP_EOF_TEXT; } } } } }); return bRet; }; var addRelevance = function(root, controls, json) { var bRet = true; _.each(controls, function(control) { if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addRelevance(root, control.children, json); } if(control.relevanceconds != undefined && control.relevanceconds[0] != undefined && control.relevanceconds[0].text['eng'] != undefined){ var relevanceCondString = ""; var i = 0; var condString = ""; var condValue = ""; var space = " "; _.each(control.relevanceconds, function(relevanceCond){ if(relevanceCond.text['eng'] == ''){ return true; } var relevanceControl = getControlById(relevanceCond.text['eng'], root); if(relevanceControl == undefined){ return true; } var fieldPath = getControlXPath(root, "/data/", relevanceCond.text['eng']); condString = relevanceCond.text[CONST_VAL]; condValue = relevanceCond.value[CONST_VAL]; if(condValue == undefined){ condValue = ''; } condValue = HtmlEncode(condValue, true); if(i != 0){ var joinString = relevanceCond.text[CONST_VALUE_JOIN]; if(joinString == undefined || joinString != CONST_VALUE_OR_LOWERCASE){ joinString = CONST_VALUE_AND_LOWERCASE; } relevanceCondString = relevanceCondString + space + joinString + space; } var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } var isNewCompareType = false; if(isVersion(VERSION_REL_TYPE)){ if(relevanceCond.value != undefined && relevanceCond.value.cmpType == CONST_VALUE_OTHER){ isNewCompareType = true; if(isVersion(VERSION_USE_VARIABLE_BF)){ // CO-560 Use variables by text calcs, numeric calc, relevance, and IF THEN ELSE in Build forms if(relevanceCond.value.val && relevanceCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ condValue = relevanceCond.value.val; }else{ condValue = getControlXPath(root, "/data/", relevanceCond.value.val); } }else{ condValue = getControlXPath(root, "/data/", relevanceCond.value.val); } } } if(isNewEmptyType){ relevanceCondString = relevanceCondString + condString + '(' + fieldPath + ')'; }else if(isNewCompareType){ relevanceCondString = relevanceCondString + fieldPath + condString + condValue; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUT_TEXT){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUT_NUMERIC || relevanceControl.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } relevanceCondString = relevanceCondString + fieldPath + condString + condValue; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } relevanceCondString = relevanceCondString + fieldPath + condString + condValue; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(relevanceControl.kind == CONST_VALUE_TIME){ relevanceCondString = relevanceCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, relevanceControl.kind) + '\')')); }else if(relevanceControl.kind == CONST_VALUE_DATE_SPACE_TIME){ relevanceCondString = relevanceCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, relevanceControl.kind) + '\')')); }else{ relevanceCondString = relevanceCondString + fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, relevanceControl.kind) + '\')')); } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(relevanceControl.isCtrlInScoreTable != undefined && relevanceControl.isCtrlInScoreTable){ if(condString == ' = '){ relevanceCondString = relevanceCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ relevanceCondString = relevanceCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(relevanceControl.isCtrlInScoreTable != undefined && relevanceControl.isCtrlInScoreTable){ if(condString == ' = '){ relevanceCondString = relevanceCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ relevanceCondString = relevanceCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(relevanceControl.isCtrlInScoreTable != undefined && relevanceControl.isCtrlInScoreTable){ if(condString == ' = '){ relevanceCondString = relevanceCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ relevanceCondString = relevanceCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ if(condString == ' = '){ relevanceCondString = relevanceCondString + 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ relevanceCondString = relevanceCondString + 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTLOCATION){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == mdi_kind_inputImage){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == mdi_kind_inputAudio){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == mdi_kind_inputVideo){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTMEDIA){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == mdi_kind_inputSketch){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == mdi_kind_inputSignature){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == 'inputDraw'){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTBARCODE){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTNFC){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == 'inputPageBreak' || relevanceControl.type == 'inputLabel' || relevanceControl.type == CONST_CTRL_TYPE_INPUTACTION || relevanceControl.type == CONST_CTRL_TYPE_INPUTPAYMENT || relevanceControl.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || relevanceControl.type == 'inputInstruction' || relevanceControl.type == 'inputSaveAndSend'){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ if(!condValue || condValue == ''){ relevanceCondString = relevanceCondString + 'totalScore(' + fieldPath + ')' + condString + "''"; }else{ relevanceCondString = relevanceCondString + 'totalScore(' + fieldPath + ')' + condString + condValue; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTNUMBERING){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || relevanceControl.type == CONST_CTRL_TYPE_INPUTFAX || relevanceControl.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(relevanceControl.kind != null && (relevanceControl.kind == CONST_VALUE_DATE || relevanceControl.kind == 'String')){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else{ if(condValue == ''){ condValue = '0'; } relevanceCondString = relevanceCondString + fieldPath + condString + condValue; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTLOOKUP){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == 'inputFacingTable'){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == 'inputLookupMulti'){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }else if(relevanceControl.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ relevanceCondString = relevanceCondString + fieldPath + condString + "'" + condValue + "'"; }/*else if (relevanceControl.type == 'inputRIF'){ }*/ i++; }); if(relevanceCondString != undefined && relevanceCondString != ''){ relevanceCondString = "(" + relevanceCondString + ")"; } var itemPath = getControlXPath(root, "/data/", control.id); var binding = getBindingObject(json, itemPath); if(binding != null){ if(binding.attrs.relevant == undefined || binding.attrs.relevant == ''){ binding.attrs.relevant = relevanceCondString; //binding.attrs.action="hide"; }else{ if(relevanceCondString != undefined && relevanceCondString != ''){ binding.attrs.relevant = binding.attrs.relevant + ' and ' + relevanceCondString; } } } } }); return bRet; }; var addReadOnlyIf = function(root, controls, json) { var bRet = true; _.each(controls, function(control) { var itemPath = getControlXPath(root, "/data/", control.id); var binding = getBindingObject(json, itemPath); if(binding.attrs.readonly == CONST_XML_FUNCTION_TRUE){ return true; } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addReadOnlyIf(root, control.children, json); } if(!control.isShowReadOnlyIf){ return true; } if(control.readOnlyIfConditions != undefined && control.readOnlyIfConditions[0] != undefined && control.readOnlyIfConditions[0].text['eng'] != undefined){ var readOnlyIfConditionString = ""; var i = 0; var condString = ""; var condValue = ""; var space = " "; _.each(control.readOnlyIfConditions, function(readOnlyIfCond){ if(readOnlyIfCond.text['eng'] == ''){ return true; } var readOnlyIfControl = getControlById(readOnlyIfCond.text['eng'], root); if(readOnlyIfControl == undefined){ return true; } var fieldPath = getControlXPath(root, "/data/", readOnlyIfCond.text['eng']); condString = readOnlyIfCond.text[CONST_VAL]; condValue = readOnlyIfCond.value[CONST_VAL]; if(condValue == undefined){ condValue = ''; } condValue = HtmlEncode(condValue, true); if(i != 0){ var joinString = readOnlyIfCond.text[CONST_VALUE_JOIN]; if(joinString == undefined || joinString != CONST_VALUE_OR_LOWERCASE){ joinString = CONST_VALUE_AND_LOWERCASE; } readOnlyIfConditionString = readOnlyIfConditionString + space + joinString + space; } var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } var isNewCompareType = false; if(isVersion(VERSION_REL_TYPE)){ if(readOnlyIfCond.value != undefined && readOnlyIfCond.value.cmpType == CONST_VALUE_OTHER){ isNewCompareType = true; if(isVersion(VERSION_USE_VARIABLE_BF)){ // CO-560 Use variables by text calcs, numeric calc, readOnlyIf, and IF THEN ELSE in Build forms if(readOnlyIfCond.value.val && readOnlyIfCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ condValue = readOnlyIfCond.value.val; }else{ condValue = getControlXPath(root, "/data/", readOnlyIfCond.value.val); } }else{ condValue = getControlXPath(root, "/data/", readOnlyIfCond.value.val); } } } if(isNewEmptyType){ readOnlyIfConditionString = readOnlyIfConditionString + condString + '(' + fieldPath + ')'; }else if(isNewCompareType){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + condValue; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUT_TEXT){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUT_NUMERIC || readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + condValue; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + condValue; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(readOnlyIfControl.kind == CONST_VALUE_TIME){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, readOnlyIfControl.kind) + '\')')); }else if(readOnlyIfControl.kind == CONST_VALUE_DATE_SPACE_TIME){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, readOnlyIfControl.kind) + '\')')); }else{ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, readOnlyIfControl.kind) + '\')')); } }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(readOnlyIfControl.isCtrlInScoreTable != undefined && readOnlyIfControl.isCtrlInScoreTable){ if(condString == ' = '){ readOnlyIfConditionString = readOnlyIfConditionString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ readOnlyIfConditionString = readOnlyIfConditionString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; } }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(readOnlyIfControl.isCtrlInScoreTable != undefined && readOnlyIfControl.isCtrlInScoreTable){ if(condString == ' = '){ readOnlyIfConditionString = readOnlyIfConditionString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ readOnlyIfConditionString = readOnlyIfConditionString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; } }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(readOnlyIfControl.isCtrlInScoreTable != undefined && readOnlyIfControl.isCtrlInScoreTable){ if(condString == ' = '){ readOnlyIfConditionString = readOnlyIfConditionString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ readOnlyIfConditionString = readOnlyIfConditionString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ if(condString == ' = '){ readOnlyIfConditionString = readOnlyIfConditionString + 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ readOnlyIfConditionString = readOnlyIfConditionString + 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } } }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTLOCATION){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == mdi_kind_inputImage){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == mdi_kind_inputAudio){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == mdi_kind_inputVideo){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTMEDIA){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == mdi_kind_inputSketch){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == mdi_kind_inputSignature){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == 'inputDraw'){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTBARCODE){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTNFC){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == 'inputPageBreak' || readOnlyIfControl.type == 'inputLabel' || readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTACTION || readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTPAYMENT || readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || readOnlyIfControl.type == 'inputInstruction' || readOnlyIfControl.type == 'inputSaveAndSend'){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ if(!condValue || condValue == ''){ readOnlyIfConditionString = readOnlyIfConditionString + 'totalScore(' + fieldPath + ')' + condString + "''"; }else{ readOnlyIfConditionString = readOnlyIfConditionString + 'totalScore(' + fieldPath + ')' + condString + condValue; } }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTNUMBERING){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTFAX || readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(readOnlyIfControl.kind != null && (readOnlyIfControl.kind == CONST_VALUE_DATE || readOnlyIfControl.kind == 'String')){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else{ if(condValue == ''){ condValue = '0'; } readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + condValue; } }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTLOOKUP){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == 'inputFacingTable'){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == 'inputLookupMulti'){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }else if(readOnlyIfControl.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ readOnlyIfConditionString = readOnlyIfConditionString + fieldPath + condString + "'" + condValue + "'"; }/*else if (readOnlyIfControl.type == 'inputRIF'){ }*/ i++; }); if(readOnlyIfConditionString != undefined && readOnlyIfConditionString != ''){ readOnlyIfConditionString = "(" + readOnlyIfConditionString + ")"; if(binding != null){ binding.attrs.readonly = readOnlyIfConditionString; } } } }); return bRet; }; /* * Function for add lookup data */ var addLookupTableData = function(root, controls, json) { var bRet = true; _.each(controls, function(control) { if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addLookupTableData(root, control.children, json); } if(control.destinationdataconds != undefined && control.destinationdataconds.length > 0){ var lookupFillString = ''; var i = 0; var fillField = ''; var lookupField = ''; var space = ' '; _.each(control.destinationdataconds, function(item){ if(item.text.val == ''){ return true; } // CO-4086 Add user variables as destination field targets start var fillFieldPath; if(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ fillFieldPath = item.text.val; }else{ var fillControl = getControlById(item.text.val, root); if(fillControl == undefined){ return true; } fillFieldPath = getControlXPath(root, "/data/", item.text.val); } // CO-4086 Add user variables as destination field targets end if(control.type == 'inputFacingTable'){ lookupField = 'col1'; }else{ lookupField = item.value.val; } if(lookupField == undefined){ return true; } if(i != 0){ lookupFillString = lookupFillString + ', '; } lookupFillString = lookupFillString + fillFieldPath + " = " + lookupField; i++; }); var itemPath = getControlXPath(root, "/data/", control.id); var binding = getBindingObject(json, itemPath); if(binding != null){ binding.attrs.fieldlist = lookupFillString; } if(isVersion(VERSION_REFRESH_ON_RETRIEVE) && lookupFillString != '' && control.isRefreshOnRetrieve){ binding.attrs.isRefreshOnRetrieve = CONST_XML_FUNCTION_TRUE; } } if(control.isRetrieve && control.modifyFields != undefined && control.modifyFields.length > 0){ var lookupFillString = ''; var i = 0; var fillField = ''; var lookupField = ''; var space = ' '; _.each(control.modifyFields, function(item){ if(item.text.val == ''){ return true; } var fillControl = getControlById(item.text.val, root); if(fillControl == undefined){ return true; } var fillFieldPath = getControlXPath(root, "/data/", item.text.val); lookupField = item.value.val; if(control.type == 'inputFacingTable'){ lookupField = 'col1'; }else{ lookupField = item.value.val; } if(lookupField == undefined){ return true; } if(i != 0){ lookupFillString = lookupFillString + ', '; } lookupFillString = lookupFillString + fillFieldPath + " = " + lookupField; i++; }); var itemPath = getControlXPath(root, "/data/", control.id); var binding = getBindingObject(json, itemPath); if(binding != null){ binding.attrs.modifyFieldlist = lookupFillString; } } if(control.isRetrieve && control.modifyFieldsAction != undefined){ if(binding != null){ binding.attrs.modifyFieldsAction = control.modifyFieldsAction || ''; } } if(control.isRetrieve && binding != null){ if(control.doNotModifyOnDispacth != undefined) { binding.attrs.doNotModifyOnDispacth = control.doNotModifyOnDispacth || false; } if(control.doNotModifyOnForward != undefined) { binding.attrs.doNotModifyOnForward = control.doNotModifyOnForward || false; } } }); return bRet; }; /* * Function for add lookup data */ var addLookupFieldData = function(root, controls, json) { var bRet = true; _.each(controls, function(control) { if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addLookupFieldData(root, control.children, json); } if(control.lookupMultiFields != undefined && control.lookupMultiFields.length > 0){ var lookupFillString = ''; var i = 0; var fillField = ''; var lookupField = ''; var space = ' '; _.each(control.lookupMultiFields, function(item){ if(item.text.val == ''){ return true; } var fillControl = getControlById(item.text.val, root); if(fillControl == undefined){ return true; } var fillFieldPath = getControlXPath(root, "/data/", item.text.val); lookupField = item.value.val; if(lookupField == undefined){ return true; } if(i != 0){ lookupFillString = lookupFillString + ', '; } lookupFillString = lookupFillString + fillFieldPath + " = " + lookupField; i++; }); var itemPath = getControlXPath(root, "/data/", control.id); var binding = getBindingObject(json, itemPath); if(binding != null){ binding.attrs.lookupfieldlist = lookupFillString; } } }); return bRet; }; /* * Function for add lookup condition data */ var addLookupConditionFieldData = function(root, controls, json) { var bRet = true; _.each(controls, function(control) { if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addLookupConditionFieldData(root, control.children, json); } if (control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ if(control.isRetrieve){ control.lookupfield = control.lookupfield4R; if(control.lookupConditionFields4R != undefined){ control.lookupConditionFields = control.lookupConditionFields4R.slice(); }else{ control.lookupConditionFields = undefined; } } } if(control.lookupConditionFields != undefined && control.lookupConditionFields.length > 0){ var lookupFillString = ''; var lookupFillAnswerString = ''; var i = 0; var fillField = ''; var lookupField = ''; var space = ' '; _.each(control.lookupConditionFields, function(item){ var condAnswerTypeVal = 'other'; // Default Answer Type if(item.condAnswerType) { if(item.condAnswerType.val.toLowerCase() == 'other' && (!item.condOperator || (item.condOperator.val != 'is_empty' && item.condOperator.val != 'not_is_empty'))) { if(item.text.val == ''){ return true; } var fillControl = getControlById(item.text.val, root); if(fillControl == undefined || fillControl == null){ return true; } } else { condAnswerTypeVal = ''; } } var fillFieldPath = getControlXPath(root, "/data/", item.text.val); if(i != 0){ lookupFillString = lookupFillString + ', '; lookupFillAnswerString = lookupFillAnswerString + ', '; } var condType = "''"; // 'And' 'Or' if(i != 0 || control.isRetrieve){ condType = "'and'"; // Default is 'and' if(item.condType && item.condType.val) { condType = "'" + item.condType.val + "'"; } } var condAnswerType = "''"; if(item.condAnswerType && item.condAnswerType.val) { condAnswerType = "'" + item.condAnswerType.val + "'"; } var otherAnswerLUField = "''"; if(item.otherAnswerLUField && item.otherAnswerLUField.val) { otherAnswerLUField = "'" + convertConstantStr(item.otherAnswerLUField.val) + "'"; } var condCompareType = "'string'"; // Default if it have not selected if(item.condCompareType && item.condCompareType.val) { condCompareType = "'" + item.condCompareType.val + "'"; } lookupFillString = lookupFillString + fillFieldPath; if(condAnswerTypeVal == 'other') { lookupFillAnswerString = lookupFillAnswerString + "cond('" + item.text.valCond + "'," + fillFieldPath; } else { lookupFillAnswerString = lookupFillAnswerString + "cond('" + item.text.valCond + "'," + otherAnswerLUField; } if(item.text.usingUnderlyValue != undefined){ if(item.text.usingUnderlyValue == true){ lookupFillAnswerString = lookupFillAnswerString + ",'" + CONST_VALUE_TRUE_STR + "'"; }else{ lookupFillAnswerString = lookupFillAnswerString + ",'" + CONST_VALUE_FALSE_STR + "'"; } } var condOperatorVal = "'='"; if(item.condOperator && item.condOperator.val) { switch(item.condOperator.val) { case('equal'): condOperatorVal = "'='"; break; case('not_equal'): condOperatorVal = "'!='"; break; case('less_than'): condOperatorVal = "'<'"; break; case('less_than_or_equal'): condOperatorVal = "'<='"; break; case('greater_than'): condOperatorVal = "'>'"; break; case('greater_than_or_equal'): condOperatorVal = "'>='"; break; case('is_empty'): condOperatorVal = "'isEmpty'"; break; case('not_is_empty'): condOperatorVal = "'isNotEmpty'"; break; case CONST_COND_CONTAINS: if(isVersion(VERSION_NEW_ITE_CONDITION)){ condOperatorVal = "'contains'"; } break; case CONST_COND_START_WITH: if(isVersion(VERSION_NEW_ITE_CONDITION)){ condOperatorVal = "'startsWith'"; } break; case CONST_COND_LENGTH_IS: if(isVersion(VERSION_NEW_ITE_CONDITION)){ condOperatorVal = "'string-length'"; } break; } } lookupFillAnswerString = lookupFillAnswerString + "," + condOperatorVal + "," + condCompareType + "," + condType + ")"; i++; }); // CO-1868 Old generation for lookup condition var lookupFillStringOld = ''; var lookupFillAnswerStringOld = ''; var j = 0; // var fillFieldOld = ''; _.each(control.lookupConditionFields, function(item){ if(item.text.val == ''){ return true; } /* var fillFieldOld = getControlById(item.text.val, root); if(fillFieldOld == undefined){ return true; } */ var fillFieldPathOld = getControlXPath(root, "/data/", item.text.val); if(j != 0){ lookupFillStringOld = lookupFillStringOld + ', '; lookupFillAnswerStringOld = lookupFillAnswerStringOld + ', '; } lookupFillStringOld = lookupFillStringOld + fillFieldPathOld; lookupFillAnswerStringOld = lookupFillAnswerStringOld + "cond('" + item.text.valCond + "'," + fillFieldPathOld; if(item.text.usingUnderlyValue != undefined){ if(item.text.usingUnderlyValue == true){ lookupFillAnswerStringOld = lookupFillAnswerStringOld + ",'" + CONST_VALUE_TRUE_STR + "'"; }else{ lookupFillAnswerStringOld = lookupFillAnswerStringOld + ",'" + CONST_VALUE_FALSE_STR + "'"; } } lookupFillAnswerStringOld = lookupFillAnswerStringOld + ")"; j++; }); // CO-1868 Old generation for lookup condition var itemPath = getControlXPath(root, "/data/", control.id); var binding = getBindingObject(json, itemPath); if(binding != null){ //binding.attrs.lookupconditionfieldlist = lookupFillString; if(binding.attrs.lookupfield == undefined){ binding.attrs.lookupfield = ", " + lookupFillString; }else{ binding.attrs.lookupfield = binding.attrs.lookupfield + ", " + lookupFillString; } if(isVersion2_12()){ //joincond(cond('col3',/data/n3),cond('col4',/data/str1),cond('col4',/data/chooseOne1,CONST_VALUE_FALSE_STR),cond('col5',/data/untitled9,CONST_VALUE_TRUE_STR)) binding.attrs.lookupCond2 = 'joincond(' + lookupFillAnswerString + ')'; // CO-1868 New generation for lookup condition binding.attrs.lookupCond = 'joincond(' + lookupFillAnswerStringOld + ')'; // CO-1868 Old generation for } } } }); return bRet; }; // START CO-2619 - Convert constant of lookupCond2 before prase to XML var convertConstantStr = function(constantVal) { return constantVal.replace(/&/gi, '&').replace(//gi, '>').replace(/'/gi, '''').replace(/"/gi, '"'); } // END CO-2619 - Convert constant of lookupCond2 before prase to XML /* * Function for add caltulation data */ var addCalculationData = function(root, controls, json) { var bRet = true; var isTheSameGroup = function(itemPath, itemPath2){ if(!itemPath || !itemPath2){ return false; } var path1 = itemPath.substring(0, itemPath.lastIndexOf('/')); var path2 = itemPath2.substring(0, itemPath2.lastIndexOf('/')); if(path1 == path2){ return true; }else{ return false; } } var calculation = function(expressions, ctrlKind, itemPath, controls) { var expressionString = ''; var hasScheduleFunction = false; if(ctrlKind == 'String'){ expressionString = 'string-concat('; } var i = 0; var operator = ''; var operation = ''; var operation1 = ''; _.each(expressions, function(item){ if(item.group != undefined && item.group.length > 0){ operator = item.text.operator; if(operator == undefined){ operator = ''; } var groupExpressionString = calculation(item.group, ctrlKind, itemPath, controls); if(groupExpressionString != undefined && groupExpressionString != ''){ expressionString = expressionString + ' ' + operator + ' (' + groupExpressionString + ')'; } i++; }else{ operator = item.text.operator; var isPreviousCal = false; if(operator && operator.myIncludes(CONST_PREVIOUS)){ isPreviousCal = true; operator = operator.replace(CONST_PREVIOUS, ''); } operation1 = item.text.operation; var dontCheckExp2ForDate = false; if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation1; if(item.text.hasExp2 == false){ dontCheckExp2ForDate = true; } }else{ operation = item.text.operation; } var otherValue = false; var otherSumValue = false; var otherCountValue = false; var otherDFMValue = false; var otherDNValue = false; var otherWNValue = false; var otherMNValue = false; var otherYNValue = false; var otherWNOValue = false; var otherMNOValue = false; var otherYNOValue = false; if(operation == undefined || operation == 'Other value'){ if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation_other_val1; }else if(ctrlKind == 'String'){ operation = "'" + item.text.operation_other_val + "'"; operation = operation.replace(/&/gi, '&').replace(//gi, '>'); }else{ operation = item.text.operation_other_val; } otherValue = true; }else if(operation != undefined && operation == 'Other sum'){ if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation_other_sum1; }else{ operation = item.text.operation_other_sum; } otherSumValue = true; }else if(operation != undefined && operation == 'Other count'){ if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation_other_count1; }else{ operation = item.text.operation_other_count; } otherCountValue = true; }else if(operation != undefined && operation == CONST_OTHER_DAY_OF_MONTH){ operation = item.text.operation_other_part_of_date; otherDFMValue = true; }else if(operation != undefined && operation == CONST_OTHER_WEEK_NUMBER){ operation = item.text.operation_other_part_of_date; otherWNOValue = true; }else if(operation != undefined && operation == CONST_OTHER_MONTH_NUMBER){ operation = item.text.operation_other_part_of_date; otherMNOValue = true; }else if(operation != undefined && operation == CONST_OTHER_YEAR_NUMBER){ operation = item.text.operation_other_part_of_date; otherYNOValue = true; }else if(operation != undefined && operation == CONST_OTHER_DAY_NAME){ operation = item.text.operation_other_part_of_date_str; otherDNValue = true; }else if(operation != undefined && operation == CONST_OTHER_WEEK_NAME){ operation = item.text.operation_other_part_of_date_str; otherWNValue = true; }else if(operation != undefined && operation == CONST_OTHER_MONTH_NAME){ operation = item.text.operation_other_part_of_date_str; otherMNValue = true; }else if(operation != undefined && operation == CONST_OTHER_YEAR_NAME){ operation = item.text.operation_other_part_of_date_str; otherYNValue = true; } if(!dontCheckExp2ForDate && (operation == undefined || operation == '')){ return true; } if(ctrlKind == CONST_VALUE_DATE){ var operationControl1 = getControlById(operation1, root); if(operationControl1 == undefined){ if(isVersion(VERSION_START_DURATION_OPTION)){ switch(operation1){ case CONST_DURATION_HOURS: case CONST_DURATION_MINUTES: case CONST_DURATION_TOTAL_HOURS: case CONST_DURATION_TOTAL_MINUTES: case CONST_SCHEDULER_START_DATE: case CONST_SCHEDULER_START_TIME: case CONST_SCHEDULER_START_DATE_TIME: hasScheduleFunction = true; expressionString = expressionString + operation1; if(!dontCheckExp2ForDate){ expressionString = expressionString + ' ' + operator + ' '; } break; case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: expressionString = expressionString + operation1; if(!dontCheckExp2ForDate){ expressionString = expressionString + ' ' + operator + ' '; } break; case 'Other sum': expressionString = expressionString + "sum('" + item.text.operation_other_sum.replace('__', "','") + "')"; if(!dontCheckExp2ForDate){ expressionString = expressionString + ' ' + operator + ' '; } break; default: if(operation1.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ expressionString = expressionString + operation1; if(!dontCheckExp2ForDate){ expressionString = expressionString + ' ' + operator + ' '; } break; } return true; } }else{ return true; } }else{ var operationPath1 = getControlXPath(root, "/data/", operation1); expressionString = expressionString + operationPath1; if(!dontCheckExp2ForDate){ expressionString = expressionString + ' ' + operator + ' '; } } } else if(ctrlKind == 'String'){ operator = ','; } if(!otherValue && !dontCheckExp2ForDate){ var operationControl = getControlById(operation, root); if(operationControl == undefined){ if(operation == 'Space'){ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += "' '"; i++; }else if(operation == 'NickName()'){ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += "NickName()"; i++; }else if(operation == 'MobileID()'){ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += "MobileID()"; i++; } // CO-2522 Add device ID for calculation else if(operation == 'DeviceID()'){ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += "DeviceID()"; i++; }else if(operation == 'MobileEmail()'){ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += "MobileEmail()"; i++; }else if(operation == 'WebUserEmail()'){ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += "WebUserEmail()"; i++; } // END CO-2252 else if(operation.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ if(isVersion(VERSION_USE_VARIABLE_BF)){ // CO-560 Use variables by text calcs, numeric calc, relevance, and IF THEN ELSE in Build forms if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += operation; i++; } }else if(operation.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ if(otherSumValue){ expressionString = expressionString + "sum('" + operation.replace('__', "','") + "')"; }else if(otherCountValue){ expressionString = expressionString + "count('" + operation.replace('__', "','") + "')"; } i++; }else{ if(isVersion(VERSION_START_DURATION_OPTION)){ switch(operation){ case CONST_DURATION_HOURS: case CONST_DURATION_MINUTES: case CONST_DURATION_TOTAL_HOURS: case CONST_DURATION_TOTAL_MINUTES: case CONST_SCHEDULER_START_DATE: case CONST_SCHEDULER_START_TIME: case CONST_SCHEDULER_START_DATE_TIME: hasScheduleFunction = true; if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += operation; i++; break; case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += operation; i++; break; case 'Other sum': expressionString = expressionString + "sum('" + item.text.operation_other_sum1.replace('__', "','") + "')"; if(!dontCheckExp2ForDate){ expressionString = expressionString + ' ' + operator + ' '; } break; default: if(operation.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString += operation; i++; } } } } return true; } var operationPath = getControlXPath(root, "/data/", operation); if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } if(otherSumValue){ expressionString = expressionString + 'sum(' + operationPath + ')'; }else if(otherCountValue){ if(controls && controls[0] && controls[0].type == CONST_CTRL_TYPE_INPUTLOOKUP){ if(controls[0].datasource != undefined){ expressionString = expressionString + "count('" + operationPath + "','" + controls[0].datasource + "')"; }else{ expressionString = expressionString + 'count(' + operationPath + ')'; } }else{ expressionString = expressionString + 'count(' + operationPath + ')'; } }else if(otherDFMValue){ expressionString = expressionString + 'dayofmonth(' + operationPath + ')'; }else if(otherDNValue){ expressionString = expressionString + 'dayofweek(' + operationPath + ')'; }else if(otherWNValue){ expressionString = expressionString + 'weekname(' + operationPath + ')'; }else if(otherWNOValue){ expressionString = expressionString + 'weeknumber(' + operationPath + ')'; }else if(otherMNValue){ expressionString = expressionString + 'monthname(' + operationPath + ')'; }else if(otherMNOValue){ expressionString = expressionString + 'monthnumber(' + operationPath + ')'; }else if(otherYNOValue){ expressionString = expressionString + 'yearnumber(' + operationPath + ')'; }else if(otherYNValue){ expressionString = expressionString + 'yearname(' + operationPath + ')'; }else if(isPreviousCal){ if(isTheSameGroup(itemPath, operationPath)){ if(itemPath !== operationPath){ expressionString = expressionString + 'previous(' + operationPath + ')'; }else{ expressionString = expressionString + "previous('" + operationPath + "')"; } }else{ expressionString = expressionString + operationPath; } }else{ expressionString = expressionString + operationPath; } }else{ if(ctrlKind != CONST_VALUE_DATE){ if(i != 0){ if(operator == undefined || operator == ''){ return true; } expressionString = expressionString + ' ' + operator + ' '; }else{ if(operator != undefined && operator == '-'){ expressionString = expressionString + ' ' + operator + ' '; } } } expressionString = expressionString + operation; } } i++; }); if(ctrlKind == 'String'){ expressionString += ')'; } if(hasScheduleFunction){ expressionString = "if(" + CONST_XML_FUNCTION_TRUE + "," + expressionString + ")"; } return expressionString; }; _.each(controls, function(control) { if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addCalculationData(root, control.children, json); } if(control.expression != undefined && control.expression.length > 0){ var itemPath = getControlXPath(root, "/data/", control.id); var expressionString = calculation(control.expression, control.kind, itemPath, controls); var binding = getBindingObject(json, itemPath); var calcType = 1; if(control.kind == CONST_VALUE_DATE){ calcType = 2; } else if(control.kind == 'String'){ calcType = 3; } if(binding != null){ binding.attrs.calculate = expressionString; binding.attrs.calcType = calcType; } } }); return bRet; }; /* * Function for add ParseDestinationFiled data */ var addParseDestinationFiledData = function(root, controls, json) { var bRet = true; _.each(controls, function(control) { if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ addParseDestinationFiledData(root, control.children, json); } if(control.parse && control.parseDestinationFields != undefined && control.parseDestinationFields.length > 0){ var parseDestinationFieldString = ''; var i = 0; var fillField = ''; var lookupField = ''; var space = ' '; _.each(control.parseDestinationFields, function(item){ if(item.text.val == ''){ return true; } var parseDestinationFieldControl = getControlById(item.text.val, root); if(parseDestinationFieldControl == undefined){ return true; } var parseDestinationFieldPath = getControlXPath(root, "/data/", item.text.val); if(i != 0){ parseDestinationFieldString = parseDestinationFieldString + ', '; } parseDestinationFieldString = parseDestinationFieldString + parseDestinationFieldPath; i++; }); var itemPath = getControlXPath(root, "/data/", control.id); var binding = getBindingObject(json, itemPath); if(binding != null){ binding.attrs.parseDestinationFields = parseDestinationFieldString; } } }); return bRet; }; /* * error = 0 : success * error = 1 : control name duplicate. */ var checkDuplicateControlsName = function(controls, objName) { var retObj = {}; var errorCode = 0; retObj.error = 0; retObj.message = ''; _.each(controls, function(control) { if(control.name && control.name.startsWith('AE__')){ return true; } if(objName[control.name.toLowerCase()] == undefined){ objName[control.name.toLowerCase()] = control.name; }else{ retObj.error = 1; retObj.message = err_more_than_one_ques_name.replace('$1', control.name.toLowerCase()); retObj.ctrlName = control.name; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ retObj = checkDuplicateControlsName(control.children, objName); if(retObj.error != 0){ errorCode = 1; } } }); if(errorCode != 0){ retObj.error = 1; } return retObj; }; /* * error = 0 : success * error = 1 : syntax error (using start, end, today, deviceid, subscriberid, simid, phonenumber, recordid, mobilekey for control name). */ var checkSyntaxForControlsName = function(controls) { var retObj = {}; var errorCode = 0; retObj.error = 0; retObj.message = ''; _.each(controls, function(control) { if(keyWord[control.name.toLowerCase()] != undefined){ retObj.error = 1; errorCode = 1; retObj.message = err_data_name_syntax.replace('$1', control.name); retObj.ctrlName = control.name; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); //return (retObj.error == 0); } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ retObj = checkSyntaxForControlsName(control.children); if(retObj.error != 0){ errorCode = 1; } //return (retObj.error == 0); } }); if(errorCode != 0){ retObj.error = 1; } return retObj; }; var checkSyntaxForCategory = function(controls) { var retObj = {}; var errorCode = 0; retObj.error = 0; retObj.message = ''; var keyWord = []; keyWord['total'] = true; _.each(controls, function(control) { if(control.type == CONST_CTRL_TYPE_INPUTSCOREONE && keyWord[control.scoreCategory.toLowerCase()] != undefined){ retObj.error = 1; errorCode = 1; retObj.message = err_category_syntax.replace('$1', control.scoreCategory); retObj.ctrlName = control.name; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); //return (retObj.error == 0); } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ retObj = checkSyntaxForCategory(control.children); if(retObj.error != 0){ errorCode = 1; } //return (retObj.error == 0); } }); if(errorCode != 0){ retObj.error = 1; } return retObj; }; var clearErrorMessage = function(controls){ $('.workspaceScrollArea:visible .justJump').removeClass('justJump'); $('.workspaceScrollArea:visible .nextJump').removeClass('nextJump'); _.each(controls, function(control) { $('.controlErrorMessage.ctrlId_' + control.id).removeClass('show').find('ul').empty(); if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ clearErrorMessage(control.children); } }); } var checkControlsData = function(controls, controlParrent, lookupDatasourceArray, optionMap, controlsOrg, useChecklistObjMap) { var retObj = {}; var errorCode = 0; retObj.error = 0; retObj.message = ''; jQuery.each(controls, function() { if(this.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ if(isVersion(VERSION_SUMMARY_FOR_CATEGORY)){ if(!fvDataNS.scoreSummary){ fvDataNS.scoreSummary = {}; } var summaryCategory = valueOrEmpty(this.summaryCategory); if(summaryCategory == ''){ summaryCategory = '_ _'; } if(!fvDataNS.scoreSummary[summaryCategory]){ fvDataNS.scoreSummary[summaryCategory] = this; }else{ if(!fvDataNS.scoreSummaryErr){ fvDataNS.scoreSummaryErr = {}; } fvDataNS.scoreSummaryErr[this.id] = this; } }else{ if(!fvDataNS.scoreSummary){ fvDataNS.scoreSummary = this; }else{ fvDataNS.scoreSummaryErr = true; } } }else{ if(this.type == CONST_CTRL_TYPE_INPUTSCOREONE){ fvDataNS.hasScoreQues = true; if(isVersion(VERSION_SUMMARY_FOR_CATEGORY)){ if(fvDataNS.scoreSummary && fvDataNS.scoreSummary['_ _']){ if(!fvDataNS.scoreSummaryErr){ fvDataNS.scoreSummaryErr = []; } fvDataNS.scoreSummaryErr[fvDataNS.scoreSummary['_ _'].id] = fvDataNS.scoreSummary['_ _']; }else{ var scoreCategory = this.scoreCategory; if(fvDataNS.scoreSummary && fvDataNS.scoreSummary[scoreCategory]){ if(!fvDataNS.scoreSummaryErr){ fvDataNS.scoreSummaryErr = []; } fvDataNS.scoreSummaryErr[fvDataNS.scoreSummary[scoreCategory].id] = fvDataNS.scoreSummary[scoreCategory]; } } }else{ if(fvDataNS.scoreSummary){ fvDataNS.scoreSummaryErr = true; } } } } retObj = checkControlData(this, lookupDatasourceArray, optionMap, controls, controlParrent, controlsOrg, useChecklistObjMap); if(this.datasource !== undefined && jQuery.trim(this.datasource) !== ''){ lookupDatasourceArray[this.id] = this.datasource; if(controlParrent != undefined && useChecklistObjMap[controlParrent.name] == undefined){ useChecklistObjMap[controlParrent.name] = this.datasource; } } if(retObj.error != 0){ errorCode = 1; } }); if(isVersion(VERSION_SUMMARY_FOR_CATEGORY)){ if(fvDataNS.scoreSummaryErr){ _.each(fvDataNS.scoreSummaryErr, function(element, key) { if(element != null){ $('.controlErrorMessage.ctrlId_' + element.id).addClass('show').find('ul').append( '
  • ' + lbl_score_summary_pos_err + '
  • '); } }); errorCode = 1; }else if(fvDataNS.scoreSummary && !fvDataNS.hasScoreQues){ _.each(fvDataNS.scoreSummary, function(element, key) { if(element != null){ $('.controlErrorMessage.ctrlId_' + element.id).addClass('show').find('ul').append( '
  • ' + msg_warning_no_score_ques + '
  • '); } }); errorCode = 1; } }else{ if(fvDataNS.scoreSummary && fvDataNS.scoreSummaryErr && !$('.controlErrorMessage.ctrlId_' + fvDataNS.scoreSummary.id).hasClass('show')){ if(!fvDataNS.isShowScoreSummaryErr){ fvDataNS.isShowScoreSummaryErr = true; $('.controlErrorMessage.ctrlId_' + fvDataNS.scoreSummary.id).addClass('show').find('ul').append( '
  • ' + lbl_score_summary_pos_err + '
  • '); } errorCode = 1; }else if(fvDataNS.scoreSummary && !fvDataNS.hasScoreQues){ if(!fvDataNS.isShowScoreQues){ fvDataNS.isShowScoreQues = true; $('.controlErrorMessage.ctrlId_' + fvDataNS.scoreSummary.id).addClass('show').find('ul').append( '
  • ' + msg_warning_no_score_ques + '
  • '); } errorCode = 1; } } if(errorCode != 0){ retObj.error = errorCode; } return retObj; }; var checkReportControlsData = function(controls, controlParrent, optionMap, controlsOrg) { var retObj = {}; var errorCode = 0; retObj.error = 0; retObj.message = ''; jQuery.each(controls, function() { retObj = checkReportControlData(this, optionMap, controls, controlParrent, controlsOrg); if(retObj.error != 0){ errorCode = 1; } }); if(errorCode != 0){ retObj.error = errorCode; } return retObj; }; var validDate = function(dateString) { var JDate = new Date(dateString); //if(!dateString.match(/^\d\d?\/\d\d?\/\d\d?\d?\d?$/)){ if(isNaN(JDate) || JDate == 'Invalid Date'){ return false; } var dateElement = dateString.split("/"); if(dateElement.length != 3){ return false; }else{ if(dateElement[0].length < 1 || dateElement[0].length >2){ return false; }else if(dateElement[1].length < 1 || dateElement[1].length > 2){ return false; }else if(dateElement[2].length != 4){ return false; } } valid = (parseInt(dateElement[0], 10) - 1 == JDate.getMonth() && parseInt(dateElement[1], 10) == JDate.getDate() && parseInt(dateElement[2], 10) == JDate.getFullYear()) return valid }; var checkRequiredAndHideError = function(control, retObj) { if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLPOD){ return false; } if(control.defaultValue !== undefined && control.defaultValue !== ''){ return false; } var errorCode = 0; if(!isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION)){ if(control.required && control.hideInMobile){ retObj.error = 29; retObj.message = msg_bf_required_hide_mobile_or_web; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.dispatchRequired && control.hideInWeb){ retObj.error = 29; retObj.message = msg_bf_required_dsp_hide_web; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(errorCode == 1){ return true; } return false; } if(control.hideViewEdit && control.requiredViewEdit){ retObj.error = 29; retObj.message = msg_bf_required_hide_view_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.hideViewNew && control.requiredViewNew){ retObj.error = 29; retObj.message = msg_bf_required_hide_view_new; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.hideFillAndSend && control.requiredFillAndSend){ retObj.error = 29; retObj.message = msg_bf_required_hide_fill_send_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(isVersion(VERSION_FNS_EDIT)){ if(control.hideFillAndSendEdit && control.requiredFillAndSendEdit){ retObj.error = 29; retObj.message = msg_bf_required_hide_fill_send; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(control.hideDispatchToEmail && control.requiredDispatchToEmail){ retObj.error = 29; retObj.message = msg_bf_required_hide_dispatch_to_email; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.hideDispatchEdit && control.requiredDispatchEdit){ retObj.error = 29; retObj.message = msg_bf_required_hide_dispatch_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.hideDispatchNew && control.requiredDispatchNew){ retObj.error = 29; retObj.message = msg_bf_required_hide_dispatch_new; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.hideInMobile && control.required){ retObj.error = 29; retObj.message = msg_bf_required_hide_mobile; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.hideWebApp && control.requiredWebApp){ retObj.error = 29; retObj.message = msg_bf_required_hide_webapp; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.hideFormLinks && control.requiredFormLinks){ retObj.error = 29; retObj.message = msg_bf_required_hide_webapp; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(errorCode == 1){ return true; } return false; } var checkRequiredAndReadOnlyError = function(control, retObj) { if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLPOD){ return false; } if(control.defaultValue !== undefined && control.defaultValue !== ''){ return false; } var errorCode = 0; if(!isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION)){ if((control.readOnly && control.required) || (control.readOnlyDsp && control.dispatchRequired) ){ var isMobileError = false; if(control.readOnly && control.required){ isMobileError = true; } if (control.type == mdi_kind_inputImage){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_image_readonly_required; }else{ retObj.message = msg_bf_disp_image_readonly_required; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if (control.type == mdi_kind_inputAudio){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_audio_readonly_required; }else{ retObj.message = msg_bf_disp_audio_readonly_required; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if (control.type == mdi_kind_inputVideo){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_video_readonly_required; }else{ retObj.message = msg_bf_disp_video_readonly_required; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if (control.type == CONST_CTRL_TYPE_INPUTMEDIA){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_media_readonly_required; }else{ retObj.message = msg_bf_disp_media_readonly_required; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if (control.type == mdi_kind_inputSketch){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_sketch_readonly_required; }else{ retObj.message = msg_bf_disp_sketch_readonly_required; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if (control.type == mdi_kind_inputSignature){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_signature_readonly_required; }else{ retObj.message = msg_bf_disp_signature_readonly_required; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if (control.type == 'inputDraw'){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_draw_readonly_required; }else{ retObj.message = msg_bf_disp_draw_readonly_required; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(control.defaultValue == ''){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_def_val_required_readonly_default; }else{ retObj.message = msg_bf_def_val_disp_required_readonly_default; } if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ var value = control.defaultValue; var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ var email = jQuery.trim(value.substring(0, contentStartPos)); var mailcontent = jQuery.trim(value.substring(contentStartPos + 2)); if(email == ''){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_def_val_required_readonly_default; }else{ retObj.message = msg_bf_def_val_disp_required_readonly_default; } $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else{ var arrMails = email.split(","); var isEmpty = true; for (var k = 0; k < arrMails.length; k++) { email = jQuery.trim(arrMails[k]); if(email != ''){ isEmpty = false; } } if(isEmpty){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_def_val_required_readonly_default; }else{ retObj.message = msg_bf_def_val_disp_required_readonly_default; } $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } }else{ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_def_val_required_readonly_default; }else{ retObj.message = msg_bf_def_val_disp_required_readonly_default; } $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } }else{ if(control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && control.type !== CONST_CTRL_TYPE_INPUTNUMBERING && control.defaultValue == ''){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_def_val_required_readonly_default; }else{ retObj.message = msg_bf_def_val_disp_required_readonly_default; } $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING && control.autoNumberType == 'Received'){ retObj.error = 10; if(isMobileError){ retObj.message = msg_bf_def_val_required_readonly_aut; }else{ retObj.message = msg_bf_def_val_disp_required_readonly_aut; } $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } if(errorCode == 1){ return true; } return false; } switch(control.type){ case CONST_CTRL_TYPE_INPUTNUMBERING: if(control.autoNumberType != 'Received'){ return false; } break; case CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT: case CONST_CTRL_TYPE_INPUTEMAILREPORT: case CONST_CTRL_TYPE_INPUTFAX: if(control.defaultValue == ''){ break; } var value = control.defaultValue; var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ var email = jQuery.trim(value.substring(0, contentStartPos)); var mailcontent = jQuery.trim(value.substring(contentStartPos + 2)); if(email == ''){ break; }else{ var arrMails = email.split(","); var isEmpty = true; for (var k = 0; k < arrMails.length; k++) { email = jQuery.trim(arrMails[k]); if(email != ''){ isEmpty = false; } } if(isEmpty){ break; }else{ return false; } } } break; default: if(control.defaultValue == undefined || control.defaultValue == ''){ break; }else{ return false; } } if(control.readOnlyViewEdit && control.requiredViewEdit){ retObj.error = 29; retObj.message = msg_bf_required_readonly_view_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.readOnlyViewNew && control.requiredViewNew){ retObj.error = 29; retObj.message = msg_bf_required_readonly_view_new; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.readOnlyFillAndSend && control.requiredFillAndSend){ retObj.error = 29; retObj.message = msg_bf_required_readonly_fill_send; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(isVersion(VERSION_FNS_EDIT)){ if(control.readOnlyFillAndSendEdit && control.requiredFillAndSendEdit){ retObj.error = 29; retObj.message = msg_bf_required_readonly_fill_send_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(control.readOnlyDispatchToEmail && control.requiredDispatchToEmail){ retObj.error = 29; retObj.message = msg_bf_required_readonly_dispatch_to_email; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.readOnlyDispatchEdit && control.requiredDispatchEdit){ retObj.error = 29; retObj.message = msg_bf_required_readonly_dispatch_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.readOnlyDispatchNew && control.requiredDispatchNew){ retObj.error = 29; retObj.message = msg_bf_required_readonly_dispatch_new; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.readOnly && control.required){ retObj.error = 29; retObj.message = msg_bf_required_readonly_mobile; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.readOnlyWebApp && control.requiredWebApp){ retObj.error = 29; retObj.message = msg_bf_required_readonly_webapp; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.readOnlyFormLinks && control.requiredFormLinks){ retObj.error = 29; retObj.message = msg_bf_required_readonly_form_links; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(errorCode == 1){ return true; } return false; } var checkRetrictsLimitToListError = function(control, retObj) { var errorCode = 0; if(!isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION)){ return false; }else{ if (control.limitToList === true){ if(control.restViewEdit === true && control.requiredViewEdit === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_view_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.restViewNew === true && control.requiredViewNew === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_view_new; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.restViewFillAndSend === true && control.requiredFillAndSend === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_fill_send; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(isVersion(VERSION_FNS_EDIT)){ if(control.restViewFillAndSendEdit === true && control.requiredFillAndSendEdit === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_fill_send_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(control.restDispatchToEmail === true && control.requiredDispatchToEmail === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_dispatch_to_email; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.restFormLinks === true && control.requiredFormLinks === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_form_links; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.restDispatchEdit === true && control.requiredDispatchEdit === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_dispatch_edit; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.restDispatchNew === true && control.requiredDispatchNew === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_dispatch_new; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.restMobile === true && control.required === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_mobile; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.restWebapp === true && control.requiredWebApp === true){ retObj.error = 29; retObj.message = msg_bf_ltl_restrict_webapp; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } var requiredError = false; var maxltMinError = false; if (!(control.type == CONST_CTRL_TYPE_INPUTLOOKUP && control.isRetrieve && control.parentCtrlType != CONST_CTRL_TYPE_CTRLTABLE) && control.type != CONST_CTRL_TYPE_CTRLSCORETABLE && control.type != 'inputPageBreak' && control.type != CONST_CTRL_TYPE_INPUTGEOFENCE && control.type != CONST_CTRL_TYPE_INPUT_SHIPPING && control.type != CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && (control.label['eng'] == undefined || trim(control.label['eng']) == '')){ if(!(control.type == CONST_CTRL_TYPE_INPUTLOCATION && isAdvanceLocation) && control.type != CONST_CTRL_TYPE_CTRLGRID && control.type != 'inputPageBreak' && control.type !== CONST_CTRL_TYPE_CTRLPOD && control.type != 'inputLabel' && control.type != CONST_CTRL_TYPE_INPUTSCORESUMMARY && (control.type != CONST_CTRL_TYPE_INPUTACTION || control.isAttachFormWidget === true) && control.type != CONST_CTRL_TYPE_INPUTPAYMENT && (controlParrent == undefined || controlParrent.type != CONST_CTRL_TYPE_CTRLGRID || (isVersion(VERSION_GRID_TYPE_FUNCTION) && (controlParrent.gridType == '1' || controlParrent.gridType == '2'))) && !(isVersion(VERSION_TABLE_LBL_NOT_REQUIRED) && (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE))){ retObj.error = 13; if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV){/* || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){*/ retObj.message = msg_bf_sec_lbl_required; }else if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ if(isVersion(VERSION_PAYMENT_TYPE) && (control.paymentType == CONST_PAYMENT_TYPE_AUTOMATED || control.paymentType == CONST_PAYMENT_TYPE_SQUARE || control.paymentType == CONST_PAYMENT_MIPOS)){ retObj.error = 0; }else{ retObj.message = msg_bf_lbl_required; } }else if(control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTPAYMENT || control.type == 'inputInstruction' || control.type == 'inputSaveAndSend'){ retObj.message = msg_bf_lbl_required; }else if(control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ retObj.message = msg_bf_lbl_required; }else if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ retObj.message = msg_bf_lbl_required; }else if(control.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ retObj.message = msg_bf_lbl_required; }else{ retObj.message = msg_bf_cap_txt_required; } if(retObj.error != 0 && !requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } //return retObj; } } if (control.name == undefined || control.name == ''){ retObj.error = 99; retObj.message = msg_bf_ctrl_name_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } //return retObj; }else{ if(!isNaN(parseInt(control.name, 10))){ retObj.error = 11; retObj.message = msg_bf_ctrl_name_not_valid; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } if(controlParrent && controlParrent.type == CONST_CTRL_TYPE_CTRLGRID && isVersion(VERSION_GRID_TYPE_FUNCTION) && (controlParrent.gridType == '1' || controlParrent.gridType == '2')){ if(control.type == 'inputLabel'){ retObj.error = 29; retObj.message = msg_bf_grid_not_accept_label; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(checkRequiredAndHideError(control, retObj)){ errorCode = 1; } /* fix change request 0026497: Could not select 'Required when dispatching' and 'Hide in mobile app' if(control.dispatchRequired && control.hideInMobile){ retObj.error = 29; retObj.message = msg_bf_required_dsp_hide_mobile; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }*/ if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID || control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY ){ if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ if(isNaN(control.loop)){ if(!isValidExtentionLoop(control.loop)){ retObj.error = 16; retObj.message = msg_bf_rep_count_not_valid.replace('$1', INTEGER_MIN_GROUP_REPEAT).replace('$2', INTEGER_MAX_GROUP_REPEAT); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } }else{ if(!odkmaker.data.currentFormHasExpCode && control.loop !== undefined && (parseInt(control.loop, 10) < 1 || parseInt(control.loop, 10) > INTEGER_MAX_GROUP_REPEAT)){ retObj.error = 16; retObj.message = msg_bf_rep_count_not_valid.replace('$1', INTEGER_MIN_GROUP_REPEAT).replace('$2', INTEGER_MAX_GROUP_REPEAT); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.type == CONST_CTRL_TYPE_CTRLPOD){ /*if(control.datasource == undefined || jQuery.trim(control.datasource) == ''){ retObj.error = 20; retObj.message = msg_bf_data_src_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }*/ /*var ctrlArr = []; var duplicateError = false; _.each(control.destinationdataconds, function(item){ if(item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_skip_cond_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_lookup_destination_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else if (!checkControlInPOD(controlsOrg, control.id, item.text.val)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ if(!lookupdatainf.hasTableColumnHeader(control.datasource, item.value.val)){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } });*/ } if(control.type == CONST_CTRL_TYPE_CTRLPOD){ control.loop = 0; }else if(control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ control.loop = 0; if(valueOrEmpty(control.repeatable) == CONST_EMPTY){ retObj.error = 97; retObj.message = msg_bf_repeatable_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(control.columns && control.columns.length>0){ var repeatableFieldPath = getControlXPath(controlsOrg, "/data/", control.repeatable); repeatableFieldPath += '/'; _.each(control.columns, function(column){ if(valueOrEmpty(column.text.val) == CONST_EMPTY){ retObj.error = 97; retObj.message = msg_bf_column_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } return false; } var columnControl = getControlById(column.text.val, controlsOrg); if(columnControl == undefined){ retObj.error = 97; retObj.message = msg_bf_column_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } return false; }else{ var columnFieldPath = getControlXPath(controlsOrg, "/data/", column.text.val); if(!columnFieldPath.startsWith(repeatableFieldPath)){ retObj.error = 97; retObj.message = msg_bf_column_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } return false; } } }); }else{ //columns is empty retObj.error = 97; retObj.message = msg_bf_columns_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } if(control.type !== CONST_CTRL_TYPE_CTRLSCORETABLE && control.type !== CONST_CTRL_TYPE_CTRLPOD && control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && isNaN(control.loop)){ if(!isValidExtentionLoop(control.loop)){ retObj.error = 16; retObj.message = msg_bf_rep_count_not_valid.replace('$1', INTEGER_MIN_GROUP_REPEAT).replace('$2', INTEGER_MAX_GROUP_REPEAT); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ // check answer options are all the same in score table var optionSizeError = false; var optionSize = -1; var optionValue; var optionKind; var switchOption; jQuery.each(control.children, function() { if(optionSizeError){ return false; } var curCtrlOptionSize = 0 if(this.options.length != undefined){ _.each(this.options, function(option, i){ if (option.isShowUnderlying !== undefined){ }else{ curCtrlOptionSize ++; } }); } if(optionSize == -1){ optionSize = curCtrlOptionSize; optionValue = this.options; optionKind = this.optionKind; switchOption = this.switchOption; }else{ if((optionKind || '') != (this.optionKind || '')){ optionSizeError = true; }else if(optionSize != curCtrlOptionSize){ optionSizeError = true; }else{ if(optionKind == CONST_CHOOSE_ONE_SWITCH){ if(switchOption != this.switchOption){ optionSizeError = true; return false; } } for(var i=0; i' + retObj.message + ''); errorCode = 1; } control.loop = 1; }else if(control.type == CONST_CTRL_TYPE_CTRLGRID){ //control.loop = 1; } // ctrlTable if (control.type !== CONST_CTRL_TYPE_CTRLPOD && control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && (control.loop == undefined || control.loop == '') && control.isMessageWidget !== true){ retObj.error = 99; retObj.message = msg_bf_ctrl_name_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } //return retObj; }else{ if(control.type == CONST_CTRL_TYPE_CTRLGRID){ if(control.loop !== undefined && (parseInt(control.loop, 10) < INTEGER_MIN_TABLE_ROW || parseInt(control.loop, 10) > INTEGER_MAX_TABLE_ROW)){ retObj.error = 16; retObj.message = msg_bf_grid_col_count_not_valid.replace('$1', INTEGER_MIN_TABLE_ROW).replace('$2', INTEGER_MAX_TABLE_ROW); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else{ // Fwd: Column Weight Issue (07-Nov-2016) // Special treating with value such as &&&21 var intLoopVal = control.loop; if ( (intLoopVal + '').indexOf('&&&') === 0 ) { try { intLoopVal = parseInt( (intLoopVal + '').replace('&&&', '') ); } catch (e) {} } if(control.gridType == '2' && (intLoopVal % 2) != 0){ retObj.error = 16; retObj.message = msg_bf_grid_col_count_not_valid_2; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } }else if(control.type != CONST_CTRL_TYPE_CTRLPOD && control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && control.isMessageWidget !== true){ if(control.loop !== undefined && (parseInt(control.loop, 10) < INTEGER_MIN_TABLE_ROW || parseInt(control.loop, 10) > INTEGER_MAX_TABLE_ROW)){ retObj.error = 16; retObj.message = msg_bf_rep_table_row_count_not_valid.replace('$1', INTEGER_MIN_TABLE_ROW).replace('$2', INTEGER_MAX_TABLE_ROW); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } if(control.type == CONST_CTRL_TYPE_CTRLTABLE){ if(!requiredError && isVersion(VERSION_CHECKLIST_CONDITION) && control.usechecklist === true){ if(control.checklistconds && control.checklistconds.length>0){ _.each(control.checklistconds, function(checklistCond){ if(valueOrEmpty(checklistCond.text.checklistField) == CONST_EMPTY){ retObj.error = 97; retObj.message = msg_bf_checklist_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; return false; } var checklistControl = getControlById(checklistCond.text.checklistField, controlsOrg); if(checklistControl == undefined){ retObj.error = 97; retObj.message = msg_bf_checklist_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; return false; } if(checklistCond.value != undefined && checklistCond.value.cmpType == CONST_VALUE_OTHER){ if(!checklistCond.value.val || valueOrEmpty(checklistCond.value.val) == CONST_EMPTY){ retObj.error = 97; retObj.message = msg_bf_checklist_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; return false; } if(!checklistCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ var checklistCmpControl = getControlById(checklistCond.value.val, controlsOrg); if(checklistCmpControl == undefined){ retObj.error = 97; retObj.message = msg_bf_checklist_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; return false; } } } }); } } } } if(isVersion(VERSION_SCHEDULE_WIDGET)){ if(control.type == CONST_CTRL_TYPE_CTRLTABLE && control.isScheduleWidget){ if(!requiredError && valueOrEmpty(control.dispatchDate) == CONST_EMPTY){ retObj.error = 99; retObj.message = msg_bf_dispatch_date_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } if(!requiredError && valueOrEmpty(control.dispatchMobile) == CONST_EMPTY){ retObj.error = 99; retObj.message = msg_bf_dispatch_mobile_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } if(!requiredError && valueOrEmpty(control.schedulePickProject) == CONST_EMPTY){ retObj.error = 99; retObj.message = msg_bf_pick_project_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } if(!requiredError && valueOrEmpty(control.schedulePickForm) == CONST_EMPTY){ retObj.error = 99; retObj.message = msg_bf_pick_form_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } if(control.scheduleFieldMappings && control.scheduleFieldMappings.length>0){ _.each(control.scheduleFieldMappings, function(scheduleFieldItem){ if(requiredError){ return false; } if(valueOrEmpty(scheduleFieldItem.text.current_field) == CONST_EMPTY){ retObj.error = 17; retObj.message = msg_bf_current_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; }else if(valueOrEmpty(scheduleFieldItem.text.new_form_field) == CONST_EMPTY){ retObj.error = 17; retObj.message = msg_bf_new_form_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }); }else{ retObj.error = 17; retObj.message = msg_bf_field_mappings_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if(!requiredError && valueOrEmpty(control.scheduleSendDispatch) == '1'){ if(valueOrEmpty(control.scheduleDateTime) == CONST_EMPTY){ retObj.error = 99; retObj.message = msg_bf_schedule_date_time_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } if(isVersion(VERSION_MESSAGE_WIDGET)){ if(control.type == CONST_CTRL_TYPE_CTRLTABLE && control.isMessageWidget){ if(!requiredError && valueOrEmpty(control.messageField) == CONST_EMPTY){ retObj.error = 99; retObj.message = msg_bf_message_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } if(!isVersion2_12()){ if(control.usechecklist != undefined && control.usechecklist == true && control.children[0] !== undefined){ var firstChild = control.children[0]; if(firstChild.lookupConditionFields != undefined && firstChild.lookupConditionFields.length > 0){ retObj.error = 25; retObj.message = msg_bf_first_control_in_table_is_conditional_lu; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } // Validate []Column weight of Grid/Table/Questionaire, // only affected in version VERSION_NEW_OPTION_CUSTOM_COLUMN_WEIGHT if (currentVersion >= VERSION_NEW_OPTION_CUSTOM_COLUMN_WEIGHT) { var finalErrorCode = validateCustomWeight4ContainerGeneralProperty(control, retObj); // Check require error if (finalErrorCode === 1) { requiredError = true; retObj.error = 13; retObj.message = msg_bf_act_required; } else if (finalErrorCode > 0) { requiredError = true; } } if(isVersion(VERSION_NEW_GRID_BUTTON) && control.type == CONST_CTRL_TYPE_CTRLGRID && !requiredError){ if(isVersion(VERSION_STACKED_EXP_FREE_FORM)){ if(control.isIgnoreGrid && (!control.ignoreScreenSize || control.ignoreScreenSize == '')){ requiredError = true; retObj.error = 13; retObj.message = msg_bf_screen_size_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } }else{ if(control.gridType == '1' || control.gridType == '2'){ if(control.isIgnoreGrid && (!control.ignoreScreenSize || control.ignoreScreenSize == '')){ requiredError = true; retObj.error = 13; retObj.message = msg_bf_screen_size_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } } } if(control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && control.children && control.children.length == 0){ retObj.error = 15; if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ retObj.message = msg_bf_group_empty; }else if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ retObj.message = msg_bf_scord_table_empty; }else if (control.type == CONST_CTRL_TYPE_CTRLGRID){ retObj.message = msg_bf_grid_empty; }else{ retObj.message = msg_bf_table_empty; } $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } if(isVersion5_0() && control.isVariableRepeats){ if(control.repValSource == undefined || control.repValSource == ''){ retObj.error = 18; retObj.message = msg_bf_rep_val_source_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if(!requiredError){ var repValSourceControl = getControlById(control.repValSource, controlsOrg); if(repValSourceControl == undefined || !checkRepValSourcePosIsCorrected(controlsOrg, control.id, control.repValSource)){ retObj.error = 17; retObj.message = msg_bf_rep_val_source_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } if(isVersion5_0() && control.isReplaceRepeatableHeader){ if(control.replaceRepeatableHeaderWith == undefined || control.replaceRepeatableHeaderWith == ''){ retObj.error = 18; retObj.message = msg_bf_rep_val_source_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } if(isVersion5_0() && control.isVariableNumberRow){ if(control.rowValSource == undefined || control.rowValSource == ''){ retObj.error = 18; retObj.message = msg_bf_row_val_source_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if(!requiredError){ var rowValSourceControl = getControlById(control.rowValSource, controlsOrg); if(rowValSourceControl == undefined || !checkRowValSourcePosIsCorrected(controlsOrg, control.id, control.rowValSource)){ retObj.error = 17; retObj.message = msg_bf_row_val_source_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } retObj.error = 0; if(control.relevanceconds != undefined && control.relevanceconds[0] != undefined){ _.each(control.relevanceconds, function(relevanceCond){ if(retObj.error != 0){ return false; } if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_NUMERIC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTTRENDS || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTDATE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTCOUNTER){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: if(relevanceCond.value[CONST_VAL] == undefined || jQuery.trim(relevanceCond.value[CONST_VAL]) == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; return false; } } } var relevanceControl = getControlById(relevanceCond.text['eng'], controlsOrg); if(relevanceControl == undefined){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false; /*}else if(relevanceCond.text[CONST_VALUE_CTRLTYPE] && relevanceCond.text[CONST_VALUE_CTRLTYPE] != relevanceControl.type){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false;*/ }else if(relevanceControl.type != relevanceCond.text.ctrlType){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false; }else { switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: if(relevanceCond.value && relevanceCond.value.cmpType == '' && relevanceCond.value.val != ''){ switch(relevanceControl.kind){ case CONST_CTRL_KIND_NUMBER: try{ if(isNaN(parseFloat(relevanceCond.value.val))){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_changed; return false; } }catch(ex){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_changed; return false; } break; } } if(relevanceCond.value[CONST_CMP_TYPE] != CONST_VALUE_OTHER){ if(relevanceControl.kind == CONST_VALUE_DATE_SPACE_TIME){ if(!isValidDateTime(jQuery.trim(relevanceCond.value[CONST_VAL]), DATE_TYPE_DATE_TIME)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.kind == CONST_VALUE_TIME){ if(!isValidDateTime(jQuery.trim(relevanceCond.value[CONST_VAL]), DATE_TYPE_TIME)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.kind == CONST_VALUE_DATE && relevanceControl.type != CONST_CTRL_TYPE_INPUTCALCULATE){ if(!isValidDateTime(jQuery.trim(relevanceCond.value[CONST_VAL]), DATE_TYPE_DATE)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.kind == 'Integer'){ if(jQuery.trim(relevanceCond.value[CONST_VAL]).indexOf(".") != -1){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(jQuery.trim(relevanceCond.value[CONST_VAL]) != '' && (optionMap[relevanceControl.name] == undefined || optionMap[relevanceControl.name][relevanceCond.value[CONST_VAL].toLowerCase()] == undefined)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(jQuery.trim(relevanceCond.value[CONST_VAL]) != '' && (optionMap[relevanceControl.name] == undefined || optionMap[relevanceControl.name][relevanceCond.value[CONST_VAL].toLowerCase()] == undefined)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(jQuery.trim(relevanceCond.value[CONST_VAL]) != '' && (optionMap[relevanceControl.name] == undefined || optionMap[relevanceControl.name][relevanceCond.value[CONST_VAL].toLowerCase()] == undefined)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else{ if(!isConditionValueValid(relevanceCond.value[CONST_VAL])){ retObj.error = 7; retObj.message = msg_bf_following_val_invalid; //return retObj; } } if (!checkCtrlPosIsCorrected(controlsOrg, relevanceCond.text['eng'], control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, relevanceCond.text['eng'], control.id, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } }else{ var isUserVariable = false; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(relevanceCond.value.val && relevanceCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; } } if(!isUserVariable){ if (!checkCtrlPosIsCorrected(controlsOrg, relevanceCond.value[CONST_VAL], control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, relevanceCond.value[CONST_VAL], control.id, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } if(!isRelevanceConditionTheSameKind(controlsOrg, relevanceCond.text['eng'], relevanceCond.value[CONST_VAL])){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } } if (!checkCtrlPosIsCorrected(controlsOrg, relevanceCond.text['eng'], control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, relevanceCond.text['eng'], control.id, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } }); if(retObj.error != 0){ errorCode = 1; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } //return retObj; } } retObj = checkControlsData(control.children, control, lookupDatasourceArray, optionMap, controlsOrg, useChecklistObjMap); if(retObj.error != 0){ errorCode = 1; } }else if (control.type == CONST_CTRL_TYPE_INPUT_TEXT){ if ((control.length !== undefined) && (control.length !== false)){ if(control.length.min == '' && control.length.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.length.min != '' && control.length.max != '' && (parseInt(control.length.max, 10) < parseInt(control.length.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.length.min == '0' && control.length.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.length.max != '' && parseInt(control.length.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }/*else if((control.length.min != '' && parseInt(control.length.min, 10) > 500) || (control.length.max != '' && parseInt(control.length.max, 10) > 500)){ retObj.error = 19; retObj.message = msg_bf_min_max_gt_500; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); maxltMinError = true; errorCode = 1; //return retObj; }*/ if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(control.defaultValue.length < parseInt(control.length.min, 10) || control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_min_max_len_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(control.defaultValue.length < parseInt(control.length.min, 10)){ retObj.error = 3; retObj.message = msg_bf_min_len_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_max_len_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && control.readOnly){ retObj.error = 10; retObj.message = msg_bf_def_val_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } } /* CO-2251 New update 2018.11.08 - stop prevent character, user could input anything * Update 2018.11.13 - Check validate allow input: 0 A and symbols (non-alphanumeric chars) */ if(control.isCustomFormat && control.txtCustomFormatVal != undefined){ // CO-2251 - Validation var customFormatTextChar = undefined; var customFormatNumChar = undefined; if(control.customFormatTextChar && control.customFormatTextChar != ''){ customFormatTextChar = control.customFormatTextChar; } if(control.customFormatNumChar && control.customFormatNumChar != ''){ customFormatNumChar = control.customFormatNumChar; } if(customFormatTextChar != '' && customFormatTextChar == customFormatNumChar){ retObj.error = 3; retObj.message = lbl_text_char_n_num_char_the_same; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(errorCode == 0 && !customFormatValidation(control.txtCustomFormatVal, customFormatTextChar, customFormatNumChar)) { retObj.error = 3; retObj.message = lbl_txt_custom_format_error; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } if(control.defaultValue != undefined && control.defaultValue != ''){ var customFormatTextChar = undefined; var customFormatNumChar = undefined; if(control.customFormatTextChar && control.customFormatTextChar != ''){ customFormatTextChar = control.customFormatTextChar; } if(control.customFormatNumChar && control.customFormatNumChar != ''){ customFormatNumChar = control.customFormatNumChar; } if(!customFormatDefaultValTest(control.txtCustomFormatVal, control.defaultValue, customFormatTextChar, customFormatNumChar)) { retObj.error = 3; retObj.message = lbl_txt_custom_format_error_default_val; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } if(isVersion(VERSION_TEXT_PARSE)){ if(!requiredError && control.textParse){ if(control.textParseDestinationFields == undefined || control.textParseDestinationFields.length == 0){ retObj.error = 14; retObj.message = msg_bf_required_destination_field; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else{ _.each(control.textParseDestinationFields, function(item){ if(requiredError){ return true; } var len = item.text.len || ''; var val = item.text.val || ''; if( len == ''){ retObj.error = 18; retObj.message = msg_bf_destination_length_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if( val == ''){ retObj.error = 18; retObj.message = msg_bf_destination_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } var parseDestinationFieldControl = getControlById(val, controlsOrg); if(parseDestinationFieldControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_destination_field_not_found; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if(item.text.isTable == true){ var parseDestinationFieldTableControl = getControlById(item.text.tablefield, controlsOrg); if(parseDestinationFieldTableControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_destination_field_not_found; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } /*if (!checkParseDestinationByIdCorrectPos(controlsOrg, control.id, item.text.tablefield)){ retObj.error = 18; retObj.message = msg_bf_destination_field_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }*/ }else{ if (!checkParseDestinationByIdCorrectPos(controlsOrg, control.id, val)){ retObj.error = 18; retObj.message = msg_bf_destination_field_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }); } } } if(isVersion(VERSION_DUPLICAT_CHECK)){ if(!requiredError && control.duplicateCheck){ if(control.duplicateCheckField == undefined || control.duplicateCheckField == ''){ retObj.error = 14; retObj.message = msg_bf_required_duplicate_field; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if (control.kind == 'Decimal'){ if(control.defaultValue != '' && (parseInt(control.defaultValue, 10) < DECIMAL_MIN_VALUE || parseInt(control.defaultValue, 10) > DECIMAL_MAX_VALUE)){ retObj.error = 23; retObj.message = msg_bf_num_min_max_out_of_range.replace('$3', "default value").replace('$1', DECIMAL_MIN_VALUE).replace('$2', DECIMAL_MAX_VALUE); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } if ((control.range !== undefined) && (control.range !== false)){ if(control.range.min == '' && control.range.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.range.min != '' && control.range.max != '' && parseFloat(control.range.max) < parseFloat(control.range.min)){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.range.min == '0' && control.range.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.range.min != '' && (parseInt(control.range.min, 10) < DECIMAL_MIN_VALUE || parseInt(control.range.min, 10) > DECIMAL_MAX_VALUE)){ retObj.error = 23; retObj.message = msg_bf_num_min_max_out_of_range.replace('$3', "minimum value").replace('$1', DECIMAL_MIN_VALUE).replace('$2', DECIMAL_MAX_VALUE); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.range.max != '' && (parseInt(control.range.max, 10) < DECIMAL_MIN_VALUE || parseInt(control.range.max, 10) > DECIMAL_MAX_VALUE)){ retObj.error = 23; retObj.message = msg_bf_num_min_max_out_of_range.replace('$3', "maximum value").replace('$1', DECIMAL_MIN_VALUE).replace('$2', DECIMAL_MAX_VALUE); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.range.min != '' && control.range.max != ''){ if(!maxltMinError){ if(parseFloat(control.defaultValue) < parseFloat(control.range.min) || parseFloat(control.defaultValue) > parseFloat(control.range.max)){ retObj.error = 4; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', control.range.min).replace('$2', control.range.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.range.min != ''){ if(parseFloat(control.defaultValue) < parseFloat(control.range.min)){ retObj.error = 4; retObj.message = msg_bf_num_min_of_def_val.replace('$1', control.range.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(parseFloat(control.defaultValue) > parseFloat(control.range.max)){ retObj.error = 4; retObj.message = msg_bf_num_max_of_def_val.replace('$1', control.range.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && control.readOnly){ retObj.error = 10; retObj.message = msg_bf_num_def_val_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } } }else{ if(control.defaultValue != '' && (parseInt(control.defaultValue, 10) < LONG_MIN_VALUE || parseInt(control.defaultValue, 10) > LONG_MAX_VALUE)){ retObj.error = 23; retObj.message = msg_bf_num_min_max_out_of_range.replace('$3', "default value").replace('$1', LONG_MIN_VALUE).replace('$2', LONG_MAX_VALUE); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } var isStarCounter = false; if(isVersion(VERSION_COUNTER_STAR_SLIDER) && control.type == CONST_CTRL_TYPE_INPUTCOUNTER && (control.counterFormat == CONST_TYPE_STARS || control.counterFormat == CONST_TYPE_SLIDER)){ // CO-1025 Add Start/Slider option for Counters if(control.counterFormat == CONST_TYPE_STARS){ isStarCounter = true; } if ((control.range != undefined) && (control.range != false)){ switch(control.counterFormat){ case CONST_TYPE_STARS: if(valueOrEmpty(control.range.stars) == ''){ retObj.error = 1; retObj.message = msg_bf_stars_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } break; case CONST_TYPE_SLIDER: break; } }else{ retObj.error = 1; retObj.message = msg_bf_lbl_range_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if (!isStarCounter && (control.range != undefined) && (control.range != false)){ if(control.range.min == '' && control.range.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.range.min != '' && control.range.max != '' && parseInt(control.range.max, 10) < parseInt(control.range.min, 10)){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.range.min == '0' && control.range.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.range.min != '' && (parseInt(control.range.min, 10) < LONG_MIN_VALUE || parseInt(control.range.min, 10) > LONG_MAX_VALUE)){ retObj.error = 23; retObj.message = msg_bf_num_min_max_out_of_range.replace('$3', "minimum value").replace('$1', LONG_MIN_VALUE).replace('$2', LONG_MAX_VALUE); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.range.max != '' && (parseInt(control.range.max, 10) < LONG_MIN_VALUE || parseInt(control.range.max, 10) > LONG_MAX_VALUE)){ retObj.error = 23; retObj.message = msg_bf_num_min_max_out_of_range.replace('$3', "maximum value").replace('$1', LONG_MIN_VALUE).replace('$2', LONG_MAX_VALUE); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.range.min != '' && control.range.max != ''){ if(!maxltMinError){ if(parseInt(control.defaultValue, 10) < parseInt(control.range.min, 10) || parseInt(control.defaultValue, 10) > parseInt(control.range.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', control.range.min).replace('$2', control.range.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.range.min != ''){ if(parseInt(control.defaultValue, 10) < parseInt(control.range.min, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_of_def_val.replace('$1', control.range.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(parseInt(control.defaultValue, 10) > parseInt(control.range.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_max_of_def_val.replace('$1', control.range.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && control.readOnly){ retObj.error = 10; retObj.message = msg_bf_num_def_val_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(isStarCounter){ if(control.defaultValue != undefined && control.defaultValue != ''){ var starMin = CONST_I_ONE; var starMax = CONST_I_FIVE; if(control.range.stars == CONST_TEN){ starMax = CONST_I_TEN; } if(parseInt(control.defaultValue, CONST_I_TEN) < starMin || parseInt(control.defaultValue, CONST_I_TEN) > starMax){ retObj.error = CONST_I_FOUR; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', starMin).replace('$2', starMax); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = CONST_I_ONE; } } } } if(isVersion(VERSION_VALIDATE_VALUE)){ if (control.validateValue){ if(control.validateValue.condition == ''){ retObj.error = 1; retObj.message = msg_bf_condition_range_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.validateValue.field == ''){ retObj.error = 2; retObj.message = msg_bf_field_range_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else{ if (!checkCtrlPosIsCorrected(controlsOrg, control.validateValue.field, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.validateValue.field, control.id, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } } } if(control.useCurrentcySymbol != undefined && control.useCurrentcySymbol == true){ if(control.currency == undefined || control.currency == '' || control.currency == 'None'){ retObj.error = 26; retObj.message = msg_bf_currency_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if (control.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(control.numberOfPrior == undefined || control.numberOfPrior == ''){//|| !checkRepValSourcePosIsCorrected(controlsOrg, control.id, control.repValSource)){ retObj.error = 30; retObj.message = msg_bf_number_of_prior_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ if(control.numberOfPrior !== undefined && (parseInt(control.numberOfPrior, 10) < INTEGER_MIN_NUMBER_OF_PRIOR || parseInt(control.numberOfPrior, 10) > INTEGER_MAX_NUMBER_OF_PRIOR)){ retObj.error = 33; retObj.message = msg_bf_number_of_prior_not_valid.replace('$1', INTEGER_MIN_NUMBER_OF_PRIOR).replace('$2', INTEGER_MAX_NUMBER_OF_PRIOR); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } if(control.trendingDate == undefined || control.trendingDate == '' || (control.trendingDate != lbl_trending_date_default && !checkTrendsSourcePosIsCorrected(controlsOrg, control.id, control.trendingDate, true, false, false))){ retObj.error = 31; retObj.message = msg_bf_trending_date_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTDATE){ var date = new Date(); //var today = (date.getMonth() +1) + '/' + date.getDate() + '/' + date.getFullYear(); var today = date; if(control.kind == CONST_VALUE_TIME){ today = date; }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ today = date; }else{ today = new Date(getSystemMMddyyyyString()); } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.defaultValue != 'today'){ if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ if(!isValidDateTime(control.defaultValue, DATE_TYPE_DATE_TIME)){ retObj.error = 7; retObj.message = msg_bf_datetime_def_val_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else if(control.kind == CONST_VALUE_TIME){ if(!isValidDateTime(control.defaultValue, DATE_TYPE_TIME)){ retObj.error = 7; retObj.message = msg_bf_time_def_val_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(!validDate(control.defaultValue)){ retObj.error = 7; retObj.message = msg_bf_date_def_val_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } } } if(isVersion(VERSION_OPTION_MINUTE_INTERVAL)){ if(control.useInterval){ if(control.minuteInterval<1 || control.minuteInterval>60){ retObj.error = 1; retObj.message = msg_bf_interval_range_error; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } if(isVersion(VERSION_TIME_VERIFY) && control.isVerifyTime == true){ if(jQuery.trim(control.compareField) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_time_compare_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else if(jQuery.trim(control.destinationField) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_time_destination_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } /*}else if(jQuery.trim(control.verifyMinRange) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_time_verify_min_range_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else if(jQuery.trim(control.verifyMaxRange) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_time_verify_max_range_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }*/ }else{ if (!checkCtrlPosIsCorrected(controlsOrg, control.compareField, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.compareField, control.id, true)){ if(!requiredError){ retObj.error = 18; retObj.message = msg_bf_compare_field_ctrl_move_down; requiredError = true; errorCode = 1; } } } if (!checkCtrlPosIsCorrected(controlsOrg, control.id, control.destinationField)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.id, control.destinationField, true)){ if(!requiredError){ retObj.error = 18; retObj.message = msg_bf_destination_field_ctrl_move_down; requiredError = true; errorCode = 1; } } } } } if ((control.range !== undefined) && (control.range !== false)){ var minDate; var maxDate; var defaultDate; if(control.range.min == '' && control.range.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else{ if(control.range.min != ''){ if(control.range.min != 'today'){ if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ if(!isValidDateTime(control.range.min, DATE_TYPE_DATE_TIME)){ retObj.error = 5; retObj.message = msg_bf_datetime_min_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } minDate = new Date(control.range.min); }else if(control.kind == CONST_VALUE_TIME){ if(!isValidDateTime(control.range.min, DATE_TYPE_TIME)){ retObj.error = 5; retObj.message = msg_bf_time_min_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } minDate = new Date(getSystemMMddyyyyString() + ' ' + control.range.min); }else{ if(!validDate(control.range.min)){ retObj.error = 5; retObj.message = msg_bf_date_min_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } minDate = new Date(control.range.min); } }else{ minDate = today;// new Date(today); } } if(control.range.max != ''){ if(control.range.max != 'today'){ if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ if(!isValidDateTime(control.range.max, DATE_TYPE_DATE_TIME)){ retObj.error = 6; retObj.message = msg_bf_datetime_max_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } maxDate = new Date(control.range.max); }else if(control.kind == CONST_VALUE_TIME){ if(!isValidDateTime(control.range.max, DATE_TYPE_TIME)){ retObj.error = 6; retObj.message = msg_bf_time_max_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } maxDate = new Date(getSystemMMddyyyyString() + ' ' + control.range.max); }else{ if(!validDate(control.range.max)){ retObj.error = 6; retObj.message = msg_bf_date_max_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } maxDate = new Date(control.range.max); } }else{ maxDate = today;// new Date(today); } } if(control.range.min != '' && control.range.max != ''){ if(maxDate.getTime() - minDate.getTime() < 0){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; } } } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.defaultValue != 'today'){ if(control.kind == CONST_VALUE_TIME){ defaultDate = new Date(getSystemMMddyyyyString() + ' ' + control.defaultValue); }else{ defaultDate = new Date(control.defaultValue); } }else{ defaultDate = today;//new Date(today); } if(control.range.min != '' && control.range.max != ''){ if(!maxltMinError){ if(defaultDate.getTime() - minDate.getTime() < 0 || defaultDate.getTime() - maxDate.getTime() > 0){ retObj.error = 4; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', control.range.min).replace('$2', control.range.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.range.min != ''){ if(defaultDate.getTime() - minDate.getTime() < 0){ retObj.error = 4; retObj.message = msg_bf_num_min_of_def_val.replace('$1', control.range.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else if(control.range.max != ''){ if(defaultDate.getTime() - maxDate.getTime() > 0){ retObj.error = 4; retObj.message = msg_bf_num_max_of_def_val.replace('$1', control.range.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.parentCtrlType != CONST_CTRL_TYPE_CTRLPOD && control.readOnly){ retObj.error = 10; retObj.message = msg_bf_num_def_val_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } } if(control.autoStamp){ if(isVersion5_0() && (control.autoStampTrigger === lbl_auto_stamp_select_opt || jQuery.trim(control.autoStampTrigger) === '')){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_auto_stamp_trigger_qes_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if((!isVersion5_0() && control.autoStampTrigger2) || (isVersion5_0() && control.autoStampTrigger == '2')){ if(control.autoStampTrigger2Ques === lbl_sel_question || jQuery.trim(control.autoStampTrigger2Ques) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_auto_stamp_trigger_qes_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ var autoStampTrigger2Ques = getControlById(control.autoStampTrigger2Ques, controlsOrg); if(autoStampTrigger2Ques == undefined){ retObj.error = 17; retObj.message = msg_bf_auto_stamp_trigger_qes_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if (!checkAutoStampTriggerQuesIsCorrectPos(controlsOrg, control.id, control.autoStampTrigger2Ques, false)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ var tmpId = control.autoStampTrigger2Ques; var refErr = false; while(fvDataNS.triggerRef[tmpId] != undefined ){ if(fvDataNS.triggerRef[tmpId] == control.id){ refErr = true; break; } tmpId = fvDataNS.triggerRef[tmpId]; } if(refErr){ retObj.error = 34; retObj.message = msg_trigger_ques_ref_err; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else{ fvDataNS.triggerRef[control.id] = control.autoStampTrigger2Ques; } } } } if((!isVersion5_0() && control.autoStampTrigger4) || (isVersion5_0() && control.autoStampTrigger == '4')){ if(control.autoStampTrigger4Ques === lbl_sel_question || jQuery.trim(control.autoStampTrigger4Ques) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_auto_stamp_trigger_qes_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ var autoStampTrigger4Ques = getControlById(control.autoStampTrigger4Ques, controlsOrg); if(autoStampTrigger4Ques == undefined){ retObj.error = 17; retObj.message = msg_bf_auto_stamp_trigger_qes_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if (!checkAutoStampTriggerQuesIsCorrectPos(controlsOrg, control.id, control.autoStampTrigger4Ques, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } } /* advancedFormat it should not be required. Subject: RE: Help links for Tools (Widgets) Date: Wed, 23 Mar 2016 01:25:46 +0700 From: Nick Legg if(control.advancedFormat && (!control.advancedFormat.format || jQuery.trim(control.advancedFormat.format) == '')){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_advance_format_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }*/ if(!control.militaryTime){ if(control.advancedFormat && control.advancedFormat.format && control.advancedFormat.format.indexOf('H')>=0){ retObj.error = 13; retObj.message = lbl_hour_format_error; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(!requiredError && control.validateValue){ var condition = valueOrEmpty(control.validateValue.condition); var field = valueOrEmpty(control.validateValue.field); if(condition == '' || field == '' || field == lbl_select_opt){ retObj.error = 13; retObj.message = msg_bf_compare_condition_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTLOCATION){ if ((control.range !== undefined) && (control.range !== false)){ if(control.range.min == '' && control.range.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.range.min != '' && control.range.max != '' && (parseInt(control.range.max, 10) < parseInt(control.range.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.range.min == '0' && control.range.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.range.max != '' && parseInt(control.range.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } if(control.autoStamp){ if(isVersion5_0() && (control.autoStampTrigger === lbl_auto_stamp_select_opt || jQuery.trim(control.autoStampTrigger) === '')){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_auto_stamp_trigger_qes_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if((!isVersion5_0() && control.autoStampTrigger2) || (isVersion5_0() && control.autoStampTrigger == '2')){ if(control.autoStampTrigger2Ques === lbl_sel_question || jQuery.trim(control.autoStampTrigger2Ques) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_auto_stamp_trigger_qes_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ var autoStampTrigger2Ques = getControlById(control.autoStampTrigger2Ques, controlsOrg); if(autoStampTrigger2Ques == undefined){ retObj.error = 17; retObj.message = msg_bf_auto_stamp_trigger_qes_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if (!checkAutoStampTriggerQuesIsCorrectPos(controlsOrg, control.id, control.autoStampTrigger2Ques, false)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ var tmpId = control.autoStampTrigger2Ques; var refErr = false; while(fvDataNS.triggerRef[tmpId] != undefined ){ if(fvDataNS.triggerRef[tmpId] == control.id){ refErr = true; break; } tmpId = fvDataNS.triggerRef[tmpId]; } if(refErr){ retObj.error = 34; retObj.message = msg_trigger_ques_ref_err; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else{ fvDataNS.triggerRef[control.id] = control.autoStampTrigger2Ques; } } } } if((!isVersion5_0() && control.autoStampTrigger4) || (isVersion5_0() && control.autoStampTrigger == '4')){ if(control.autoStampTrigger4Ques === lbl_sel_question || jQuery.trim(control.autoStampTrigger4Ques) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_auto_stamp_trigger_qes_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ var autoStampTrigger4Ques = getControlById(control.autoStampTrigger4Ques, controlsOrg); if(autoStampTrigger4Ques == undefined){ retObj.error = 17; retObj.message = msg_bf_auto_stamp_trigger_qes_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if (!checkAutoStampTriggerQuesIsCorrectPos(controlsOrg, control.id, control.autoStampTrigger4Ques, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } } if(isVersion(VERSION_GPS_VERIFY_ADDRESS) && control.isVerifyAddress == true){ if(jQuery.trim(control.compareField) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_gps_compare_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else if(jQuery.trim(control.destinationField) === ''){ if(!requiredError){ retObj.error = 13; retObj.message = msg_bf_gps_destination_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ if (!checkCtrlPosIsCorrected(controlsOrg, control.compareField, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.compareField, control.id, true)){ if(!requiredError){ retObj.error = 18; retObj.message = msg_bf_compare_field_ctrl_move_down; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } if (!checkCtrlPosIsCorrected(controlsOrg, control.id, control.destinationField)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.id, control.destinationField, true)){ if(!requiredError){ retObj.error = 18; retObj.message = msg_bf_destination_field_ctrl_move_down; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } } // CO-4087: Add Get address option to GPS location start if(isVersion(VERSION_GPS_GET_ADDRESS)){ if(control.isGetAddress == true){ if(control.addressData && control.addressData.length>0){ for(var i = 0; i< control.addressData.length; i++){ if(requiredError){ break; } var address = control.addressData[i]; if(!address.active){ continue; } if(!address.text || !address.text.val || address.text.val === ''){ retObj.error = 13; retObj.message = msg_bf_address_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!address.value || !address.value.val || address.value.val === ''){ retObj.error = 13; retObj.message = msg_bf_address_value_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ if(!address.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ var ctrl1 = getControlFromArrayById(controlsOrg, address.text.val, false); if(ctrl1 == null){ retObj.error = 13; retObj.message = msg_bf_address_value_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } } } if(control.hasGPSDestination == true){ if(control.locationStype && control.locationStype == CONST_TYPE_ADVANCED){ if(control.destinationdata && control.destinationdata.length>0){ for(var i = 0; i< control.destinationdata.length; i++){ if(requiredError){ break; } var destination = control.destinationdata[i]; if(!destination.active){ continue; } if(!destination.text || !destination.text.val || destination.text.val === ''){ retObj.error = 13; retObj.message = msg_bf_address_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!destination.value || !destination.value.val || destination.value.val === ''){ retObj.error = 13; retObj.message = msg_bf_address_value_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ if(!destination.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ var ctrl1 = getControlFromArrayById(controlsOrg, destination.text.val, false); if(ctrl1 == null){ retObj.error = 13; retObj.message = msg_bf_address_value_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } } } } } // CO-4087: Add Get address option to GPS location end // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end var isAutoRun = false; if(isVersion(VERSION_LOCATION_STYLE)){ if(control.actionKind == CONST_TYPE_AUTO_RUN){ isAutoRun = true; } } if (isAutoRun && control.autoRunTrigger != undefined && control.autoRunTrigger != '' && control.autoRunTrigger != lbl_action_select_a_trigger){ if(!requiredError && control.autoRunTrigger == '2' && (control.autoRunQuestionTrigger == undefined || control.autoRunQuestionTrigger == lbl_sel_question || control.autoRunQuestionTrigger == '')) { retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else if (control.type == mdi_kind_inputImage){ }else if (control.type == mdi_kind_inputAudio){ }else if (control.type == mdi_kind_inputVideo){ }else if (control.type == CONST_CTRL_TYPE_INPUTMEDIA){ }else if (control.type == mdi_kind_inputSketch){ }else if (control.type == mdi_kind_inputSignature){ }else if (control.type == 'inputDraw'){ }else if (control.type == CONST_CTRL_TYPE_INPUTBARCODE){ if ((control.length !== undefined) && (control.length !== false)){ if(control.length.min == '' && control.length.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.length.min != '' && control.length.max != '' && (parseInt(control.length.max, 10) < parseInt(control.length.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.length.min == '0' && control.length.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.length.max != '' && parseInt(control.length.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if((control.length.min != '' && parseInt(control.length.min, 10) > 500) || (control.length.max != '' && parseInt(control.length.max, 10) > 500)){ if(control.kind !== 'Number'){ retObj.error = 19; retObj.message = msg_bf_min_max_gt_500; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); maxltMinError = true; errorCode = 1; //return retObj; } } if(control.defaultValue != undefined && control.defaultValue != ''){ /*if(control.kind !== 'Number'){*/ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(control.defaultValue.length < parseInt(control.length.min, 10) || control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_min_max_len_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(control.defaultValue.length < parseInt(control.length.min, 10)){ retObj.error = 3; retObj.message = msg_bf_min_len_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_max_len_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } /*}else{ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10) || parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_max_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }*/ }else{ if(control.readOnly){ retObj.error = 10; retObj.message = msg_bf_def_val_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(control.displayImage){ if(control.barcodeType == undefined || control.barcodeType == ''){ if(!requiredError){ retObj.error = 18; retObj.message = msg_bf_barcode_type_requred; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } if(control.parse){ if(control.parseDestinationFields != undefined && control.parseDestinationFields.length > 0){ _.each(control.parseDestinationFields, function(item){ if(requiredError){ return true; } if(item.text.val == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } var parseDestinationFieldControl = getControlById(item.text.val, controlsOrg); if(parseDestinationFieldControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if (!checkParseDestinationByIdCorrectPos(controlsOrg, control.id, item.text.val)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } if(isVersion(VERSION_BC_LENGTH_PARSE)){ if(!requiredError && control.textParse){ if(control.textParseDestinationFields == undefined || control.textParseDestinationFields.length == 0){ retObj.error = 14; retObj.message = msg_bf_required_destination_field; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else{ _.each(control.textParseDestinationFields, function(item){ if(requiredError){ return true; } var len = item.text.len || ''; var val = item.text.val || ''; if( len == ''){ retObj.error = 18; retObj.message = msg_bf_destination_length_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if( val == ''){ retObj.error = 18; retObj.message = msg_bf_destination_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } var parseDestinationFieldControl = getControlById(val, controlsOrg); if(parseDestinationFieldControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_destination_field_not_found; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if(item.text.isTable == true){ var parseDestinationFieldTableControl = getControlById(item.text.tablefield, controlsOrg); if(parseDestinationFieldTableControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_destination_field_not_found; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } }else{ if (!checkParseDestinationByIdCorrectPos(controlsOrg, control.id, val)){ retObj.error = 18; retObj.message = msg_bf_destination_field_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }); } } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTNFC){ if ((control.length !== undefined) && (control.length !== false)){ if(control.length.min == '' && control.length.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.length.min != '' && control.length.max != '' && (parseInt(control.length.max, 10) < parseInt(control.length.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.length.min == '0' && control.length.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.length.max != '' && parseInt(control.length.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if((control.length.min != '' && parseInt(control.length.min, 10) > 500) || (control.length.max != '' && parseInt(control.length.max, 10) > 500)){ retObj.error = 19; retObj.message = msg_bf_min_max_gt_500; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); maxltMinError = true; errorCode = 1; //return retObj; } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(control.defaultValue.length < parseInt(control.length.min, 10) || control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_min_max_len_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(control.defaultValue.length < parseInt(control.length.min, 10)){ retObj.error = 3; retObj.message = msg_bf_min_len_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_max_len_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.readOnly){ retObj.error = 10; retObj.message = msg_bf_def_val_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } if(control.parse){ if(control.parseDestinationFields != undefined && control.parseDestinationFields.length > 0){ _.each(control.parseDestinationFields, function(item){ if(requiredError){ return true; } if(item.text.val == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } var parseDestinationFieldControl = getControlById(item.text.val, controlsOrg); if(parseDestinationFieldControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if (!checkParseDestinationByIdCorrectPos(controlsOrg, control.id, item.text.val)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } if(isVersion(VERSION_NFC_LENGTH_PARSE)){ if(!requiredError && control.textParse){ if(control.textParseDestinationFields == undefined || control.textParseDestinationFields.length == 0){ retObj.error = 14; retObj.message = msg_bf_required_destination_field; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else{ _.each(control.textParseDestinationFields, function(item){ if(requiredError){ return true; } var len = item.text.len || ''; var val = item.text.val || ''; if( len == ''){ retObj.error = 18; retObj.message = msg_bf_destination_length_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if( val == ''){ retObj.error = 18; retObj.message = msg_bf_destination_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } var parseDestinationFieldControl = getControlById(val, controlsOrg); if(parseDestinationFieldControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_destination_field_not_found; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } if(item.text.isTable == true){ var parseDestinationFieldTableControl = getControlById(item.text.tablefield, controlsOrg); if(parseDestinationFieldTableControl == undefined){ item.text.val = ''; retObj.error = 18; retObj.message = msg_bf_destination_field_not_found; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return true; } }else{ if (!checkParseDestinationByIdCorrectPos(controlsOrg, control.id, val)){ retObj.error = 18; retObj.message = msg_bf_destination_field_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }); } } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ if ((control.length !== undefined) && (control.length !== false)){ if(control.length.min == '' && control.length.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.length.min != '' && control.length.max != '' && (parseInt(control.length.max, 10) < parseInt(control.length.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.length.min == '0' && control.length.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.length.max != '' && parseInt(control.length.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if((control.length.min != '' && parseInt(control.length.min, 10) > 500) || (control.length.max != '' && parseInt(control.length.max, 10) > 500)){ retObj.error = 19; retObj.message = msg_bf_min_max_gt_500; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); maxltMinError = true; errorCode = 1; //return retObj; } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(control.defaultValue.length < parseInt(control.length.min, 10) || control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_min_max_len_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(control.defaultValue.length < parseInt(control.length.min, 10)){ retObj.error = 3; retObj.message = msg_bf_min_len_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_max_len_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.readOnly){ retObj.error = 10; retObj.message = msg_bf_def_val_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == 'inputPageBreak'){ }else if (control.type == 'inputLabel' || control.type == 'inputInstruction'){ }else if (control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ //check CONST_CTRL_TYPE_IMAGE_VIEWER error if (control.imageUrl == undefined || control.imageUrl == '' || control.imageUrl == lbl_select_opt){ retObj.error = 99; retObj.message = msg_bf_image_url_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } //return retObj; }else{ if (!checkCtrlPosIsCorrected(controlsOrg, control.imageUrl, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.imageUrl, control.id, true)){ retObj.error = 18; retObj.message = msg_bf_image_url_ctrl_move_down; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } }else if (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ }else if (control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTACTION){ var isAutoRun = false; var isSetDestinationFields = true; if(isVersion(VERSION_GROUP_FUNCTION)){ if(control.actionKind == CONST_TYPE_AUTO_RUN){ isAutoRun = true; } if(control.isShowDestinationFields == false){ isSetDestinationFields = false; } } if(!isAutoRun && (control.useImage === undefined || control.useImage === true) && (control.hintLink === undefined || jQuery.trim(control.hintLink) === '')){ retObj.error = 13; retObj.message = msg_bf_hintlink_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!isAutoRun && control.kind === 'Image' && (control.hintLink === undefined || jQuery.trim(control.hintLink) === '')){ retObj.error = 13; retObj.message = msg_bf_hintlink_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ if(control.imgAction === CONST_ACTION_CALL){ if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(control.imgActionMobileNumberParamType !== CONST_VALUE_OTHER){ if(control.imgActionMobileNumber === undefined || jQuery.trim(control.imgActionMobileNumber) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ // equal other if(control.imgActionMobileNumberCtrl && control.imgActionMobileNumberCtrl != ''){ if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionMobileNumberCtrl, 'Phone')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionMobileNumberCtrl, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else{ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else{ if(control.imgActionMobileNumberCtrl && control.imgActionMobileNumberCtrl != ''){ if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionMobileNumberCtrl, 'Phone')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionMobileNumberCtrl, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else{ if(control.imgActionMobileNumber === undefined || jQuery.trim(control.imgActionMobileNumber) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } }else if(control.imgAction === CONST_ACTION_SEND_TEXT_MESSAGE){ if(isVersion(VERSION_SEND_TEXT_MESSAGE)){ if(control.imgActionMobileNumberParamType !== CONST_VALUE_OTHER){ if(control.imgActionMobileNumber === undefined || jQuery.trim(control.imgActionMobileNumber) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ // equal other if(control.imgActionMobileNumberCtrl && control.imgActionMobileNumberCtrl != ''){ if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionMobileNumberCtrl, 'Phone')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionMobileNumberCtrl, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else{ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(control.imgActionMessageType !== CONST_VALUE_OTHER){ if(control.imgActionMessage === undefined || jQuery.trim(control.imgActionMessage) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ // equal other if(control.imgActionMessageCtrl && control.imgActionMessageCtrl != ''){ if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionMessageCtrl, 'Phone')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionMessageCtrl, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else{ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } }else if(control.imgAction === CONST_ACTION_LANCH_PROGRAM){ var imgiOSActionParam = undefined; if(isVersion(VERSION_IOS_APP_SELECT_OPTION)){ if(control.iOSApp == undefined || jQuery.trim(control.iOSApp) === '' || control.iOSApp == lbl_sel_question || control.iOSApp == CONS_OPTION_CONSTANT_VALUE){ imgiOSActionParam = control.imgiOSActionParam; }else{ imgiOSActionParam = control.iOSApp; } }else{ imgiOSActionParam = control.imgiOSActionParam; } if(isVersion(VERSION_ANDROID_APP)){ if((control.androidApp === undefined || jQuery.trim(control.androidApp) === '' || control.androidApp == lbl_sel_question) && (imgiOSActionParam === undefined || jQuery.trim(imgiOSActionParam) === '')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ if((control.imgActionParam === undefined || jQuery.trim(control.imgActionParam) === '') && (imgiOSActionParam === undefined || jQuery.trim(imgiOSActionParam) === '')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else if(control.imgAction === CONST_ACTION_SEND_STATUS){ if(isVersion(VERSION_ACTION_SEND_STATUS_NEW_OPT)){ if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(valueOrEmpty(control.imgActionParamType) == CONST_VALUE_OTHER){ if(valueOrEmpty(control.imgActionStatusCtrl) == ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionStatusCtrl, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ if (!checkCtrlPosIsCorrected(controlsOrg, control.imgActionStatusCtrl, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.imgActionStatusCtrl, control.id, true)){ retObj.error = 18; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } } }else{ if(valueOrEmpty(control.imgActionParam) == ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else{ if(valueOrEmpty(control.imgActionStatusCtrl) == '' && (control.imgActionParam === undefined || jQuery.trim(control.imgActionParam) === '')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else{ if(control.imgActionParam === undefined || jQuery.trim(control.imgActionParam) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else if(control.imgAction === CONST_ACTION_PLAY_VIDEO){ if(control.imgActionParam === undefined || jQuery.trim(control.imgActionParam) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else if(control.imgAction === CONST_ACTION_OPEN_WEB_PAGE){ if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(control.imgOpenWebPageParamType !== CONST_VALUE_OTHER){ if(control.imgActionParam === undefined || jQuery.trim(control.imgActionParam) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ if(control.imgOpenWebPageQues === undefined || jQuery.trim(control.imgOpenWebPageQues) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } var destinationControl = getControlById(control.imgOpenWebPageQues, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else if(control.imgOpenWebPageQues != undefined && control.imgOpenWebPageQues !== '__Constant__' && isVersion(VERSION_OPEN_WEB_PAGE_NEW)){ }else{ if(control.imgActionParam === undefined || jQuery.trim(control.imgActionParam) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else if(control.imgAction === lbl_sel_action_for_ctrl || control.imgAction === lbl_sel_action_for_btn || control.imgAction === lbl_sel_action_for_img){ retObj.error = 13; retObj.message = msg_bf_hintlink_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(control.imgAction === CONST_ACTION_JUMP_TO_QUES){ if(control.imgActionParamDesQues === lbl_sel_question || jQuery.trim(control.imgActionParamDesQues) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionParamDesQues, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else if(control.imgAction === CONST_ACTION_JUMP_TO_PAGE){ if(control.imgActionParamDesPage === lbl_sel_page || jQuery.trim(control.imgActionParamDesPage) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ switch(control.imgActionParamDesPage){ case 'top': case 'previous': case 'next': case 'bottom': case 'first': case 'last': if(isVersion(VERSION_ADD_OPTION_JTP)){ }else{ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } break; default: var destinationControl = getControlById(control.imgActionParamDesPage, controlsOrg); if(destinationControl == undefined || destinationControl.type != 'inputPageBreak'){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }else if(control.imgAction === CONST_ACTION_LAUNCH_GOOGLE_MAP || control.imgAction === CONST_ACTION_LAUNCH_GARMIN_DIRECTIONS){ var checkRouteTypeNRoute = false; if(control.mapActionGroup == CONST_MAP_ACTION_GROUP_ROUTE){ checkRouteTypeNRoute= true; } //if(isVersion(VERSION_GOOGLE_MAP_ROUTES)){ if(checkRouteTypeNRoute){ if(control.routeType === ''){ retObj.error = 13; retObj.message = msg_bf_route_type_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ if(control.route.start === ''){ retObj.error = 13; retObj.message = msg_bf_route_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(control.route.stops.length > 0){ for(var i = 0; i< control.route.stops.length; i++){ if(requiredError){ break; } var stop = control.route.stops[i]; if(stop.val === ''){ retObj.error = 13; retObj.message = msg_bf_route_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } if(!requiredError && control.hasTravelTime){ if(jQuery.trim(control.routeTravelTime) === ''){ retObj.error = 13; retObj.message = msg_bf_route_travel_time_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(jQuery.trim(control.routeTravelTimeField) === ''){ retObj.error = 13; retObj.message = msg_bf_route_travel_time_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError && control.hasRouteDistance){ if(jQuery.trim(control.routeDistance) === ''){ retObj.error = 13; retObj.message = msg_bf_route_distance_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(jQuery.trim(control.routeDistanceField) === ''){ retObj.error = 13; retObj.message = msg_bf_route_travel_distance_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError && control.hasRouteMap){ if(jQuery.trim(control.routeMap) === ''){ retObj.error = 13; retObj.message = msg_bf_route_map_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError && control.hasArrivalTime){ if(jQuery.trim(control.arrivalTime) === ''){ retObj.error = 13; retObj.message = msg_bf_arrival_time_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } //} if(!requiredError){ if(!isVersion(VERSION_GMAP_REMOVE_INPUT_SRC) && (control.imgActionParamMapInputSourceParam === lbl_sel_map_input_source_param_opt || jQuery.trim(control.imgActionParamMapInputSourceParam) === '')){ retObj.error = 13; retObj.message = msg_bf_act_param_map_input_source_param_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!checkRouteTypeNRoute){ if(control.imgActionParamMapLatLongParam === lbl_sel_map_lat_long_param_opt || jQuery.trim(control.imgActionParamMapLatLongParam) === ''){ retObj.error = 13; retObj.message = msg_bf_act_param_map_lat_long_param_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionParamMapLatLongParam, controlsOrg); if(!isVersion(VERSION_GMAP_REMOVE_INPUT_SRC)){ if(destinationControl == undefined || !checkInputSourcePosIsCorrected(controlsOrg, control.id, control.imgActionParamMapLatLongParam, control.imgActionParamMapInputSourceParam)){ retObj.error = 17; retObj.message = msg_bf_act_param_map_lat_long_param_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }else{ if(destinationControl == undefined || !checkInputSourcePosIsCorrected(controlsOrg, control.id, control.imgActionParamMapLatLongParam, control.imgActionParamMap)){ retObj.error = 17; retObj.message = msg_bf_act_param_map_lat_long_param_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } } } }else if(control.imgAction === 'Credit Card Payment'){ if(control.imgActionParamCCP_TransAmount === lbl_ccp_transaction_amount_opt || jQuery.trim(control.imgActionParamCCP_TransAmount) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionParamCCP_TransAmount, 'Amount')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionParamCCP_TransAmount, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else if(control.imgAction === CONST_ACTION_FLINT_APP){ if(control.imgActionParamFA_TransSubtotal === lbl_fa_transaction_subtotal_opt || jQuery.trim(control.imgActionParamFA_TransSubtotal) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionParamFA_TransSubtotal, 'Subtotal')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionParamFA_TransSubtotal, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } if(!requiredError){ if(control.imgActionParamFA_TransMemo === lbl_fa_transaction_memo_opt || jQuery.trim(control.imgActionParamFA_TransMemo) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionParamFA_TransMemo, 'Memo')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionParamFA_TransMemo, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }else if(control.imgAction === CONST_ACTION_PROPAY){ if(jQuery.trim(control.imgActionParamPP_Amount) === ''){ retObj.error = 13; retObj.message = msg_bf_paypro_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.imgActionParamPP_Amount, 'Amount')){ retObj.error = 13; retObj.message = msg_bf_paypro_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionParamPP_Amount, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_paypro_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } if(!requiredError){ if(jQuery.trim(control.imgActionParamPP_Currency) === ''){ retObj.error = 13; retObj.message = msg_bf_paypro_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else if(control.imgAction === CONST_ACTION_ONCLICK){ if(jQuery.trim(control.imgActionParamDesQues) === ''){ retObj.error = 13; retObj.message = msg_bf_onclick_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.imgActionParamDesQues, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_onclick_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(!checkOnClickDesPosIsCorrected(controlsOrg, control, control.imgActionParamDesQues)){ retObj.error = 17; retObj.message = msg_bf_onclick_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } }else if(control.imgAction === CONST_ACTION_OPEN_FORM){ if(isVersion(VERSION_OFE_SEND_DATA)){ if(control.imgActionParam_isSendValues === true){ if(control.imgActionParam_sendValues && control.imgActionParam_sendValues.length>0){ _.each(control.imgActionParam_sendValues, function(sendValuesItem){ if(requiredError){ return false; } if(valueOrEmpty(sendValuesItem.text.current_field) == CONST_EMPTY){ retObj.error = 17; retObj.message = msg_bf_current_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(valueOrEmpty(sendValuesItem.text.new_form_field) == CONST_EMPTY){ retObj.error = 17; retObj.message = msg_bf_new_form_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }); }else{ retObj.error = 17; retObj.message = msg_bf_send_values_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } if(isVersion(VERSION_OFE_RETURN_DATA)){ if(control.imgActionParam_isReturnValues === true){ if(control.imgActionParam_returnValues && control.imgActionParam_returnValues.length>0){ _.each(control.imgActionParam_returnValues, function(returnValuesItem){ if(requiredError){ return false; } if(valueOrEmpty(returnValuesItem.text.current_field) == CONST_EMPTY){ retObj.error = 17; retObj.message = msg_bf_current_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(valueOrEmpty(returnValuesItem.text.new_form_field) == CONST_EMPTY){ retObj.error = 17; retObj.message = msg_bf_new_form_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }); }else{ retObj.error = 17; retObj.message = msg_bf_return_values_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }else if(control.imgAction === CONST_ACTION_PRINT_MOBILE){ var printType = ''; if(isVersion(VERSION_ACTION_PRINTER)){ printType = control.imgActionParamPrinter; } switch(printType){ case CONST_PRN_ZEBRA: if(control.imgActionParamPrintFields && control.imgActionParamPrintFields.length > 0){ for(var i=0;i' + retObj.message + ''); requiredError = true; errorCode = 1; break; } } }/*else if(isVersion(VERSION_BROTHER_RJ_2150)){ retObj.error = 13; retObj.message = msg_bf_print_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }*/ break; default: if(valueOrEmpty(control.imgActionParamPrintPage) != '' && control.imgActionParamPrintPage != CONST_ALL){ var controlPage = getControlById(control.imgActionParamPrintPage, controlsOrg); if(controlPage == undefined){ retObj.error = 13; retObj.message = msg_bf_print_page_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }else if(control.imgAction === CONST_ACTION_ZEBRA_PRINT){ if(isVersion(VERSION_ACTION_ZEBRA_PRINT)){ var isPTouch = false; if(isVersion(VERSION_BROTHER_TEMPLATE_TYPE)){ if(control.zebraPrinter == CONST_BROTHER_RJ_2150 && control.brotherTemplateType === CONST_BROTHER_TEMPLATE_TYPE_PTOUCH){ isPTouch = true; } } if(isPTouch){ if(control.ptouchSettingFile == undefined || control.ptouchSettingFile == ''){ retObj.error = 13; retObj.message = msg_bf_ptouch_setting_file_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } if(!requiredError){ if(control.ptouchTemplateName == undefined || control.ptouchTemplateName == ''){ retObj.error = 13; retObj.message = msg_bf_ptouch_template_name_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError){ if(control.ptouchTemplateKey == undefined || control.ptouchTemplateKey == ''){ retObj.error = 13; retObj.message = msg_bf_ptouch_template_key_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError){ if(control.ptouchPrintFields && control.ptouchPrintFields.length > 0){ for(var i=0;i' + retObj.message + ''); requiredError = true; errorCode = 1; break; } if(noUseFieldName4Mapping && (mappingName == undefined || mappingName == '')){ retObj.error = 13; retObj.message = msg_bf_ptouch_map_field_name_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; break; } } } } }else{ if(control.zebraPrinter == CONST_BROTHER_RJ_2150 || control.zebraPrinter == CONST_PRN_BIXOLON){ if(control.printerSettingFile == undefined || control.printerSettingFile == ''){ retObj.error = 13; retObj.message = msg_bf_printer_setting_file_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError){ var isTwoColumn = false; switch(control.zebraPrinterColumn){ case CONST_TWO_STR: isTwoColumn = true; break; } var isManualPrint = true; if(isVersion(VERSION_ZEBRA_PRINT_TYPE)){ if(control.zebraPrinterType && control.zebraPrinterType != CONST_ZEBRA_PRINT_TYPE_MANUAL){ isManualPrint = false; } } if(isManualPrint){ if(control.zebraPrintColumns && control.zebraPrintColumns.length > 0){ for(var i=0;i' + retObj.message + ''); requiredError = true; errorCode = 1; break; } if(ctrlType != 'Blank' || ctrlId != '__blank__'){ if(ctrl == undefined){ retObj.error = 13; retObj.message = msg_bf_print_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; break; } } if(isTwoColumn){ ctrlId = item.column2.val; ctrlType = item.column2.type; ctrl = getControlById(ctrlId, controlsOrg); if(ctrlType == undefined || ctrlType == ''){ retObj.error = 13; retObj.message = msg_bf_print_field_type_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; break; } if(ctrlType != 'Blank' || ctrlId != '__blank__'){ if(ctrl == undefined){ retObj.error = 13; retObj.message = msg_bf_print_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; break; } } } } }else{ retObj.error = 13; retObj.message = msg_bf_print_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ if(control.zebraPrintFiles && control.zebraPrintFiles.length > 0){ for(var i=0;i' + retObj.message + ''); requiredError = true; errorCode = 1; break; } } }else{ retObj.error = 13; retObj.message = msg_bf_print_file_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } } }else if(control.imgAction === CONST_ACTION_OPEN_FILE){ if(control.ofRequired == CONST_REQ_CHOOSE_FILE){ if(control.openFile === undefined || jQuery.trim(control.openFile) === ''){ retObj.error = 13; retObj.message = msg_open_forms_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else if(control.ofRequired == CONST_REQ_CHOOSE_FILE_DISPATCH){ if(control.ofDispatchCaptionText === undefined || jQuery.trim(control.ofDispatchCaptionText) === ''){ retObj.error = 13; retObj.message = msg_of_choose_in_dispatch_caption_text; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }else if(control.imgAction === CONST_SET_STATUS_TO_GPS){ if(isVersion(VERSION_SET_STATUS_TO_GPS) && !requiredError){ if(control.statusText === undefined || jQuery.trim(control.statusText) === ''){ retObj.error = 13; retObj.message = msg_bf_status_text_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ switch(control.statusText){ case CONST_OTHER_QUES: if(valueOrEmpty(control.statusTextQuestion) == ''){ retObj.error = 13; retObj.message = msg_bf_status_text_ques_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.statusTextQuestion, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_status_text_ques_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ if (!checkCtrlPosIsCorrected(controlsOrg, control.statusTextQuestion, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, control.statusTextQuestion, control.id, true)){ retObj.error = 18; retObj.message = msg_bf_status_text_ques_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } } break; default: } } if(!requiredError){ if(control.statusType === undefined || jQuery.trim(control.statusType) === ''){ retObj.error = 13; retObj.message = msg_bf_status_type_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } }else if(control.imgAction === CONST_ACTION_AUDIT){ // CO-4561 Add Audit action to Action button start validateAuditInfo(controlsOrg, control, retObj, requiredError); // CO-4561 Add Audit action to Action button end } // CO-2254 Required field if (isAutoRun && control.autoActionStampTrigger != undefined && control.autoActionStampTrigger != '' && control.autoActionStampTrigger != lbl_action_select_a_trigger){ if(control.autoActionStampTrigger == '2' && (control.autoActionStampQuestionTrigger == undefined || control.autoActionStampQuestionTrigger == lbl_sel_question || control.autoActionStampQuestionTrigger == '')) { retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } // END CO-2254 if(isSetDestinationFields && isVersion(VERSION_ACTION_SET_DESTINATION_FIELD) && !requiredError){ var ctrlArr = []; var duplicateError = false; _.each(control.actionDestinationData, function(item){ if(item.text && item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined && !(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT))){ retObj.error = 17; retObj.message = msg_bf_skip_cond_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_destination_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(item.value.val.startsWith('Other')){ if(item.value.val === 'Other value'){ }else{ if(item.value.other_ctrl_id == undefined || jQuery.trim(item.value.other_ctrl_id) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }); }else if(isVersion(VERSION_ACTION_SET_DESTINATION_FIELD) && !requiredError && control.actionDestinationData4SDF){ var ctrlArr = []; var duplicateError = false; _.each(control.actionDestinationData4SDF, function(item){ if(item.text && item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined && !(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT))){ retObj.error = 17; retObj.message = msg_bf_skip_cond_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_destination_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(item.value.val.startsWith('Other')){ if(item.value.val === 'Other value'){ }else{ if(item.value.other_ctrl_id == undefined || jQuery.trim(item.value.other_ctrl_id) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }); } // CO-4022: Hide if start if(isVersion(VERSION_HIDE_IF) && !requiredError && control.isHideIfClick == true){ var ctrlArr = []; var duplicateError = false; _.each(control.hideIfFields, function(item){ if(item.text && item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_hide_if_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_hide_if_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_hide_if_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }); } // CO-4022: Hide if end // CO-4789:Add Retrieve form actions to action button start if(control.imgAction === CONST_ACTION_CLOSE_AND_RETRIEVE){ validateRetrieveInfo(controlsOrg, control, retObj, requiredError); }else if(control.imgAction === CONST_ACTION_SEND_AND_RETRIEVE){ validateRetrieveInfo(controlsOrg, control, retObj, requiredError); } // CO-4789:Add Retrieve form actions to action button end } }else if (control.type == CONST_CTRL_TYPE_INPUTPAYMENT){ if((control.useImage === undefined || control.useImage === true) && (control.hintLink === undefined || jQuery.trim(control.hintLink) === '')){ retObj.error = 13; retObj.message = msg_bf_hintlink_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(control.kind === 'Image' && (control.hintLink === undefined || jQuery.trim(control.hintLink) === '')){ retObj.error = 13; retObj.message = msg_bf_hintlink_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ if(control.payment_TransSubtotal === lbl_fa_transaction_subtotal_opt || jQuery.trim(control.payment_TransSubtotal) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.payment_TransSubtotal, 'Subtotal')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.payment_TransSubtotal, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } if(!requiredError){ if(control.payment_TransMemo === lbl_fa_transaction_memo_opt || jQuery.trim(control.payment_TransMemo) === ''){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else if(!checkTransactionParamByIdCorrectPos(controlsOrg, control.id, control.payment_TransMemo, 'Memo')){ retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var destinationControl = getControlById(control.payment_TransMemo, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }else if (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ var validateRet = validateNewPaymentInfo(controlsOrg, control, retObj, requiredError); if(validateRet.requiredError){ errorCode = 1; requiredError = true; } }else if (control.type == 'inputSaveAndSend'){ }else if (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(!control.isFaxWidget && control.defaultValue != undefined && control.defaultValue != ''){ var value = control.defaultValue; var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ var email = jQuery.trim(value.substring(0, contentStartPos)); var arrMails = email.replace(/;/g, ",").split(","); var repMailToFormatError = false; var blankCount = 0; for (var k = 0; k < arrMails.length; k++) { email = jQuery.trim(arrMails[k]); if(email != '' && !isEmailAddress(email)){ if(isVersion(VERSION_SUPPORT_SMS) && isValidMobileNumber(email)){ }else{ retObj.error = 4; retObj.message = msg_bf_mail_rep_mail_to_format; if(!repMailToFormatError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; repMailToFormatError = true; } } //return retObj; }else if(email == ''){ blankCount++; } } /*if(!repMailToFormatError && blankCount == arrMails.length){ retObj.error = 4; retObj.message = msg_bf_mail_rep_mail_to_format; if(!repMailToFormatError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; repMailToFormatError = true; } }*/ }else{ retObj.error = 4; retObj.message = msg_bf_mail_rep_mail_to_format; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ } // Prevent error when control.reportSettingBuildForm_2 === undefined // Check required field in Email Widget // with (.)Custom Report Template + Not choose Excel Template Item if (control.reportSettingBuildForm_2 !== undefined && control.reportSettingBuildForm_2.reportSettingBuildFormReportType === '2' && (control.reportSettingBuildForm_2.reportSettingBuildFormExcelTemplateKey === '' || control.reportSettingBuildForm_2.reportSettingBuildFormExcelTemplateKey === undefined) ) { retObj.error = 13; retObj.message = msg_bf_act_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ }else if (control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ if ((control.length !== undefined) && (control.length !== false)){ if(control.length.min == '' && control.length.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.length.min != '' && control.length.max != '' && (parseInt(control.length.max, 10) < parseInt(control.length.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.length.min == '0' && control.length.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.length.max != '' && parseInt(control.length.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if((control.length.min != '' && parseInt(control.length.min, 10) > 500) || (control.length.max != '' && parseInt(control.length.max, 10) > 500)){ if(control.kind !== 'Number'){ retObj.error = 19; retObj.message = msg_bf_min_max_gt_500; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); maxltMinError = true; errorCode = 1; //return retObj; } } if(control.defaultValue != undefined && control.defaultValue != ''){ //if(control.kind !== 'Number'){ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(control.defaultValue.length < parseInt(control.length.min, 10) || control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_min_max_len_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(control.defaultValue.length < parseInt(control.length.min, 10)){ retObj.error = 3; retObj.message = msg_bf_min_len_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_max_len_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } /*}else{ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10) || parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_max_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }*/ }else{ if(control.readOnly){ retObj.error = 10; retObj.message = msg_bf_def_val_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } } if(checkRetrictsLimitToListError(control, retObj)){ errorCode = 1; } if(control.datasource == undefined || jQuery.trim(control.datasource) == '' || lookupdatainf.lookupTables == undefined || lookupdatainf.lookupTables[control.datasource] == undefined){ if(!lookupdatainf.isSystemLookupTable(control.datasource)){ retObj.error = 20; retObj.message = msg_bf_data_src_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } //return retObj; } if(control.isRetrieve){ control.lookupfield = control.lookupfield4R; if(control.lookupConditionFields4R != undefined){ control.lookupConditionFields = control.lookupConditionFields4R.slice(); }else{ control.lookupConditionFields = undefined; } } if(control.lookupfield == undefined || jQuery.trim(control.lookupfield) == '' || lookupdatainf.LookupTablesHeaders == undefined || lookupdatainf.LookupTablesHeaders[control.datasource] == undefined || lookupdatainf.LookupTablesHeaders[control.datasource][control.lookupfield] == undefined){ if(!lookupdatainf.isSystemLookupTablesHeader(control.datasource, control.lookupfield)){ retObj.error = 21; retObj.message = msg_bf_lookup_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } if(isVersion(VERSION_LOW_FREQUENCY_BLUETOOTH) && control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ if(!requiredError){ if(control.lookupkey == undefined || jQuery.trim(control.lookupkey) == ''){ retObj.error = 21; retObj.message = msg_bf_bluetooth_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; }/*else if(!checkControlByIdCorrectPos(controlsOrg, control.lookupkey, control.id)){ retObj.error = 13; retObj.message = msg_bf_bluetooth_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var lookupkeyControl = getControlById(control.lookupkey, controlsOrg); if(lookupkeyControl == undefined){ retObj.error = 17; retObj.message = msg_bf_bluetooth_field_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }*/ } if(!requiredError){ /*if(control.bluetoothkey == undefined || jQuery.trim(control.bluetoothkey) == ''){ retObj.error = 21; retObj.message = msg_bf_bluetooth_key_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; }else if(!checkControlByIdCorrectPos(controlsOrg, control.bluetoothkey, control.id)){ retObj.error = 13; retObj.message = msg_bf_bluetooth_key_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; }else{ var lookupkeyControl = getControlById(control.bluetoothkey, controlsOrg); if(lookupkeyControl == undefined){ retObj.error = 17; retObj.message = msg_bf_bluetooth_key_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }*/ } } if(control.isRetrieve && !requiredError){ if(control.lookupValue == undefined || control.lookupValue.val == undefined || jQuery.trim(control.lookupValue.val) == ''){ // check required lookup value retObj.error = 21; retObj.message = msg_bf_lookup_value_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ var lookupValueControl = getControlById(control.lookupValue.val, controlsOrg); if(lookupValueControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }/*else if (!checkLookupConditionAnsByIdCorrectPos(controlsOrg, control.id, control.lookupValue)){ retObj.error = 18; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }*/ if(!requiredError && control.retrieveKind != "autoRun" && control.btnKind === 'Image' && (control.hintLink === undefined || jQuery.trim(control.hintLink) === '')){ retObj.error = 13; retObj.message = msg_bf_hintlink_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!control.isModifyOnly && !control.isRetrieve && (!control.destinationdataconds || control.destinationdataconds.length == 0)){ retObj.error = 13; retObj.message = msg_bf_destination_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } if(!requiredError && control.retrieveKind == CONST_TYPE_AUTO_RUN){ if(control.autoActionStampTriggerRetrieve != undefined && (control.autoActionStampTriggerRetrieve == '2')){ var autoActionStampQuestionTriggerRetrieve = getControlById(control.autoActionStampQuestionTriggerRetrieve, controlsOrg); if(control.autoActionStampQuestionTriggerRetrieve == undefined || autoActionStampQuestionTriggerRetrieve == undefined){ retObj.error = 13; retObj.message = msg_bf_retrieve_question_trigger_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } if(control.maxRows && parseInt(control.maxRows) > 5000){ retObj.error = 21; retObj.message = lbl_lu_max_rows_gt_5000_err; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } if(control.lookupConditionFields != undefined && control.lookupConditionFields.length > 0){ var ctrlArr = []; var duplicateError = false; var datasourceDiff = false; _.each(control.lookupConditionFields, function(item){ var itemCondOperator = item.condOperator ? item.condOperator.val : undefined; if(item.text.val != undefined){ // CO-2693 | fix bug: required field when is_empty and not_is_empty condition selected if(item.condAnswerType && item.condAnswerType.val.toLowerCase() == 'other' && itemCondOperator != CONST_VALUE_IS_EMPTY && itemCondOperator != CONST_VALUE_NOT_IS_EMPTY) { var destinationControl = ''; destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } /*// CO-1868 - Do not need check duplicate condition fields else if (!checkLookupConditionAnsByIdCorrectPos(controlsOrg, control.id, item.text.val)){ retObj.error = 18; retObj.message = msg_bf_act_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } * /// CO-1868 - Do not need check duplicate condition fields else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_lookup_condition_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } } */ else{ ctrlArr.push(item.text.val); } } } // CO-1868 - Check valid date only other is selected + CO-2693 | fix bug: required field when is_empty and not_is_empty condition selected if(item.condAnswerType && item.condAnswerType.val.toLowerCase() == 'other' && (item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == '') && itemCondOperator != CONST_VALUE_IS_EMPTY && itemCondOperator != CONST_VALUE_NOT_IS_EMPTY){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } if(isVersion2_12()){ if(item.text == undefined || item.text.valCond == undefined || jQuery.trim(item.text.valCond) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } }else{ if(!datasourceDiff){ // data source different if(item.text != undefined && item.text.val != undefined && jQuery.trim(item.text.val) != '' && control.datasource !== lookupDatasourceArray[item.text.val]){ retObj.error = 24; retObj.message = msg_bf_lookup_condition_datasource_diff_error; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; datasourceDiff = true; } } } }); } var ctrlArr = []; var duplicateError = false; var fillTable = null; _.each(control.destinationdataconds, function(item){ // CO-4086 Add user variables as destination field targets if(item.text.val != undefined && !(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT))){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined || (destinationControl.type == CONST_CTRL_TYPE_INPUTACTION && destinationControl.imgAction != CONST_ACTION_LAUNCH_GOOGLE_MAP && destinationControl.imgAction != CONST_ACTION_LAUNCH_GARMIN_DIRECTIONS)){ retObj.error = 17; retObj.message = msg_bf_skip_cond_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_lookup_destination_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else if (!checkLUDestinationByIdCorrectPos(controlsOrg, control.isRetrieve, control.id, item.text.val)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ var tableName = null; if(!lookupdatainf.LookupTablesHeaders4BF || !lookupdatainf.LookupTablesHeaders4BF[control.datasource]){ lookupdatainf.makeLookupTablesHeaders4BF(control.datasource); } if(lookupdatainf.LookupTablesHeaders4BF && lookupdatainf.LookupTablesHeaders4BF[control.datasource]){ tableName = lookupdatainf.LookupTablesHeaders4BF[control.datasource][item.value.val]; } if(tableName != null){ if(fillTable == null){ fillTable = tableName; } } if(fillTable && tableName && fillTable != tableName){ retObj.error = 1; retObj.message = msg_bf_des_tbl_fill_dif; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; }else{ ctrlArr.push(item.text.val); } } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ if(!item.value.val.startsWith(CONST_BT_PARSE_PREFIX)){ if(!lookupdatainf.hasTableColumnHeader(control.datasource, item.value.val)){ if(!lookupdatainf.isSystemLookupTablesHeader(control.datasource, item.value.val)){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } } }); if(control.isModifyOnly){ _.each(control.modifyFields, function(item){ if(item.action.val != CONS_RETRIVE_ACTION_CLEAR_VALUE && (item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == '')){ retObj.error = 22; retObj.message = msg_bf_modify_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_modify_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } }); if(isVersion(VERSION_AUTO_RUN_MODIFY) && !requiredError && control.modifyKind == CONST_TYPE_AUTO_RUN){ if(control.autoActionStampTriggerModify != undefined){ if(control.autoActionStampTriggerModify == '2'){ var autoActionStampQuestionTriggerModify = getControlById(control.autoActionStampQuestionTriggerModify, controlsOrg); if(control.autoActionStampQuestionTriggerModify == undefined || autoActionStampQuestionTriggerModify == undefined){ retObj.error = 13; retObj.message = msg_bf_modify_question_trigger_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else if(control.autoActionStampTriggerModify == '32'){ // on retrieve if(control.isRetrieveDS == false){ retObj.error = 13; retObj.message = msg_bf_retrieve_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end // CO-4750: Add set destination fields option to Retrieve / Modify if(checkSetDestinationFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4750: Add set destination fields option to Retrieve / Modify }else if (control.type == 'inputFacingTable'){ if ((control.length !== undefined) && (control.length !== false)){ if(control.length.min == '' && control.length.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.length.min != '' && control.length.max != '' && (parseInt(control.length.max, 10) < parseInt(control.length.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.length.min == '0' && control.length.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.length.max != '' && parseInt(control.length.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if((control.length.min != '' && parseInt(control.length.min, 10) > 500) || (control.length.max != '' && parseInt(control.length.max, 10) > 500)){ if(control.kind !== 'Number'){ retObj.error = 19; retObj.message = msg_bf_min_max_gt_500; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); maxltMinError = true; errorCode = 1; //return retObj; } } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.kind !== 'Number'){ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(control.defaultValue.length < parseInt(control.length.min, 10) || control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_min_max_len_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(control.defaultValue.length < parseInt(control.length.min, 10)){ retObj.error = 3; retObj.message = msg_bf_min_len_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_max_len_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10) || parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_max_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } } }else{ if(control.readOnly){ retObj.error = 10; retObj.message = msg_bf_def_val_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } } if(control.datasource == undefined || jQuery.trim(control.datasource) == '' || lookupdatainf.lookupTables == undefined || lookupdatainf.lookupTables[control.datasource] == undefined){ if(!lookupdatainf.isSystemLookupTable(control.datasource)){ retObj.error = 20; retObj.message = msg_bf_data_src_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } //return retObj; } if(control.storeid == undefined || jQuery.trim(control.storeid) == ''){ retObj.error = 21; retObj.message = msg_bf_storeid_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } if(control.aislevalue == undefined || jQuery.trim(control.aislevalue) == ''){ retObj.error = 21; retObj.message = msg_bf_storeid_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } if(control.aislecolumn == undefined || jQuery.trim(control.aislecolumn) == ''){ retObj.error = 21; retObj.message = msg_bf_storeid_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } var ctrlArr = []; var duplicateError = false; _.each(control.destinationdataconds, function(item){ if(item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_skip_cond_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_lookup_destination_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else if (!checkControlSkipByIdCorrectPos(controlsOrg, control.id, item.text.val)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } }); }else if (control.type == 'inputLookupMulti'){ if ((control.length !== undefined) && (control.length !== false)){ if(control.length.min == '' && control.length.max == ''){ retObj.error = 1; retObj.message = msg_bf_max_min_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.length.min != '' && control.length.max != '' && (parseInt(control.length.max, 10) < parseInt(control.length.min, 10))){ retObj.error = 2; retObj.message = msg_bf_max_lt_min; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; maxltMinError = true; //return retObj; }else if(control.length.min == '0' && control.length.max == '0'){ retObj.error = 2; retObj.message = msg_bf_min_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if(control.required && control.length.max != '' && parseInt(control.length.max, 10) == 0){ retObj.error = 14; retObj.message = msg_bf_required_and_max_zero; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; }else if((control.length.min != '' && parseInt(control.length.min, 10) > 500) || (control.length.max != '' && parseInt(control.length.max, 10) > 500)){ if(control.kind !== 'Number'){ retObj.error = 19; retObj.message = msg_bf_min_max_gt_500; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); maxltMinError = true; errorCode = 1; //return retObj; } } if(control.defaultValue != undefined && control.defaultValue != ''){ if(control.kind !== 'Number'){ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(control.defaultValue.length < parseInt(control.length.min, 10) || control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_min_max_len_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(control.defaultValue.length < parseInt(control.length.min, 10)){ retObj.error = 3; retObj.message = msg_bf_min_len_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(control.defaultValue.length > parseInt(control.length.max, 10)){ retObj.error = 3; retObj.message = msg_bf_max_len_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else{ if(control.length.min != '' && control.length.max != ''){ if(!maxltMinError){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10) || parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_max_of_def_val.replace('$1', control.length.min).replace('$2', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } }else if(control.length.min != ''){ if(parseInt(control.defaultValue, 10) < parseInt(control.length.min, 10)){ retObj.error = 4; retObj.message = msg_bf_num_min_of_def_val.replace('$1', control.length.min); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } }else{ if(parseInt(control.defaultValue, 10) > parseInt(control.length.max, 10)){ retObj.error = 4; retObj.message = msg_bf_num_max_of_def_val.replace('$1', control.length.max); $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; //return retObj; } } } }else{ if(control.readOnly){ retObj.error = 10; retObj.message = msg_bf_def_val_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } } if(control.datasource == undefined || jQuery.trim(control.datasource) == '' || lookupdatainf.lookupTables == undefined || lookupdatainf.lookupTables[control.datasource] == undefined){ if(!lookupdatainf.isSystemLookupTable(control.datasource)){ retObj.error = 20; retObj.message = msg_bf_data_src_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } //return retObj; }else if(control.lookupMultiFields == undefined || control.lookupMultiFields.length == 0){ retObj.error = 21; retObj.message = msg_bf_lookup_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ var ctrlArrLookupFields = []; var duplicateErrorLookupFields = false; var hasLookupField = false; _.each(control.lookupMultiFields, function(item){ hasLookupField = true; if(item.text.val != undefined){ if(jQuery.inArray(item.text.val, ctrlArrLookupFields) >= 0){ retObj.error = 22; retObj.message = msg_bf_lookup_field_duplicate_error; if(!duplicateErrorLookupFields){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateErrorLookupFields = true; } }else{ ctrlArrLookupFields.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } }); if(!hasLookupField){ retObj.error = 21; retObj.message = msg_bf_lookup_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } var ctrlArr = []; var duplicateError = false; _.each(control.destinationdataconds, function(item){ if(item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_skip_cond_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_lookup_destination_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else if (!checkControlSkipByIdCorrectPos(controlsOrg, control.id, item.text.val)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_lookup_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } }); } }else if (control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(control.kind == CONST_VALUE_DATE){ control.useCurrentcySymbol = false; control.currency = ''; } if(control.useCurrentcySymbol != undefined && control.useCurrentcySymbol == true){ if(control.currency == undefined || control.currency == '' || control.currency == 'None'){ retObj.error = 26; retObj.message = msg_bf_currency_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } var calculationCheckExpressionsRequired = function(expressions, ctrlKind, controlParrent, useChecklistObjMap) { var i = 0; var operator = ''; var operation = ''; var operation1 = ''; retObj.error = 0; _.each(expressions, function(item){ if(retObj.error != 0){ return false; } if(item.group != undefined && item.group.length > 0){ operator = item.text.operator; if(i != 0){ if(operator == undefined || operator == ''){ retObj.error = 22; retObj.message = msg_bf_required_fields_blank; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } }else{ } calculationCheckExpressionsRequired(item.group, ctrlKind, controlParrent, useChecklistObjMap); i++; }else{ operator = item.text.operator; operation = item.text.operation; operation1 = item.text.operation; var isPreviousCal = false; if(operator && operator.myIncludes(CONST_PREVIOUS)){ isPreviousCal = true; } var dontCheckExp2ForDate = false; if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation1; if(item.text.hasExp2 == false){ dontCheckExp2ForDate = true; } } var otherValue = false; var checkSum = false; var checkCount = false; if(operation == undefined || operation == 'Other value' || operation == 'Other sum' || operation == 'Other count' || operation == CONST_OTHER_DAY_OF_MONTH || operation == CONST_OTHER_DAY_NAME || operation == CONST_OTHER_WEEK_NAME || operation == CONST_OTHER_WEEK_NUMBER || operation == CONST_OTHER_MONTH_NAME || operation == CONST_OTHER_MONTH_NUMBER || operation == CONST_OTHER_YEAR_NUMBER || operation == CONST_OTHER_YEAR_NAME){ if(operation != undefined && operation == 'Other value'){ if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation_other_val1; }else{ operation = item.text.operation_other_val; } otherValue = true; }else if(operation != undefined && operation == 'Other sum'){ if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation_other_sum1; }else{ operation = item.text.operation_other_sum; } otherValue = true; checkSum = true; }else if(operation != undefined && operation == 'Other count'){ if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation_other_count1; }else{ operation = item.text.operation_other_count; } otherValue = true; checkCount = true; }else if(operation != undefined && operation == CONST_OTHER_DAY_OF_MONTH){ operation = item.text.operation_other_part_of_date; otherValue = true; checkCount = false; }else if(operation != undefined && operation == CONST_OTHER_WEEK_NUMBER){ operation = item.text.operation_other_part_of_date; otherValue = true; checkCount = false; }else if(operation != undefined && operation == CONST_OTHER_MONTH_NUMBER){ operation = item.text.operation_other_part_of_date; otherValue = true; checkCount = false; }else if(operation != undefined && operation == CONST_OTHER_YEAR_NUMBER){ operation = item.text.operation_other_part_of_date; otherValue = true; checkCount = false; }else if(operation != undefined && operation == CONST_OTHER_DAY_NAME){ operation = item.text.operation_other_part_of_date_str; otherValue = true; checkCount = false; }else if(operation != undefined && operation == CONST_OTHER_MONTH_NAME){ operation = item.text.operation_other_part_of_date_str; otherValue = true; checkCount = false; }else if(operation != undefined && operation == CONST_OTHER_WEEK_NAME){ operation = item.text.operation_other_part_of_date_str; otherValue = true; checkCount = false; }else if(operation != undefined && operation == CONST_OTHER_YEAR_NAME){ operation = item.text.operation_other_part_of_date_str; otherValue = true; checkCount = false; }else{ if(ctrlKind == CONST_VALUE_DATE){ operation = item.text.operation_other_sum1; }else{ operation = item.text.operation_other_sum; } otherValue = true; } } if(((operation == undefined || operation == '') && !dontCheckExp2ForDate) || (ctrlKind == CONST_VALUE_DATE && (operation1 == undefined || operation1 == ''))){ retObj.error = 22; retObj.message = msg_bf_required_fields_blank; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return false; }else if(checkSum){ var calOperationControl = getControlById(operation, controlsOrg); if(operation != undefined && operation.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ if(controlParrent != undefined && controlParrent.type == CONST_CTRL_TYPE_CTRLTABLE){ var arr = operation.split('__'); if(arr.length != 2 || useChecklistObjMap[controlParrent.name] != arr[1]){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } //return false; }else if(calOperationControl == undefined && (operation == undefined || !operation.startsWith(CONST_DATASOURCE_HEADER_PREFIX))){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return false; }else if (!checkCalculateSumCtrlPosIsCorrected(controlsOrg, ctrlKind, control.id, operation)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }else if(checkCount){ var calOperationControl = getControlById(operation, controlsOrg); if(operation != undefined && operation.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ if(controlParrent != undefined && controlParrent.type == CONST_CTRL_TYPE_CTRLTABLE){ var arr = operation.split('__'); if(arr.length != 2 || useChecklistObjMap[controlParrent.name] != arr[1]){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } //return false; }else if(calOperationControl == undefined && (operation == undefined || !operation.startsWith(CONST_DATASOURCE_HEADER_PREFIX))){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return false; }else if (!checkCalculateCountCtrlPosIsCorrected(controlsOrg, ctrlKind, control.id, operation)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } if(ctrlKind == CONST_VALUE_DATE && operation1 != undefined){ var operationControl1 = getControlById(operation1, controlsOrg); if(!isVersion3_2()){ if(operationControl1 != undefined && ctrlKind == CONST_VALUE_DATE && operationControl1.kind == CONST_VALUE_TIME){ operationControl1 = undefined; } } var isCheckError = true; if(isVersion(VERSION_START_DURATION_OPTION)){ switch(operation1){ case CONST_DURATION_HOURS: case CONST_DURATION_MINUTES: case CONST_DURATION_TOTAL_HOURS: case CONST_DURATION_TOTAL_MINUTES: case CONST_SCHEDULER_START_DATE: case CONST_SCHEDULER_START_TIME: case CONST_SCHEDULER_START_DATE_TIME: case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: isCheckError = false; break; case 'Other sum': if(item.text.operation_other_sum && item.text.operation_other_sum.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ isCheckError = false; } break; default: if(operation1.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isCheckError = false; } } } if(isCheckError){ if(operationControl1 == undefined){ retObj.error = 22; retObj.message = msg_bf_ctrl_in_required_field_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return false; }else if (!checkCalculateCtrlPosIsCorrected(controlsOrg, ctrlKind, control.id, operation1, isPreviousCal)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } if(!otherValue){ var operationControl = getControlById(operation, controlsOrg); if(!isVersion3_2()){ if(operationControl!= undefined && ctrlKind == CONST_VALUE_DATE && operationControl.type == CONST_CTRL_TYPE_INPUTDATE && operationControl.kind == CONST_VALUE_TIME){ operationControl = undefined; } } var isUserVariable = false; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(operation && operation.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; } } if(isVersion(VERSION_START_DURATION_OPTION)){ switch(operation){ case CONST_DURATION_HOURS: case CONST_DURATION_MINUTES: case CONST_DURATION_TOTAL_HOURS: case CONST_DURATION_TOTAL_MINUTES: case CONST_SCHEDULER_START_DATE: case CONST_SCHEDULER_START_TIME: case CONST_SCHEDULER_START_DATE_TIME: case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: isUserVariable = true; break; case 'Other sum': if(item.text.operation_other_sum1 && item.text.operation_other_sum1.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ isUserVariable = false; } break; default: if(operation.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; } } } if(!isUserVariable){ if(!dontCheckExp2ForDate && operationControl == undefined && operation != 'Space' && operation != 'NickName()' && operation != 'MobileID()' && operation != 'DeviceID()' && operation != 'MobileEmail()' && operation != 'WebUserEmail()'){ // Calculation string retObj.error = 22; retObj.message = msg_bf_ctrl_in_required_field_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return false; }else if(ctrlKind == CONST_VALUE_DATE && !dontCheckExp2ForDate){ if(operator == undefined || operator == ''){ retObj.error = 22; retObj.message = msg_bf_required_fields_blank; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }/*else if(operator == '+'){ if(operationControl.type == CONST_CTRL_TYPE_INPUTDATE){ retObj.error = 27; retObj.message = msg_bf_ctrl_cal_date_add_date_err; } }*/ } if (operationControl != undefined && !checkCalculateCtrlPosIsCorrected(controlsOrg, ctrlKind, control.id, operation, isPreviousCal)){ item.text.operation = ''; retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } if(i != 0){ if(operator == undefined || operator == ''){ retObj.error = 22; retObj.message = msg_bf_required_fields_blank; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } }else{ } if(ctrlKind == CONST_VALUE_DATE){ if(operation1 != undefined){ var operationControl1 = getControlById(operation1, controlsOrg); if(operationControl1 == undefined){ var isError = true; if(isVersion(VERSION_START_DURATION_OPTION)){ switch(operation1){ case CONST_DURATION_HOURS: case CONST_DURATION_MINUTES: case CONST_DURATION_TOTAL_HOURS: case CONST_DURATION_TOTAL_MINUTES: case CONST_SCHEDULER_START_DATE: case CONST_SCHEDULER_START_TIME: case CONST_SCHEDULER_START_DATE_TIME: case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: isError = false; break; case 'Other sum': if(item.text.operation_other_sum && item.text.operation_other_sum.startsWith(CONST_DATASOURCE_HEADER_PREFIX)){ if(controlParrent != undefined && controlParrent.type == CONST_CTRL_TYPE_CTRLTABLE){ var arr = item.text.operation_other_sum.split('__'); if(arr.length != 2 || useChecklistObjMap[controlParrent.name] != arr[1]){ isError = true; break; } } isError = false; } break; default: if(operation1.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isError = false; } } } if(isError){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return false; } } } /*if(!requiredError){ if (!checkCalculateCtrlPosIsCorrected(controlsOrg, ctrlKind, control.id, operation1)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } if(!requiredError){ if (!checkCalculateCtrlPosIsCorrected(controlsOrg, ctrlKind, control.id, operation)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }*/ } } i++; }); }; if(control.expression == undefined || control.expression.length == 0){ retObj.error = 22; retObj.message = msg_bf_required_fields_blank; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else{ calculationCheckExpressionsRequired(control.expression, control.kind, controlParrent, useChecklistObjMap); } if(retObj.error != 0){ errorCode = 1; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end /*}else if (control.type == 'inputRIF'){*/ }else if (control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ var optionKind = ''; if(isVersion(VERSION_CHOOSE_ONE_SLIDER)){ if(control.optionKind != undefined){ optionKind = control.optionKind; } } if(optionKind == CONST_CHOOSE_ONE_SWITCH){ if(control.switchOption == CONST_SWITCH_CUSTOM){ if(control.switchCustomOn == undefined || control.switchCustomOn == ''){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(control.switchCustomOff == undefined || control.switchCustomOff == ''){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } if(!requiredError){ var optionValueList = {}; if(optionValueList[control.switchCustomOn.toLowerCase()] == undefined){ optionValueList[control.switchCustomOn.toLowerCase()] = control.switchCustomOn; } if(optionValueList[control.switchCustomOff.toLowerCase()] == undefined){ optionValueList[control.switchCustomOff.toLowerCase()] = control.switchCustomOff; } optionMap[control.name] = optionValueList; } }else{ var optionValueList = {}; var underlyingConflictError = false; _.each(control.options, function(option){ if (option.isShowUnderlying !== undefined){ return true; } if(optionValueList[option.val.toLowerCase()] == undefined){ optionValueList[option.val.toLowerCase()] = option.val; } }); optionMap[control.name] = optionValueList; } }else{ if(control.options == undefined || control.options.length == 0){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(control.options.length == 1 && control.options[0].isShowUnderlying !== undefined){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ var optionValueList = {}; var underlyingConflictError = false; _.each(control.options, function(option){ if (option.isShowUnderlying !== undefined){ return true; } if(option.text == undefined || option.text['eng'] == undefined || jQuery.trim(option.text['eng']) == ''){ retObj.error = 9; retObj.message = msg_bf_option_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(option.val == undefined || option.val == ''){ retObj.error = 9; retObj.message = msg_bf_option_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ if(optionValueList[option.val.toLowerCase()] == undefined){ optionValueList[option.val.toLowerCase()] = option.val; }else{ retObj.error = 12; retObj.message = msg_bf_option_underlying_conflict; if(!underlyingConflictError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; underlyingConflictError = true; } //return retObj; } } }); optionMap[control.name] = optionValueList; } } // CO-4022: Hide if start if(checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj)){ errorCode = 1; requiredError = true; } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(control.scoreCategory == undefined || trim(control.scoreCategory) == ''){ retObj.error = 9; retObj.message = msg_bf_category_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(control.options == undefined || control.options.length == 0){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(control.options.length == 1 && control.options[0].isShowUnderlying !== undefined){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ var optionValueList = {}; var underlyingConflictError = false; _.each(control.options, function(option){ if (option.isShowUnderlying !== undefined){ return true; } if(option.text == undefined || option.text['eng'] == undefined || jQuery.trim(option.text['eng']) == ''){ retObj.error = 9; retObj.message = msg_bf_option_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(option.val == undefined || option.val == ''){ retObj.error = 9; retObj.message = msg_bf_option_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ if(optionValueList[option.val.toLowerCase()] == undefined){ optionValueList[option.val.toLowerCase()] = option.val; }else{ retObj.error = 12; retObj.message = msg_bf_option_underlying_conflict; if(!underlyingConflictError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; underlyingConflictError = true; } //return retObj; } } }); optionMap[control.name] = optionValueList; } }else if (control.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(control.options == undefined || control.options.length == 0){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(control.options.length == 1 && control.options[0].isShowUnderlying !== undefined){ retObj.error = 8; retObj.message = msg_bf_option_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ var optionValueList = {}; var underlyingConflictError = false; _.each(control.options, function(option){ if (option.isShowUnderlying !== undefined){ return true; } if(option.text == undefined || option.text['eng'] == undefined || jQuery.trim(option.text['eng']) == ''){ retObj.error = 9; retObj.message = msg_bf_option_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else if(option.val == undefined || option.val == ''){ retObj.error = 9; retObj.message = msg_bf_option_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ if(optionValueList[option.val.toLowerCase()] == undefined){ optionValueList[option.val.toLowerCase()] = option.val; }else{ retObj.error = 12; retObj.message = msg_bf_option_underlying_conflict; if(!underlyingConflictError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; underlyingConflictError = true; } //return retObj; } } }); optionMap[control.name] = optionValueList; } // CO-4022: Hide if start if(isVersion(VERSION_HIDE_IF) && !requiredError && control.isHideIfChecked == true){ var ctrlArr = []; var duplicateError = false; _.each(control.hideIfFields, function(item){ if(item.text && item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_hide_if_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_hide_if_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_hide_if_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }); } // CO-4022: Hide if end }else if (control.type == CONST_CTRL_TYPE_INPUTGEOFENCE){ var validateRet = validateGeofenceInfo(controlsOrg, control, retObj, requiredError); if(validateRet.requiredError){ errorCode = 1; requiredError = true; } }else if (control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ var validateRet = validateShippingInfo(controlsOrg, control, retObj, requiredError); if(validateRet.requiredError){ errorCode = 1; requiredError = true; } }else{ } if(checkRequiredAndReadOnlyError(control, retObj)){ errorCode = 1; } var isShowSkipCondition = true; if(isVersion(VERSION_NEW_TOOL_LAYOUT)){ if(control.isShowSkipCondition == false){ isShowSkipCondition = false; control.skipconds = []; } } if(isIgnoreSkip(control.parentCtrlType)){ isShowSkipCondition = false; } if(!isFreeAccount() && control.skipconds != undefined && control.skipconds[0] != undefined && isShowSkipCondition){ showSkipWrning = true; var skipToControl = getControlById(control.skipconds[0].text['eng'], controlsOrg); if(skipToControl != undefined && skipToControl.type == 'inputPageBreak'){ skipToControl = undefined; } if(control.skipconds[0].text['eng'] == undefined){ control.skipconds[0].text['eng'] = CONST_JUMP_EOF_VAL; } if(skipToControl == undefined && control.skipconds[0].text['eng'] != CONST_JUMP_EOF_VAL){ retObj.error = 17; retObj.message = msg_bf_skip_cond_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; }else{ //var internal = odkmaker.data.extract(); if(control.skipconds[0].text['eng'] != CONST_JUMP_EOF_VAL){ if (!checkControlSkipByIdCorrectPos(controlsOrg, control.id, control.skipconds[0].text['eng'])){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_up; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } retObj.error = 0; _.each(control.skipconds, function(skipCond){ if(retObj.error != 0){ return false; } switch(skipCond.text[CONST_VAL]){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: return true; } if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS || control.type == CONST_CTRL_TYPE_INPUTDATE || control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(skipCond.value[CONST_VAL] == undefined || jQuery.trim(skipCond.value[CONST_VAL]) == ''){ retObj.error = 17; retObj.message = msg_bf_skip_cond_all_required; return false; } } if(!isConditionValueValid(skipCond.value[CONST_VAL])){ retObj.error = 17; retObj.message = msg_bf_following_val_invalid; //return retObj; } }); if(retObj.error != 0){ errorCode = 1; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } return retObj; } } var isShowRelevanceCondition = true; if(isVersion(VERSION_NEW_TOOL_LAYOUT)){ if(control.isShowRelevanceCondition == false){ isShowRelevanceCondition = false; control.relevanceconds = []; } } if(isIgnoreRelevance(control.parentCtrlType)){ isShowRelevanceCondition = false; } if(!isFreeAccount() && control.relevanceconds != undefined && control.relevanceconds[0] != undefined && isShowRelevanceCondition){ retObj.error = 0; _.each(control.relevanceconds, function(relevanceCond){ if(retObj.error != 0){ return false; } if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_NUMERIC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTTRENDS || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTDATE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTCOUNTER){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: if(relevanceCond.value[CONST_VAL] == undefined || jQuery.trim(relevanceCond.value[CONST_VAL]) == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; return false; } } } var relevanceControl = getControlById(relevanceCond.text['eng'], controlsOrg); if(relevanceControl == undefined){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false; /*}else if(relevanceCond.text[CONST_VALUE_CTRLTYPE] && relevanceCond.text[CONST_VALUE_CTRLTYPE] != relevanceControl.type){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false;*/ }else if(relevanceControl.type != relevanceCond.text.ctrlType){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false; }else{ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: if(relevanceCond.value && relevanceCond.value.cmpType == '' && relevanceCond.value.val != ''){ switch(relevanceControl.kind){ case CONST_CTRL_KIND_NUMBER: try{ if(isNaN(parseFloat(relevanceCond.value.val))){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_changed; return false; } }catch(ex){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_changed; return false; } break; } } if(relevanceCond.value[CONST_CMP_TYPE] != CONST_VALUE_OTHER){ if(relevanceControl.kind == CONST_VALUE_DATE_SPACE_TIME){ if(!isValidDateTime(jQuery.trim(relevanceCond.value[CONST_VAL]), DATE_TYPE_DATE_TIME)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.kind == CONST_VALUE_TIME){ if(!isValidDateTime(jQuery.trim(relevanceCond.value[CONST_VAL]), DATE_TYPE_TIME)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.kind == CONST_VALUE_DATE && relevanceControl.type != CONST_CTRL_TYPE_INPUTCALCULATE){ if(!isValidDateTime(jQuery.trim(relevanceCond.value[CONST_VAL]), DATE_TYPE_DATE)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.kind == 'Integer'){ if(jQuery.trim(relevanceCond.value[CONST_VAL]).indexOf(".") != -1){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(jQuery.trim(relevanceCond.value[CONST_VAL]) != '' && (optionMap[relevanceControl.name] == undefined || optionMap[relevanceControl.name][relevanceCond.value[CONST_VAL].toLowerCase()] == undefined)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(jQuery.trim(relevanceCond.value[CONST_VAL]) != '' && (optionMap[relevanceControl.name] == undefined || optionMap[relevanceControl.name][relevanceCond.value[CONST_VAL].toLowerCase()] == undefined)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(relevanceControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(jQuery.trim(relevanceCond.value[CONST_VAL]) != '' && (optionMap[relevanceControl.name] == undefined || optionMap[relevanceControl.name][relevanceCond.value[CONST_VAL].toLowerCase()] == undefined)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else{ if(!isConditionValueValid(relevanceCond.value[CONST_VAL])){ retObj.error = 7; retObj.message = msg_bf_following_val_invalid; //return retObj; } } if (!checkCtrlPosIsCorrected(controlsOrg, relevanceCond.text['eng'], control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, relevanceCond.text['eng'], control.id, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } }else{ var isUserVariable = false; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(relevanceCond.value.val && relevanceCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; } } if(!isUserVariable){ if (!checkCtrlPosIsCorrected(controlsOrg, relevanceCond.value[CONST_VAL], control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, relevanceCond.value[CONST_VAL], control.id, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } if(!isRelevanceConditionTheSameKind(controlsOrg, relevanceCond.text['eng'], relevanceCond.value[CONST_VAL])){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } } if (!checkCtrlPosIsCorrected(controlsOrg, relevanceCond.text['eng'], control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, relevanceCond.text['eng'], control.id, true)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } }); if(retObj.error != 0){ errorCode = 1; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } var isShowITECondition = true; if(isVersion(VERSION_NEW_TOOL_LAYOUT)){ if(control.isShowITE == undefined || control.isShowITE == false){ isShowITECondition = false; control.iteConditions = []; } } if(!isFreeAccount() && control.iteConditions && control.iteConditions.conditions != undefined && control.iteConditions.conditions[0] != undefined && isShowITECondition){ retObj.error = 0; _.each(control.iteConditions.conditions, function(iteCond){ if(retObj.error != 0){ return false; } if(iteCond.text['eng'] == undefined || jQuery.trim(iteCond.text['eng']) == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; return false; } if(valueOrEmpty(iteCond.text[CONST_VAL]) == ''){ retObj.error = 18; retObj.message = msg_bf_ite_cmp_type_required; return false; } if(iteCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_NUMERIC || iteCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTTRENDS || iteCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTDATE || iteCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTCOUNTER){ switch(iteCond.text[CONST_VAL]){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: if(iteCond.value[CONST_VAL] == undefined || jQuery.trim(iteCond.value[CONST_VAL]) == ''){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; return false; } } } var iteCondId = iteCond.text['eng']; var isPreviousIteCondField = false; if(iteCondId && iteCondId.myIncludes(CONST_PREVIOUS)){ isPreviousIteCondField = true; iteCondId = iteCondId.replace(CONST_PREVIOUS + ' ', ''); } var iteControl = getControlById(iteCondId, controlsOrg); if(iteControl == undefined || !isCorrectIteControlType(iteControl)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false; }else { switch(iteCond.text[CONST_VAL]){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: if(iteCond.value[CONST_CMP_TYPE] != CONST_VALUE_OTHER){ if(iteControl.kind == CONST_VALUE_DATE_SPACE_TIME){ if(!isValidDateTime(jQuery.trim(iteCond.value[CONST_VAL]), DATE_TYPE_DATE_TIME)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(iteControl.kind == CONST_VALUE_TIME){ if(!isValidDateTime(jQuery.trim(iteCond.value[CONST_VAL]), DATE_TYPE_TIME)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(iteControl.kind == CONST_VALUE_DATE && iteControl.type != CONST_CTRL_TYPE_INPUTCALCULATE){ if(!isValidDateTime(jQuery.trim(iteCond.value[CONST_VAL]), DATE_TYPE_DATE)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(iteControl.kind == 'Integer'){ if(jQuery.trim(iteCond.value[CONST_VAL]).indexOf(".") != -1){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(jQuery.trim(iteCond.value[CONST_VAL]) != '' && ((optionMap[iteControl.name] == undefined || optionMap[iteControl.name][iteCond.value[CONST_VAL].toLowerCase()] == undefined) && !isPreviousIteCondField)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(jQuery.trim(iteCond.value[CONST_VAL]) != '' && ((optionMap[iteControl.name] == undefined || optionMap[iteControl.name][iteCond.value[CONST_VAL].toLowerCase()] == undefined) && !isPreviousIteCondField)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(jQuery.trim(iteCond.value[CONST_VAL]) != '' && ((optionMap[iteControl.name] == undefined || optionMap[iteControl.name][iteCond.value[CONST_VAL].toLowerCase()] == undefined) && !isPreviousIteCondField)){ retObj.error = 7; retObj.message = msg_bf_rel_cond_invalid; //return retObj; } }else{ if(!isConditionValueValid(iteCond.value[CONST_VAL])){ retObj.error = 7; retObj.message = msg_bf_following_val_invalid; //return retObj; } } if (!checkCtrlPosIsCorrected(controlsOrg, iteCondId, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, iteCondId, control.id, true)){ if(isPreviousIteCondField && isTheSameGroupForPrevious(controlsOrg, iteCondId, control.id)){ //is previous compare }else{ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } }else{ var isUserVariable = false; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(iteCond.value.val && iteCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; }else if(isVersion(VERSION_ADD_TRIP_VAIABLES)){ switch(iteCond.value.val){ case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: isUserVariable = true; break; } } } if(!isUserVariable){ var isPreviousIteCondValueField = false; var iteCondValueField = iteCond.value[CONST_VAL]; if(iteCondValueField && iteCondValueField.myIncludes(CONST_PREVIOUS)){ isPreviousIteCondValueField = true; iteCondValueField = iteCondValueField.replace(CONST_PREVIOUS, '').trim(); } if (!checkCtrlPosIsCorrected(controlsOrg, iteCondValueField, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, iteCondValueField, control.id, true)){ if(isPreviousIteCondValueField && isTheSameGroupForPrevious(controlsOrg, iteCondValueField, control.id)){ //is previous compare }else{ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } if(!isITEConditionTheSameKind(controlsOrg, iteCondId, iteCondValueField)){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } } if (!checkCtrlPosIsCorrected(controlsOrg, iteCondId, control.id)){ if(!checkControlByIdCorrectPos2(controlsOrg, iteCondId, control.id, true)){ if(isPreviousIteCondField && isTheSameGroupForPrevious(controlsOrg, iteCondId, control.id)){ //is previous compare }else{ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_move_down; return false; } } } if(retObj.error == 0){ switch(iteCond.text[CONST_VALUE_THENTYPE]){ case CONST_VALUE_OTHER: var thenOtherValue = valueOrEmpty(iteCond.text[CONST_VALUE_THENOTHERVALUE]); if( thenOtherValue == '' || thenOtherValue == '- Select -'){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; return false; }else{ var isUserVariable = false; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(thenOtherValue && thenOtherValue.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; }else if(isVersion(VERSION_ADD_TRIP_VAIABLES)){ switch(thenOtherValue){ case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: isUserVariable = true; break; } } } if(!isUserVariable){ if(thenOtherValue && thenOtherValue.myIncludes(CONST_PREVIOUS)){ thenOtherValue = thenOtherValue.replace(CONST_PREVIOUS + ' ', ''); } var thenOtherControl = getControlById(thenOtherValue, controlsOrg); if(thenOtherControl == undefined){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; return false; } } } break; } } } }); if(retObj.error == 0){ switch(control.iteConditions[CONST_VALUE_THENTYPE]){ case CONST_VALUE_OTHER: var thenOtherValue = valueOrEmpty(control.iteConditions[CONST_VALUE_THENOTHERVALUE]); if( thenOtherValue == '' || thenOtherValue == '- Select -'){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; }else{ var isUserVariable = false; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(thenOtherValue && thenOtherValue.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; }else if(isVersion(VERSION_ADD_TRIP_VAIABLES)){ switch(thenOtherValue){ case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: isUserVariable = true; break; } } } if(!isUserVariable){ if(thenOtherValue && thenOtherValue.myIncludes(CONST_PREVIOUS)){ thenOtherValue = thenOtherValue.replace(CONST_PREVIOUS + ' ', ''); }else if(thenOtherValue && thenOtherValue.endsWith(CONST_CHOOSE_ONE_CAPTION)){ thenOtherValue = thenOtherValue.replace(CONST_CHOOSE_ONE_CAPTION, ''); } var thenOtherControl = getControlById(thenOtherValue, controlsOrg); if(thenOtherControl == undefined){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; } } } break; } } if(retObj.error == 0 && control.iteConditions['hasResultElse']){ switch(control.iteConditions['elseType']){ case CONST_VALUE_OTHER: var elseOtherValue = valueOrEmpty(control.iteConditions['elseOtherValue']); if( elseOtherValue == '' || elseOtherValue == '- Select -'){ retObj.error = 18; retObj.message = msg_bf_rel_cand_all_required; }else{ var isUserVariable = false; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(elseOtherValue && elseOtherValue.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ isUserVariable = true; }else if(isVersion(VERSION_ADD_TRIP_VAIABLES)){ switch(elseOtherValue){ case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: isUserVariable = true; break; } } } if(!isUserVariable){ if(elseOtherValue && elseOtherValue.myIncludes(CONST_PREVIOUS)){ elseOtherValue = elseOtherValue.replace(CONST_PREVIOUS + ' ', ''); }else if(elseOtherValue && elseOtherValue.endsWith(CONST_CHOOSE_ONE_CAPTION)){ elseOtherValue = elseOtherValue.replace(CONST_CHOOSE_ONE_CAPTION, ''); } var thenOtherControl = getControlById(elseOtherValue, controlsOrg); if(thenOtherControl == undefined){ retObj.error = 18; retObj.message = msg_bf_rel_cand_ctrl_deleted; } } } break; } } if(retObj.error != 0){ errorCode = 1; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } //return retObj; } } if(!requiredError){ var skipIfConditionError = validateSkipIfCondition(control, controlsOrg); if(skipIfConditionError != null && skipIfConditionError.error != undefined && skipIfConditionError.error != 0){ retObj.error = skipIfConditionError.error; retObj.message = skipIfConditionError.message; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } if(errorCode != 0 || requiredError){ retObj.error = 1; } return retObj; }; var checkReportControlData = function(control, optionMap, controls, controlParrent, controlsOrg) { var retObj = {}; var errorCode = 0; retObj.error = 0; retObj.message = ''; retObj.ctrlName = control.name; var requiredError = false; var maxltMinError = false; switch(control.type){ case 'ctrlDataSource': if(!control.dataSourceProject || control.dataSourceProject == ''){ retObj.error = 1; retObj.message = msg_bf_report_project_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError && (!control.dataSource || control.dataSource == '')){ retObj.error = 1; retObj.message = msg_bf_report_data_source_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } /*if(!requiredError && (!control.dataSourceTable)){ retObj.error = 1; retObj.message = msg_bf_report_ds_table_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }*/ if(!requiredError && (!control.dataSourceDate || control.dataSourceDate == '' || control.dataSourceDate == '(none)')){ retObj.error = 1; retObj.message = msg_bf_report_ds_date_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(control.dataSourceDateFilter && control.dataSourceDateFilter == '2'){ if(control.twNumOfDay){ if(parseInt(control.twNumOfDay, 10) > 7){ retObj.error = 1; retObj.message = err_num_of_day; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } }else{ control.twNumOfDay = 7; } }else if(control.dataSourceDateFilter && control.dataSourceDateFilter == '3'){ if(control.lwNumOfDay){ if(parseInt(control.lwNumOfDay, 10) > 7){ retObj.error = 1; retObj.message = err_num_of_day; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } }else{ control.lwNumOfDay = 7; } }else if(control.dataSourceDateFilter && control.dataSourceDateFilter == '6'){ //is custom date check range 31 day if(!control.reportDateRange){ retObj.error = 1; retObj.message = err_report_data_range_invalid; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } }else{ if(control.reportDateRange.useDateRange){ if(control.reportDateRange.min == '' || control.reportDateRange.max == ''){ retObj.error = 1; retObj.message = err_report_data_range_invalid; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } }else{ if(control.reportDateRange.nDaysBefore == ''){ retObj.error = 1; retObj.message = err_report_data_range_invalid; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } }else{ var days; try{ days = parseInt(control.reportDateRange.nDaysBefore); if(isNaN(days)){ days = 0; } }catch(e){ days = 0; } 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } } } } break; case 'ctrlHeaderGrid': break; case 'ctrlDataFilter': if(!control.filterField || control.filterField == {}){ retObj.error = 1; retObj.message = msg_bf_report_filter_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError && (control.filterField.filterField || '') == ''){ retObj.error = 1; retObj.message = msg_bf_report_filter_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } if(!requiredError && (control.filterField.filterCondition || '') == ''){ retObj.error = 1; retObj.message = msg_bf_report_filter_cond_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } break; case 'ctrlReportBreakPoint': if(!control.reportBreakPoint || control.reportBreakPoint == ''){ retObj.error = 1; retObj.message = msg_bf_report_break_point_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }/*else{ var groupByCtrl = $('.ctrlBreakPointDataElement[data_id="' + control.reportBreakPoint + '"]'); if(groupByCtrl.length == 0){ retObj.error = 1; retObj.message = msg_bf_report_break_point_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } }*/ break; case 'ctrlBreakPointData': if(control.reportColumnsSpaceType == undefined || control.reportColumnsSpaceType == 2){ if(!control.withFormat4ColumnWeight || control.withFormat4ColumnWeight == ''){ retObj.error = 1; retObj.message = msg_bf_report_break_data_col_weight_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ var finalErrorCode = validateCustomWeight4ContainerGeneralProperty(control, retObj); // Check require error if (finalErrorCode === 1) { requiredError = true; retObj.error = 13; retObj.message = msg_bf_act_required; } else if (finalErrorCode > 0) { requiredError = true; } } } break; case 'ctrlBreakPointDataElement': break; case 'ctrlFooterGrid': break; case 'ctrlEmailSchedule': switch(control.reportFrequency.frequency){ case '0': if(control.reportFrequency.datefilter == '' || control.reportFrequency.timefilter == ''){ retObj.error = 1; retObj.message = msg_bf_email_report_data_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } } } break; case '1': if(control.reportFrequency.datefilter == '' || control.reportFrequency.timefilter == '' || (!control.reportFrequency.su && !control.reportFrequency.mn && !control.reportFrequency.te && !control.reportFrequency.wd && !control.reportFrequency.th && !control.reportFrequency.fa && !control.reportFrequency.sa)){ retObj.error = 1; retObj.message = msg_bf_email_report_data_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } break; case '2': if(control.reportFrequency.datefilter == '' || control.reportFrequency.timefilter == '' || (control.reportFrequency.weeklyDay || '') == ''){ retObj.error = 1; retObj.message = msg_bf_email_report_data_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; 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( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } } break; case '3': if(control.reportFrequency.timefilter == '' || control.reportFrequency.dayfilter == ''){ retObj.error = 1; retObj.message = msg_bf_email_report_data_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } }else{ var day = parseInt(control.reportFrequency.dayfilter); if(day < 1 || day > 31){ retObj.error = 1; retObj.message = msg_bf_day_in_1_to_31; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; } } break; } if('column' === control.excelReportType && '0' === control.reportFileType){ // CO-1638: check for PDF only if(!control.useCustomTemplate){ retObj.error = 1; retObj.message = "Use custom template must be checked"; } else if('' === control.excelTemplate){ retObj.error = 1; retObj.message = "Report name must be select"; } if(retObj.error == 1 && !requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } try{ // Validate email address if(errorCode != 1){ if (control.forwardReportTo > 0) { // The report is assigned if (control.forwardReportTo == 2 && control.frtWebGroup.trim() == '') { retObj.error = 1; retObj.message = msg_bf_mail_web_group_required; } else if (control.forwardReportTo == 3 && control.frtWebUser.trim() == '') { retObj.error = 1; retObj.message = msg_bf_mail_web_users_required; } var emailAddress = control.reportEmail == undefined || control.reportEmail == '' ? "" : control.reportEmail.split('$$')[0]; if (emailAddress == '') { // not do something } else { var emails = emailAddress.split(';'); _.each(emails, function(mail) { if (!isValidEmail(mail)) { retObj.error = 1; retObj.message = msg_bf_mail_rep_mail_to_format; return false; } }); } } else { var emailAddress = control.reportEmail.split('$$')[0]; if (control.reportEmail == undefined || control.reportEmail == '' || emailAddress == '') { retObj.error = 1; retObj.message = lbl_pls_enter_email; } else { var emails = emailAddress.split(';'); _.each(emails, function(mail) { if (!isValidEmail(mail)) { retObj.error = 1; retObj.message = msg_bf_mail_rep_mail_to_format; return false; } }); } } if (retObj.error == 1 && !requiredError) { $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append('
  • ' + retObj.message + '
  • '); requiredError = true; errorCode = 1; } } } catch(e){} break; } if(errorCode != 0 || requiredError){ retObj.error = 1; } return retObj; }; odkmaker.data.serialize = function() { odkmaker.data.lookupTablesArr = {}; odkmaker.data.openFilesArr = {}; odkmaker.data.lookupTablesUseInMobileArr = {}; var internal = odkmaker.data.extract(); showSkipWrning = false; var json = internalToXForm(internal); if(!isFreeAccount()){ if(!isVersion5_0()){ addSkipLogic(internal.controls, internal.controls, json); } addRelevance(internal.controls, internal.controls, json); addReadOnlyIf(internal.controls, internal.controls, json); } addLookupTableData(internal.controls, internal.controls, json); addLookupFieldData(internal.controls, internal.controls, json); addLookupConditionFieldData(internal.controls, internal.controls, json); addCalculationData(internal.controls, internal.controls, json); // Fix bug 0022156: Barcode-NFC Parsing : Pls hiding Parse checkbox of NFC //if(isVersion(VERSION_NFC_BAR_PARSE)){ if(isVersion(VERSION_NFC_BAR_PARSE) || isVersion(VERSION_NFC_PARSE_ONLY)){ addParseDestinationFiledData(internal.controls, internal.controls, json); } return JSONtoXML(json, false, 0); }; odkmaker.data.inputDataSerialize = function(json) { if(fvDataNS.inputData){ fvDataNS.inputData.PODDataHasGenTOJSon = {}; } var data = makeScoreData(json); if(!jQuery.isEmptyObject(data)){ var scoreData = ''; var totalPoss = 0; var totalScore = 0; var totalPercent = 0; var ctrlPropreties = fvDataNS.dataArray['data &ScoreSummary']; _.each(data, function(item, categoryName) { var poss = item.poss; var value = item.value; var percent = 0; if(value == '' && (typeof value) == 'string'){ percent = ''; }else if(poss == 0){ percent = 100; }else{ percent = value * 100 / poss; } totalPoss += poss; if(value == '' && (typeof value) == 'string'){ }else{ totalScore += value; } if(percent == ''){ scoreData += ''; }else{ scoreData += ''; } }); if(totalPoss == 0){ totalPercent = 100; }else{ totalPercent = totalScore * 100 / totalPoss; } scoreData += ''; scoreData = '' + scoreData + ''; json.children.push({ name: 'score-data', val: scoreData, children: [] }); } return JSONtoXML(json, true, 0); } var makeScoreData = function(obj) { var result = {}; if (_.isString(obj)) return {}; if(obj.isCtrlHidden != undefined && obj.isCtrlHidden){ return {}; } if(obj.skipByCtrls != undefined && obj.skipByCtrls.length > 0){ return {}; } if(obj.ctrlType == CONST_CTRL_TYPE_INPUTSCOREONE){ if(obj.name.indexOf('__comment') > 0){ return {}; } if(isNaN(obj.val)){ return {}; }else{ var value = obj.val; var poss = fvDataNS.scoreData[obj.scoreCategory][obj.name]; if(jQuery.trim(value) == ''){ /*value = undefined; poss = undefined; result[obj.scoreCategory] = { value: undefined, poss: undefined };*/ result = {}; }else{ result[obj.scoreCategory] = { value: parseFloat(value), poss: poss }; } return result; } }else if (obj.children !== undefined){ _.each(obj.children, function(child) { if(child == undefined){ return false; } var result1 = makeScoreData(child); if(!jQuery.isEmptyObject(result1)){ if(child.ctrlType == CONST_CTRL_TYPE_CTRLSCORETABLE){ _.each(result1, function(item, category){ if(result[category] != undefined){ result[category].value += item.value; result[category].poss += item.poss; }else{ result[category] = item; } }); }else if(child.ctrlType == CONST_CTRL_TYPE_CTRLGRID){ _.each(result1, function(item, category){ if(result[category] != undefined){ result[category].value += item.value; result[category].poss += item.poss; }else{ result[category] = item; } }); }else if(child.ctrlType == CONST_CTRL_TYPE_GROUP){ _.each(result1, function(item, category){ if(result[category] != undefined){ result[category].value += item.value; result[category].poss += item.poss; }else{ result[category] = item; } }); }else{ if(result[child.scoreCategory] != undefined){ result[child.scoreCategory].value += result1[child.scoreCategory].value; result[child.scoreCategory].poss += result1[child.scoreCategory].poss; }else{ result[child.scoreCategory] = result1[child.scoreCategory]; } } } }); } return result; }; odkmaker.data.lookupTables = function() { var ret = ''; _.each(odkmaker.data.lookupTablesArr, function(item, key){ if(odkmaker.data.lookupTablesUseInMobileArr[key] == undefined){ if(key.indexOf('|')<0){ key = key + '&dispOl=true'; }else{ key = key.replace(/ /g, '%20'); } } if(ret != ''){ ret = ret + ' '; } ret = ret + key; }); return ret; }; odkmaker.data.openFiles = function() { return JSON.stringify(odkmaker.data.openFilesArr); }; odkmaker.data.checkReportDataValid = function() { showSkipWrning = false; var internal = odkmaker.data.extract(); var retObj = {}; retObj.error = 0; retObj.message = ''; var controls = internal.controls; if($(controls).length == 0){ retObj.error = 98; retObj.message = msg_bf_report_empty; }else if(controls[0].type != 'ctrlDataSource'){ retObj.error = 99; retObj.message = msg_bf_report_no_data_source; }else if(controls[controls.length - 1].type != 'ctrlEmailSchedule'){ retObj.error = 100; retObj.message = msg_bf_report_no_email_schedule; }else{ var hasError = false; clearErrorMessage(controls); var optionMap = {}; fvDataNS.triggerRef = {}; retObj = checkReportControlsData(controls, undefined, optionMap, controls); if(retObj.error != 0){ hasError = true; } if(hasError){ retObj.error = 1; } } if(retObj.error == 0 && showSkipWrning){ retObj.skipwarning = true; } return retObj; }; odkmaker.data.validateDynamicTables = function(controls){ var dynamicTables = []; try{ jQuery.each(controls, function() { if(this.type == CONST_CTRL_TYPE_CTRLTABLE && (true == this.autoAddNewRow || true == this.isMessageWidget)){ var tableName = this.label.eng; if(tableName == undefined || tableName == ''){ tableName = this.name; } if(true == this.isMessageWidget){ dynamicTables.push({name: this.name, caption: tableName, loop: MESSAGE_WIDGET_TEMPLATE_ROW_COUNT, isMessageWidget: this.isMessageWidget}); }else{ dynamicTables.push({name: this.name, caption: tableName, loop: this.loop}); } } }); } catch(e){} return dynamicTables; }; odkmaker.data.checkFormDataValid = function() { showSkipWrning = false; var internal = odkmaker.data.extract(); var retObj = {}; retObj.error = 0; retObj.message = ''; var controls = internal.controls; if($(controls).length == 0){ retObj.error = 98; retObj.message = msg_bf_form_empty; }else{ var hasError = false; clearErrorMessage(controls); retObj = checkSyntaxForControlsName(controls); if(retObj.error != 0){ //return retObj; hasError = true; } retObj = checkSyntaxForCategory(controls); if(retObj.error != 0){ //return retObj; hasError = true; } var objName = []; retObj = checkDuplicateControlsName(controls, objName); if(retObj.error != 0){ hasError = true; } var lookupDatasourceArray = []; var optionMap = {}; var useChecklistObjMap = {}; fvDataNS.scoreSummary = undefined; fvDataNS.scoreSummaryErr = false; fvDataNS.hasScoreQues = false; fvDataNS.isShowScoreSummaryErr = false; fvDataNS.isShowScoreQues = false; fvDataNS.triggerRef = {}; retObj = checkControlsData(controls, undefined, lookupDatasourceArray, optionMap, controls, useChecklistObjMap); if(retObj.error != 0){ hasError = true; } if(hasError){ retObj.error = 1; } } if(retObj.error == 0 && showSkipWrning){ retObj.skipwarning = true; } return retObj; }; odkmaker.data.getCtrlProperties = function(ctrlId) { var internal = odkmaker.data.extract(); var controls = internal.controls; return getProperties(controls, ctrlId); }; var getProperties = function(controls, ctrlId) { var ret = undefined; _.each(controls, function(control) { if(ret != undefined){ return false; } if(control.id == ctrlId){ ret = control; return false; } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData') || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID){ ret = getProperties(control.children, ctrlId); if(ret != undefined){ return false; } } }); return ret; }; var addGroupLoopItem = function(ctrlPropretiesGroup, groupName, loopIndex, parent){ var isTheFirstItemClass = ''; if(loopIndex == 1){ isTheFirstItemClass = 'isTheFirstItem'; }else{ isTheFirstItemClass = 'notIsTheFirstItem'; } var $groupLoop = $('#formview_templates .groupLoop') .clone() .addClass(isTheFirstItemClass) .addClass(groupName) .addClass('fvCtrlName_' + groupName + CONST_VALUE_DASH_LOOP + loopIndex) .addClass(groupName + CONST_VALUE_DASH_LOOP + loopIndex) .appendTo(parent) .on("AddGroupItem", function(event, groupName){ if(ctrlPropretiesGroup.name == groupName){ ctrlPropretiesGroup.isCtrlHidden = false; $(this).removeClass(CONST_CLASS_HIDE_CONTROL); fvDataNS.hidGroupMap[ctrlPropretiesGroup.classPath] = false; $(this).find('.fvControl').trigger('Control_Update'); } }) .on("ClearGroupItemData", function(event, groupName){ if(ctrlPropretiesGroup.name == groupName){ $(this).find('.fvControl').trigger('clearData', false); } $(this).find('.groupDelete').trigger('groupDeleteAll'); }) .on("ResetGroupItemToDefaultValue", function(event){ $(this).find('.fvControl').trigger('clearData', true); }) .on("DeleteGroupItem", function(event, groupName){ if(ctrlPropretiesGroup.name == groupName){ ctrlPropretiesGroup.isCtrlHidden = true; $(this).addClass(CONST_CLASS_HIDE_CONTROL); fvDataNS.hidGroupMap[ctrlPropretiesGroup.classPath] = true; $(this).find('.fvControl').trigger('clearData', true); $(this).find('.groupDelete').trigger('groupDeleteAll'); } }); parent.attr('loopcount', loopIndex); if(loopIndex <= 1){ parent.find('.isTheFirstItem:first .deleteGroupItem:first').css('display', 'none'); }else{ parent.find('.isTheFirstItem:first .deleteGroupItem:first').css('display', ''); } $groupLoop.find('.controlLabelButtonDelete4Shading .deleteGroupItem').click(function(event, notShowConfirmMsg){ $($(this).parents('.workspaceInnerWrapper')[0]).siblings('.groupFooter').find('.groupDelete').trigger('click', [notShowConfirmMsg, undefined, true, loopIndex]); }); $groupLoop.find('.controlLabelButtonDelete4Shading .expandCollapse').click(function(event){ var groupLoop = $($(this).parents('.groupLoop')[0]); if(groupLoop.hasClass('collapse')){ groupLoop.removeClass('collapse'); $(this).empty().append('-'); }else{ groupLoop.addClass('collapse'); $(this).empty().append('+'); } }) // Apply Shading in WebApps (for group) // PCA-293: Webapp/Preview - Apply new block formats for all widgets. //if(isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && glbBuildFormSettingsWA.isShadedheadings === true) if(isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { //hqkhanh $groupLoop.find('.workspaceInnerWrapper').addClass('group-shaded-mode-shading').addClass('no-padding-left-shading'); } fvDataNS.ctrlIndex++; $groupLoop.find('.controlData').attr('id', 'ctrlDataId_' + fvDataNS.ctrlIndex); ctrlPropretiesGroup.ctrlDataId = fvDataNS.ctrlIndex; fvDataNS.ctrlArray[ctrlPropretiesGroup.classPath] = $groupLoop; return $groupLoop; } var getCtrlIncompleteProperties = function(rootInputProperties, ctrlPropreties){ if(rootInputProperties == undefined || rootInputProperties == []){ return undefined; } for(var i=0; i version 1.0 }else if(control.type == 'inputFacingTable'){ // not support control version < 2.0 return false; } } var properties = null; if ((control.type == CONST_CTRL_TYPE_GROUP) || (control.type == CONST_CTRL_TYPE_CTRLTABLE) || (control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) || (control.type == CONST_CTRL_TYPE_CTRLPOD) || (control.type == CONST_CTRL_TYPE_CTRLINV) || (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) || (control.type == CONST_CTRL_TYPE_CTRLGRID) || (control.type == 'branch') || (control.type == 'inputPageBreak') || (control.type == 'inputLabel') || (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY) || (control.type == CONST_CTRL_TYPE_INPUTNUMBERING) || (control.type == CONST_CTRL_TYPE_INPUTACTION) || (control.type == CONST_CTRL_TYPE_INPUTPAYMENT) || (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT) || (control.type == 'inputInstruction') || //(control.type == CONST_CTRL_TYPE_INPUTCALCULATE) || (control.type == CONST_CTRL_TYPE_INPUTLOOKUP) || (control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) || (control.type == 'inputFacingTable') || (control.type == 'inputLookupMulti') || (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTFAX) || (control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) || (control.type == 'inputSaveAndSend') || (control.type == 'ctrlDataSource') || (control.type == 'ctrlHeaderGrid') || (control.type == 'ctrlDataFilter') || (control.type == 'ctrlReportBreakPoint') || (control.type == 'ctrlBreakPointData') || (control.type == 'ctrlBreakPointDataElement') || (control.type == 'ctrlFooterGrid') || (control.type == 'ctrlEmailSchedule')){ if(control.relevanceconds == undefined){ control.relevanceconds = []; } properties = $.extend(true, {}, $.fn.odkControl.controlProperties[control.type]); }else{ properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[control.type]); removeUnsupportProperty(properties, control.type); } removeUnuseVersion(properties); if(control.isAttachFormWidget === true){ appendProperties4AttachFormWidget(properties); } if(rootInputProperties && rootInputProperties.requiredRows == true && !jQuery.isEmptyObject(rootInputProperties.requiredOptionsGroup)){ if(rootInputProperties.requiredOptionsGroup[control.id]){ control.required = true; if(control.requiredViewEdit != undefined){ control.requiredDispatchEdit = true; control.requiredDispatchNew = true; control.requiredFillAndSend = true; if(isVersion(VERSION_FNS_EDIT)){ control.requiredFillAndSendEdit = true; } control.requiredDispatchToEmail = true; control.requiredViewNew = true; control.requiredViewEdit = true; control.requiredWebApp = true; control.requiredFormLinks = true; value: control.required = true; } } } properties.id.ctrlType = control.type; var ctrlPropreties = { name: control.name, classPath: rootInputProperties.classPath + ' ' + control.name, id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [] }; if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropreties.hideWebApp = true; control.hideWebApp = true; }else if(!control.hideWebApp){ //CO-6096: Modify action button is visible on webclient ctrlPropreties.hideWebApp = false; control.hideWebApp = false; } } } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.isRetrieve){ ctrlPropreties.datasource = control.datasource; ctrlPropreties.destinationdataconds = control.destinationdataconds ctrlPropreties.modifyFields = control.modifyFields; ctrlPropreties.lookupValue = control.lookupValue; ctrlPropreties.lookupfield = control.lookupfield; ctrlPropreties.lookupConditionFields = control.lookupConditionFields; ctrlPropreties.notDisplayRecNotFound = control.notDisplayRecNotFound; ctrlPropreties.isModifyAllMatches = control.isModifyAllMatches; ctrlPropreties.isCaseSensitiveCmp = control.isCaseSensitiveCmp; ctrlPropreties.isRetrieveOldestRecord = control.isRetrieveOldestRecord; ctrlPropreties.retrieveRecordKind = control.retrieveRecordKind; ctrlPropreties.isModifyAdd = control.isModifyAdd; ctrlPropreties.modifyAddFields = control.modifyAddFields; } appendControlProperties4Widget(ctrlPropreties, control); //appendControlProperties4ShippingWidget(ctrlPropreties, control); /*if(control.type == CONST_CTRL_TYPE_INPUTLOCATION && isVersion(VERSION_GPS_ZOOM_LEVEL) && control.zoomLevel){ // CO-2736 ctrlPropreties.zoomLevel = control.zoomLevel; }*/ if(control.displayCCIcon){ ctrlPropreties.displayCCIcon = control.displayCCIcon; } if(control.isDisplayAmountCharged != false){ ctrlPropreties.isDisplayAmountCharged = control.isDisplayAmountCharged; } if(control.addMessage){ ctrlPropreties.addMessage = control.addMessage; }else{ ctrlPropreties.addMessage = { check: true, text: lbl_default_add_msg }; } if(control.amountCharged){ ctrlPropreties.amountCharged = control.amountCharged; } if(control.totalAmountPaid){ ctrlPropreties.totalAmountPaid = control.totalAmountPaid; } if(control.transactionClientId){ ctrlPropreties.transactionClientId = control.transactionClientId; } if(control.requiredViewEdit != undefined){ // new enchance ctrlPropreties.requiredDispatchEdit = { value: control.requiredDispatchEdit}; ctrlPropreties.requiredDispatchNew = { value: control.requiredDispatchNew}; ctrlPropreties.requiredFillAndSend = { value: control.requiredFillAndSend}; if(isVersion(VERSION_FNS_EDIT)){ ctrlPropreties.requiredFillAndSendEdit = { value: control.requiredFillAndSendEdit}; } ctrlPropreties.requiredDispatchToEmail = { value: control.requiredDispatchToEmail}; ctrlPropreties.requiredViewNew = { value: control.requiredViewNew}; ctrlPropreties.requiredViewEdit = { value: control.requiredViewEdit}; ctrlPropreties.requiredWebApp = { value: control.requiredWebApp}; ctrlPropreties.requiredFormLinks = { value: control.requiredFormLinks}; ctrlPropreties.required = { value: control.required}; } // CO-3502 if(control.ofDispatchCaptionText != undefined && CONST_ACTION_ATTACH_FORM != control.imgAction){ ctrlPropreties.label = { eng: control.ofDispatchCaptionText}; } if(control.ofDispatchRequired != undefined){ ctrlPropreties.ofDispatchRequired = { value: control.ofDispatchRequired}; } if(control.hideButtonAfterClick != undefined){ ctrlPropreties.hideButtonAfterClick = control.hideButtonAfterClick; // CO-4027: Hide button after click } if(control.realType){ ctrlPropreties.realType = control.realType; } if(control.militaryTime == true){ ctrlPropreties.militaryTime = true; } if(control.useCurrentcySymbol == true){ ctrlPropreties.useCurrentcySymbol = true; ctrlPropreties.currency = control.currency; } if(rootInputProperties && rootInputProperties.ctrlType == CONST_CTRL_TYPE_GROUP){ ctrlPropreties.parentKind = CONST_CTRL_TYPE_GROUP; } if(control.length != undefined && control.length != false){ ctrlPropreties.length = { min: control.length.min || '', max: control.length.max || '', cannotExceedMaximum : control.length.cannotExceedMaximum || false } if(control.kind != undefined){ ctrlPropreties.kind = control.kind; } }else if(control.range != undefined && control.range != false){ ctrlPropreties.range = { min: control.range.min || '', max: control.range.max || '' } } if(control.validateValue != undefined && control.validateValue != false){ ctrlPropreties.validateValue = {}; ctrlPropreties.validateValue.value = control.validateValue; } if(control.kind != undefined){ ctrlPropreties.kind = control.kind; } if(control.showDecimalValue != undefined){ ctrlPropreties.showDecimalValue = control.showDecimalValue; } if(control.dispatchRequired != undefined && control.dispatchRequired == true){ ctrlPropreties.dispatchRequired = true; if(isWebAppDispatch()){ control.required = true; ctrlPropreties.required = true; } } if(control.isNotUseDispatchTab != undefined){ ctrlPropreties.isNotUseDispatchTab = control.isNotUseDispatchTab; } if(control.isUseDispOnly != undefined){ ctrlPropreties.isUseDispOnly = control.isUseDispOnly; } if(control.podDataSource != undefined){ ctrlPropreties.podDataSource = control.podDataSource; } if(control.requiredForwarded != undefined){ ctrlPropreties.requiredForwarded = {value: control.requiredForwarded}; // CO-941 } if(control.requiredOnRetrieve != undefined){ // CO-4940: Required setting - Turned off for retrieve not working ctrlPropreties.requiredOnRetrieve = {value: control.requiredOnRetrieve}; } if(control.isUseViewdataOnly != undefined){ ctrlPropreties.isUseViewdataOnly = control.isUseViewdataOnly; } // CO-3852: New Retrieve Setting - Auto Run if(control.isRetrieveDS == true && control.autoActionStampTriggerRetrieve != undefined && (control.autoActionStampTriggerRetrieve == '2' // specific question || control.autoActionStampTriggerRetrieve == '8') // open form ){ ctrlPropreties.retrieveKind = control.retrieveKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerRetrieve = control.autoActionStampTriggerRetrieve; ctrlPropreties.autoActionStampQuestionTriggerRetrieve = control.autoActionStampQuestionTriggerRetrieve; ctrlPropreties.hideRetrieveButtonAuto = control.hideRetrieveButtonAuto; } // CO-3853 if(control.autoActionStampTriggerModify != undefined && (control.autoActionStampTriggerModify == '2' // specific question || control.autoActionStampTriggerModify == '8' || control.autoActionStampTriggerModify == '32') // on retrieve ){ ctrlPropreties.modifyKind = control.modifyKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerModify = control.autoActionStampTriggerModify; ctrlPropreties.autoActionStampQuestionTriggerModify = control.autoActionStampQuestionTriggerModify; ctrlPropreties.hideModifyButtonAuto = control.hideModifyButtonAuto; } if(control.hideRetrieveButton){ ctrlPropreties.hideRetrieveButton = control.hideRetrieveButton; } if((control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTLOCATION) && control.iconColor){ // CO-4050 ctrlPropreties.iconColor = control.iconColor; } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.iconColor){ ctrlPropreties.applyScreenSize = control.applyScreenSize; ctrlPropreties.buttonSize = control.buttonSize; ctrlPropreties.ifScreenSmallerThan = control.ifScreenSmallerThan; ctrlPropreties.ifScreenSmallerSize = control.ifScreenSmallerSize; } if(isVersion(VERSION_RESTRICT_OPTION) && (control.type == CONST_CTRL_TYPE_INPUTLOOKUP || control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH)){ if(control.restViewEdit == undefined){ ctrlPropreties.restViewEdit = control.restViewEdit; } if(control.restViewNew == undefined){ ctrlPropreties.restViewNew = control.restViewNew; } if(control.restViewFillAndSend == undefined){ ctrlPropreties.restViewFillAndSend = control.restViewFillAndSend; } if(isVersion(VERSION_FNS_EDIT)){ if(control.restViewFillAndSendEdit == undefined){ ctrlPropreties.restViewFillAndSendEdit = control.restViewFillAndSendEdit; } } if(control.restDispatchToEmail == undefined){ ctrlPropreties.restDispatchToEmail = control.restDispatchToEmail; } if(control.restDispatchEdit == undefined){ ctrlPropreties.restDispatchEdit = control.restDispatchEdit; } if(control.restDispatchNew == undefined){ ctrlPropreties.restDispatchNew = control.restDispatchNew; } if(control.restMobile == undefined){ ctrlPropreties.restMobile = control.restMobile; } if(control.restWebapp == undefined){ ctrlPropreties.restWebapp = control.restWebapp; } if(control.restDispatchToEmail == undefined){ ctrlPropreties.restDispatchToEmail = control.restDispatchToEmail; } } // old /* if(control.type == CONST_CTRL_TYPE_GROUP || control.type == CONST_CTRL_TYPE_CTRLTABLE){ ctrlPropreties.classPath = rootInputProperties.classPath + ' ' + control.name + CONST_VALUE_DASH_LOOP + 1; } */ // new start if(control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ ctrlPropreties.classPath = rootInputProperties.classPath + ' ' + control.name; }else if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ var ctrlPropretiesTable = ctrlPropreties; ctrlPropreties = $.extend(true,{},ctrlPropreties); ctrlPropretiesTable.children.push(ctrlPropreties); ctrlPropreties.classPath = rootInputProperties.classPath + ' ' + control.name + CONST_VALUE_DASH_LOOP + 1; fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name] = ctrlPropretiesTable; fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; }else if(control.type == CONST_CTRL_TYPE_CTRLPOD){ ctrlPropreties.classPath = rootInputProperties.classPath + ' ' + control.name + CONST_VALUE_DASH_LOOP + 1; fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name] = ctrlPropreties; } // new end // old /* if(fvDataNS.dataArray['forsum__' + control.id] == undefined){ fvDataNS.dataArray['forsum__' + control.id] = []; } var formsumIndex = fvDataNS.dataArray['forsum__' + control.id].length; fvDataNS.dataArray['forsum__' + control.id][formsumIndex] = ctrlPropreties; if(fvDataNS.dataArray['forcount__' + control.id] == undefined){ fvDataNS.dataArray['forcount__' + control.id] = []; } var formcountIndex = fvDataNS.dataArray['forcount__' + control.id].length; fvDataNS.dataArray['forcount__' + control.id][formcountIndex] = ctrlPropreties; */ // new start // new end if(fvDataNS.incomplete){ // old /* switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : //case CONST_CTRL_TYPE_INPUTACTION : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: var tmp = ctrlPropreties; ctrlPropreties = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties); if(ctrlPropreties == undefined){ ctrlPropreties = tmp; rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } */ // new start var tmp = ctrlPropreties; ctrlPropreties = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties); if(control.type == CONST_CTRL_TYPE_CTRLGRID){ UpdateNewChildClassPath(ctrlPropreties); } if(control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE){ if(ctrlPropreties.classPath.endsWith(control.name + '_loop_1')){ var ctrlTablePropreties = fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name]; ctrlTablePropreties.children = []; ctrlTablePropreties.children.push(ctrlPropreties); fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; }else{ fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name] = ctrlPropreties; } } if(control.type == CONST_CTRL_TYPE_CTRLPOD){ if(ctrlPropreties.classPath.endsWith(control.name + '_loop_1')){ var ctrlTablePropreties = fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name]; ctrlTablePropreties.children = []; ctrlTablePropreties.children.push(ctrlPropreties); fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; }else{ fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name] = ctrlPropreties; } } if(ctrlPropreties == undefined){ ctrlPropreties = tmp; rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } // new end }else{ // old /* switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; case CONST_CTRL_TYPE_INPUTACTION : //if(control.imgAction == CONST_ACTION_SAVE_AND_SEND){ rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; //}else{ //} break; default: rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } */ // new start if(fvDataNS.currentForm.editRecordData){ getEditRecordData(ctrlPropreties, fvDataNS.currentForm.editRecordData, control); } rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; // new end } //fvDataNS.ctrlMap[control.id] = control.name; _.each(properties, function(property, key) { if((control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) && key == 'defaultValue'){ var value = control[key]; if(value != undefined){ var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ property.value = value.substring(0, contentStartPos); property.mailcontent = value.substring(contentStartPos + 2); }else{ property.value = value; } } if(isVersion(VERSION_EMAIL_REPORT_NEW_DEFAULT)){ property.selectedCtrl = control[key+'_selectedCtrl']; } }else if(control.type == 'ctrlEmailSchedule' && key == 'reportEmail'){ var value = control[key]; if(value != undefined){ var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ property.value = value.substring(0, contentStartPos); property.mailcontent = value.substring(contentStartPos + 2); }else{ property.value = value; } } }else{ property.value = control[key]; if(key == 'relevanceconds' && property.value != undefined){ _.each(property.value, function(relevanceCond){ if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == '' || relevanceCond.text[CONST_VALUE_CTRLTYPE] == undefined){ return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_TEXT || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTLOCATION || relevanceCond.text[CONST_VALUE_CTRLTYPE] == mdi_kind_inputImage || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTBARCODE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTNFC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSECUREFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSCOREONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTMANY || relevanceCond.text[CONST_VALUE_CTRLTYPE] == 'inputRIF'){ if(relevanceCond.text[CONST_VAL]){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_EQUAL: case CONST_VALUE_NOT_EQUAL: case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } }else{ relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } } }); }else if(key == 'lookupConditionFields' && property.value != undefined){ _.each(property.value, function(lookupConditionField){ if(lookupConditionField.text.valCond == undefined || jQuery.trim(lookupConditionField.text.valCond) == ''){ return false; } if(lookupConditionField.text.valCond == properties.lookupfield.value){ lookupConditionField.text.valCond = ''; } }); } } }); // if(control.type != 'inputPageBreak' && properties.label.value.eng != undefined){ // if(properties.name.valueinput == ""){ // var controlidTmp = replaceNonAlphaNumericChar(properties.label.value.eng); // if(properties.name.value != controlidTmp){ // properties.name.valueinput = properties.name.value; // } // } // } // // Fix bug 0020311: Data name is changed into default name after user open form! // else if(control.type != 'inputPageBreak' && properties.label.value.eng == undefined){ // if(properties.name.value != undefined && !properties.name.value.match(/^untitled/) && properties.name.valueinput == ""){ // properties.name.valueinput = properties.name.value; // }else if(properties.name.value.match(/^untitled/) && !properties.name.value.match(/^untitled[0-9]+$/) ){ // properties.name.valueinput = properties.name.value; // } // } // Always set properties.name.valueinput = properties.name.value in loading data properties.name.valueinput = properties.name.value; var ctrlType = control.type; if(control.type == CONST_CTRL_TYPE_INPUTMEDIA){ switch (properties.kind.value) { case mdi_kind_image : ctrlType = mdi_kind_inputImage; break; case mdi_kind_audio : ctrlType = mdi_kind_inputAudio; break; case mdi_kind_video : ctrlType = mdi_kind_inputVideo; break; } }else if(control.type == 'inputDraw'){ switch (properties.kind.value) { case mdi_kind_sketch : ctrlType = mdi_kind_inputSketch; break; case mdi_kind_signature : ctrlType = mdi_kind_inputSignature; break; } } if(control.type == 'inputPageBreak' && parentPath == ''){ wpRoot = $root; } fvDataNS.ctrlIndex++; ctrlPropreties.ctrlDataId = fvDataNS.ctrlIndex; // CO-3502: Button upload - Choose a file in dispatch var buttonUpload = ''; if(control.kind === CONST_TYPE_BUTTON && control.ofRequired === '2' && isApplyActionOpenFile(properties)){ buttonUpload = 'Upload'; } // CO-4008 if(control.type === 'inputPageBreak'){ parentPageBreak = control.id; } if(control.type !== 'inputPageBreak' && parentPageBreak != ''){ ctrlPropreties.parentPageBreak = parentPageBreak; } // Choose the method of cloning controls (Media/Date/Counter) // Get selected control for cloning object, using in WebApps // Apply task : https://doforms.atlassian.net/browse/PCA-145 (Implement Shading for webapp) var $control = getSelectedQuery4CloneObjectWA('#formview_templates .' + ctrlType + buttonUpload, ctrlType, control); // var $control = $('#formview_templates .' + ctrlType) // .clone() if(control && control.podCtrlName){ ctrlPropreties.podCtrlName = control.podCtrlName; } if(ctrlType == CONST_CTRL_TYPE_CTRLPOD){ if(!fvDataNS.podDataArrayOrg){ fvDataNS.podDataArrayOrg = {}; } fvDataNS.podDataArrayOrg['data ' + ctrlPropreties.name] = control; } initGeofencesInfo(control); // CO-4372 var hideShowRefControl = function(ctrlId, isHidden, hideClass) { if (fvDataNS.repeatableRef && fvDataNS.repeatableRef[ctrlId]) { _.each(fvDataNS.repeatableRef[ctrlPropreties.id], function(element) { var classPathArr = fvDataNS.ctrlIdMap[element]; var classPath = ''; if (classPathArr) { classPath = Object.keys(classPathArr)[0]; } var $control = fvDataNS.ctrlArray[classPath]; if ($control) { if (isHidden) { $control.addClass(hideClass); } else { $control.removeClass(hideClass); } } }) } } $control = $control.clone() .attr('id', 'fvCtrlID_' + control.id) .addClass(ctrlType) .addClass('fvControl') .addClass('fvCtrlID_' + control.id) .addClass('fvCtrlName_' + control.name) .odkControlFV(ctrlType, null, properties, ctrlPropreties) .appendTo(wpRoot) .on("fvCtrlShowHideChange", function(event, addToChangeList){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } if(control.type == 'inputPageBreak'){ var hideClass = CONST_CSS_CLASS_HIDE_SESSION; var isHideCtrl = $(this).hasClass(hideClass); var isStateChage = false; var pageSkip = $control.hasClass('pageSkip'); if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ if(!pageSkip){ $control.addClass('pageSkip'); } }else{ if(ctrlPropreties.isCtrlHidden){ if(!pageSkip){ $control.addClass('pageSkip'); } }else{ if(pageSkip){ $control.removeClass('pageSkip'); $control.removeClass(CONST_CLASS_HIDE_CONTROL); //reArrangeLayoutOfChooseOneWithShadingWALastAction($control); } } } // CO-4008: Add Only display this question if to Page try{ if(ctrlPropreties.relevancecondsExpression != undefined && ctrlPropreties.relevancecondsExpression.relevanceCondString != undefined && ctrlPropreties.relevancecondsExpression.relevanceCondString != ''){ // var relevanceValue = calculateRelevanceConds(...) var cssClass = ' .fvCtrlID_' + ctrlPropreties.id; if(ctrlPropreties.isCtrlHidden){ // hide $('.formView' + cssClass).addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.popup-page-menu .scroll_contain' + cssClass).addClass(CONST_CSS_CLASS_HIDE_SESSION); if(!isHideCtrl){ isStateChage = true; } } else{ // show $('.formView' + cssClass).removeClass(CONST_CSS_CLASS_HIDE_SESSION); $('.popup-page-menu .scroll_contain' + cssClass).removeClass(CONST_CSS_CLASS_HIDE_SESSION); if(isHideCtrl){ isStateChage = true; } } // Update page number var pages = $('.fvWorkspaceScrollArea .inputPageBreak').length; var hidePage = $('.fvWorkspaceScrollArea .inputPageBreak.' + CONST_CSS_CLASS_HIDE_SESSION).length; var hideOnMobileAppPage = $('.fvWorkspaceScrollArea .inputPageBreak.hideOnMobileApp').length; var hideOnMobileAppAndRelevancePage = $('.fvWorkspaceScrollArea .inputPageBreak.hideOnMobileApp.' + CONST_CSS_CLASS_HIDE_SESSION).length; var hidePageCount = hidePage + hideOnMobileAppPage - hideOnMobileAppAndRelevancePage; $('.pageMenuIconText').empty().append('Pages(' + (pages - hidePageCount) + ')'); if((pages - hidePageCount) <= 1 ){ $('#pageMenuIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION); $('.liFvPageIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION); // CO-2051 hide page icon $('.pageMenuIconText').addClass(CONST_CSS_CLASS_HIDE_SESSION); } else{ $('#pageMenuIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $('.liFvPageIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $('.pageMenuIconText').removeClass(CONST_CSS_CLASS_HIDE_SESSION); } } } catch(e){} if(isStateChage){ $(this).trigger("Control_Update"); var childs = $(this).find('.fvControl'); for(var i=0;i 0){ if(!isHideCtrl){ $(this).addClass(hideClass); isStateChage = true; } }else{ if(ctrlPropreties.isCtrlHidden){ if(!isHideCtrl){ $(this).addClass(hideClass); isStateChage = true; //CO-6062: Select Multiple changes value on edit //if(fvDataNS.isLoading == true && fvDataNS.isdispatch == true){ if(fvDataNS.isLoading == true){ isSetDefaultValueIfEmpty = true; } if (control.type == CONST_CTRL_TYPE_GROUP) { hideShowRefControl(ctrlPropreties.id, ctrlPropreties.isCtrlHidden, hideClass); } } }else{ if(isHideCtrl){ $(this).removeClass(hideClass); resizeTextareaWhenUnhide($(this)); if(control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ //renderRepeatableSummary(control.id); } if (control.type == CONST_CTRL_TYPE_GROUP) { hideShowRefControl(ctrlPropreties.id, ctrlPropreties.isCtrlHidden, hideClass); } //reArrangeLayoutOfChooseOneWithShadingWALastAction($(this)); isStateChage = true; //isSetDefaultValueIfEmpty = true; } } } if(isStateChage){ if(isSetDefaultValueIfEmpty){ if((control.defaultValue != undefined && control.defaultValue != '') && (ctrlPropreties.val == undefined || ctrlPropreties.val == '')){ //ctrlPropreties.val = control.defaultValue; $(this).trigger('clearData', true); } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(!$(this).hasClass(hideClass)){ $(this).trigger('Calculate_Data_Change_New', true); } }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(!$(this).hasClass(hideClass)){ $(this).trigger('Calculate_Data_Change_New', true); } } if(isHideCtrl && (ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLTABLE || ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLSCHEDULE) && control.isVariableNumberRow){ var controlName = fvDataNS.ctrlMap[ctrlPropreties.rowValSource]; var valObj = getControlInputValueNew(controlName, ctrlPropreties); var tmpLoopCountNew = 0; if(valObj != undefined && (valObj.value || '' != '')){ if(valObj.isParentCtrlHidden || valObj.isCtrlHidden){ }else{ if(!isNaN(valObj.value)){ tmpLoopCountNew = parseInt(valObj.value); // Save current value for next checking [Change Value] ctrlPropreties.tmpLoopCountSaveOnlyForChecking = tmpLoopCountNew; if(tmpLoopCountNew > ctrlPropreties.maxLoopCount){ tmpLoopCountNew = ctrlPropreties.maxLoopCount; } } } } ctrlPropreties.tmpLoopCount = tmpLoopCountNew; $control.find('.controlData table').trigger("changeTableDataSource", [true, false]); }else{ if(isHideCtrl && (ctrlType == CONST_CTRL_TYPE_CTRLTABLE || ctrlType == CONST_CTRL_TYPE_CTRLSCHEDULE || ctrlType == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY)){ $control.find('.controlData table').trigger("changeTableDataSource", [true, false]); } if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLGRID || ctrlPropreties.ctrlType == CONST_CTRL_TYPE_GROUP || ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLSCORETABLE || ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLTABLE || ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLSCHEDULE || ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLPOD){ var childs = $(this).find('.fvControl'); //childs.trigger('fvParentCtrlShowHideChange', [$(this).hasClass(hideClass), addToChangeList]); for(var i=0;i 0){ $(this).find('img').trigger('onload'); } if(isStateChage && ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ if($(this).hasClass(hideClass)){ $('.formView .scoreSummary').addClass(hideClass); }else{ $('.formView .scoreSummary').removeClass(hideClass); } } event.stopPropagation(); }) .on("fvParentCtrlShowHideChange", function(event, ctrlHidden, addToChangeList, triggerCtrlID){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } if(triggerCtrlID && this.id !== triggerCtrlID){ event.stopPropagation(); return; } ctrlPropreties.isParentCtrlHidden = ctrlHidden; if(addToChangeList){ if(ctrlHidden == false){ ctrlPropreties.isValueChange = true; } if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } //CO-6062: Select Multiple changes value on edit if(fvDataNS.isLoading){ $(this).trigger('clearData', true); //CO-6655: Records where one Employees EarnCode did not populate if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ ctrlPropreties.destinationNotFound = true; } } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger('Control_Update'); } event.stopPropagation(); }) // CO-4022 .on("fvContainerShowHideChange", function(event){ event.stopPropagation(); processHideIf($(this), ctrlPropreties); }); if(ctrlType == CONST_CTRL_TYPE_CTRLTABLE){ var ctrlTablePropreties = fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name]; copyPropertiesToParrent(ctrlTablePropreties, ctrlPropreties); } /*fvDataNS.ctrlIndex++; $control.find('.controlData').attr('id', 'ctrlDataId_' + fvDataNS.ctrlIndex); ctrlPropreties.ctrlDataId = fvDataNS.ctrlIndex;*/ if(control.usechecklist != undefined && control.usechecklist == true && control.children[0] !== undefined && control.children[0].type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ $control.addClass(CONST_CLASS_USECHECKLISTBLUETOOTH); } $control.find('.controlErrorMessage').addClass('ctrlId_' + control.id); if(wpRoot.children().length == 1){ $control.addClass('last-child'); }else if($(wpRoot.children()[wpRoot.children().length - 2]).hasClass('last-child')){ $(wpRoot.children()[wpRoot.children().length - 2]).removeClass('last-child'); $control.addClass('last-child'); } if(control.type == 'inputPageBreak' && parentPath == ''){ if(isFirstPage){ isFirstPage = false; $control.find('.pageBreak').addClass('pageBreakHeader'); }else{ $('.fvWorkspaceScrollArea .pageBreakFooter').removeClass('pageBreakFooterShowDetail').removeClass('pageBreakFooter'); $control.find('.pageBreak').addClass('pageBreakFooter'); if(!$control.find('.fvPageDetail').hasClass('hidePageDetail')){ $control.find('.pageBreak').addClass('pageBreakFooterShowDetail'); } $('.fvWorkspaceScrollArea .lastPageBtn').removeClass('lastPageBtn'); $control.find('.hideShowDetailBtn').addClass('lastPageBtn'); $('.fvWorkspaceScrollArea .fvLastPageDetail').removeClass('fvLastPageDetail'); $control.find('.fvPageDetail').addClass('fvLastPageDetail'); } wpRoot = $control.find('.fvPageWorkspace'); } if (control.type == CONST_CTRL_TYPE_GROUP || (control.type == 'ctrlBreakPointData')){ ctrlPropreties.tmpLoopCount = 10; // CO-1322: set HeaderWith value for ctrlProperties ctrlPropreties.isReplaceRepeatableHeader = control.isReplaceRepeatableHeader; ctrlPropreties.replaceRepeatableHeaderWith = control.replaceRepeatableHeaderWith; if(control.isReplaceRepeatableHeader && control.replaceRepeatableHeaderWith){ if(!fvDataNS.replaceRepeatIdRef){ fvDataNS.replaceRepeatIdRef = {}; } if(!fvDataNS.replaceRepeatIdRef[control.replaceRepeatableHeaderWith]){ fvDataNS.replaceRepeatIdRef[control.replaceRepeatableHeaderWith] = []; } fvDataNS.replaceRepeatIdRef[control.replaceRepeatableHeaderWith].push(control.id); } // CO-1322-END // CO-3735:Add option to clear repeats when variable start ctrlPropreties.isDeleteWhenVarChange = control.isDeleteWhenVarChange; // CO-3735:Add option to clear repeats when variable end // CO-2745 Auto collapse repeat - new setting if(isVersion(VERSION_AUTO_COLLAPSE_REPEAT)){ ctrlPropreties.isAutoCollapseRepeat = control.isAutoCollapseRepeat; } // CO-2745-END if(control.loop == undefined){ control.loop = ''; }else{ control.loop = control.loop.toString(); } if(control.loop != ''){ if(control.loop.indexOf("&") == 0){ control.loop = control.loop.replace(/&/gi, ""); } ctrlPropreties.tmpLoopCount = parseInt(control.loop); } var maxLoopCount = ctrlPropreties.tmpLoopCount; if(fvDataNS.incomplete && ctrlPropreties.loopCount){ if(!isNaN(ctrlPropreties.loopCount)){ ctrlPropreties.tmpLoopCount = ctrlPropreties.loopCount; } } if(control.isAllRepRequired){ ctrlPropreties.isAllRepRequired = true; } if(isVersion(VERSION_REQUIRED_REPEAT) && control.requiredRows){ ctrlPropreties.requiredRows = true; ctrlPropreties.requiredOptionsGroup = control.requiredOptionsGroup; } var loopCountNew = 0; if(control.isVariableRepeats && 1==1){ ctrlPropreties.isVariableRepeats = true; ctrlPropreties.repValSource = control.repValSource; var controlName = fvDataNS.ctrlMap[control.repValSource]; var valObj = getControlInputValueNew(controlName, ctrlPropreties); if(valObj == null || valObj.value == ''){ ctrlPropreties.tmpLoopCount = 0; }else{ if(valObj.isParentCtrlHidden || valObj.isCtrlHidden){ loopCountNew = 0; }else{ try{ loopCountNew = parseInt(valObj.value); if(isNaN(loopCountNew)){ loopCountNew = 0; } }catch (e) { loopCountNew = 0; } if(isNaN(loopCountNew)){ loopCountNew = 0; } } if(loopCountNew <= 0){ ctrlPropreties.tmpLoopCount = 0; }else if(loopCountNew <= maxLoopCount){ ctrlPropreties.tmpLoopCount = loopCountNew; }else{ ctrlPropreties.tmpLoopCount = maxLoopCount; } } } var groupName = control.name; // old () // deleted // new start var loadRecurseGroupFV = function(parrentInputProperties, groupIndex, $control, control, $ctrlGroupWorkspaceInner, $ctrlGroupFooter, maxRepeatCount, isAddNew){ var i; if(isAddNew){ i = parrentInputProperties.children.length; }else{ var tmp = groupIndex; i = 0; while(tmp >= 0 && i < parrentInputProperties.children.length){ if(parrentInputProperties.children[i]){ tmp--; } if(tmp>=0){ i++; } } } if(isVersion(VERSION_AUTO_COLLAPSE_REPEAT) && parrentInputProperties.isAutoCollapseRepeat){ var curProperties = parrentInputProperties.children[i - 1]; if(curProperties && curProperties[CONST_CLS_CLASSPATH]){ var classPath = curProperties[CONST_CLS_CLASSPATH]; var groupItem = fvDataNS.ctrlArray[classPath]; if(!groupItem.hasClass(CONST_CLS_COLLAPSE)){ groupItem.find('.controlLabelButtonDelete4Shading .expandCollapse').click(); } } } var ctrlPropretiesGroup = { name: control.name, classPath: parrentInputProperties.classPath + CONST_VALUE_DASH_LOOP + (i + 1), isLoopChildItem: true, id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [], parentKind: CONST_CTRL_TYPE_GROUP, // CO-1322: set HeaderWith value for ctrlProperties isReplaceRepeatableHeader: control.isReplaceRepeatableHeader, replaceRepeatableHeaderWith: control.replaceRepeatableHeaderWith // CO-1322-END }; if(parrentInputProperties.requiredRows == true){ ctrlPropretiesGroup.requiredRows = true; ctrlPropretiesGroup.requiredOptionsGroup = parrentInputProperties.requiredOptionsGroup; } if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropretiesGroup.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropretiesGroup.hideWebApp = true; if($control.hideWebApp == undefined){ $control.hideWebApp = {}; } $control.hideWebApp.value = true; }else{ ctrlPropretiesGroup.hideWebApp = false; if($control.hideWebApp != undefined){ $control.hideWebApp.value = true; } } } } if(fvDataNS.incomplete){ var tmp = ctrlPropretiesGroup; ctrlPropretiesGroup = getCtrlIncompleteProperties(parrentInputProperties, ctrlPropretiesGroup); if(ctrlPropretiesGroup == undefined){ ctrlPropretiesGroup = tmp; parrentInputProperties.children.push(ctrlPropretiesGroup); ctrlPropretiesGroup.parrentProperties = parrentInputProperties.classPath; } }else{ parrentInputProperties.children.push(ctrlPropretiesGroup); ctrlPropretiesGroup.parrentProperties = parrentInputProperties.classPath; } fvDataNS.dataArray[ctrlPropretiesGroup.classPath] = ctrlPropretiesGroup; var $groupLoop = addGroupLoopItem(ctrlPropretiesGroup, groupName, i + 1, $ctrlGroupWorkspaceInner, parrentInputProperties); // CO-3976 var getHeaderQuestionRepeat2 = function(groupChildren, replaceHeaderId){ var objHeaderReplace = undefined; try{ var gridParent = ''; for(var t = 0; t < groupChildren.length; t++){ var control = groupChildren[t]; if(control.type == CONST_CTRL_TYPE_CTRLGRID){ for(var j = 0; j < control.children.length; j++){ var child = control.children[j]; if(child.id == replaceHeaderId){ objHeaderReplace = child; gridParent = control.name; break; } } } else if(control.id == replaceHeaderId){ objHeaderReplace = control; break; } } if(objHeaderReplace && gridParent != ''){ objHeaderReplace.classPath = gridParent + ' ' + objHeaderReplace.name; } } catch(e){} return objHeaderReplace; } var $groupLoopWorkspaceInner = $groupLoop.find('.workspaceInner'); if(control.isRepCountDisplay){ $groupLoop.find('.controlLabel').on('update_group_label', function(event) { // CO-1322, CO-3976: Replace Repeatable Header if(control.isReplaceRepeatableHeader) { var getValueFromHeaderQuestion = ''; try{ var replaceHeaderRepeatObj = getHeaderQuestionRepeat2(control.children, control.replaceRepeatableHeaderWith); if(replaceHeaderRepeatObj && replaceHeaderRepeatObj.defaultValue){ getValueFromHeaderQuestion = replaceHeaderRepeatObj.defaultValue; } if(fvDataNS.currentForm.editRecordData != undefined){ var tmpProperties = {}; tmpProperties.name = replaceHeaderRepeatObj.name; tmpProperties.ctrlType = replaceHeaderRepeatObj.type; tmpProperties.parentKind = ctrlPropretiesGroup.parentKind; tmpProperties.classPath = ctrlPropretiesGroup.classPath + ' ' + (replaceHeaderRepeatObj.classPath ? replaceHeaderRepeatObj.classPath : replaceHeaderRepeatObj.name); var editVal = getEditRecordData2(tmpProperties, fvDataNS.currentForm.editRecordData); if(editVal != undefined){ getValueFromHeaderQuestion = editVal; } } } catch(e){} if(getValueFromHeaderQuestion != ''){ getValueFromHeaderQuestion += ' '; } $(this).empty() .append(control.label.eng + ' (' + getValueFromHeaderQuestion + '' + ( groupIndex + 1) + '/' + ctrlPropreties.tmpLoopCount + ')'); /*$(this).empty() .append(control.label.eng + ' (' + getHeaderQuestionRepeat[0].label.eng + ' ' + ( groupIndex + 1) + '/' + ctrlPropreties.tmpLoopCount + ')'); */ //hqkhanh fix the same mobile //.append(parentPath + control.label.eng + ' (' + ( groupIndex + 1) + '/' + ctrlPropreties.tmpLoopCount + ')'); } else { $(this).empty() .append(control.label.eng + ' (' + ( groupIndex + 1) + '/' + ctrlPropreties.tmpLoopCount + ')'); //hqkhanh fix the same mobile //.append(parentPath + control.label.eng + ' (' + ( groupIndex + 1) + '/' + ctrlPropreties.tmpLoopCount + ')'); } // CO-1322-END }).trigger('update_group_label'); }else{ // CO-1322, CO-3976: Replace Repeatable Header if(control.isReplaceRepeatableHeader) { var getValueFromHeaderQuestion = ''; try{ var replaceHeaderRepeatObj = getHeaderQuestionRepeat2(control.children, control.replaceRepeatableHeaderWith); if(replaceHeaderRepeatObj && replaceHeaderRepeatObj.defaultValue){ getValueFromHeaderQuestion = replaceHeaderRepeatObj.defaultValue; } if(fvDataNS.currentForm.editRecordData != undefined){ var tmpProperties = {}; tmpProperties.name = replaceHeaderRepeatObj.name; tmpProperties.ctrlType = replaceHeaderRepeatObj.type; tmpProperties.parentKind = ctrlPropretiesGroup.parentKind; tmpProperties.classPath = ctrlPropretiesGroup.classPath + ' ' + (replaceHeaderRepeatObj.classPath ? replaceHeaderRepeatObj.classPath : replaceHeaderRepeatObj.name); var editVal = getEditRecordData2(tmpProperties, fvDataNS.currentForm.editRecordData); if(editVal != undefined){ getValueFromHeaderQuestion = editVal; } } } catch(e){} var data = ''; if(getValueFromHeaderQuestion == ''){ getValueFromHeaderQuestion = (groupIndex + 1).toString(); data = getValueFromHeaderQuestion; } $groupLoop.find('.controlLabel') .empty() .append(control.label.eng + ' (' + getValueFromHeaderQuestion + ')'); //hqkhanh fix the same mobile //.append(parentPath + control.label.eng + ' (' + ( groupIndex + 1) + ')'); } else { $groupLoop.find('.controlLabel') // CO-1322-END .empty() .append(control.label.eng + ' (' + ( groupIndex + 1) + ')'); //hqkhanh fix the same mobile //.append(parentPath + control.label.eng + ' (' + ( groupIndex + 1) + ')'); } } if(i==0){ ctrlPropretiesGroup.isCtrlHidden = false; var isGroupFooterExisted = false; if($($ctrlGroupFooter[$ctrlGroupFooter.length - 1]).hasClass('groupFooter') && $($ctrlGroupFooter[$ctrlGroupFooter.length - 1]).find('.groupFooterButton').length > 0){ $groupFooterButton = $($ctrlGroupFooter[$ctrlGroupFooter.length - 1]).find('.groupFooterButton'); isGroupFooterExisted = true; }else{ $groupFooterButton = $('#formview_templates .groupFooterButton') .clone() .appendTo($ctrlGroupFooter); } if(parrentInputProperties.inputRepeatCount == undefined){ parrentInputProperties.inputRepeatCount = 1; } if(parrentInputProperties.inputRepeatCount >= ctrlPropreties.tmpLoopCount){ $groupFooterButton.find('.groupAdd').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP).addClass(CONST_CSS_CLASS_GROUP_FULL); }else if(isLastGroupEmpty(parrentInputProperties)){ $groupFooterButton.find('.groupAdd').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP).removeClass(CONST_CSS_CLASS_GROUP_FULL); } if(!isGroupFooterExisted){ // Apply button Add New with shading and width: 100% // PCA-293: Webapp/Preview - Apply new block formats for all widgets. //if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && glbBuildFormSettingsWA.isShadedheadings === true) { if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { if (control.repeatTransitionText !== undefined && control.repeatTransitionText.eng !== undefined) { var repeatTransitionText = control.repeatTransitionText.eng // Fix bug 0025894: Group in Group - Button 'This question ends....' of Group is not good // Fix bug 0025660: Group - Repeat section Button doesn't smooth in case 'Repeat transitition text' doesn't input on Build Form if (!repeatTransitionText || repeatTransitionText === null || repeatTransitionText === '' ) { repeatTransitionText = msg_warning_add_group_item; } $groupFooterButton.find('.groupAdd') .text(repeatTransitionText) ; } // Hide button "Delete" $groupFooterButton.find('.groupDelete').hide(); } $groupFooterButton.find('.groupAdd') .click(function(event, notShowConfirmMsg, dontCallTrigger, dontCheckRepeatCount) { // Check if this button is hidden or not // (by check class hideSessionImp if (!dontCheckRepeatCount && $(this).hasClass(CONST_CSS_CLASS_HIDE_SESSION_IMP)) { if(!notShowConfirmMsg || !dontCallTrigger){ writeToLogInfo('This group is HIDDEN => DO NOTHING ...'); return; } } // read only if(!dontCheckRepeatCount && !fvDataNS.isLoading && $(this).parents('.group').hasClass('ctrlReadOnly')){ writeToLogInfo('This group is readonly => DO NOTHING ...'); return; } // 0025805: Add New - Select Multiple - 'Display' property work incorrectly after this widget is shown by Trigger Relevance // 0025807: Add New - Image inside Group - Button doesn't smooth after this widget is shown by Trigger Relevance // // Reset the array data using in Shading layout // listOptionsControls4WAShadings = new Array(); // listMediaControls4WAShadings = new Array(); // listCounterControls4WAShadings = new Array(); // // listContainerControls4WAShadings = new Array(); if(notShowConfirmMsg){ event.stopPropagation(); if(dontCheckRepeatCount == true || parrentInputProperties.inputRepeatCount < ctrlPropreties.tmpLoopCount){ loadRecurseGroupFV(parrentInputProperties, parrentInputProperties.inputRepeatCount, $control, control, $ctrlGroupWorkspaceInner, $ctrlGroupFooter, maxRepeatCount, false); var lastGroupIndex = parrentInputProperties.children.length - 1; var lastGroupProperty = parrentInputProperties.children[lastGroupIndex]; if(lastGroupProperty.children.length > 0){ if(!notShowConfirmMsg && !dontCallTrigger){ var firstCtrlInGroup = lastGroupProperty.children[0]; fvCtrlFocus(fvDataNS.ctrlArray[firstCtrlInGroup.classPath], false); } } parrentInputProperties.inputRepeatCount += 1; setDontCallTrigger(); var inputCtrls = getInputCtrlSortList(fvDataNS.inputData); fvDataNS.inputCtrlsSrt = inputCtrls; resetListCtrlChange(); if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } var newGroupItem = parrentInputProperties.children[parrentInputProperties.children.length - 1]; addToListCtrlChange(newGroupItem); if(!dontCallTrigger){ resetDontCallTrigger(); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(undefined, true); } //$ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + ctrlPropreties.inputRepeatCount).trigger('AddGroupItem', groupName); }else{ $(this).addClass(CONST_CSS_CLASS_GROUP_FULL); } if(parrentInputProperties.inputRepeatCount >= ctrlPropreties.tmpLoopCount){ $(this).addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP);//.remove(); } initCtrlWidth(); }else{ var ctrlAction = $(this); var confirmMsg = msg_warning_add_group_item; // Fix bug 0019620: Warning message is empty when "Repeat transition text" is empty if(control.repeatTransitionText !== undefined && control.repeatTransitionText !== null && control.repeatTransitionText.eng !== undefined && control.repeatTransitionText.eng !== null && control.repeatTransitionText.eng != ''){ confirmMsg = control.repeatTransitionText.eng; } /* Please do that it is not needed if the customer clicks the “Add New” button. So we would only use it in QV. */ //jConfirm(confirmMsg,lbl_warning,function(result2){ //if(result2){ event.stopPropagation(); if(dontCheckRepeatCount == true || parrentInputProperties.inputRepeatCount < ctrlPropreties.tmpLoopCount){ loadRecurseGroupFV(parrentInputProperties, parrentInputProperties.inputRepeatCount, $control, control, $ctrlGroupWorkspaceInner, $ctrlGroupFooter, maxRepeatCount, true); var lastGroupIndex = parrentInputProperties.children.length - 1; var lastGroupProperty = parrentInputProperties.children[lastGroupIndex]; if(lastGroupProperty.children.length > 0){ if(!notShowConfirmMsg && !dontCallTrigger){ var firstCtrlInGroup = lastGroupProperty.children[0]; fvCtrlFocus(fvDataNS.ctrlArray[firstCtrlInGroup.classPath], false); } } parrentInputProperties.inputRepeatCount += 1; setDontCallTrigger(); var inputCtrls = getInputCtrlSortList(fvDataNS.inputData); fvDataNS.inputCtrlsSrt = inputCtrls; resetListCtrlChange(); if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } var newGroupItem = parrentInputProperties.children[parrentInputProperties.children.length - 1]; addToListCtrlChange(newGroupItem); if(!dontCallTrigger){ resetDontCallTrigger(); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(undefined, true); } //$ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + ctrlPropreties.inputRepeatCount).trigger('AddGroupItem', groupName); } if(parrentInputProperties.inputRepeatCount >= ctrlPropreties.tmpLoopCount){ ctrlAction.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP);//.remove(); } initCtrlWidth(); //} //}); } // Refresh layout for shading (if needed) // Refresh layout after finishing load GUI WebApps reArrangeLayoutOfChooseOneWithShadingWALastAction(); }); $groupFooterButton.on('showHideAddBtn', function(event){ var $ctrlTmp = $(this)[0]; if(parrentInputProperties.inputRepeatCount >= ctrlPropreties.tmpLoopCount){ $($ctrlTmp.parentNode).find('.groupAdd').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP).addClass(CONST_CSS_CLASS_GROUP_FULL); }else{ $($ctrlTmp.parentNode).find('.groupAdd').removeClass(CONST_CSS_CLASS_GROUP_FULL); if(!isLastGroupEmpty(parrentInputProperties)){ // read only if($(this).parents('.group').hasClass('ctrlReadOnly')){ writeToLogInfo('This group is readonly => DO NOTHING ...'); return; } $($ctrlTmp.parentNode).find('.groupAdd').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $($ctrlTmp.parentNode).find('.groupAdd').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } }); $groupFooterButton.find('.groupDelete') // Add the button x when in Shading WebApps /*.add($groupLoop.find('.controlLabelButtonDelete4Shading').click(function(event){$groupFooterButton.find('.groupDelete').trigger('click')}))*/ .on('groupDeleteAll', function(event, deleteAll, newinputRepeatCount){ if(newinputRepeatCount == undefined){ newinputRepeatCount = 0; } if(parrentInputProperties.inputRepeatCount > newinputRepeatCount){ while(parrentInputProperties.inputRepeatCount > newinputRepeatCount){ $(this).trigger('click', [true, deleteAll]); } //$(this).trigger('click', [true, deleteAll]); }else if(parrentInputProperties.inputRepeatCount == 0){ $(this).trigger('click', [true, deleteAll]); } }) .click(function(event, notShowConfirmMsg, deleteAll, resetGroupDeleteMap, deleteIndex) { // read only if(!fvDataNS.isLoading && $(this).parents('.group').hasClass('ctrlReadOnly')){ writeToLogInfo('This group is readonly => DO NOTHING ...'); return; } if(event.cancelable !== undefined || resetGroupDeleteMap){ fvDataNS.groupDeleteMap = {}; } var $ctrlTmp = $(this)[0]; if(notShowConfirmMsg != undefined && notShowConfirmMsg && deleteIndex == undefined){ event.stopPropagation(); if(parrentInputProperties.inputRepeatCount > 1 || deleteAll){ if(parrentInputProperties.inputRepeatCount == 0){ $ctrlGroupWorkspaceInner.find('.' + groupName + '_loop_1').remove(); }else{ $ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + parrentInputProperties.inputRepeatCount).remove(); } var delProperties = parrentInputProperties.children.pop(); parrentInputProperties.inputRepeatCount -= 1; if(parrentInputProperties.inputRepeatCount < 0){ parrentInputProperties.inputRepeatCount = 0; } calculateDataChangeForDeleteItem(fvDataNS.inputData, parrentInputProperties); }else{ if(!fvDataNS.groupDeleteMap){ fvDataNS.groupDeleteMap = {}; } if(fvDataNS.groupDeleteMap[this] != undefined){ return; } fvDataNS.groupDeleteMap[this] = true; $ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + parrentInputProperties.inputRepeatCount).trigger('ClearGroupItemData', groupName); } if(parrentInputProperties.inputRepeatCount < ctrlPropreties.tmpLoopCount){ if(!isLastGroupEmpty(parrentInputProperties)){ $($ctrlTmp.parentNode).find('.groupAdd').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP).removeClass(CONST_CSS_CLASS_GROUP_FULL); } }else if(parrentInputProperties.inputRepeatCount == 0){ $control.addClass('hideOnMobileApp'); } }else{ // Fix bug 0019535: Repeatable - Warning message displays incorrectly when delete section var groupCaptionValue = parrentInputProperties.name; if (parrentInputProperties.label !== undefined && parrentInputProperties.label !== null && parrentInputProperties.label.eng !== undefined && parrentInputProperties.label.eng !== null && parrentInputProperties.label.eng !== '') { groupCaptionValue = parrentInputProperties.label.eng; }; if(!deleteIndex){ deleteIndex = parrentInputProperties.inputRepeatCount; } var groupItem = $ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + deleteIndex); var loopIndex = $(groupItem.find('.groupLoopIndex')[0]).text(); var deleteGroupItem = function() { console.log('loopIndex : ' + loopIndex); event.stopPropagation(); if(parrentInputProperties.inputRepeatCount > 1){ $ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + deleteIndex).remove(); //var delProperties = parrentInputProperties.children.pop(); if(deleteIndex == parrentInputProperties.children.length){ parrentInputProperties.children.pop(); while(parrentInputProperties.children.length > 0 && !parrentInputProperties.children[parrentInputProperties.children.length - 1]){ parrentInputProperties.children.pop(); } var i = 1; var groupIndex = 0; while(i <= parrentInputProperties.children.length){ var groupItem = $ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + i); if(groupItem.length>0){ groupIndex++; } i++; } $ctrlGroupWorkspaceInner.attr('loopcount', groupIndex); if(groupIndex <= 1){ $ctrlGroupWorkspaceInner.find('.isTheFirstItem:first .deleteGroupItem:first').css('display', 'none'); }else{ $ctrlGroupWorkspaceInner.find('.isTheFirstItem:first .deleteGroupItem:first').css('display', ''); } }else{ delete(parrentInputProperties.children[deleteIndex - 1]); //change group index after delete an item var i = 1; var groupIndex = 0; while(i <= parrentInputProperties.children.length){ var groupItem = $ctrlGroupWorkspaceInner.find('.' + groupName + CONST_VALUE_DASH_LOOP + i); if(groupItem.length>0){ if(groupIndex == 0){ groupItem.removeClass('notIsTheFirstItem').addClass('isTheFirstItem'); } // CO-1322: Only change repeatable has no header question (isReplaceRepeatableHeader = false) if(!parrentInputProperties.isReplaceRepeatableHeader) { groupItem.find('.groupLoopIndex').empty().append(groupIndex + 1); } // CO-1322-END groupIndex++; } i++; } $ctrlGroupWorkspaceInner.attr('loopcount', groupIndex); if(groupIndex <= 1){ $ctrlGroupWorkspaceInner.find('.isTheFirstItem:first .deleteGroupItem:first').css('display', 'none'); }else{ $ctrlGroupWorkspaceInner.find('.isTheFirstItem:first .deleteGroupItem:first').css('display', ''); } } parrentInputProperties.inputRepeatCount -= 1; if(parrentInputProperties.inputRepeatCount < 0){ parrentInputProperties.inputRepeatCount = 0; } //calculateDataChangeForDeleteItem(fvDataNS.inputData, parrentInputProperties); setDontCallTrigger(); var inputCtrls = getInputCtrlSortList(fvDataNS.inputData); fvDataNS.inputCtrlsSrt = inputCtrls; resetListCtrlChange(); resetListCtrlValue(); var newGroupItem; var i = 0; while(i DO NOTHING ...'); return; } $($ctrlTmp.parentNode).find('.groupAdd').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP).removeClass(CONST_CSS_CLASS_GROUP_FULL); } } } if(notShowConfirmMsg != undefined && notShowConfirmMsg){ deleteGroupItem(); }else{ // Fix bug 0018784: Dialog of 'Delete Section' displaying lack of loops number should do same as Android jConfirm(msg_warning_delete_group_item.replace('$1', groupCaptionValue + '(' + loopIndex + ')'),lbl_warning,function(result2){ if(result2){ setTimeout(deleteGroupItem(), 50); } }); } } }); } } loadRecurseFV($groupLoopWorkspaceInner, control.children, parentPath + control.label.eng + '/', ctrlPropretiesGroup); var parentClass = ctrlPropretiesGroup.classPath.substr(ctrlPropretiesGroup.classPath.lastIndexOf(' ')+1); autoResizeTextarea(parentClass); try { if(isWebAppDispatch()){ // 21820 //$('.ctrlHref .controlLabel .required').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); $('.ctrlHref .controlInfMsg').css(CONST_CSS_KEY_DISPLAY,CONST_VALUE_NONE); //$('.hideOnMobileApp').css(CONST_CSS_KEY_DISPLAY,'block'); } } catch (e) { } } var $ctrlGroupWorkspaceInner = $control.find('.workspaceInner'); var $ctrlGroupFooter = $control.find('.groupFooter'); var defaultLoopCount = 1; if(ctrlPropreties.inputRepeatCount != undefined){ defaultLoopCount = ctrlPropreties.inputRepeatCount; }else{ ctrlPropreties.inputRepeatCount = 1; } if(ctrlPropreties.clearOnRetrieve !== true && fvDataNS.currentForm.editRecordData){ if(!ctrlPropreties.isCtrlHidden){ defaultLoopCount = getEditRecordDataGroupCount(control, ctrlPropreties, fvDataNS.currentForm.editRecordData); ctrlPropreties.inputRepeatCount = defaultLoopCount; }else{ //defaultLoopCount = 0; ctrlPropreties.inputRepeatCount = defaultLoopCount; } }else{ if(control.isVariableRepeats && (control.repValSource || '' != '')){ var controlName = fvDataNS.ctrlMap[control.repValSource]; var valObj = getControlInputValueNew(controlName, ctrlPropreties); if(valObj){ if(!(valObj.isParentCtrlHidden == true || valObj.isCtrlHidden == true)){ if(!isNaN(valObj.value)){ defaultLoopCount = parseInt(valObj.value); if(isNaN(defaultLoopCount)){ defaultLoopCount = 0; } ctrlPropreties.inputRepeatCount = defaultLoopCount; } } } } } if(defaultLoopCount == 0){ loadRecurseGroupFV(ctrlPropreties, 0, $control, control, $ctrlGroupWorkspaceInner, $ctrlGroupFooter, defaultLoopCount, false); $ctrlGroupFooter.find('.groupDelete').trigger('groupDeleteAll', true); $control.find('.group').trigger('RepeatCountChange'); $control.trigger('GroupRepeatCountChange', [0, ctrlPropreties.id]); }else{ for(var j = 0; j < defaultLoopCount; j++){ loadRecurseGroupFV(ctrlPropreties, j, $control, control, $ctrlGroupWorkspaceInner, $ctrlGroupFooter, defaultLoopCount, false); } } // check is variable repeat if(control.isVariableRepeats && 1==1){ $control.on('RepeatCountChange', function(event){ //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath, false); }); $control.off('GroupRepeatCountChange').on('GroupRepeatCountChange', function(event, loopCountChange, ctrlTriggerId){ if(ctrlPropreties.id != ctrlTriggerId){ return; } var groupRepeatCountChange = function(loopCountNewParam){ if(ctrlPropreties.loopCountNew == loopCountNewParam){ return; } var isGTMaxCount = false; if(loopCountNewParam <= 0){ ctrlPropreties.tmpLoopCount = 0; }else if(loopCountNewParam <= maxLoopCount){ ctrlPropreties.tmpLoopCount = loopCountNewParam; }else{ ctrlPropreties.tmpLoopCount = maxLoopCount; if(loopCountNewParam){ isGTMaxCount = true; } } ctrlPropreties.loopCount = ctrlPropreties.tmpLoopCount; ctrlPropreties.loopCountNew = loopCountNewParam; if(ctrlPropreties.tmpLoopCount > 0 ){ if(isGTMaxCount){ alert(lbl_exceed_maximum_number_row); } resetListCtrlChange(); resetListCtrlValue(); for(var j = 0; j < ctrlPropreties.tmpLoopCount; j++){ $ctrlGroupFooter.find('.groupAdd').trigger('click', [true, true]); } //fvDataNS.isExecuteControlChangeRunning = false; resetDontCallTrigger(); executeControlChange(undefined, true); $control.find('.controlLabel').trigger('update_group_label'); $control.removeClass('hideOnMobileApp'); }else{ $control.addClass('hideOnMobileApp'); } } groupRepeatCountChange(loopCountChange); }); if(!fvDataNS.isLoading ){ if(fvDataNS.incomplete){ if(defaultLoopCount == 0){ $ctrlGroupFooter.find('.groupDelete').trigger('groupDeleteAll', true); } }else{ if(loopCountNew != ctrlPropreties.loopCountNew){ $ctrlGroupFooter.find('.groupDelete').trigger('groupDeleteAll', true); $control.trigger('GroupRepeatCountChange', [ctrlPropreties.tmpLoopCount, ctrlPropreties.id]); } } } } // new end }else if (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ if (control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ var colCount = control.columns.length; control.loop = getActiveRepeatCount(control.repeatable); if(control.children == undefined){ control.children = []; } for(var i=0;i 0){ var donotMakeLKConditionalParam = false; if(!fvDataNS.lkConditionalParamcache){ fvDataNS.lkConditionalParamcache = {}; }else if(fvDataNS.lkConditionalParamcache[ctrlPropreties.id]){ lkConditionalParam = fvDataNS.lkConditionalParamcache[ctrlPropreties.id]; donotMakeLKConditionalParam = true; } for(var i=0; i 0){ lkConditionalParam[0]['&id'] = ctrlPropreties.id; } fvDataNS.lkConditionalParamcache[ctrlPropreties.id] = lkConditionalParam; } if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLTABLE && ctrlPropreties.classPath.endsWith('_loop_1')){ var replaced = ctrlPropreties.classPath.substring(0, ctrlPropreties.classPath.lastIndexOf("_loop_1")); addToCtrlIdRefForLookup({value: lookupCtrl.lookupConditionFields}, replaced); } addToCtrlIdRefForLookup({value: lookupCtrl.lookupConditionFields}, ctrlPropreties.classPath); } }else{ if(!fvDataNS.lkDataMap){ fvDataNS.lkDataMap = {}; } fvDataNS.lkDataMap[control.name] = {}; } var isUseEditLoopCount = false; if(control.type !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY && ctrlPropreties.clearOnRetrieve !== true && fvDataNS.currentForm.editRecordData){ if(!ctrlPropreties.isCtrlHidden){ var defaultLoopCount = getEditRecordDataGroupCount(control, ctrlPropreties, fvDataNS.currentForm.editRecordData); ctrlPropreties.tmpLoopCount = defaultLoopCount; isUseEditLoopCount = true; }else{ ctrlPropreties.tmpLoopCount = 0; } }else{ if(control.loop == undefined){ control.loop = ''; }else{ control.loop = control.loop.toString(); } if(control.loop != ''){ if(control.loop.indexOf("&") == 0){ control.loop = control.loop.replace(/&/gi, ""); } ctrlPropreties.tmpLoopCount = parseInt(control.loop); }else{ ctrlPropreties.tmpLoopCount = 10; } if(isVersion(VERSION_USE_CHECKLIST_LIMIT_200)){ if(control.usechecklist && ctrlPropreties.tmpLoopCount < 200){ ctrlPropreties.tmpLoopCount = 200; } } } if(control.isVariableNumberRow){ if(control.loop == undefined){ control.loop = ''; }else{ control.loop = control.loop.toString(); } if(control.loop != ''){ if(control.loop.indexOf("&") == 0){ control.loop = control.loop.replace(/&/gi, ""); } ctrlPropreties.maxLoopCount = parseInt(control.loop); }else{ ctrlPropreties.maxLoopCount = 10; } if(isNaN(ctrlPropreties.maxLoopCount)){ ctrlPropreties.maxLoopCount = 10; } ctrlPropreties.isVariableNumberRow = true; ctrlPropreties.rowValSource = control.rowValSource; if(!isUseEditLoopCount){ var controlName = fvDataNS.ctrlMap[ctrlPropreties.rowValSource]; var valObj = getControlInputValueNew(controlName, ctrlPropreties); if(valObj != undefined && (valObj.value || '' != '')){ if(!isNaN(valObj.value)){ var tmpLoopCountNew = 0; if(valObj.isParentCtrlHidden || valObj.isCtrlHidden){ tmpLoopCountNew = 0; }else{ try{ tmpLoopCountNew = parseInt(valObj.value); if(isNaN(tmpLoopCountNew)){ tmpLoopCountNew = 0; } }catch (e) { tmpLoopCountNew = 0; } } if(tmpLoopCountNew < ctrlPropreties.maxLoopCount){ ctrlPropreties.tmpLoopCount = tmpLoopCountNew; } }else{ ctrlPropreties.tmpLoopCount = 0; } }else{ ctrlPropreties.tmpLoopCount = 0; } } } var callChangeTableDataSource = function(actControl, isFirstTime, isCheckChange, dontResetLoopCount){ if(lkConditionalParam != null && isCheckChange){ var hasCondChange = false; if(fvDataNS.inputCtrlsSrt != null){ for(var i=0; i 200){ ctrlPropreties.tmpLoopCount = 200; } } if(!fvDataNS.lkDataMap){ fvDataNS.lkDataMap = {}; } fvDataNS.lkDataMap[control.name] = {}; fvDataNS.lkDataMap[control.name]['isSearchUndValue'] = lookupCtrl.isSearchUndValue; fvDataNS.lkDataMap[control.name][lookupCtrl.id] = 'Column_' + lkFieldInd; if(!lookupCtrl.isUseCondLookup){ _.each(lookupCtrl.destinationdataconds, function(item){ var lkFieldIndTmp = parseInt(item.value.val.replace('col', ''), 10) - 1; fvDataNS.lkDataMap[control.name][item.text.val] = 'Column_' + lkFieldIndTmp; }); } if(ctrlPropreties.tmpLoopCount <= 0){ ctrlPropreties.tmpLoopCount = 1; } }else{ ctrlPropreties.tmpLoopCount = 1; } }else{ ctrlPropreties.tmpLoopCount = 1; } }else{ if(!isFirstTime){ return; } if(!dontResetLoopCount && !control.isVariableNumberRow){ if(control.loop == undefined){ control.loop = ''; }else{ control.loop = control.loop.toString(); } if(control.loop != ''){ if(control.loop.indexOf("&") == 0){ control.loop = control.loop.replace(/&/gi, ""); } ctrlPropreties.tmpLoopCount = parseInt(control.loop); }else{ ctrlPropreties.tmpLoopCount = 10; } if(isVersion(VERSION_USE_CHECKLIST_LIMIT_200)){ if(control.usechecklist && ctrlPropreties.tmpLoopCount < 200){ ctrlPropreties.tmpLoopCount = 200; } } } } var callChangeTableDataSource2 = function(actControl, isFirstTime, isCheckChange, dontResetLoopCount, isUseChecklist, isShowRowIndex){ if(fvDataNS.incomplete){ if(rootInputProperties.children && rootInputProperties.children.length){ ctrlPropreties.tmpLoopCount = rootInputProperties.children.length; } } //rootInputProperties.children = []; var $tableHeader = $(actControl).find('.tblHeader'); var $tableBody = $(actControl).find('.tblBody'); // remove all table row var rowCount = $tableBody.attr('rowCount'); var startPos = rootInputProperties.children.indexOf(ctrlPropreties); if(rowCount != undefined && rowCount != ''){ ctrlPropreties.children = []; if(startPos>=0){ rootInputProperties.children.splice(startPos + 1, parseInt(rowCount) - 1); } } if(!ctrlPropreties.isCtrlHidden && ctrlPropreties.tmpLoopCount > 0){ $tableBody.attr('rowCount', ctrlPropreties.tmpLoopCount); $control.removeClass(CONST_CSS_CLASS_HIDE_SESSION); var rowIndex = 0; var lookupMap = {}; var lookupCtrlId = control.children[0].id; var lookupCtrlName = control.children[0].name; var lookupCtrlCol = ''; var tableName = ctrlPropreties.name; if(fvDataNS.lkDataMap != undefined && fvDataNS.lkDataMap[tableName] != undefined){ lookupCtrlCol = fvDataNS.lkDataMap[tableName][lookupCtrlId]; } var pleaseResetDontCallTrigger = false; if(!fvDataNS.dontCallTrigger){ pleaseResetDontCallTrigger = true; setDontCallTrigger(true); fvDataNS.callSetToListCtrlDataChange = true; } for(var i=0; i=0){ rootInputProperties.children.splice(startPos + rowIndex, 0, ctrlPropretiesGroup); }else{ rootInputProperties.children.splice(rootInputProperties.children.length, 0, ctrlPropretiesGroup); } } }else{ if(startPos>=0){ rootInputProperties.children.splice(startPos + rowIndex, 0, ctrlPropretiesGroup); }else{ rootInputProperties.children.splice(rootInputProperties.children.length, 0, ctrlPropretiesGroup); } } ctrlPropretiesGroup.parrentProperties = rootInputProperties.classPath; } if(control.isMessageWidget === true){ ctrlPropretiesGroup.isMessageWidget = true; } if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropretiesGroup.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropretiesGroup.hideWebApp = true; if($control.hideWebApp == undefined){ $control.hideWebApp = {}; } $control.hideWebApp.value = true; }else{ ctrlPropretiesGroup.hideWebApp = false; if($control.hideWebApp != undefined){ $control.hideWebApp.value = true; } } } } if(control.isColumnWeightCustom){ ctrlPropretiesGroup.isColumnWeightCustom = true; }else{ ctrlPropretiesGroup.isColumnWeightCustom = false; } if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ ctrlPropretiesGroup.equallySpaceColumns = control.equallySpaceColumns; }else{ ctrlPropretiesGroup.columnsSpaceType = control.columnsSpaceType; if(control.columnsSpaceType == '0'){ ctrlPropretiesGroup.equallySpaceColumns = true; } } if(control.isUseVerticalCaption == undefined || control.isUseVerticalCaption == ''){ ctrlPropretiesGroup.isUseVerticalCaption = false; ctrlPropretiesGroup.captionHeight = 1; }else{ ctrlPropretiesGroup.isUseVerticalCaption = control.isUseVerticalCaption; ctrlPropretiesGroup.captionHeight = control.captionHeight; } if(control.adjustWidthNormal){ ctrlPropretiesGroup.adjustWidthNormal = control.adjustWidthNormal; }else{ ctrlPropretiesGroup.adjustWidthNormal = '100'; } // CO-4008 if(ctrlPropreties.parentPageBreak){ ctrlPropretiesGroup.parentPageBreak = ctrlPropreties.parentPageBreak; } ctrlPropretiesGroup.withFormat4ColumnWeight = control.withFormat4ColumnWeight; ctrlPropretiesGroup.isRowCountDisplay = control.isRowCountDisplay; loadRecurseTableFV($control, control.children, parentPath, ctrlPropretiesGroup, i, rowIndex, false, isUseChecklist, isShowRowIndex); rowIndex++; } if(pleaseResetDontCallTrigger){ resetDontCallTrigger(); fvDataNS.callSetToListCtrlDataChange = false; executeControlChange(ctrlPropreties.classPath, true); } $control.off('table_delete_row').on("table_delete_row", function(event, rowClassPath, noAddEmptyRow){ var rowData = fvDataNS.dataArray[rowClassPath]; var tableRow = $('tr[data-class-path="' + rowClassPath + '"]'); if(tableRow.length > 0){ var tableProperties = tableRow.parents('.ctrlTable').data('odkControlCtrlPropreties'); tableRow.remove(); if(rowData.children && rowData.children.length > 0){ rowData.children.forEach(function callback(itemValue, itemIndex) { delete(fvDataNS.dataArray[itemValue.classPath]); // var tmpObj = Object.assign({}, fvDataNS.autoStampTriggerMap); // tmpObj = deleteObjectProperty (tmpObj, itemValue.classPath, true); // fvDataNS.autoStampTriggerMap = Object.assign({}, tmpObj); if(fvDataNS.autoStampTriggerMap && itemValue && itemValue.autoActionStampTrigger) { if(fvDataNS.autoStampTriggerMap[itemValue.autoActionStampTrigger]) { if(fvDataNS.autoStampTriggerMap[itemValue.autoActionStampTrigger] [itemValue.autoActionStampQuestionTrigger] && undefined != fvDataNS.autoStampTriggerMap [itemValue.autoActionStampTrigger] [itemValue.autoActionStampQuestionTrigger][itemValue.classPath]) { delete fvDataNS.autoStampTriggerMap[itemValue.autoActionStampTrigger] [itemValue.autoActionStampQuestionTrigger][itemValue.classPath]; } } } }); delete(fvDataNS.dataArray[rowClassPath]); var deleteItemIndex = fvDataNS.dataArray.data.children.indexOf(rowData); fvDataNS.dataArray.data.children.splice(deleteItemIndex, 1); } if(tableProperties.autoAddNewRow == undefined || tableProperties.autoAddNewRow == false){ var orgMaxLoopCount; if(control.loop != ''){ if(control.loop.indexOf("&") == 0){ control.loop = control.loop.replace(/&/gi, ""); } orgMaxLoopCount = parseInt(control.loop); }else{ orgMaxLoopCount = 10; } if($control.find('tbody tr').length < orgMaxLoopCount){ var i = ctrlPropreties.tmpLoopCount; rowIndex = i; if(!noAddEmptyRow) { ctrlPropreties.tmpLoopCount ++; addTableEmptyRow(rowIndex); } } } executeTableChange(rootInputProperties); } }); $control.off('table_add_empty_row').on("table_add_empty_row", function(event, notCheckLoopNum, isAddToListCtrlChange = true){ var i = ctrlPropreties.tmpLoopCount; try{ var maxLoopNum = ctrlPropreties.maxLoop; $control.find('.forCtrlTable.controlData .infoMessage').remove(); if(maxLoopNum != undefined && maxLoopNum != '' && maxLoopNum != '0' && i >= parseInt(maxLoopNum) && $control.find('.forCtrlTable tr').length > maxLoopNum && !notCheckLoopNum && false != isAutoAddEmptyRow){ // CO-4565 //jAlert(msg_warning_table_max_rows_limit); /*if($control.find('.forCtrlTable.controlData .errorMessage.max_rows_limit').length<=0){ $control.find('.forCtrlTable.controlData .errorMessage').remove(); var errorMsg = $('

    '); errorMsg.find('p').append(msg_warning_table_max_rows_limit); $control.find('.forCtrlTable.controlData').append(errorMsg); }*/ if($control.find('.forCtrlTable.controlData .infoMessage.max_rows_limit').length<=0){ //$control.find('.forCtrlTable.controlData .infoMessage').remove(); var infoMessage = $('

    '); infoMessage.find('p').append(msg_warning_table_max_rows_limit); $control.find('.forCtrlTable.controlData').append(infoMessage); } return; } } catch(e){} var lastLoopPos = ctrlPropreties.classPath.lastIndexOf('_loop_'); var splitStr = ctrlPropreties.classPath.substr(0, lastLoopPos + 6) + i; var lastRow = $('[data-class-path="' + splitStr + '"]'); if(lastRow.find('.fvControl.ctrl_selected').length == 0 && !notCheckLoopNum){ return; } rowIndex = i; ctrlPropreties.tmpLoopCount ++; if(isUseChecklist && fvDataNS.lkData[tableName][i]){ if(fvDataNS.lkData[tableName + ' duplicate'] == true){ }else{ var luValue = fvDataNS.lkData[tableName][i][lookupCtrlCol] || ''; if(lookupMap[luValue]){ return; }else{ lookupMap[luValue] = true; } } } addTableEmptyRow(rowIndex, isAddToListCtrlChange); var parentClass = control.name + CONST_VALUE_DASH_LOOP + (rowIndex + 1); autoResizeTextarea(parentClass); }); var addTableEmptyRow = function(rowIndex, isAddToListCtrlChange = true){ var ctrlPropretiesGroup; if(rowIndex == 0){ ctrlPropretiesGroup = ctrlPropreties; ctrlPropreties.classPath = rootInputProperties.classPath + ' ' + control.name + CONST_VALUE_DASH_LOOP + (rowIndex + 1); var ctrlPropretiesTable = getPropertiesByID(control.id); ctrlPropretiesTable.children= []; ctrlPropretiesTable.children.push(ctrlPropretiesGroup); }else{ var startPos = rootInputProperties.children.indexOf(ctrlPropreties); ctrlPropretiesGroup = { name: control.name, classPath: rootInputProperties.classPath + ' ' + control.name + CONST_VALUE_DASH_LOOP + (rowIndex + 1), id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [], parentKind: 'table' }; var ctrlPropretiesTable = getPropertiesByID(control.id); ctrlPropretiesTable.children.push(ctrlPropretiesGroup); if(isVersion(VERSION_TABLE_REQUIRED_ROW)){ ctrlPropretiesGroup.requiredRows = control.requiredRows; } if(startPos>=0){ rootInputProperties.children.splice(startPos + rowIndex, 0, ctrlPropretiesGroup); }else{ rootInputProperties.children.splice(rootInputProperties.children.length, 0, ctrlPropretiesGroup); } ctrlPropretiesGroup.parrentProperties = rootInputProperties.classPath; } if(control.isMessageWidget === true){ ctrlPropretiesGroup.isMessageWidget = true; } if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropretiesGroup.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropretiesGroup.hideWebApp = true; if($control.hideWebApp == undefined){ $control.hideWebApp = {}; } $control.hideWebApp.value = true; }else{ ctrlPropretiesGroup.hideWebApp = false; if($control.hideWebApp != undefined){ $control.hideWebApp.value = true; } } } } if(control.isColumnWeightCustom){ ctrlPropretiesGroup.isColumnWeightCustom = true; }else{ ctrlPropretiesGroup.isColumnWeightCustom = false; } if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ ctrlPropretiesGroup.equallySpaceColumns = control.equallySpaceColumns; }else{ ctrlPropretiesGroup.columnsSpaceType = control.columnsSpaceType; if(control.columnsSpaceType == '0'){ ctrlPropretiesGroup.equallySpaceColumns = true; } } if(control.isUseVerticalCaption == undefined || control.isUseVerticalCaption == ''){ ctrlPropretiesGroup.isUseVerticalCaption = false; ctrlPropretiesGroup.captionHeight = 1; }else{ ctrlPropretiesGroup.isUseVerticalCaption = control.isUseVerticalCaption; ctrlPropretiesGroup.captionHeight = control.captionHeight; } if(control.adjustWidthNormal){ ctrlPropretiesGroup.adjustWidthNormal = control.adjustWidthNormal; }else{ ctrlPropretiesGroup.adjustWidthNormal = '100'; } ctrlPropretiesGroup.withFormat4ColumnWeight = control.withFormat4ColumnWeight; ctrlPropretiesGroup.isRowCountDisplay = control.isRowCountDisplay; loadRecurseTableFV($control, control.children, parentPath, ctrlPropretiesGroup, i, rowIndex, false, isUseChecklist, isShowRowIndex); if(isAddToListCtrlChange) { addToListCtrlChange(ctrlPropretiesGroup); } refreshLayout4GridTableShadingWA($control, control.type, control); } var lastRow = $control.find('tbody tr:last-child'); if(!isUseChecklist && !isEmtyRow(lastRow)){ if($control.hasClass('auto-add-new-row')){ $control.trigger('table_add_empty_row'); } } var executeTableChange = function(rootInputProperties){ pushToLoadingQueue(); setTimeout(function(){ try { if(fvDataNS.isExecuteControlChangeRunning){ executeTableChange(rootInputProperties); }else{ var startPos = rootInputProperties.children.indexOf(ctrlPropreties); setDontCallTrigger(); var inputCtrls = getInputCtrlSortList(fvDataNS.inputData); fvDataNS.inputCtrlsSrt = inputCtrls; resetListCtrlChange(); fvDataNS.isExecuteControlChangeRunning = false; resetListCtrlValue(true); for(var i=0; i '); if(tblHeaderCol.hasClass(CONST_CSS_CLASS_HIDE_SESSION)){ cel.addClass(CONST_CSS_CLASS_HIDE_SESSION); } if(tblHeaderCol.hasClass('hideOnMobileApp')){ cel.addClass('hideOnMobileApp'); } tblBodyRow.append(cel); } }else{ tblBodyRow.remove(); } } } // Refresh layout in case of useChecklist + LK Conditional of field LK in FixedTables // Fix bug 0025561: Add New-Table checklist - Automatically change from First col only/Every other col to Every other row after filling value for LU if(isUseChecklist) { // Put this table for apply later (this table) var objItemContainerSP = new Object(); objItemContainerSP.control = $control; objItemContainerSP.ctrlType = control.type; objItemContainerSP.parent = control; listContainerControls4WAShadings.push(objItemContainerSP); } } if(fvDataNS.isLoading || fvDataNS.isRetrieving){ callChangeTableDataSource2(actControl, isFirstTime, isCheckChange, dontResetLoopCount, isUseChecklist, isShowRowIndex); }else{ waitForDataLoading(true); if(!fvDataNS.callChangeTableDataSource2Waiting){ fvDataNS.callChangeTableDataSource2Waiting = {}; } if(fvDataNS.callChangeTableDataSource2Waiting[ctrlPropreties.id] !== true){ fvDataNS.callChangeTableDataSource2Waiting[ctrlPropreties.id] = true; setTimeout(function(){ console.log('callChangeTableDataSource2 : ' + ctrlPropreties.id); fvDataNS.callChangeTableDataSource2Waiting[ctrlPropreties.id] = false; callChangeTableDataSource2(actControl, isFirstTime, isCheckChange, dontResetLoopCount, isUseChecklist, isShowRowIndex); waitForDataLoading(false); }, 10); } } }; $control.find('.controlData table').on('changeTableDataSource', function(event, isFirstTime, isCheckChange){ if(isFirstTime == undefined){ isFirstTime = false; } if(isCheckChange == undefined){ isCheckChange = false; } callChangeTableDataSource(this, isFirstTime, isCheckChange); autoResizeTextarea(CONST_CTRL_TYPE_CTRLTABLE); });//.trigger('changeTableDataSource', true); callChangeTableDataSource($control.find('.controlData table'), true, undefined, true); // Put this table for apply later (this table) var objItemContainer = new Object(); objItemContainer.control = $control; objItemContainer.ctrlType = control.type; objItemContainer.parent = control; listContainerControls4WAShadings.push(objItemContainer); var ctrlTablePropreties = fvDataNS.dataArray[rootInputProperties.classPath + ' ' + control.name]; copyPropertiesToParrent(ctrlTablePropreties, ctrlPropreties); }else if (control.type == CONST_CTRL_TYPE_CTRLPOD){ ctrlPropreties.tmpLoopCount = 0; control.usechecklist = true; if(!fvDataNS.lkDataMap){ fvDataNS.lkDataMap = {}; } fvDataNS.lkDataMap[control.name] = {}; if(fvDataNS.currentForm.editRecordData){ var defaultLoopCount = getEditPODRecordDataGroupCount(control, ctrlPropreties, fvDataNS.currentForm.editRecordData); ctrlPropreties.tmpLoopCount = defaultLoopCount; } var callChangeTableDataSource = function(actControl, isFirstTime, isCheckChange, mobileParam){ isUseChecklist = true; var mobileNumber; if(mobileParam != undefined){ // Dispatch mobile changing if(CONST_VALUE_NONE === ctrlPropreties.podDataSource || 'dispatch' === ctrlPropreties.podDataSource){ waitForDataLoading(false); return; } mobileNumber = mobileParam; try{ // reset current POD datasource for re-loading if(fvDataNS.lkData[control.name] != undefined){ delete fvDataNS.lkData[control.name]; } } catch(e){} } else{ mobileNumber = authNS.currentUser.MobileNumber; } if(!fvDataNS.incomplete && !fvDataNS.currentForm.editRecordData){ switch(ctrlPropreties.podDataSource){ case CONST_VALUE_NONE: break; case 'form': break; case 'inter form': if(ctrlPropreties.datasourceChanged){ ctrlPropreties.datasourceChanged = false; var sourceDs = fvDataNS.inputData.PODExtData[ctrlPropreties.podInterFormName]; //fvDataNS.lkData[control.name] //fvDataNS.lkData[control.name] = []; fvDataNS.podInterFormData = {}; fvDataNS.podInterFormData[control.name] = []; var rowIndex = 0; for(var i=0; i 0){ keyName = keyName.split('__')[1]; } else{ keyName = cellData.label.eng.replace(/\s/g, '_'); } } catch(e){} newRowData[keyName] = cellValue; colIndex ++; /*var arr = cellName.split('__'); if(arr.length == 2){ var specialColName = arr[1].toLowerCase(); switch(specialColName){ case 'qty': case 'id': case 'stopno': newRowData[specialColName] = cellValue; break; default: newRowData['Column_' + colIndex] = cellValue; colIndex ++; } }else{ newRowData['Column_' + colIndex] = cellValue; colIndex ++; }*/ } //fvDataNS.lkData[control.name].push(newRowData); fvDataNS.podInterFormData[control.name].push(newRowData); rowIndex ++; } } } break; default: var isDaily = false; try{ isDaily = control.manifest.withDate; }catch(ex){ isDaily = false; } var suffix = false; try{ suffix = control.manifest.prefix; }catch(ex){ suffix = false; } loadPODData(control.name, mobileNumber, isDaily, suffix); } if(fvDataNS.lkData && fvDataNS.lkData[control.name]){ var luDataCount = fvDataNS.lkData[control.name].length; ctrlPropreties.tmpLoopCount = luDataCount; if(!fvDataNS.lkDataMap){ fvDataNS.lkDataMap = {}; } fvDataNS.lkDataMap[control.name] = {}; var index = 0; _.each(control.children, function(item){ if(item.name && item.name.indexOf('__') >= 0){ var arr = item.name.split('__'); if(arr[1] == undefined){ arr[1] = ''; } switch(arr[1]){ case 'ID': case 'Qty': case 'StopNo': fvDataNS.lkDataMap[control.name][item.name] = arr[1].toLowerCase(); break; case 'Status': case 'AutoID': //ignore field break; } }else{ fvDataNS.lkDataMap[control.name][item.name] = item.name.toLowerCase() + "|Column_" + index; index++; } }); if(control.isSort && control.sortColumn && control.sortColumn != ''){ var sortColumn = fvDataNS.lkDataMap[control.name][control.sortColumn]; if(sortColumn){ var arr = sortColumn.split('|'); sortColumn = arr[0]; if(fvDataNS.lkData[control.name][0] && fvDataNS.lkData[control.name][0][arr[0]]){ }else if(arr[1]){ sortColumn = arr[1]; } fvDataNS.lkData[control.name].sort(function(a, b) { var aVal; try{ aVal = a[sortColumn].toLowerCase(); }catch(ex){ aVal = ''; } var bVal; try{ bVal = b[sortColumn].toLowerCase(); }catch(ex){ bVal = ''; } if (aVal == bVal) { return 0; // if they are equal, return 0 (no sorting) } else if (aVal > bVal) { return 1; // if a should come after b, return 1 } else { return -1; // if b should come after a, return -1 } }); } } if(ctrlPropreties.tmpLoopCount <= 0){ ctrlPropreties.tmpLoopCount = 0; } } // CO-1457: POD Inter form else if(fvDataNS.podInterFormData && fvDataNS.podInterFormData[control.name]){ ctrlPropreties.tmpLoopCount = fvDataNS.podInterFormData[control.name].length; } else{ ctrlPropreties.tmpLoopCount = 0; } } if(fvDataNS.incomplete){ if(rootInputProperties.children && rootInputProperties.children.length){ ctrlPropreties.tmpLoopCount = rootInputProperties.children.length; } } try{ // CO-1456: POD None Data Source if(CONST_VALUE_NONE === ctrlPropreties.podDataSource){ ctrlPropreties.tmpLoopCount = 1; } } catch(e){ } //rootInputProperties.children = []; var $tableHeader = $(actControl).find('.tblHeader'); var $tableBody = $(actControl).find('.tblBody'); // remove all table row var rowCount = $tableBody.attr('rowCount'); var startPos = rootInputProperties.children.indexOf(ctrlPropreties); if(rowCount != undefined && rowCount != ''){ ctrlPropreties.children = []; if(startPos>=0){ rootInputProperties.children.splice(startPos + 1, parseInt(rowCount) - 1); } } $tableBody.attr('rowCount', ctrlPropreties.tmpLoopCount); if(ctrlPropreties.tmpLoopCount > 0){ $control.removeClass(CONST_CSS_CLASS_HIDE_SESSION); var rowIndex = 0; var lookupCountMap = {}; var tableName = ctrlPropreties.name; for(var i=0; i=0){ rootInputProperties.children.splice(startPos + rowIndex, 0, ctrlPropretiesGroup); }else{ rootInputProperties.children.splice(rootInputProperties.children.length, 0, ctrlPropretiesGroup); } } }else{ if(startPos>=0){ rootInputProperties.children.splice(startPos + rowIndex, 0, ctrlPropretiesGroup); }else{ rootInputProperties.children.splice(rootInputProperties.children.length, 0, ctrlPropretiesGroup); } } ctrlPropretiesGroup.parrentProperties = rootInputProperties.classPath; } if(control.isMessageWidget === true){ ctrlPropretiesGroup.isMessageWidget = true; } if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropretiesGroup.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropretiesGroup.hideWebApp = true; if($control.hideWebApp == undefined){ $control.hideWebApp = {}; } $control.hideWebApp.value = true; }else{ ctrlPropretiesGroup.hideWebApp = false; if($control.hideWebApp != undefined){ $control.hideWebApp.value = true; } } } } if(control.isColumnWeightCustom){ ctrlPropretiesGroup.isColumnWeightCustom = true; }else{ ctrlPropretiesGroup.isColumnWeightCustom = false; } if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ ctrlPropretiesGroup.equallySpaceColumns = control.equallySpaceColumns; }else{ ctrlPropretiesGroup.columnsSpaceType = control.columnsSpaceType; if(control.columnsSpaceType == '0'){ ctrlPropretiesGroup.equallySpaceColumns = true; } } ctrlPropretiesGroup.withFormat4ColumnWeight = control.withFormat4ColumnWeight; ctrlPropretiesGroup.isRowCountDisplay = control.isRowCountDisplay; loadRecurseTableFV($control, control.children, parentPath, ctrlPropretiesGroup, i, rowIndex, false, isUseChecklist, false, true); rowIndex++; } if(fvDataNS.currentForm.editRecordData){ loadEditPODOSDReportData(ctrlPropreties, fvDataNS.currentForm.editRecordData); loadEditPODDeliverReportData($control, ctrlPropreties, fvDataNS.currentForm.editRecordData); } if(fvDataNS.incomplete || fvDataNS.currentForm.editRecordData){ if(!fvDataNS.inputData.PODData){ fvDataNS.inputData.PODData = {}; } if(!fvDataNS.inputData.PODData[ctrlPropreties.name]){ fvDataNS.inputData.PODData[ctrlPropreties.name] = {'Qty': 0, 'Damaged': 0, 'Over': 0}; } if(fvDataNS.inputData.PODExtData){ loadDeliveredReportSession($control, ctrlPropreties); } $control.trigger('TrigerControlValueChange'); updateZebraTable($control.find('.controlData table')); updateZebraTable($control.find('.DeliveredReportSession table')); }else{ if(!fvDataNS.inputData.PODData){ fvDataNS.inputData.PODData = {}; } fvDataNS.inputData.PODData[ctrlPropreties.name] = {'Qty': 0, 'Damaged': 0, 'Over': 0}; var $qtyArr = $control.find('.controlData input.__Qty'); if($qtyArr.length == 0){ fvDataNS.inputData.PODData[ctrlPropreties.name].Qty = $control.find('.controlData tbody tr').length; }else{ var qty = 0; for(var i=0; i<$qtyArr.length; i++){ var $item = $($qtyArr[i]); var val = 1; try{ val = parseInt($item.val()); if(isNaN(val)){ val = 1; } }catch(ex){ val = 1; } qty += val; } fvDataNS.inputData.PODData[ctrlPropreties.name].Qty = qty; fvDataNS.inputData.PODData[ctrlPropreties.name].Damaged = 0; fvDataNS.inputData.PODData[ctrlPropreties.name].Over = 0; } } $control.find('.OSDReportSession .OSDRShort').empty().append(fvDataNS.inputData.PODData[ctrlPropreties.name].Qty); $control.find('.OSDReportSession .OSDRDamaged').empty().append(fvDataNS.inputData.PODData[ctrlPropreties.name].Damaged); $control.find('.OSDReportSession .OSDROver').empty().append(fvDataNS.inputData.PODData[ctrlPropreties.name].Over); $control.trigger('TrigerControlValueChange'); var executeTableChange = function(rootInputProperties){ pushToLoadingQueue(); setTimeout(function(){ try { if(fvDataNS.isExecuteControlChangeRunning){ executeTableChange(rootInputProperties); }else{ var startPos = rootInputProperties.children.indexOf(ctrlPropreties); setDontCallTrigger(); var inputCtrls = getInputCtrlSortList(fvDataNS.inputData); fvDataNS.inputCtrlsSrt = inputCtrls; resetListCtrlChange(); fvDataNS.isExecuteControlChangeRunning = false; resetListCtrlValue(true); for(var i=0; i '); if(tblHeaderCol.hasClass(CONST_CSS_CLASS_HIDE_SESSION)){ cel.addClass(CONST_CSS_CLASS_HIDE_SESSION); } if(tblHeaderCol.hasClass('hideOnMobileApp')){ cel.addClass('hideOnMobileApp'); } tblBodyRow.append(cel); } }else{ tblBodyRow.remove(); } } } // Refresh layout in case of useChecklist + LK Conditional of field LK in FixedTables // Fix bug 0025561: Add New-Table checklist - Automatically change from First col only/Every other col to Every other row after filling value for LU if(isUseChecklist) { // Put this table for apply later (this table) var objItemContainerSP = new Object(); objItemContainerSP.control = $control; objItemContainerSP.ctrlType = control.type; objItemContainerSP.parent = control; listContainerControls4WAShadings.push(objItemContainerSP); } }; $control.find('.controlData table').on('changeTableDataSource', function(event, isFirstTime, isCheckChange, mobileParam){ if(isFirstTime == undefined){ isFirstTime = false; } if(isCheckChange == undefined){ isCheckChange = false; } callChangeTableDataSource(this, isFirstTime, isCheckChange, mobileParam); autoResizeTextarea(CONST_CTRL_TYPE_CTRLPOD); autoResizeTextarea(CONST_CTRL_TYPE_CTRLINV); });//.trigger('changeTableDataSource', true); callChangeTableDataSource($control.find('.controlData table'), true); // Put this table for apply later (this table) var objItemContainer = new Object(); objItemContainer.control = $control; objItemContainer.ctrlType = control.type; objItemContainer.parent = control; listContainerControls4WAShadings.push(objItemContainer); }else if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE){ var ctrlPropretiesGroup = ctrlPropreties; ctrlPropretiesGroup.appendComment = control.appendComment; // Apply task : https://doforms.atlassian.net/browse/PCA-136 // (Ability to change the caption when appending a comment in Questionaire) // Add comment label into ctrlPropretiesGroup if (currentVersion >= VERSION_SHOW_COMMENT_LABEL_QUESTIONNAIRE_PRINT_PREVIEW) { if (control.commentLabel !== undefined) { ctrlPropretiesGroup.commentLabel = control.commentLabel; } } if(control.isColumnWeightCustom){ ctrlPropretiesGroup.isColumnWeightCustom = true; ctrlPropretiesGroup.withFormat4ColumnWeight = control.withFormat4ColumnWeight; } if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ ctrlPropretiesGroup.equallySpaceColumns = control.equallySpaceColumns; }else{ ctrlPropretiesGroup.columnsSpaceType = control.columnsSpaceType; if(control.columnsSpaceType == '0'){ ctrlPropretiesGroup.equallySpaceColumns = true; } ctrlPropretiesGroup.withFormat4ColumnWeight = control.withFormat4ColumnWeight; ctrlPropretiesGroup.withFormat4ColumnWeight2 = control.withFormat4ColumnWeight2; } loadRecurseScoreTableFV($control, control.children, parentPath, ctrlPropretiesGroup); updateZebraTable($control.find('.controlData table')); // Put this Questionnaire for applying shading later var objItemContainer = new Object(); objItemContainer.control = $control; objItemContainer.ctrlType = control.type; objItemContainer.parent = control; listContainerControls4WAShadings.push(objItemContainer); }else if (control.type == CONST_CTRL_TYPE_CTRLGRID){ var ctrlPropretiesGroup = ctrlPropreties; if(control.loop == undefined || control.loop == ''){ ctrlPropretiesGroup.colCount = 10; }else{ ctrlPropretiesGroup.colCount = ('' + control.loop).replace('&&&', ''); } if(control.isColumnWeightCustom){ ctrlPropretiesGroup.isColumnWeightCustom = true; ctrlPropretiesGroup.withFormat4ColumnWeight = control.withFormat4ColumnWeight; } if(control.stackedExpand){ ctrlPropretiesGroup.stackedExpand = control.stackedExpand; } if(control.isIgnoreGrid){ ctrlPropretiesGroup.isIgnoreGrid = control.isIgnoreGrid; ctrlPropretiesGroup.ignoreScreenSize = control.ignoreScreenSize; } if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ ctrlPropretiesGroup.equallySpaceColumns = control.equallySpaceColumns; }else{ ctrlPropretiesGroup.columnsSpaceType = control.columnsSpaceType; if(control.columnsSpaceType == '0'){ ctrlPropretiesGroup.equallySpaceColumns = true; } } ctrlPropretiesGroup.withFormat4ColumnWeight = control.withFormat4ColumnWeight; var tmpBoolean1 = false; var tmpBoolean2 = false; var tmpBoolean3 = false; tmpBoolean1 = properties.isIgnoreGrid && properties.isIgnoreGrid.value//grid && properties.ignoreScreenSize && properties.ignoreScreenSize.value && !(previewEmbedHtml && location.protocol == 'https:') && properties.stackedExpand && properties.stackedExpand.value == 'stacked'; if(tmpBoolean1) { tmpBoolean2 = getParent() && getParent().previewMode && getParent().previewMode.size && parseFloat(properties.ignoreScreenSize.value) > parseFloat(getParent().previewMode.size); if(!tmpBoolean2) { tmpBoolean3 = getParent() && !getParent().previewMode && getParent().innerWidth && parseFloat(properties.ignoreScreenSize.value) > (Math.sqrt(getParent().innerWidth * getParent().innerWidth + getParent().innerHeight * getParent().innerHeight) / (inchToPx('1in') * Math.sqrt(2))); } } // if(properties.isIgnoreGrid && properties.isIgnoreGrid.value//grid // && properties.ignoreScreenSize && properties.ignoreScreenSize.value // && !(previewEmbedHtml && location.protocol == 'https:') // && ((getParent() && getParent().previewMode && getParent().previewMode.size // && parseFloat(properties.ignoreScreenSize.value) > parseFloat(getParent().previewMode.size)) // || (getParent() && !getParent().previewMode && getParent().innerWidth // && parseFloat(properties.ignoreScreenSize.value) > // (Math.sqrt(getParent().innerWidth * getParent().innerWidth + getParent().innerHeight // * getParent().innerHeight) / (inchToPx('1in') * Math.sqrt(2))))) // && properties.stackedExpand && properties.stackedExpand.value == 'stacked') { if(tmpBoolean1 && (tmpBoolean2 || tmpBoolean3)) { if(control.gridType == '2') { ctrlPropretiesGroup.colCount = 1; } else if(control.gridType == '1') { ctrlPropretiesGroup.colCount = 1; ctrlPropretiesGroup.caseStackedSatisfied = true; } else if(control.gridType == '') { ctrlPropretiesGroup.colCount = 1; ctrlPropretiesGroup.caseStackedSatisfied = true; } } if(control.isUseVerticalCaption == undefined || control.isUseVerticalCaption == ''){ ctrlPropretiesGroup.isUseVerticalCaption = false; ctrlPropretiesGroup.captionHeight = 1; }else{ ctrlPropretiesGroup.isUseVerticalCaption = control.isUseVerticalCaption; ctrlPropretiesGroup.captionHeight = control.captionHeight; } if(control.adjustWidthNormal){ ctrlPropretiesGroup.adjustWidthNormal = control.adjustWidthNormal; }else{ ctrlPropretiesGroup.adjustWidthNormal = '100'; } ctrlPropretiesGroup.gridType = control.gridType; if(ctrlPropretiesGroup.gridType == CONST_GRID_TYPE_CENTER){ ctrlPropretiesGroup.leftPadding = control.leftPadding; ctrlPropretiesGroup.rightPadding = control.rightPadding; } if(isVersion(VERSION_GRID_TYPE_FUNCTION_WEBAPP) && control.gridType == '1' && !control.isButtonGrid){ loadRecurseGridFV_RowBase($control, control.children, parentPath, ctrlPropretiesGroup); }else if(isVersion(VERSION_GRID_TYPE_FUNCTION_WEBAPP) && control.gridType == '2' && !control.isButtonGrid){ if(ctrlPropretiesGroup.colCount != 1){ loadRecurseGridFV_ColBase($control, control.children, parentPath, ctrlPropretiesGroup); }else{ loadRecurseGridFV_RowBase($control, control.children, parentPath, ctrlPropretiesGroup); } }else if(isVersion(VERSION_GRID_TYPE_CENTER) && control.gridType == CONST_GRID_TYPE_CENTER && control.noCaptions == false){ loadRecurseGridFV_RowBase($control, control.children, parentPath, ctrlPropretiesGroup); }else{ loadRecurseGridFV($control, control.children, parentPath, ctrlPropretiesGroup); } // Put this Grid for apply later (this Grid) var objItemContainer = new Object(); objItemContainer.control = $control; objItemContainer.ctrlType = control.type; objItemContainer.parent = control; // Fwd: FW: bug, I have two free form grids here. One grid is the labels and the other is the text boxes. I removed space below on top and above on bottom. When I did that I lost the line on top of thebox in preview. Not sure if this happens on mobiles or pdfs or printing. Please check and correct. try { formViewUtils.processGridMissingBorderTop(objItemContainer); } catch (e) { } listContainerControls4WAShadings.push(objItemContainer); } // PCA-178: Web App support for Shading and Spacing (custom options) // Apply shading for Table/Grid/Questionnaire // Ignore for OLD FORMs of Shading + Border if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && glbBuildFormSettingsWA.isNewForm4UsingShading !== false) { if(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_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ // PCA-265: Web AppPreview support for color option in Grids, questionnaires and Tables // Do not add oddRow into Grid if (control.type == CONST_CTRL_TYPE_CTRLGRID) { $control.find('table tr').removeClass('oddRow').removeClass('evenRow'); $control.find('table td, table th').removeClass('oddCell').removeClass('evenCell'); } // Add class for custom options var customOptions = getCustomOptionsInObjectWA(control); if (customOptions.apperance === LABEL_CONSTANTS_VALUE_OPTION_BUILD_FORM_APPEARANCE_CUSTOM) { // Only apply when [x]Shade headings // PCA-265: Web AppPreview support for color option in Grids, questionnaires and Tables // PCA-392: WebApp/Preview - Apply changes regarding border option //if (customOptions.isShadedHeadings === true || customOptions.isShadedRow === true) { // Apply custom class var headingColor = 'transparent'; var textColor = ''; var activeTextColor = ''; if (customOptions.isShadedHeadings === true) { headingColor = customOptions.headingColor; textColor = customOptions.textColor; activeTextColor = customOptions.activeTextColor; } // Create new class for custom option indxCustomCtrlOptions4WAShadings++; var classNameContainer = 'shadingHeadingsControl4WA_' + indxCustomCtrlOptions4WAShadings; // Get the matching template var template = TEMPLATE_SHADE_HEADINGS_WEBAPP_TABLE_CONTAINER; template = template.replace(/#class_name_tbl#/g, classNameContainer); if (customOptions.isShadedHeadings === true) { template = template.replace(/#background#/g, headingColor); template = template.replace(/#color#/g, textColor); // PCA-392: WebApp/Preview - Apply changes regarding border option // if (customOptions.isBorderAroundHeading !== true) { // // // Check if we need apply border around heading // if (customOptions.isBorderAroundHeading === true) { // template = template.replace(/#border_color#/g, FORMVIEW_BORDER_COLOR); // } else { // // Get the same color as background // template = template.replace(/#border_color#/g, headingColor); // } // // // Only add no border right with row-based // if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) { // $control.addClass('noBorderSpecial'); // } else if (control.type == CONST_CTRL_TYPE_CTRLTABLE) { // if (control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_FIRST_COL_ONLY // && control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_EVERY_OTHER_COL) { // $control.addClass('noBorderSpecial'); // } // } // } } else { template = template.replace(/#background#/g, CONST_VALUE_INITIAL); } // PCA-392: WebApp/Preview - Apply changes regarding border option if (customOptions.isBorderAroundHeading !== true) { // Check if we need apply border around heading if (customOptions.isBorderAroundHeading === true) { template = template.replace(/#border_color#/g, FORMVIEW_BORDER_COLOR); } else { // Get the same color as background template = template.replace(/#border_color#/g, headingColor); } // Only add no border right with row-based if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) { $control.addClass('noBorderSpecial'); } else if (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) { if (control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_FIRST_COL_ONLY && control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_EVERY_OTHER_COL) { $control.addClass('noBorderSpecial'); } } else if (control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV) { if (control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_FIRST_COL_ONLY && control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_EVERY_OTHER_COL) { $control.addClass('noBorderSpecial'); } } } // PCA-265: Web AppPreview support for color option in Grids, questionnaires and Tables if (customOptions.isShadedRow === true) { var rowColor = customOptions.rowColor; var rowTextColor = customOptions.rowTextColor; template = template.replace(/#background_shade_row#/g, rowColor); template = template.replace(/#color_text_row#/g, rowTextColor); } else { template = template.replace(/#background_shade_row#/g, 'transparent'); } // Add this class template into this control $control.addClass(classNameContainer); listCustomCtrlOptions4WAShadings.push(template); } // PCA-392: WebApp/Preview - Apply changes regarding border option // else { // // Create new class for custom option // indxCustomCtrlOptions4WAShadings++; // var classNameContainer = 'shadingHeadingsControl4WA_' + indxCustomCtrlOptions4WAShadings; // // // The custom default, we will clear all shading rows but skip the shading header // var template = TEMPLATE_SHADE_HEADINGS_WEBAPP_TABLE_CONTAINER; // template = template.replace(/#class_name_tbl#/g, classNameContainer); // template = template.replace(/#background_shade_row#/g, 'transparent'); // // // Add this class template into this control // $control.addClass(classNameContainer); // // listCustomCtrlOptions4WAShadings.push(template); // } } else { // We are in Default Appearance + Shade Headings // Replace the container heading class (Table/Grid/Questionnaire) // Add default template $control.addClass('shadingControlBackground4TableDefault'); // PCA-265: Web AppPreview support for color option in Grids, questionnaires and Tables if (glbBuildFormSettingsWA.isShadedheadings === true) { // PCA-392: WebApp/Preview - Apply changes regarding border option // if (glbBuildFormSettingsWA.isBorderAroundHeading !== true) { // // Only add no border right with row-based // if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) { // $control.addClass('noBorderSpecial'); // } else if (control.type == CONST_CTRL_TYPE_CTRLTABLE) { // if (control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_FIRST_COL_ONLY // && control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_EVERY_OTHER_COL) { // $control.addClass('noBorderSpecial'); // } // } // } } // PCA-392: WebApp/Preview - Apply changes regarding border option if (glbBuildFormSettingsWA.isBorderAroundHeading !== true) { // Only add no border right with row-based if (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) { $control.addClass('noBorderSpecial'); } else if (control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) { if (control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_FIRST_COL_ONLY && control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_EVERY_OTHER_COL) { $control.addClass('noBorderSpecial'); } } else if (control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV) { if (control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_FIRST_COL_ONLY && control.shadedKind !== TABLE_CONSTANTS_VALUE_OPTION_BF_EVERY_OTHER_COL) { $control.addClass('noBorderSpecial'); } } } // Fwd: Questionnaire (9/2/2015 9:22 PM) // Fix error with Table/Questionnaire using Default Appearance + Not shade rows // <=> Show rows with default shading color // Customer ticket : Fwd: Questionnaire (9/2/2015 9:22 PM) // Why in preview (right) are there bigger black lines and no shading but on iOS./Android it looks beautiful? // Only apply with OLD FORM of Shading + Border if (glbBuildFormSettingsWA.isNewForm4UsingShading === false) { if (control.type === CONST_CTRL_TYPE_CTRLSCORETABLE || control.type === CONST_CTRL_TYPE_CTRLTABLE || control.type === CONST_CTRL_TYPE_CTRLSCHEDULE || control.type === CONST_CTRL_TYPE_CTRLPOD || control.type === CONST_CTRL_TYPE_CTRLINV || control.type === CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY) { var tableCells = $control.find('tr:even').addClass('oddRow'); $control.find('tr:odd').addClass('oddRow'); // for (var t = 0; t < tableCells.length; t++) { // var objCell = $(tableCells[t]); // var currentStyle = objCell.attr('style'); // if (!currentStyle || currentStyle === null) { // currentStyle = ''; // } // currentStyle += '; background-color:#E9E9E9 !important;'; // objCell.attr('style', currentStyle); // } } } // if (control.type === CONST_CTRL_TYPE_CTRLSCORETABLE // || (control.type === CONST_CTRL_TYPE_CTRLTABLE && (control.shadedKind === undefined || control.shadedKind === '') ) // ) { // if (glbBuildFormSettingsWA.isShadedRow === false) { // var tableCells = $control.find('tr:even').addClass('oddRow').find('td'); // for (var t = 0; t < tableCells.length; t++) { // var objCell = $(tableCells[t]); // var currentStyle = objCell.attr('style'); // if (!currentStyle || currentStyle === null) { // currentStyle = ''; // } // currentStyle += '; background-color:#E9E9E9 !important;'; // objCell.attr('style', currentStyle); // } // } // } } } } }); }; var loadRecurseTableFV = function($control, controls, parentPath, rootInputProperties, rowIndex, realIndex, headerOnly, isUseChecklist, isShowRowIndex, isPOD, isINV){ if(rootInputProperties != undefined){ fvDataNS.dataArray[rootInputProperties.classPath] = rootInputProperties; if(rootInputProperties.ctrlType !== CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ addToListCtrlChange(rootInputProperties); } } if(isUseChecklist){ $control.addClass('useCheckList'); } var $tableHeader = $control.find('.tblHeader'); var $tableDeliveredHeader = $control.find('.tableDeliveredHeader'); var $tableBodyRow = $(''); $tableBodyRow.attr('data-class-path', rootInputProperties.classPath); //if(isPOD || isINV){ fvDataNS.ctrlArray[rootInputProperties.classPath] = $tableBodyRow; //} $tableBodyRow.addClass('row_' + realIndex); $tableBodyRow.addClass(rootInputProperties.name + '_loop_' + (realIndex+1)); if(realIndex % 2 == 0){ $tableBodyRow.addClass('evenRow'); }else { $tableBodyRow.addClass('oddRow'); } if(realIndex == 0){ $tableHeader.empty(); $control.find('.tblBody').empty(); if(isShowRowIndex){ var rowIndexCel = $(''); $tableHeader.append(rowIndexCel); } if(isPOD || isINV){ $tableDeliveredHeader.empty(); $control.find('.tblDeliveredBody').empty(); } } $control.find('.tblBody').find('.last-row').removeClass('last-row'); $tableBodyRow.addClass('last-row'); $control.find('.tblBody').append($tableBodyRow); if(isVersion(VERSION_CHECKLIST_CONDITION)){ $tableBodyRow.off('Checklist_Conds_Change').on('Checklist_Conds_Change', function(event, addToChangeList){ var ctrlPropreties = $control.data('odkControl-ctrlPropreties'); if(!executeCalculateChecklistConds(ctrlPropreties, rootInputProperties)){ $tableBodyRow.addClass(CONST_HIDEONMOBILEAPP); }else{ $tableBodyRow.removeClass(CONST_HIDEONMOBILEAPP); } }); } var rowIndexCel = null; if(isShowRowIndex){ rowIndexCel = $(''); rowIndexCel.text(realIndex + 1); $tableBodyRow.append(rowIndexCel); } isLookupUseChecklist = true; var itemWidth = {}; var itemMinWidth = {}; var isFixToScreen; var isEquallySpaceColumns; var isColumnWeightCustom = false; var columnWeightCustomArr; var headerVerticalWidth = TABLE_HEADER_HEIGHT; var headerHeight = TABLE_HEADER_HEIGHT; var taltalLength = 0; var hasCache = false; var cacheJson = {}; if(!fvDataNS.cache){ fvDataNS.cache = {}; }else if(fvDataNS.cache[rootInputProperties.id]){ hasCache = true; cacheJson = fvDataNS.cache[rootInputProperties.id]; isFixToScreen = cacheJson.isFixToScreen; isEquallySpaceColumns = cacheJson.isEquallySpaceColumns; isColumnWeightCustom = cacheJson.isColumnWeightCustom; columnWeightCustomArr = cacheJson.columnWeightCustomArr; itemMinWidth = cacheJson.itemMinWidth; itemWidth = cacheJson.itemWidth; } if(!hasCache){ isFixToScreen = $control.find('.controlData').hasClass('fitToWidth'); isEquallySpaceColumns = $control.find('.controlData').hasClass('equallySpaceColumns'); } if(!hasCache && isVersion(VERSION_GRID_TYPE_FUNCTION_WEBAPP)){ if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ isColumnWeightCustom = rootInputProperties.isColumnWeightCustom; }else{ if(rootInputProperties.columnsSpaceType == '2'){ isColumnWeightCustom = true; } } if(isColumnWeightCustom){ columnWeightCustomArr = rootInputProperties.withFormat4ColumnWeight.split('|'); } cacheJson.isColumnWeightCustom = isColumnWeightCustom; cacheJson.columnWeightCustomArr = columnWeightCustomArr; } var ths = $tableHeader.find('th'); ths.css('word-wrap', 'break-word'); ths.css('word-break', CONST_DEF_WORD_BREAK); ths.css('white-space', 'normal'); if(isPOD || isINV){ var thsDelivered = $tableDeliveredHeader.find('th'); thsDelivered.css('word-wrap', 'break-word'); thsDelivered.css('word-break', CONST_DEF_WORD_BREAK); thsDelivered.css('white-space', 'normal'); } if(rootInputProperties.isUseVerticalCaption) { headerVerticalWidth = rootInputProperties.captionHeight * TABLE_HEADER_HEIGHT; headerHeight = TABLE_HEADER_VERTICAL_MIN_HEIGHT; } var colCount = controls.length; var index4RowCount = 0; if(rootInputProperties.isRowCountDisplay){ colCount++; index4RowCount = 1; } if(!hasCache){ if(isFixToScreen){ if(isEquallySpaceColumns){ var minWidth = 0; if(rootInputProperties.isRowCountDisplay){ minWidth = COL_COUNT_WIDTH; } var ignoreSpecialWidth = false; if(isUseChecklist){ ignoreSpecialWidth = true; } if(!rootInputProperties.isUseVerticalCaption) { for(var i = 0; i < controls.length; i++){ var control = controls[i]; var minCtrlWidth = getMinTableCtrlWidth(control, ignoreSpecialWidth); ignoreSpecialWidth = false; if(minWidth < minCtrlWidth){ minWidth = minCtrlWidth; } } for(var i = 0; i < colCount; i++){ itemMinWidth[i] = minWidth + 'px'; } if(rootInputProperties.isRowCountDisplay){ itemMinWidth[0] = COL_COUNT_WIDTH; } /*var per = 100 / controls.length; for(var i = 0; i < controls.length; i++){ itemWidth[i] = per + '%'; }*/ var per; if(rootInputProperties.isRowCountDisplay){ per = (fvDataNS.ctrlWidth - COL_COUNT_WIDTH) / (colCount - 1); itemWidth[0] = COL_COUNT_WIDTH + 'px'; for(var i = 1; i < colCount; i++){ itemWidth[i] = per + 'px'; } }else{ per = fvDataNS.ctrlWidth / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + 'px'; } } } else { // equallySpaceMinWidth = headerVerticalWidth; for(var i = 0; i < controls.length; i++){ ignoreSpecialWidth = false; var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } for(var i = 0; i < colCount; i++){ itemMinWidth[i] = headerVerticalWidth + 'px'; } var per = fvDataNS.ctrlWidth / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + 'px'; } } }else if(isColumnWeightCustom){ /* hqkhanh PCA-583 Adjust column width in portal for(var i = 0; i < controls.length; i++){ var control = controls[i]; var minCtrlWidth = getMinTableCtrlWidth(control, true); itemMinWidth[i] = minCtrlWidth + 'px'; if(columnWeightCustomArr.length > i){ itemWidth[i] = jQuery.trim(columnWeightCustomArr[i]) + '%'; }else{ itemWidth[i] = 0; } }*/ for(var i = 0; i < colCount; i++){ itemMinWidth[i] = 0 + 'px'; if(columnWeightCustomArr.length > i){ itemWidth[i] = jQuery.trim(columnWeightCustomArr[i]) + '%'; }else{ itemWidth[i] = '0%'; } } if(rootInputProperties.isUseVerticalCaption) { $control.find('table').css('table-layout','fixed'); for(var i = 0; i < controls.length; i++){ var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } } }else{ if(!rootInputProperties.isUseVerticalCaption) { var taltalLength = 0; var zeroItemCount = 0; var ignoreSpecialWidth = false; if(isUseChecklist){ ignoreSpecialWidth = true; } if(index4RowCount==1){ itemWidth[0] = COL_COUNT_WIDTH; taltalLength = COL_COUNT_WIDTH; } for(var i = 0; i < controls.length; i++){ var control = controls[i]; var minCtrlWidth = getMinTableCtrlWidth(control, ignoreSpecialWidth); ignoreSpecialWidth = false; itemWidth[i + index4RowCount] = minCtrlWidth; if(itemWidth[i + index4RowCount] == 0){ zeroItemCount++; } taltalLength += minCtrlWidth; } if(taltalLength >= (fvDataNS.ctrlWidth - 4)){ $control.find('table').css('width', fvDataNS.ctrlWidth + 'px'); } var screenWidth = fvDataNS.ctrlWidth - 4; var addWidth = 0; if(taltalLength < screenWidth){ addWidth = (screenWidth - taltalLength)/colCount; taltalLength = screenWidth; for(var i = 0; i < colCount; i++){ itemWidth[i] += addWidth; itemMinWidth[i] = itemWidth[i] + 'px'; itemWidth[i] = itemWidth[i]*100/taltalLength + '%'; } }else{ $control.find('table').css('width', taltalLength + 'px').addClass('dont_resize'); } // if(rootInputProperties.isUseVerticalCaption) { } else { for(var i = 0; i < controls.length; i++){ var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } var per = fvDataNS.ctrlWidth / colCount; for(var i = 0; i < colCount; i++){ itemMinWidth[i] = headerVerticalWidth + 'px'; itemWidth[i] = per + 'px'; } } } }else{ if(isEquallySpaceColumns){ if(!rootInputProperties.isUseVerticalCaption) { var minWidth = 0; if(rootInputProperties.isRowCountDisplay){ minWidth = COL_COUNT_WIDTH; } var ignoreSpecialWidth = false; if(isUseChecklist){ ignoreSpecialWidth = true; } for(var i = 0; i < controls.length; i++){ var control = controls[i]; var minCtrlWidth = getMinTableCtrlWidth(control, ignoreSpecialWidth); ignoreSpecialWidth = false; if(minCtrlWidth < minWidth){ minWidth = minCtrlWidth; } } for(var i = 0; i < colCount; i++){ itemWidth[i] = minWidth + 'px'; itemMinWidth[i] = itemWidth[i]; } } else { if(rootInputProperties.isRowCountDisplay){ itemMinWidth[0] = COL_COUNT_WIDTH + 'px'; itemWidth[0] = COL_COUNT_WIDTH + 'px'; } for(var i = 0; i < controls.length; i++){ ignoreSpecialWidth = false; var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } itemMinWidth[i + index4RowCount] = headerVerticalWidth + 'px'; itemWidth[i+ index4RowCount] = headerVerticalWidth + 'px'; } } }else{ var taltalLength = 0; var ignoreSpecialWidth = false; if(isUseChecklist){ ignoreSpecialWidth = true; } if(!rootInputProperties.isUseVerticalCaption) { if(rootInputProperties.isRowCountDisplay){ itemMinWidth[0] = COL_COUNT_WIDTH + 'px'; itemWidth[0] = COL_COUNT_WIDTH + 'px'; taltalLength += COL_COUNT_WIDTH; } for(var i = 0; i < controls.length; i++){ var control = controls[i]; var minCtrlWidth = getMinTableCtrlWidth(control, ignoreSpecialWidth); ignoreSpecialWidth = false; itemWidth[i + index4RowCount] = minCtrlWidth + 'px'; itemMinWidth[i + index4RowCount] = itemWidth[i + index4RowCount]; taltalLength += minCtrlWidth; } } else { if(rootInputProperties.isRowCountDisplay){ itemMinWidth[0] = COL_COUNT_WIDTH + 'px'; itemWidth[0] = COL_COUNT_WIDTH + 'px'; } for(var i = 0; i < controls.length; i++){ ignoreSpecialWidth = false; var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } itemMinWidth[i + index4RowCount] = headerVerticalWidth + 'px'; itemWidth[i + index4RowCount] = headerVerticalWidth + 'px'; } } if(taltalLength >= (fvDataNS.ctrlWidth - 4)){ $control.find('table').css('width', fvDataNS.ctrlWidth + 'px'); } } } cacheJson.itemMinWidth = itemMinWidth; cacheJson.itemWidth = itemWidth; fvDataNS.cache[rootInputProperties.id] = cacheJson; } // var calColsWidth = 0; // for(var i = 0; i < itemMinWidth.length; i++) { // calColsWidth += itemMinWidth[i].replace('px','').replace('%',''); // } var index = 0; _.each(controls, function(control){ // convert nfc, barcode to input action preview mode only /* CO-2067 Action button images in web forms not appearing if(isTabletPreview){*/ switch(control.type){ case CONST_CTRL_TYPE_INPUTNFC: case CONST_CTRL_TYPE_INPUTBARCODE: if(control.parse && control.isUseActionButton){ control.imgAction = control.type; control.type = CONST_CTRL_TYPE_INPUTACTION; control.kind = control.btnKind; } break; } /*}*/ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP && control.isRetrieve){ control.type = CONST_CTRL_TYPE_INPUTACTION; control.imgAction = CONST_ACTION_RETRIEVE; control.kind = control.btnKind; if( control.btnKind == CONST_TYPE_IMAGE ){ control.useImage = true; }else{ control.useImage = false; } /*if((control.isRetrieveDS == undefined && control.isModifyOnly == true) || control.isRetrieveDS == false || (control.retrieveKind == CONST_TYPE_AUTO_RUN && control.hideRetrieveButtonAuto == true)){ control.hideViewEdit = true; control.hideDispatchNew = true; control.hideDispatchEdit = true; control.hideFillAndSend = true; control.hideInMobile = true; control.hideWebAppGrp = true; control.hideViewNew = true; control.hideDispatchToEmail = true; control.hideFillAndSendEdit = true; control.hideWebApp = true; control.hideEmbeddedForm = true; control.hideFormLinks = true; control.hideInPDF = true; control.hidePdfWeb = true; control.hideInWeb = true; }*/ } if(fvDataNS && fvDataNS.currentForm && fvDataNS.currentForm.formVersion && (parseFloat(fvDataNS.currentForm.formVersion) < parseFloat(FORM_VERSION))){ if(control.autoStamp){ if(control.isAllowEdit == undefined){ control.isAllowEdit = false; } }else{ control.isAllowEdit = true; } }else{ if(control.isAllowEdit == undefined){ control.isAllowEdit = true; } } if(!headerOnly){ var properties = null; if ((control.type == CONST_CTRL_TYPE_GROUP) || (control.type == CONST_CTRL_TYPE_CTRLTABLE) || (control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) || (control.type == CONST_CTRL_TYPE_CTRLPOD) || (control.type == CONST_CTRL_TYPE_CTRLINV) || (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) || (control.type == CONST_CTRL_TYPE_CTRLGRID) || (control.type == 'branch') || (control.type == 'inputPageBreak') || (control.type == 'inputLabel') || (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY) || (control.type == CONST_CTRL_TYPE_INPUTNUMBERING) || (control.type == CONST_CTRL_TYPE_INPUTACTION) || (control.type == CONST_CTRL_TYPE_INPUTPAYMENT) || (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT) || (control.type == 'inputInstruction') || //(control.type == CONST_CTRL_TYPE_INPUTCALCULATE) || (control.type == CONST_CTRL_TYPE_INPUTLOOKUP) || (control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) || (control.type == 'inputFacingTable') || (control.type == 'inputLookupMulti') || (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTFAX) || (control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) || (control.type == 'inputSaveAndSend') || (control.type == 'ctrlDataSource') || (control.type == 'ctrlHeaderGrid') || (control.type == 'ctrlDataFilter') || (control.type == 'ctrlReportBreakPoint') || (control.type == 'ctrlBreakPointData') || (control.type == 'ctrlBreakPointDataElement') || (control.type == 'ctrlFooterGrid') || (control.type == 'ctrlEmailSchedule')){ if(control.relevanceconds == undefined){ control.relevanceconds = []; } properties = $.extend(true, {}, $.fn.odkControl.controlProperties[control.type]); }else{ properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[control.type]); removeUnsupportProperty(properties, control.type); } removeUnuseVersion(properties); if(control.isAttachFormWidget === true){ appendProperties4AttachFormWidget(properties); } properties.id.ctrlType = control.type; parentKind = 'table'; if(isPOD){ parentKind = CONST_CTRL_TYPE_CTRLPOD; } if(isINV){ parentKind = CONST_CTRL_TYPE_CTRLINV; } var ctrlPropreties = { name: control.name, parentName: rootInputProperties.name, classPath: rootInputProperties.classPath + ' ' + control.name, rowIndex: rowIndex, id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [], parentKind: parentKind }; if(rootInputProperties.ctrlType === CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ ctrlPropreties.id = rowIndex + '_' + ctrlPropreties.id; } if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropreties.hideWebApp = true; control.hideWebApp = true; }else{ ctrlPropreties.hideWebApp = false; control.hideWebApp = false; } } } if(control.displayCCIcon){ ctrlPropreties.displayCCIcon = control.displayCCIcon; } if(control.isDisplayAmountCharged != false){ ctrlPropreties.isDisplayAmountCharged = control.isDisplayAmountCharged; } if(control.addMessage){ ctrlPropreties.addMessage = control.addMessage; }else{ ctrlPropreties.addMessage = { check: true, text: lbl_default_add_msg }; } if(control.amountCharged){ ctrlPropreties.amountCharged = control.amountCharged; } if(control.totalAmountPaid){ ctrlPropreties.totalAmountPaid = control.totalAmountPaid; } if(control.transactionClientId){ ctrlPropreties.transactionClientId = control.transactionClientId; } if(control.requiredViewEdit != undefined){ // new enchance ctrlPropreties.requiredDispatchEdit = { value: control.requiredDispatchEdit}; ctrlPropreties.requiredDispatchNew = { value: control.requiredDispatchNew}; ctrlPropreties.requiredFillAndSend = { value: control.requiredFillAndSend}; if(isVersion(VERSION_FNS_EDIT)){ ctrlPropreties.requiredFillAndSendEdit = { value: control.requiredFillAndSendEdit}; } ctrlPropreties.requiredDispatchToEmail = { value: control.requiredDispatchToEmail}; ctrlPropreties.requiredViewNew = { value: control.requiredViewNew}; ctrlPropreties.requiredViewEdit = { value: control.requiredViewEdit}; ctrlPropreties.requiredWebApp = { value: control.requiredWebApp}; ctrlPropreties.requiredFormLinks = { value: control.requiredFormLinks}; ctrlPropreties.required = { value: control.required}; } // CO-3502 if(control.ofDispatchCaptionText != undefined){ ctrlPropreties.label = { eng: control.ofDispatchCaptionText}; } if(control.ofDispatchRequired != undefined){ ctrlPropreties.ofDispatchRequired = { value: control.ofDispatchRequired}; } if(control.hideButtonAfterClick != undefined){ ctrlPropreties.hideButtonAfterClick = control.hideButtonAfterClick; // CO-4027: Hide button after click } if(control.kind != undefined){ ctrlPropreties.kind = control.kind; } if(control.length != undefined && control.length != false){ ctrlPropreties.length = { min: control.length.min || '', max: control.length.max || '', cannotExceedMaximum : control.length.cannotExceedMaximum || false } }else if(control.range != undefined && control.range != false){ ctrlPropreties.range = { min: control.range.min || '', max: control.range.max || '' } } if(control.validateValue != undefined && control.validateValue != false){ ctrlPropreties.validateValue = {}; ctrlPropreties.validateValue.value = control.validateValue; } if(control.dispatchRequired != undefined && control.dispatchRequired == true){ ctrlPropreties.dispatchRequired = true; if(isWebAppDispatch()){ control.required = true; ctrlPropreties.required = true; } } if(control.requiredForwarded != undefined){ ctrlPropreties.requiredForwarded = {value: control.requiredForwarded}; // CO-941 } if(control.requiredOnRetrieve != undefined){ // CO-4940: Required setting - Turned off for retrieve not working ctrlPropreties.requiredOnRetrieve = {value: control.requiredOnRetrieve}; } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.isRetrieve){ ctrlPropreties.datasource = control.datasource; ctrlPropreties.destinationdataconds = control.destinationdataconds ctrlPropreties.modifyFields = control.modifyFields; ctrlPropreties.lookupValue = control.lookupValue; ctrlPropreties.lookupfield = control.lookupfield; ctrlPropreties.lookupConditionFields = control.lookupConditionFields; ctrlPropreties.notDisplayRecNotFound = control.notDisplayRecNotFound; ctrlPropreties.jumpAfterScan = control.jumpAfterScan; ctrlPropreties.jumpAfterScanOption = control.jumpAfterScanOption; ctrlPropreties.isModifyAllMatches = control.isModifyAllMatches; ctrlPropreties.isCaseSensitiveCmp = control.isCaseSensitiveCmp; ctrlPropreties.isRetrieveOldestRecord = control.isRetrieveOldestRecord; ctrlPropreties.retrieveRecordKind = control.retrieveRecordKind; ctrlPropreties.isModifyAdd = control.isModifyAdd; ctrlPropreties.modifyAddFields = control.modifyAddFields; } appendControlProperties4Widget(ctrlPropreties, control); //appendControlProperties4ShippingWidget(ctrlPropreties, control); // CO-3852: New Retrieve Setting - Auto Run if(control.isRetrieveDS == true && control.autoActionStampTriggerRetrieve != undefined && (control.autoActionStampTriggerRetrieve == '2' // specific question || control.autoActionStampTriggerRetrieve == '8') // open form ){ ctrlPropreties.retrieveKind = control.retrieveKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerRetrieve = control.autoActionStampTriggerRetrieve; ctrlPropreties.autoActionStampQuestionTriggerRetrieve = control.autoActionStampQuestionTriggerRetrieve; ctrlPropreties.hideRetrieveButtonAuto = control.hideRetrieveButtonAuto; } // CO-3853 if(control.autoActionStampTriggerModify != undefined && (control.autoActionStampTriggerModify == '2' // specific question || control.autoActionStampTriggerModify == '8' || control.autoActionStampTriggerModify == '32') // on retrieve ){ ctrlPropreties.modifyKind = control.modifyKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerModify = control.autoActionStampTriggerModify; ctrlPropreties.autoActionStampQuestionTriggerModify = control.autoActionStampQuestionTriggerModify; ctrlPropreties.hideModifyButtonAuto = control.hideModifyButtonAuto; } // CO-3853 if(control.hideRetrieveButton){ ctrlPropreties.hideRetrieveButton = control.hideRetrieveButton; } if((control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTLOCATION) && control.iconColor){ // CO-4050 ctrlPropreties.iconColor = control.iconColor; } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.iconColor){ ctrlPropreties.applyScreenSize = control.applyScreenSize; ctrlPropreties.buttonSize = control.buttonSize; ctrlPropreties.ifScreenSmallerThan = control.ifScreenSmallerThan; ctrlPropreties.ifScreenSmallerSize = control.ifScreenSmallerSize; } if(rootInputProperties.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; }else{ if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; } } } if(fvDataNS.isRetrieve){ if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropreties.hideWebApp = true; control.hideWebApp = true; }else{ ctrlPropreties.hideWebApp = false; control.hideWebApp = false; } } } if(fvDataNS.incomplete){ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : //case CONST_CTRL_TYPE_INPUTACTION : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: var tmp = ctrlPropreties; ctrlPropreties = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties); if(ctrlPropreties == undefined){ ctrlPropreties = tmp; rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } }else{ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: if(fvDataNS.currentForm.editRecordData){ getEditRecordData(ctrlPropreties, fvDataNS.currentForm.editRecordData, control); } rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } _.each(properties, function(property, key) { if((control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) && key == 'defaultValue'){ var value = control[key]; if(value != undefined){ var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ property.value = value.substring(0, contentStartPos); property.mailcontent = value.substring(contentStartPos + 2); }else{ property.value = value; } } if(isVersion(VERSION_EMAIL_REPORT_NEW_DEFAULT)){ property.selectedCtrl = control[key+'_selectedCtrl']; } }else if(control.type == 'ctrlEmailSchedule' && key == 'reportEmail'){ var value = control[key]; if(value != undefined){ var contentStartPos = value.indexOf('$$', 0); if(contentStartPos >= 0){ property.value = value.substring(0, contentStartPos); property.mailcontent = value.substring(contentStartPos + 2); }else{ property.value = value; } } }else{ property.value = control[key]; if(key == 'relevanceconds' && property.value != undefined){ _.each(property.value, function(relevanceCond){ if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == '' || relevanceCond.text[CONST_VALUE_CTRLTYPE] == undefined){ return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_TEXT || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTLOCATION || relevanceCond.text[CONST_VALUE_CTRLTYPE] == mdi_kind_inputImage || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTBARCODE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTNFC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSECUREFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSCOREONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTMANY || relevanceCond.text[CONST_VALUE_CTRLTYPE] == 'inputRIF'){ if(relevanceCond.text[CONST_VAL]){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_EQUAL: case CONST_VALUE_NOT_EQUAL: case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } }else{ relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } } }); }else if(key == 'lookupConditionFields' && property.value != undefined){ _.each(property.value, function(lookupConditionField){ if(lookupConditionField.text.valCond == undefined || jQuery.trim(lookupConditionField.text.valCond) == ''){ return false; } if(lookupConditionField.text.valCond == properties.lookupfield.value){ lookupConditionField.text.valCond = ''; } }); } } }); // CO-4008 if(rootInputProperties.parentPageBreak){ ctrlPropreties.parentPageBreak = rootInputProperties.parentPageBreak; } var fvCtrlID; if(rootInputProperties.ctrlType === CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ fvCtrlID = 'fvCtrlID_' + rowIndex + '_' + control.id; }else{ fvCtrlID = 'fvCtrlID_' + control.id; } var $tableBodyRowCell = $('') .addClass('fvControl') .addClass('fvCtrlID_' + control.id) .addClass('fvCtrlName_' + control.name) .attr('id', fvCtrlID) .on("fvParentCtrlShowHideChange", function(event, ctrlHidden, addToChangeList, triggerCtrlID){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } if(triggerCtrlID && this.id !== triggerCtrlID){ event.stopPropagation(); return; } ctrlPropreties.isParentCtrlHidden = ctrlHidden; if(addToChangeList){ if(ctrlHidden == false){ ctrlPropreties.isValueChange = true; } if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } //CO-6062: Select Multiple changes value on edit if(fvDataNS.isLoading){ $(this).trigger('clearData', true); //CO-6655: Records where one Employees EarnCode did not populate if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ ctrlPropreties.destinationNotFound = true; } } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger('Control_Update'); } event.stopPropagation(); }) // CO-4022 .on("fvContainerShowHideChange", function(event){ event.stopPropagation(); processHideIf($(this), ctrlPropreties); }); // CO-3502: Button upload - Choose a file in dispatch var buttonUpload = ''; if(control.kind === CONST_TYPE_BUTTON && control.ofRequired === '2' && isApplyActionOpenFile(properties)){ buttonUpload = 'Upload'; } // Get selected control for cloning object, using in WebApps (inside FixedTable) // Apply task : https://doforms.atlassian.net/browse/PCA-145 (Implement Shading for webapp) var cellPrefix = 'ctrlTableCell_'; if(isPOD){ cellPrefix = 'ctrlPODCell_'; } if(isINV){ cellPrefix = 'ctrlINVCell_'; } var controlInTable = getSelectedQuery4CloneObjectWA('#formview_templates .' + cellPrefix + control.type + buttonUpload, control.type, control); $tableBodyRowCell.append(controlInTable.clone()); // tdchien: Add control type of ChooseOne/Score/SelectMultiple inside Table if (control.type === CONST_CTRL_TYPE_INPUTSCOREONE || control.type === CONST_CTRL_TYPE_INPUTSELECTONE || control.type === CONST_CTRL_TYPE_INPUTSELECTMANY) { $tableBodyRowCell.addClass(control.type); } $tableBodyRow.append($tableBodyRowCell); $tableBodyRowCell.find('.tblCellNowBtn').attr('id', control.name + '__' + realIndex); fvDataNS.ctrlIndex++; //$tableBodyRowCell.find('.controlData').attr('id', 'ctrlDataId_' + fvDataNS.ctrlIndex); ctrlPropreties.ctrlDataId = fvDataNS.ctrlIndex; if(isUseChecklist && isLookupUseChecklist){ ctrlPropreties.isLookupUseChecklist = true; ctrlPropreties.datasource = properties.datasource.value; isLookupUseChecklist = false; $tableBodyRowCell.find('.ico_lookup_table').removeClass('ico_lookup_table'); } if(isPOD || isINV){ if(control.name.indexOf('__AutoID')>=0){ if(fvDataNS.currentForm.editRecordData){ ctrlPropreties.val = getEditRecordData(ctrlPropreties, fvDataNS.currentForm.editRecordData, control); }else{ ctrlPropreties.val = realIndex; } } fillDataControlPODFV($tableBodyRowCell, control.type, properties, ctrlPropreties); }else{ fillDataControlTableFV($tableBodyRowCell, control.type, properties, ctrlPropreties); if(rootInputProperties.ctrlType === CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ $tableBodyRowCell.find('div .controlData').empty(); if(listContainerControls4WAShadings && listContainerControls4WAShadings.length>0){ _.each(listContainerControls4WAShadings, function(item){ if(item.ctrlType === CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ item.isFinishAdjustLayout = false; } }) } } } }else{ } if($tableBodyRowCell){ if(index == 0 && rowIndexCel != null){ var maxWidth = itemMinWidth[index]; if(maxWidth == '0px'){ if(itemWidth[index] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[index]; } } rowIndexCel.css('width', itemWidth[index]).css('min-width', itemMinWidth[index]); if(!rootInputProperties.isUseVerticalCaption) { if(isEquallySpaceColumns){ rowIndexCel.css('max-width', itemWidth[index]); }else{ rowIndexCel.css('max-width', maxWidth); } } if(itemWidth[index] == '0%'){ rowIndexCel.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } index++; } var maxWidth = itemMinWidth[index]; if(maxWidth == '0px'){ if(itemWidth[index] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[index]; } } if(isEquallySpaceColumns){ maxWidth = itemWidth[index]; } $tableBodyRowCell.css('width', itemWidth[index]).css('min-width', itemMinWidth[index]); if(!rootInputProperties.isUseVerticalCaption) { $tableBodyRowCell.css('max-width', maxWidth); } if(itemWidth[index] == '0%'){ $tableBodyRowCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } if(realIndex == 0){ var headerLabel; if(control.label != undefined && control.label.eng != undefined){ headerLabel = control.label.eng; }else{ headerLabel = ''; } var $tableHeaderLabel = $('
    ' + headerLabel + '
    '); if(rootInputProperties.isUseVerticalCaption) { $tableHeaderLabel.css('-ms-transform', 'rotate(270deg)'); /* IE 9 */ $tableHeaderLabel.css('-webkit-transform','rotate(270deg)'); /* Safari 3-8 */ $tableHeaderLabel.css('transform','rotate(270deg)'); // $tableHeaderLabel.css('height', headerVerticalWidth); $tableHeaderLabel.css('position', 'relative'); $tableHeaderLabel.css('word-wrap', 'normal'); $tableHeaderLabel.css('word-break', 'normal'); headerHeight = roundNum(headerHeight); $tableHeaderLabel.css('width', headerHeight + 'px'); $tableHeaderLabel.css('display', 'inline-block'); $tableHeaderLabel.css('text-align', 'inherit'); var width = 0; var minWidth = 0; if(itemWidth[index]) { width = parseInt(('' + itemWidth[index]).replace('px','')); minWidth = parseInt(('' + itemMinWidth[index]).replace('px','')); } if(width < minWidth) { width = minWidth; } if(isColumnWeightCustom){ // var tableWidth = columnWeightCustomArr.length * 70; // if(!tableWidth || tableWidth < fvDataNS.ctrlWidth) { // tableWidth = fvDataNS.ctrlWidth; // } // width = width * tableWidth / 100; width = width * fvDataNS.ctrlWidth / 100; if(rootInputProperties.adjustWidthNormal) { width = width * parseInt(rootInputProperties.adjustWidthNormal) / 100; } // if(width > headerHeight) { // //incase colum too large (80-90%) // //, => height before translate = max header height (5 lines) // width = headerHeight; // } } width -= 2;//remove 2 borders $tableHeaderLabel.css('overflow', 'hidden'); $tableHeaderLabel.css('word-wrap', 'break-word'); $tableHeaderLabel.css('line-height', '18px'); $tableHeaderLabel.css('vertical-align', 'middle'); var heightBeforeTran = 18*getNumOfLine(control.label.eng, headerHeight/* - 4border*/); if(heightBeforeTran> width) { heightBeforeTran = width; } $tableHeaderLabel.css('height', heightBeforeTran + 'px'); // if(width < headerHeight) { // var cal = ((headerHeight - width) / 2) + 'px'; // $tableHeaderLabel.css('left', '-' + cal); // } var fixAbsoluteCenter = false; var cal = ((heightBeforeTran - headerHeight) / 2 - TABLE_GRID_VERRTICAL_HEADER_PADDING); if(cal > 0) { $tableHeaderLabel.css('position', 'absolute'); $tableHeaderLabel.css('top', '-' + cal + 'px'); fixAbsoluteCenter = true; } } var $tableColHeader = $('') .append($tableHeaderLabel); applyJustification($tableColHeader, properties); if(rootInputProperties.isUseVerticalCaption) { //if(heightBeforeTran > headerHeight) { applyJustificationVertical($tableHeaderLabel, properties, heightBeforeTran , headerHeight, itemWidth[index], itemMinWidth[index], headerHeight , rootInputProperties.adjustWidthNormal / 100, true, fixAbsoluteCenter); //} } $control.on('checkAndSetRequired', function() { fvAppendRequired2(control, $tableColHeader); }); $control.trigger('checkAndSetRequired'); // hideInMobile // CO-314 : Add Caption Text Color in Table form web forms // Apply shading for current header cell formViewUtils.applyShading4TableHeader(properties, $tableColHeader); if(properties == undefined){ if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION)){ if(isTabletPreview){ // is preview // using hideInMobile flag if(control.hideInMobile){ $tableColHeader.addClass('hideOnMobileApp'); } if(!isPOD && !isINV) return; } if(isWADispatchPlus() || isWebAppDispatch()){ if(previewRecordKey){ // is dispatch // using hideDispatchEdit if(control.hideDispatchEdit){ $tableColHeader.addClass('hideOnMobileApp'); } }else{ // is dispatch // using hideDispatchNew if(control.hideDispatchNew){ $tableColHeader.addClass('hideOnMobileApp'); } } if(!isPOD && !isINV) return; } if(viewDataFillAndSend){ // Fix error make Form links/Web clients dead GUI // is fill & send // using hideFillAndSend if(control.hideFillAndSend){ $tableColHeader.addClass('hideOnMobileApp'); } if(!isPOD) return; } if(dispatchToEmail){ // is dispatch to email // using hideDispatchToEmail if(control.hideDispatchToEmail){ $tableColHeader.addClass('hideOnMobileApp'); } if(!isPOD && !isINV) return; } if(isWebAppDataviewAddNew()){ // is data view add new // using hideViewNew if(control.hideViewNew){ $tableColHeader.addClass('hideOnMobileApp'); } if(!isPOD) return; } if(isWebAppDataview()){ // is data view add edit // using hideViewEdit if(control.hideViewEdit){ $tableColHeader.addClass('hideOnMobileApp'); } if(!isPOD && !isINV) return; } if(previewSubmit){ // is data view add new // using hideViewNew if(control.hideViewNew){ $tableColHeader.addClass('hideOnMobileApp'); } if(!isPOD) return; } // is webapp // using hideWebApp if(control.hideWebApp){ $tableColHeader.addClass('hideOnMobileApp'); } if(!isPOD && !isINV) return; }else{ if(isWebDataDispatch() || (typeof previewWebAppUrl != 'undefined' && typeof previewWebAppUrl != null && previewWebAppUrl)){ // use hideInWeb flag if(control.hideInWeb){ $tableColHeader.addClass('hideOnMobileApp'); } }else{ // is web client // use hideInMobile flag if(control.hideInMobile){ $tableColHeader.addClass('hideOnMobileApp'); } } } }else{ execShowHideWebAppControl($tableColHeader, properties); } var maxWidth = itemMinWidth[index]; if(maxWidth == '0px'){ if(itemWidth[index] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[index]; } } $tableColHeader.css('width', itemWidth[index]).css('min-width', itemMinWidth[index]).css('max-width', maxWidth); if(itemWidth[index] == '0%'){ $tableColHeader.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } if(rootInputProperties.isUseVerticalCaption) { var style = $tableColHeader.attr('style'); if(isColumnWeightCustom){ style += 'padding-left:0px!important;'; } $tableColHeader.attr('style', style + 'height:' + headerHeight + 'px!important;' + 'padding-top:' + TABLE_GRID_VERRTICAL_HEADER_PADDING + 'px!important;' + 'padding-bottom:' + TABLE_GRID_VERRTICAL_HEADER_PADDING + 'px!important;'); $tableColHeader.css('text-align','center'); $tableColHeader.css('word-break', 'normal'); $tableColHeader.css('width', itemWidth[index]); $tableColHeader.css('position', 'relative'); // height: 254px !important; // white-space: normal; // $tableColHeader.css('display','inline-block'); } // if(!rootInputProperties.isUseVerticalCaption) { // $tableBodyOddRow.css('word-break', 'normal'); // } $tableColHeader.addClass('tblCol_' + ctrlPropreties.name); // CO-4022 $tableHeader.append($tableColHeader); if(isPOD ||isINV){ if(control.name.indexOf('__Deliver')>=0){ }else if(control.name.indexOf('__Status')>=0){ var cloneCel = $tableColHeader.clone().removeClass('hideOnMobileApp'); if(index != $tableDeliveredHeader.length){ if(itemWidth[$tableDeliveredHeader.length] == '0%'){ cloneCel.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ cloneCel.removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } $tableDeliveredHeader.append(cloneCel); }else{ var cloneCel = $tableColHeader.clone(); if(index != $tableDeliveredHeader.length){ if(itemWidth[$tableDeliveredHeader.length] == '0%'){ cloneCel.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ cloneCel.removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } $tableDeliveredHeader.append(cloneCel); } } } index += 1; }); if(realIndex == 0 && $tableDeliveredHeader){ if($tableDeliveredHeader.find('.__Over').length == 0){ if(rootInputProperties.itemPerRow == 'single' && rootInputProperties.manifestMethod == 'button'){ $tableDeliveredHeader.append($('Over')); }else{ $tableDeliveredHeader.append($('Over')); } } $tableDeliveredHeader.append($('Edit')); } if((isPOD || isINV) && (fvDataNS.incomplete || fvDataNS.currentForm.editRecordData)){ var $rejectCtrl = $tableBodyRow.find('.__Rejected'); if($rejectCtrl.is(':checked')){ var $deliverCell = $tableBodyRow.find('.ctrlPODCell_inputAction'); $deliverCell.addClass('disable-btn-cell'); } } } var loadRecurseScoreTableFV = function($control, controls, parentPath, rootInputProperties){ var $tableHeader = $control.find('.tblHeader'); $tableHeader.empty(); $control.find('.tblBody').empty(); var itemWidth = {}; var isFixToScreen = $control.find('.controlData').hasClass('fitToWidth'); var isEquallySpaceColumns = $control.find('.controlData').hasClass('equallySpaceColumns'); var isColumnWeightCustom = false; var isColumnWeightCustom2 = false; var columnWeightCustomArr; if(isVersion(VERSION_GRID_TYPE_FUNCTION_WEBAPP)){ if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ isColumnWeightCustom = rootInputProperties.isColumnWeightCustom; }else{ if(rootInputProperties.columnsSpaceType == '2'){ isColumnWeightCustom = true; } } if(isColumnWeightCustom){ if(rootInputProperties.withFormat4ColumnWeight2){ isColumnWeightCustom2 = true; columnWeightCustomArr = []; columnWeightCustomArr.push(rootInputProperties.withFormat4ColumnWeight2.withFormat4CWQuestion); columnWeightCustomArr.push(rootInputProperties.withFormat4ColumnWeight2.withFormat4CWAnswer); columnWeightCustomArr.push(rootInputProperties.withFormat4ColumnWeight2.withFormat4CWComment); }else if(rootInputProperties.withFormat4ColumnWeight){ columnWeightCustomArr = rootInputProperties.withFormat4ColumnWeight.split('|'); } } } var addHeader = true; var rowIndex = 0; _.each(controls, function(control){ if(fvDataNS && fvDataNS.currentForm && fvDataNS.currentForm.formVersion && (parseFloat(fvDataNS.currentForm.formVersion) < parseFloat(FORM_VERSION))){ if(control.autoStamp){ if(control.isAllowEdit == undefined){ control.isAllowEdit = false; } }else{ control.isAllowEdit = true; } }else{ if(control.isAllowEdit == undefined){ control.isAllowEdit = true; } } var $tableBodyRow = $(''); if(rowIndex % 2 == 0){ $tableBodyRow.addClass('evenRow'); }else { $tableBodyRow.addClass('oddRow'); } rowIndex++; $control.find('.tblBody').append($tableBodyRow); var properties = null; if ((control.type == CONST_CTRL_TYPE_GROUP) || (control.type == CONST_CTRL_TYPE_CTRLTABLE) || (control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) || (control.type == CONST_CTRL_TYPE_CTRLPOD) || (control.type == CONST_CTRL_TYPE_CTRLINV) || (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) || (control.type == CONST_CTRL_TYPE_CTRLGRID) || (control.type == 'branch') || (control.type == 'inputPageBreak') || (control.type == 'inputLabel') || (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY) || (control.type == CONST_CTRL_TYPE_INPUTNUMBERING) || (control.type == CONST_CTRL_TYPE_INPUTACTION) || (control.type == CONST_CTRL_TYPE_INPUTPAYMENT) || (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT) || (control.type == 'inputInstruction') || //(control.type == CONST_CTRL_TYPE_INPUTCALCULATE) || (control.type == CONST_CTRL_TYPE_INPUTLOOKUP) || (control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) || (control.type == 'inputFacingTable') || (control.type == 'inputLookupMulti') || (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTFAX) || (control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) || (control.type == 'inputSaveAndSend') || (control.type == 'ctrlDataSource') || (control.type == 'ctrlHeaderGrid') || (control.type == 'ctrlDataFilter') || (control.type == 'ctrlReportBreakPoint') || (control.type == 'ctrlBreakPointData') || (control.type == 'ctrlBreakPointDataElement') || (control.type == 'ctrlFooterGrid') || (control.type == 'ctrlEmailSchedule')){ if(control.relevanceconds == undefined){ control.relevanceconds = []; } properties = $.extend(true, {}, $.fn.odkControl.controlProperties[control.type]); }else{ properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[control.type]); removeUnsupportProperty(properties, control.type); } removeUnuseVersion(properties); if(control.isAttachFormWidget === true){ appendProperties4AttachFormWidget(properties); } properties.id.ctrlType = control.type; var ctrlPropreties = { name: control.name, parentName: rootInputProperties.name, classPath: rootInputProperties.classPath + ' ' + control.name, id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [], parentKind: 'scoreTable' }; if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropreties.hideWebApp = true; control.hideWebApp = true; }else{ ctrlPropreties.hideWebApp = false; control.hideWebApp = false; } } } if(control.displayCCIcon){ ctrlPropreties.displayCCIcon = control.displayCCIcon; } if(control.isDisplayAmountCharged != false){ ctrlPropreties.isDisplayAmountCharged = control.isDisplayAmountCharged; } if(control.addMessage){ ctrlPropreties.addMessage = control.addMessage; }else{ ctrlPropreties.addMessage = { check: true, text: lbl_default_add_msg }; } if(control.amountCharged){ ctrlPropreties.amountCharged = control.amountCharged; } if(control.totalAmountPaid){ ctrlPropreties.totalAmountPaid = control.totalAmountPaid; } if(control.transactionClientId){ ctrlPropreties.transactionClientId = control.transactionClientId; } if(control.requiredViewEdit != undefined){ // new enchance ctrlPropreties.requiredDispatchEdit = { value: control.requiredDispatchEdit}; ctrlPropreties.requiredDispatchNew = { value: control.requiredDispatchNew}; ctrlPropreties.requiredFillAndSend = { value: control.requiredFillAndSend}; if(isVersion(VERSION_FNS_EDIT)){ ctrlPropreties.requiredFillAndSendEdit = { value: control.requiredFillAndSendEdit}; } ctrlPropreties.requiredDispatchToEmail = { value: control.requiredDispatchToEmail}; ctrlPropreties.requiredViewNew = { value: control.requiredViewNew}; ctrlPropreties.requiredViewEdit = { value: control.requiredViewEdit}; ctrlPropreties.requiredWebApp = { value: control.requiredWebApp}; ctrlPropreties.requiredFormLinks = { value: control.requiredFormLinks}; ctrlPropreties.required = { value: control.required}; } if(control.length != undefined && control.length != false){ ctrlPropreties.length = { min: control.length.min || '', max: control.length.max || '', cannotExceedMaximum : control.length.cannotExceedMaximum || false } }else if(control.range != undefined && control.range != false){ ctrlPropreties.range = { min: control.range.min || '', max: control.range.max || '' } } if(control.validateValue != undefined && control.validateValue != false){ ctrlPropreties.validateValue = {}; ctrlPropreties.validateValue.value = control.validateValue; } if(control.dispatchRequired != undefined && control.dispatchRequired == true){ ctrlPropreties.dispatchRequired = true; if(isWebAppDispatch()){ control.required = true; ctrlPropreties.required = true; } } if(control.requiredForwarded != undefined){ ctrlPropreties.requiredForwarded = {value: control.requiredForwarded}; // CO-941 } if(control.requiredOnRetrieve != undefined){ // CO-4940: Required setting - Turned off for retrieve not working ctrlPropreties.requiredOnRetrieve = {value: control.requiredOnRetrieve}; } if(fvDataNS.incomplete){ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : //case CONST_CTRL_TYPE_INPUTACTION : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: var tmp = ctrlPropreties; ctrlPropreties = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties); if(ctrlPropreties == undefined){ ctrlPropreties = tmp; rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } }else{ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: if(fvDataNS.currentForm.editRecordData){ getEditRecordData(ctrlPropreties, fvDataNS.currentForm.editRecordData, control); } rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } _.each(properties, function(property, key) { property.value = control[key]; if(key == 'relevanceconds' && property.value != undefined){ _.each(property.value, function(relevanceCond){ if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == '' || relevanceCond.text[CONST_VALUE_CTRLTYPE] == undefined){ return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_TEXT || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTLOCATION || relevanceCond.text[CONST_VALUE_CTRLTYPE] == mdi_kind_inputImage || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTBARCODE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTNFC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSECUREFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSCOREONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTMANY || relevanceCond.text[CONST_VALUE_CTRLTYPE] == 'inputRIF'){ if(relevanceCond.text[CONST_VAL]){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_EQUAL: case CONST_VALUE_NOT_EQUAL: case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } }else{ relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } } }); } }); $tableBodyRow .addClass('fvControl') .addClass('fvCtrlID_' + control.id) .addClass('fvCtrlName_' + control.name) .on("fvCtrlShowHideChange", function(event, addToChangeList){ var isHideCtrl = $(this).hasClass(CONST_CLASS_HIDE_CONTROL); var isStateChage = false; var isSetDefaultValueIfEmpty = false; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; } }else{ if(ctrlPropreties.isCtrlHidden){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; //CO-6062: Select Multiple changes value on edit //if(fvDataNS.isLoading == true && fvDataNS.isdispatch == true){ if(fvDataNS.isLoading == true){ isSetDefaultValueIfEmpty = true; } } }else{ if(isHideCtrl){ $(this).removeClass(CONST_CLASS_HIDE_CONTROL); resizeTextareaWhenUnhide($(this)); //reArrangeLayoutOfChooseOneWithShadingWALastAction($(this)); isStateChage = true; //isSetDefaultValueIfEmpty = true; } } } if(isStateChage){ if(isSetDefaultValueIfEmpty){ if((control.defaultValue != undefined && control.defaultValue != '') && (ctrlPropreties.val == undefined || ctrlPropreties.val == '')){ //ctrlPropreties.val = control.defaultValue; $(this).trigger('clearData', true); } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } } if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger("Control_Update"); } } if(isStateChage && $(this).find('img').length > 0){ $(this).find('img').trigger('onload'); } event.stopPropagation(); }) .on("fvParentCtrlShowHideChange", function(event, ctrlHidden, addToChangeList, triggerCtrlID){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } if(triggerCtrlID && this.id !== triggerCtrlID){ event.stopPropagation(); return; } ctrlPropreties.isParentCtrlHidden = ctrlHidden; if(addToChangeList){ if(ctrlHidden == false){ ctrlPropreties.isValueChange = true; } if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } //CO-6062: Select Multiple changes value on edit if(fvDataNS.isLoading){ $(this).trigger('clearData', true); //CO-6655: Records where one Employees EarnCode did not populate if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ ctrlPropreties.destinationNotFound = true; } } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger('Control_Update'); } event.stopPropagation(); }); fvDataNS.ctrlIndex++; ctrlPropreties.ctrlDataId = fvDataNS.ctrlIndex; fillDataControlScoreTableFV($tableBodyRow, control.type, properties, ctrlPropreties); // add comment if (rootInputProperties.appendComment != undefined && rootInputProperties.appendComment == true){ var commentName = control.name + '__comment'; var ctrlPropreties_Comment = { name: commentName, parentName: rootInputProperties.name, classPath: rootInputProperties.classPath + ' ' + commentName, id: control.id + '__comment', label: control.label, readOnly: control.readOnly, ctrlType: control.type, //required: control.required || false, children: [], parentKind: 'scoreTable', duplicateCheck: false, }; if(fvDataNS.incomplete){ var tmp = ctrlPropreties_Comment; ctrlPropreties_Comment = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties_Comment); if(ctrlPropreties_Comment == undefined){ ctrlPropreties_Comment = tmp; rootInputProperties.children.push(ctrlPropreties_Comment); ctrlPropreties_Comment.parrentProperties = rootInputProperties.classPath; } }else{ if(fvDataNS.currentForm.editRecordData){ getEditRecordData(ctrlPropreties_Comment, fvDataNS.currentForm.editRecordData, control); } rootInputProperties.children.push(ctrlPropreties_Comment); ctrlPropreties_Comment.parrentProperties = rootInputProperties.classPath; } var properties_Comment = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties['inputScoreTable_Comment']); properties_Comment.id.ctrlType = 'inputScoreTable_Comment'; _.each(properties_Comment, function(property, key) { property.value = ctrlPropreties_Comment[key]; }); fillDataControlScoreTableFV($tableBodyRow, 'inputScoreTable_Comment', properties_Comment, ctrlPropreties_Comment); $tableBodyRow.find('.ctrlScoreTable_comment') .on("fvParentCtrlShowHideChange", function(event, ctrlHidden, addToChangeList, triggerCtrlID){ if(ctrlPropreties_Comment == undefined){ event.stopPropagation(); return; } if(triggerCtrlID && this.id !== triggerCtrlID){ event.stopPropagation(); return; } ctrlPropreties_Comment.isParentCtrlHidden = ctrlHidden; if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } //CO-6062: Select Multiple changes value on edit if(fvDataNS.isLoading){ $(this).trigger('clearData', true); //CO-6655: Records where one Employees EarnCode did not populate if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ ctrlPropreties.destinationNotFound = true; } } setListCtrlDataChange(ctrlPropreties_Comment.classPath, true, ctrlPropreties_Comment.val); }else{ $(this).trigger('Control_Update'); } event.stopPropagation(); }); } if(addHeader){ var $tableColHeader = $(''); $tableHeader.append($tableColHeader); _.each(properties.options.value, function(option, key) { if (option.isShowUnderlying !== undefined){ return true; } var $tableColHeader = $('') .append(option.text.eng); $tableHeader.append($tableColHeader); addHeader = false; }); if (rootInputProperties.appendComment != undefined && rootInputProperties.appendComment == true){ // Apply task : https://doforms.atlassian.net/browse/PCA-136 // (Ability to change the caption when appending a comment in Questionaire) // Process default comment or custom comment var lblCommentHeader = lbl_score_table_col_comment; if (currentVersion >= VERSION_SHOW_COMMENT_LABEL_QUESTIONNAIRE_PRINT_PREVIEW) { if (rootInputProperties.commentLabel !== undefined && rootInputProperties.commentLabel !== '') { lblCommentHeader = rootInputProperties.commentLabel; } } $tableColHeader = $('') .append(lblCommentHeader); $tableHeader.append($tableColHeader); } /*if($control.find('.controlData').hasClass("equallySpaceColumns")){ var colCount = $tableHeader.find('.fv_tbl_cols01').length; var colPer = 100 / colCount; $tableHeader.find('.fv_tbl_cols01').attr('style','width:' + colPer + '%'); }*/ } }); var colWidthArr = calculateScoreTableCol($control.find('table')); var headerColWidth = colWidthArr[0]; var ths = $tableHeader.find('th'); var colCount = ths.length; var controlNameCell = $control.find('.tblBody td.controlNameCell'); controlNameCell.css('width', headerColWidth + 'px').css('max-width', headerColWidth + 'px').css('min-width', headerColWidth + 'px'); controlNameCell.css('word-wrap', 'break-word'); controlNameCell.css('word-break', 'break-word'); // CO-2617 change break-all into break-word to stop break the word controlNameCell.css('white-space', 'normal'); var maxColWidth = 0; var totalColWidth = 0; for(var i=1; i'); row.append(emptyCell); } var loadRecurseGridFV = function($control, controls, parentPath, rootInputProperties){ var $tableHeader = $control.find('.tblHeader'); var $tableBody = $control.find('.tblBody'); $tableHeader.empty(); $tableBody.find('.tblBody').empty(); var cellIndex = 1; var rowIndex = 1; var colCount = rootInputProperties.colCount; var colPercen = eval(100/colCount); var itemWidth = {}; var itemMinWidth = {}; var equallySpaceMinWidth = undefined; var isFixToScreen = $control.find('.controlData').hasClass('fitToWidth'); var isEquallySpaceColumns = $control.find('.controlData').hasClass('equallySpaceColumns'); var isColumnWeightCustom = false; var columnWeightCustomArr; var colPadding = false; var colPaddingLeftPercen = 0; var colPaddingRightPercen = 0; if(rootInputProperties.gridType == CONST_GRID_TYPE_CENTER){ colPaddingLeftPercen = getFloatValue(rootInputProperties.leftPadding); colPaddingRightPercen = getFloatValue(rootInputProperties.rightPadding); colPadding = true; } if(isVersion(VERSION_GRID_TYPE_FUNCTION_WEBAPP)){ if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ isColumnWeightCustom = rootInputProperties.isColumnWeightCustom; }else{ if(rootInputProperties.columnsSpaceType == '2'){ isColumnWeightCustom = true; } } if(isColumnWeightCustom){ columnWeightCustomArr = rootInputProperties.withFormat4ColumnWeight.split('|'); } } var colCount = rootInputProperties.colCount; var tableColClass = ''; switch(colCount){ case '1': tableColClass = 'oneCol'; break; case '2': tableColClass = 'twoCol'; break; default: tableColClass = 'manyCol'; } $control.find('table').addClass(tableColClass); if(isFixToScreen){ if(isEquallySpaceColumns){ /*var per = 100 / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + '%'; }*/ var adjustWidthNormal = 1; if(rootInputProperties.adjustWidthNormal){ if(!$control.find('table').hasClass('dont_resize')){ adjustWidthNormal = parseFloat(rootInputProperties.adjustWidthNormal)/100; } } var ctrlWidth = (fvDataNS.ctrlWidth * adjustWidthNormal); if(colPadding){ colPaddingLeftPercen = ((ctrlWidth*colPaddingLeftPercen)/100); colPaddingRightPercen = ((ctrlWidth*colPaddingRightPercen)/100); ctrlWidth -= (colPaddingLeftPercen + colPaddingRightPercen); colPaddingLeftPercen += 'px'; colPaddingRightPercen += 'px'; } var per = ctrlWidth / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + 'px'; } equallySpaceMinWidth = 0; for(var i = 0; i < controls.length; i++){ var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ equallySpaceMinWidth = SPECIAL_CTRL_MIN_WIDTH; break; } var minCtrlWidth = getMinGridCtrlWidth(control, true, isFixToScreen); if(equallySpaceMinWidth < minCtrlWidth){ equallySpaceMinWidth = minCtrlWidth; } } for(var i = 0; i < colCount; i++){ itemMinWidth[i] = equallySpaceMinWidth + 'px'; } }else if(isColumnWeightCustom){ if(rootInputProperties.isIgnoreGrid && rootInputProperties.ignoreScreenSize && !(previewEmbedHtml && location.protocol == 'https:') && getParent() && getParent().previewMode && getParent().previewMode.size && parseFloat(rootInputProperties.ignoreScreenSize) > parseFloat(getParent().previewMode.size) && rootInputProperties.stackedExpand && rootInputProperties.stackedExpand == 'stacked') { //do nothing } else { if(colPadding){ colPaddingLeftPercen += '%'; colPaddingRightPercen += '%'; } for(var i = 0; i < colCount; i++){ if(columnWeightCustomArr.length > i){ itemWidth[i] = jQuery.trim(columnWeightCustomArr[i]) + '%'; }else{ itemWidth[i] = CTRL_MIN_WIDTH + 'px'; } itemMinWidth[i] = CTRL_MIN_WIDTH + 'px'; } } /*var colSpecialMap = {}; var colIndex = 0; for(var i = 0; i < controls.length; i++){ if(colIndex >= colCount){ colIndex = 0; } var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ colSpecialMap[colIndex] = true; } if(colSpecialMap[colIndex]){ itemMinWidth[colIndex] = SPECIAL_CTRL_MIN_WIDTH + 'px';; }else{ // is CTRL_MIN_WIDTH } colIndex += 1; }*/ }else{ var taltalLength = 0; var colIndex = 0; var colSpecialMap = {}; colPadding = false; for(var i = 0; i < controls.length; i++){ if(colIndex >= colCount){ colIndex = 0; } var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ colSpecialMap[colIndex] = true; } if(colSpecialMap[colIndex]){ itemWidth[colIndex] = SPECIAL_CTRL_MIN_WIDTH; }else{ var minCtrlWidth = getMinGridCtrlWidth(control, true, isFixToScreen); if(itemWidth[colIndex] && itemWidth[colIndex] > minCtrlWidth){ }else{ itemWidth[colIndex] = minCtrlWidth; } } colIndex += 1; } var zeroItemCount = 0; for(var i = 0; i < colCount; i++){ if(!itemWidth[i]){ itemWidth[i] = CTRL_MIN_WIDTH; } if(itemWidth[i] == 0){ zeroItemCount++; } taltalLength += itemWidth[i]; } var screenWidth = fvDataNS.ctrlWidth - 4; var addWidth = 0; if(taltalLength < screenWidth){ addWidth = (screenWidth - taltalLength)/colCount; taltalLength = screenWidth; for(var i = 0; i < colCount; i++){ itemWidth[i] += addWidth; itemMinWidth[i] = itemWidth[i] + 'px'; itemWidth[i] = itemWidth[i]*100/taltalLength + '%'; } }else{ $control.find('table').css('width', taltalLength + 'px').addClass('dont_resize'); } } }else{ if(isEquallySpaceColumns){ var minWidth = 0; for(var i = 0; i < controls.length; i++){ var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ minWidth = SPECIAL_CTRL_MIN_WIDTH; break; } var minCtrlWidth = getMinGridCtrlWidth(control, true, isFixToScreen); if(minWidth < minCtrlWidth){ minWidth = minCtrlWidth; } } for(var i = 0; i < colCount; i++){ itemWidth[i] = minWidth + 'px'; itemMinWidth[i] = minWidth + 'px'; } }/*else if(isColumnWeightCustom){ for(var i = 0; i < colCount; i++){ if(columnWeightCustomArr.length > i){ itemWidth[i] = jQuery.trim(columnWeightCustomArr[i]) + '%'; }else{ itemWidth[i] = CTRL_MIN_WIDTH + 'px'; } itemMinWidth[i] = CTRL_MIN_WIDTH + 'px'; } }*/else{ var colIndex = 0; var colSpecialMap = {}; for(var i = 0; i < controls.length; i++){ var control = controls[i]; var minCtrlWidth = getMinGridCtrlWidth(control, true, isFixToScreen); if(colIndex >= colCount){ colIndex = 0; } var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ colSpecialMap[colIndex] = true; } if(colSpecialMap[colIndex]){ itemWidth[colIndex] = SPECIAL_CTRL_MIN_WIDTH; }else{ if(itemWidth[colIndex] && itemWidth[colIndex] > minCtrlWidth){ }else{ itemWidth[colIndex] = minCtrlWidth; } } colIndex += 1; } for(var i = 0; i < colCount; i++){ if(!itemWidth[i]){ itemWidth[i] = CTRL_MIN_WIDTH; } itemWidth[i] += "px"; itemMinWidth[i] = itemWidth[i]; } } } //var $tableBodyRow = $(''); var $tableBodyRow = $(''); $tableBodyRow.css('word-wrap', 'break-word'); $tableBodyRow.css('word-break', CONST_DEF_WORD_BREAK); $tableBodyRow.css('white-space', 'normal'); if(controls.length > 0){ $control.find('.tblBody').append($tableBodyRow); } var rowClass = 'evenRow'; var $tableBodyLeftPaddingCell; var $tableBodyRightPaddingCell; if(colPadding){ $tableBodyLeftPaddingCell = $(''); if(equallySpaceMinWidth){ $tableBodyLeftPaddingCell.css('width', colPaddingLeftPercen).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ var maxWidth = itemMinWidth[0]; if(maxWidth == '0px'){ if(colPaddingLeftPercen == '0px'){ maxWidth = '70px'; }else{ maxWidth = colPaddingLeftPercen; } } $tableBodyLeftPaddingCell.css('width', colPaddingLeftPercen).css('min-width', itemMinWidth[0]).css('max-width', maxWidth); if(colPaddingLeftPercen == '0%'){ $tableBodyLeftPaddingCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } $tableBodyRow.append($tableBodyLeftPaddingCell.clone()); $tableBodyRightPaddingCell = $(''); if(equallySpaceMinWidth){ $tableBodyRightPaddingCell.css('width', colPaddingRightPercen).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ var maxWidth = itemMinWidth[0]; if(maxWidth == '0px'){ if(colPaddingRightPercen == '0px'){ maxWidth = '70px'; }else{ maxWidth = colPaddingRightPercen; } } $tableBodyRightPaddingCell.css('width', colPaddingRightPercen).css('min-width', itemMinWidth[0]).css('max-width', maxWidth); if(colPaddingRightPercen == '0%'){ $tableBodyRightPaddingCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } } var isCellIndexChange = true; _.each(controls, function(control){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP && control.isRetrieve){ control.type = CONST_CTRL_TYPE_INPUTACTION; control.imgAction = CONST_ACTION_RETRIEVE; control.kind = control.btnKind; if( control.btnKind == CONST_TYPE_IMAGE ){ control.useImage = true; }else{ control.useImage = false; } /*if((control.isRetrieveDS == undefined && control.isModifyOnly == true) || control.isRetrieveDS == false || (control.retrieveKind == CONST_TYPE_AUTO_RUN && control.hideRetrieveButtonAuto == true)){ control.hideViewEdit = true; control.hideDispatchNew = true; control.hideDispatchEdit = true; control.hideFillAndSend = true; control.hideInMobile = true; control.hideWebAppGrp = true; control.hideViewNew = true; control.hideDispatchToEmail = true; control.hideFillAndSendEdit = true; control.hideWebApp = true; control.hideEmbeddedForm = true; control.hideFormLinks = true; control.hideInPDF = true; control.hidePdfWeb = true; control.hideInWeb = true; }*/ }else if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT && control.paymentType && (control.paymentType == CONST_PAYMENT_TYPE_AUTOMATED || control.paymentType == CONST_PAYMENT_TYPE_SQUARE || control.paymentType == CONST_PAYMENT_MIPOS)){ control.type = CONST_CTRL_TYPE_INPUTACTION; if(control.paymentType == CONST_PAYMENT_TYPE_SQUARE){ control.imgAction = CONST_ACTION_SQUARE; }else if(control.paymentType == CONST_PAYMENT_MIPOS){ control.imgAction = CONST_ACTION_MIPOD; }else{ control.imgAction = CONST_ACTION_PROPAY; } if(!isVersion(VERSION_PAYMENT_TYPE)){ control.actionBtnText = control.label.eng; control.hintLink = ''; control.useImage = false; control.imgJustify = 'Center'; }else{ if(control.kind == 'Button'){ control.useImage = false; control.hintLink = ''; } } }else if(control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ control.type = CONST_CTRL_TYPE_INPUTACTION; var defaultLabel = ''; if(control.transaction == CONST_CREATE_LABEL){ control.imgAction = CONST_ACTION_SHIPPING_CREATE_LABEL; defaultLabel = lbl_create_label; }else{ control.imgAction = CONST_ACTION_SHIPPING_GET_RATE; defaultLabel = lbl_get_rate; } if(control.kind == CONST_TYPE_IMAGE){ control.actionBtnText = control.imageText; }else{ control.actionBtnText = control.actionBtnText; } if(control.actionBtnText == undefined || control.actionBtnText == ''){ control.actionBtnText = defaultLabel; } }else{ // convert nfc, barcode to input action preview mode only /* CO-2067 Action button images in web forms not appearing if(isTabletPreview){*/ switch(control.type){ case CONST_CTRL_TYPE_INPUTNFC: case CONST_CTRL_TYPE_INPUTBARCODE: if(control.parse && control.isUseActionButton){ control.imgAction = control.type; control.type = CONST_CTRL_TYPE_INPUTACTION; control.kind = control.btnKind; } break; } /*}*/ } if(fvDataNS && fvDataNS.currentForm && fvDataNS.currentForm.formVersion && (parseFloat(fvDataNS.currentForm.formVersion) < parseFloat(FORM_VERSION))){ if(control.autoStamp){ if(control.isAllowEdit == undefined){ control.isAllowEdit = false; } }else{ control.isAllowEdit = true; } }else{ if(control.isAllowEdit == undefined){ control.isAllowEdit = true; } } if(cellIndex > colCount){ if(colPadding){ $tableBodyRow.append($tableBodyRightPaddingCell.clone()); } appendEmptyCell($tableBodyRow); $tableBodyRow = $(''); $tableBodyRow.css('word-wrap', 'break-word'); $tableBodyRow.css('word-break', CONST_DEF_WORD_BREAK); $tableBodyRow.css('white-space', 'normal'); $tableBody.append($tableBodyRow); if(colPadding){ $tableBodyRow.append($tableBodyLeftPaddingCell.clone()); } cellIndex = 1; rowIndex += 1; if(rowClass == 'oddRow'){ rowClass = 'evenRow'; }else{ rowClass = 'oddRow'; } } if(isCellIndexChange){ $tableBodyCell = $(''); if(cellIndex == colCount){ $tableBodyCell.addClass('last-col'); } if(itemWidth[cellIndex - 1]){ if(equallySpaceMinWidth){ $tableBodyCell.css('width', itemWidth[cellIndex-1]).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ var maxWidth = itemMinWidth[cellIndex - 1]; if(maxWidth == '0px'){ if(itemWidth[cellIndex-1] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[cellIndex-1]; } } $tableBodyCell.css('width', itemWidth[cellIndex-1]).css('min-width', itemMinWidth[cellIndex-1]).css('max-width', maxWidth); if(itemWidth[cellIndex-1] == '0%'){ $tableBodyCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } } $tableBodyRow.append($tableBodyCell); } var properties = null; if ((control.type == CONST_CTRL_TYPE_GROUP) || (control.type == CONST_CTRL_TYPE_CTRLTABLE) || (control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) || (control.type == CONST_CTRL_TYPE_CTRLPOD) || (control.type == CONST_CTRL_TYPE_CTRLINV) || (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) || (control.type == CONST_CTRL_TYPE_CTRLGRID) || (control.type == 'branch') || (control.type == 'inputPageBreak') || (control.type == 'inputLabel') || (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY) || (control.type == CONST_CTRL_TYPE_INPUTNUMBERING) || (control.type == CONST_CTRL_TYPE_INPUTACTION) || (control.type == CONST_CTRL_TYPE_INPUTPAYMENT) || (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT) || (control.type == 'inputInstruction') || //(control.type == CONST_CTRL_TYPE_INPUTCALCULATE) || (control.type == CONST_CTRL_TYPE_INPUTLOOKUP) || (control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) || (control.type == 'inputFacingTable') || (control.type == 'inputLookupMulti') || (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTFAX) || (control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) || (control.type == 'inputSaveAndSend') || (control.type == 'ctrlDataSource') || (control.type == 'ctrlHeaderGrid') || (control.type == 'ctrlDataFilter') || (control.type == 'ctrlReportBreakPoint') || (control.type == 'ctrlBreakPointData') || (control.type == 'ctrlBreakPointDataElement') || (control.type == 'ctrlFooterGrid') || (control.type == 'ctrlEmailSchedule')){ if(control.relevanceconds == undefined){ control.relevanceconds = []; } properties = $.extend(true, {}, $.fn.odkControl.controlProperties[control.type]); }else{ properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[control.type]); removeUnsupportProperty(properties, control.type); } removeUnuseVersion(properties); if(control.isAttachFormWidget === true){ appendProperties4AttachFormWidget(properties); } properties.id.ctrlType = control.type; var ctrlPropreties = { name: control.name, parentName: rootInputProperties.name, //classPath: 'data ' + control.name, classPath: rootInputProperties.classPath + ' ' + control.name, id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [], parentKind: 'grid' }; if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropreties.hideWebApp = true; control.hideWebApp = true; }else{ ctrlPropreties.hideWebApp = false; control.hideWebApp = false; } } } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.isRetrieve){ ctrlPropreties.datasource = control.datasource; ctrlPropreties.destinationdataconds = control.destinationdataconds ctrlPropreties.modifyFields = control.modifyFields; ctrlPropreties.lookupValue = control.lookupValue; ctrlPropreties.lookupfield = control.lookupfield; ctrlPropreties.lookupConditionFields = control.lookupConditionFields; ctrlPropreties.notDisplayRecNotFound = control.notDisplayRecNotFound; ctrlPropreties.isModifyAllMatches = control.isModifyAllMatches; ctrlPropreties.isCaseSensitiveCmp = control.isCaseSensitiveCmp; ctrlPropreties.isRetrieveOldestRecord = control.isRetrieveOldestRecord; ctrlPropreties.retrieveRecordKind = control.retrieveRecordKind; ctrlPropreties.isModifyAdd = control.isModifyAdd; ctrlPropreties.modifyAddFields = control.modifyAddFields; } appendControlProperties4Widget(ctrlPropreties, control); //appendControlProperties4ShippingWidget(ctrlPropreties, control); if(control.displayCCIcon){ ctrlPropreties.displayCCIcon = control.displayCCIcon; } if(control.isDisplayAmountCharged != false){ ctrlPropreties.isDisplayAmountCharged = control.isDisplayAmountCharged; } if(control.addMessage){ ctrlPropreties.addMessage = control.addMessage; }else{ ctrlPropreties.addMessage = { check: true, text: lbl_default_add_msg }; } if(control.amountCharged){ ctrlPropreties.amountCharged = control.amountCharged; } if(control.totalAmountPaid){ ctrlPropreties.totalAmountPaid = control.totalAmountPaid; } if(control.transactionClientId){ ctrlPropreties.transactionClientId = control.transactionClientId; } if(control.requiredViewEdit != undefined){ // new enchance ctrlPropreties.requiredDispatchEdit = { value: control.requiredDispatchEdit}; ctrlPropreties.requiredDispatchNew = { value: control.requiredDispatchNew}; ctrlPropreties.requiredFillAndSend = { value: control.requiredFillAndSend}; if(isVersion(VERSION_FNS_EDIT)){ ctrlPropreties.requiredFillAndSendEdit = { value: control.requiredFillAndSendEdit}; } ctrlPropreties.requiredDispatchToEmail = { value: control.requiredDispatchToEmail}; ctrlPropreties.requiredViewNew = { value: control.requiredViewNew}; ctrlPropreties.requiredViewEdit = { value: control.requiredViewEdit}; ctrlPropreties.requiredWebApp = { value: control.requiredWebApp}; ctrlPropreties.requiredFormLinks = { value: control.requiredFormLinks}; ctrlPropreties.required = { value: control.required}; } // CO-3502 if(control.ofDispatchCaptionText != undefined){ ctrlPropreties.label = { eng: control.ofDispatchCaptionText}; } if(control.ofDispatchRequired != undefined){ ctrlPropreties.ofDispatchRequired = { value: control.ofDispatchRequired}; } if(control.hideButtonAfterClick != undefined){ ctrlPropreties.hideButtonAfterClick = control.hideButtonAfterClick; // CO-4027: Hide button after click } if(control.kind != undefined){ ctrlPropreties.kind = control.kind; } if(control.length != undefined && control.length != false){ ctrlPropreties.length = { min: control.length.min || '', max: control.length.max || '', cannotExceedMaximum : control.length.cannotExceedMaximum || false } }else if(control.range != undefined && control.range != false){ ctrlPropreties.range = { min: control.range.min || '', max: control.range.max || '' } } if(control.validateValue != undefined && control.validateValue != false){ ctrlPropreties.validateValue = {}; ctrlPropreties.validateValue.value = control.validateValue; } if(control.dispatchRequired != undefined && control.dispatchRequired == true){ ctrlPropreties.dispatchRequired = true; if(isWebAppDispatch()){ control.required = true; ctrlPropreties.required = true; } } if(control.readOnlyDsp != undefined){ ctrlPropreties.readOnlyDsp = control.readOnlyDsp; } if(control.requiredForwarded != undefined){ ctrlPropreties.requiredForwarded = {value: control.requiredForwarded}; // CO-941 } if(control.requiredOnRetrieve != undefined){ // CO-4940: Required setting - Turned off for retrieve not working ctrlPropreties.requiredOnRetrieve = {value: control.requiredOnRetrieve}; } // CO-3852: New Retrieve Setting - Auto Run if(control.isRetrieveDS == true && control.autoActionStampTriggerRetrieve != undefined && (control.autoActionStampTriggerRetrieve == '2' // specific question || control.autoActionStampTriggerRetrieve == '8') // open form ){ ctrlPropreties.retrieveKind = control.retrieveKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerRetrieve = control.autoActionStampTriggerRetrieve; ctrlPropreties.autoActionStampQuestionTriggerRetrieve = control.autoActionStampQuestionTriggerRetrieve; ctrlPropreties.hideRetrieveButtonAuto = control.hideRetrieveButtonAuto; } // CO-3853 if(control.autoActionStampTriggerModify != undefined && (control.autoActionStampTriggerModify == '2' // specific question || control.autoActionStampTriggerModify == '8' || control.autoActionStampTriggerModify == '32') // on retrieve ){ ctrlPropreties.modifyKind = control.modifyKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerModify = control.autoActionStampTriggerModify; ctrlPropreties.autoActionStampQuestionTriggerModify = control.autoActionStampQuestionTriggerModify; ctrlPropreties.hideModifyButtonAuto = control.hideModifyButtonAuto; } // CO-3853 if(control.hideRetrieveButton){ ctrlPropreties.hideRetrieveButton = control.hideRetrieveButton; } if((control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTLOCATION) && control.iconColor){ // CO-4050 ctrlPropreties.iconColor = control.iconColor; } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.iconColor){ ctrlPropreties.applyScreenSize = control.applyScreenSize; ctrlPropreties.buttonSize = control.buttonSize; ctrlPropreties.ifScreenSmallerThan = control.ifScreenSmallerThan; ctrlPropreties.ifScreenSmallerSize = control.ifScreenSmallerSize; } if(fvDataNS.incomplete){ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : //case CONST_CTRL_TYPE_INPUTACTION : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: var tmp = ctrlPropreties; ctrlPropreties = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties); if(ctrlPropreties == undefined){ ctrlPropreties = tmp; rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } }else{ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: if(fvDataNS.currentForm.editRecordData){ getEditRecordData(ctrlPropreties, fvDataNS.currentForm.editRecordData, control); } rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } _.each(properties, function(property, key) { property.value = control[key]; if(key == 'relevanceconds' && property.value != undefined){ _.each(property.value, function(relevanceCond){ if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == '' || relevanceCond.text[CONST_VALUE_CTRLTYPE] == undefined){ return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_TEXT || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTLOCATION || relevanceCond.text[CONST_VALUE_CTRLTYPE] == mdi_kind_inputImage || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTBARCODE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTNFC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSECUREFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSCOREONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTMANY || relevanceCond.text[CONST_VALUE_CTRLTYPE] == 'inputRIF'){ if(relevanceCond.text[CONST_VAL]){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_EQUAL: case CONST_VALUE_NOT_EQUAL: case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } }else{ relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } } }); } }); // CO-3502: Button upload - Choose a file in dispatch var buttonUpload = ''; if(control.kind === CONST_TYPE_BUTTON && control.ofRequired === '2' && isApplyActionOpenFile(properties)){ buttonUpload = 'Upload'; } // Get selected control for cloning object, using in WebApps // Apply task : https://doforms.atlassian.net/browse/PCA-145 (Implement Shading for webapp) var controlInGrid = getSelectedQuery4CloneObjectWA('#formview_templates .ctrlGrid_' + control.type + buttonUpload, control.type, control); //var $control = $('#formview_templates .ctrlGrid_' + control.type) var $control = controlInGrid .clone() .attr('id', 'fvCtrlID_' + control.id) .addClass(control.type) .addClass('fvControl') .addClass('fvCtrlID_' + control.id) .addClass('fvCtrlName_' + control.name) //.odkControlFV(control.type, null, properties, ctrlPropreties) .appendTo($tableBodyCell) .on("fvCtrlShowHideChange", function(event, addToChangeList){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } var isHideCtrl = $(this).hasClass(CONST_CLASS_HIDE_CONTROL); var isStateChage = false; var isSetDefaultValueIfEmpty = false; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; } }else{ if(ctrlPropreties.isCtrlHidden){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; //CO-6062: Select Multiple changes value on edit //if(fvDataNS.isLoading == true && fvDataNS.isdispatch == true){ if(fvDataNS.isLoading == true){ isSetDefaultValueIfEmpty = true; } } }else{ if(isHideCtrl){ $(this).removeClass(CONST_CLASS_HIDE_CONTROL); resizeTextareaWhenUnhide($(this)); //reArrangeLayoutOfChooseOneWithShadingWALastAction($(this)); isStateChage = true; //isSetDefaultValueIfEmpty = true; } } } if(isStateChage){ if(isSetDefaultValueIfEmpty){ if((control.defaultValue != undefined && control.defaultValue != '') && (ctrlPropreties.val == undefined || ctrlPropreties.val == '')){ //ctrlPropreties.val = control.defaultValue; $(this).trigger('clearData', true); } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } } if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger("Control_Update"); } } if(isStateChage && $(this).find('img').length > 0){ $(this).find('img').trigger('onload'); } event.stopPropagation(); }) .on("fvParentCtrlShowHideChange", function(event, ctrlHidden, addToChangeList, triggerCtrlID){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } if(triggerCtrlID && this.id !== triggerCtrlID){ event.stopPropagation(); return; } ctrlPropreties.isParentCtrlHidden = ctrlHidden; if(addToChangeList){ if(ctrlHidden == false){ ctrlPropreties.isValueChange = true; } if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } //CO-6062: Select Multiple changes value on edit if(fvDataNS.isLoading){ $(this).trigger('clearData', true); //CO-6655: Records where one Employees EarnCode did not populate if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ ctrlPropreties.destinationNotFound = true; } } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger('Control_Update'); } event.stopPropagation(); }) // CO-4022 .on("fvContainerShowHideChange", function(event){ event.stopPropagation(); // Grid column base without caption processHideIf($(this), ctrlPropreties); }); fvDataNS.ctrlIndex++; //$control.find('.controlData').attr('id', 'ctrlDataId_' + fvDataNS.ctrlIndex); ctrlPropreties.ctrlDataId = fvDataNS.ctrlIndex; ctrlPropreties.row = rowIndex; ctrlPropreties.col = cellIndex; fillDataControlGridFV($control, control.type, properties, ctrlPropreties); if($control.hasClass('hideOnMobileApp')){ /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? $tableBodyCell.find('.fvControl').addClass('hideOnMobileApp'); */ isCellIndexChange = false; } else if(isWebAppDispatch() && $control.hasClass(CONST_CLASS_HIDE_CONTROL)){ /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? $tableBodyCell.find('.fvControl').addClass(CONST_CLASS_HIDE_CONTROL); */ isCellIndexChange = false; } else{ cellIndex++; isCellIndexChange = true; } }); /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? */ if(!isCellIndexChange){ if(cellIndex == 1){ if($tableBodyCell.find('.fvControl:visible').length == 0){ $tableBodyRow.addClass(CONST_CLASS_HIDE_CONTROL); } } cellIndex++; } if(controls.length > 0 && cellIndex <= colCount){ for(var i=cellIndex; i<=colCount; i++){ // Draw border for last cells (fix layout) // var $tableBodyCell = $(''); var $tableBodyCell = $(''); /*if(!isColumnWeightCustom){ if (rootInputProperties.equallySpaceColumns !== undefined && rootInputProperties.equallySpaceColumns === true){ $tableBodyCell.attr('style', 'width:' + colPercen + '%;'); } }else{ if(columnWeightCustomArr.length >= i){ $tableBodyCell.attr('style', 'width:' + columnWeightCustomArr[i-1] + '%;'); } }*/ if(itemWidth[i - 1]){ var maxWidth = itemMinWidth[index - 1]; if(maxWidth == '0px'){ if(itemWidth[i-1] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[i-1]; } } $tableBodyCell.css('width', itemWidth[i-1]).css('min-width', itemMinWidth[i-1]).css('max-width', maxWidth); if(itemWidth[i-1] == '0%'){ $tableBodyCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } $tableBodyRow.append($tableBodyCell); } } if(colPadding){ $tableBodyRow.append($tableBodyRightPaddingCell.clone()); } appendEmptyCell($tableBodyRow); } var loadRecurseGridFV_RowBase = function($control, controls, parentPath, rootInputProperties){ var $tableHeader = $control.find('.tblHeader'); var $tableBody = $control.find('.tblBody'); $tableHeader.empty(); $tableBody.find('.tblBody').empty(); var cellIndex = 1; var rowIndex = 1; var colCount = rootInputProperties.colCount; var colPercen = eval(100/colCount); var itemWidth = {}; var itemMinWidth = {}; var equallySpaceMinWidth = undefined; var isFixToScreen = $control.find('.controlData').hasClass('fitToWidth'); var isEquallySpaceColumns = $control.find('.controlData').hasClass('equallySpaceColumns'); var isColumnWeightCustom = false; var columnWeightCustomArr; var caseStackedSatisfied = rootInputProperties.caseStackedSatisfied; var headerVerticalWidth = TABLE_HEADER_HEIGHT; var headerHeight = TABLE_HEADER_HEIGHT; var taltalLength = 0; var colPadding = false; var colPaddingLeftPercen = 0; var colPaddingRightPercen = 0; if(rootInputProperties.gridType == CONST_GRID_TYPE_CENTER){ colPaddingLeftPercen = getFloatValue(rootInputProperties.leftPadding); colPaddingRightPercen = getFloatValue(rootInputProperties.rightPadding); colPadding = true; } if(isVersion(VERSION_GRID_TYPE_FUNCTION_WEBAPP)){ if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ isColumnWeightCustom = rootInputProperties.isColumnWeightCustom; }else{ if(rootInputProperties.columnsSpaceType == '2'){ isColumnWeightCustom = true; } } if(isColumnWeightCustom){ columnWeightCustomArr = rootInputProperties.withFormat4ColumnWeight.split('|'); } } var colCount = rootInputProperties.colCount; if(rootInputProperties.isUseVerticalCaption) { headerVerticalWidth = rootInputProperties.captionHeight * TABLE_HEADER_HEIGHT; headerHeight = TABLE_HEADER_VERTICAL_MIN_HEIGHT; // ctrlPropretiesGroup.isUseVerticalCaption = control.isUseVerticalCaption; // ctrlPropretiesGroup.captionHeight = control.captionHeight; } if(isFixToScreen){ if(isEquallySpaceColumns){ /*var per = 100 / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + '%'; }*/ var adjustWidthNormal = 1; if(rootInputProperties.adjustWidthNormal){ if(!$control.find('table').hasClass('dont_resize')){ adjustWidthNormal = parseFloat(rootInputProperties.adjustWidthNormal)/100; } } var ctrlWidth = (fvDataNS.ctrlWidth * adjustWidthNormal); if(colPadding){ colPaddingLeftPercen = ((ctrlWidth*colPaddingLeftPercen)/100); colPaddingRightPercen = ((ctrlWidth*colPaddingRightPercen)/100); ctrlWidth -= (colPaddingLeftPercen + colPaddingRightPercen); colPaddingLeftPercen += 'px'; colPaddingRightPercen += 'px'; } var per = ctrlWidth / colCount; //var per = fvDataNS.ctrlWidth / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + 'px'; } equallySpaceMinWidth = 0; if(!rootInputProperties.isUseVerticalCaption) { var hasSpecialControl = false; for(var i = 0; i < controls.length; i++){ var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ equallySpaceMinWidth = SPECIAL_CTRL_MIN_WIDTH; hasSpecialControl = true; break; } var minCtrlWidth = getMinGridCtrlWidth(control); if(equallySpaceMinWidth < minCtrlWidth){ equallySpaceMinWidth = minCtrlWidth; } } } else { // if(rootInputProperties.isUseVerticalCaption) { equallySpaceMinWidth = headerVerticalWidth; for(var i = 0; i < controls.length; i++){ var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } } /* hqkhanh this code use If Fit to Width = True AND the sum of the columns is GREATER than the working screen width, then shrink the columns equally so they fill the working screen width (i.e., rap the first Label caption text as needed) if(!hasSpecialControl){ var minCtrlWidth = (fvDataNS.ctrlWidth / colCount)-2; if(minCtrlWidth < equallySpaceMinWidth){ equallySpaceMinWidth = minCtrlWidth; } if(equallySpaceMinWidth < CTRL_MIN_WIDTH){ equallySpaceMinWidth = CTRL_MIN_WIDTH; } } */ for(var i = 0; i < colCount; i++){ itemMinWidth[i] = equallySpaceMinWidth + 'px'; } }else if(isColumnWeightCustom){ if(colPadding){ colPaddingLeftPercen += '%'; colPaddingRightPercen += '%'; } for(var i = 0; i < colCount; i++){ if(columnWeightCustomArr.length > i){ itemWidth[i] = jQuery.trim(columnWeightCustomArr[i]) + '%'; }else{ itemWidth[i] = CTRL_MIN_WIDTH + 'px'; } itemMinWidth[i] = CTRL_MIN_WIDTH + 'px'; } if(rootInputProperties.isUseVerticalCaption) { $control.find('table').css('table-layout','fixed'); for(var i = 0; i < controls.length; i++){ var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } } /*var colSpecialMap = {}; var colIndex = 0; for(var i = 0; i < controls.length; i++){ if(colIndex >= colCount){ colIndex = 0; } var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ colSpecialMap[colIndex] = true; } if(colSpecialMap[colIndex]){ itemMinWidth[colIndex] = SPECIAL_CTRL_MIN_WIDTH + 'px';; }else{ // is CTRL_MIN_WIDTH } colIndex += 1; }*/ }else{ colPadding = false; if(!rootInputProperties.isUseVerticalCaption) { var taltalLength = 0; var colCount = rootInputProperties.colCount; var colIndex = 0; var colSpecialMap = {}; for(var i = 0; i < controls.length; i++){ if(colIndex >= colCount){ colIndex = 0; } var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ colSpecialMap[colIndex] = true; } if(colSpecialMap[colIndex]){ itemWidth[colIndex] = SPECIAL_CTRL_MIN_WIDTH; }else{ var minCtrlWidth = getMinGridCtrlWidth(control); if(itemWidth[colIndex] && itemWidth[colIndex] > minCtrlWidth){ }else{ itemWidth[colIndex] = minCtrlWidth; } } colIndex += 1; } var zeroItemCount = 0; for(var i = 0; i < colCount; i++){ if(!itemWidth[i]){ itemWidth[i] = CTRL_MIN_WIDTH; } if(itemWidth[i] == 0){ zeroItemCount++; } taltalLength += itemWidth[i]; } var screenWidth = fvDataNS.ctrlWidth - 4; var addWidth = 0; if(taltalLength < screenWidth){ addWidth = (screenWidth - taltalLength)/colCount; taltalLength = screenWidth; for(var i = 0; i < colCount; i++){ itemWidth[i] += addWidth; itemMinWidth[i] = itemWidth[i] + 'px'; itemWidth[i] = itemWidth[i]*100/taltalLength + '%'; } }else{ $control.find('table').css('width', taltalLength + 'px').addClass('dont_resize'); } } else { // if(rootInputProperties.isUseVerticalCaption) { equallySpaceMinWidth = headerVerticalWidth; for(var i = 0; i < controls.length; i++){ var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } var per = fvDataNS.ctrlWidth / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + 'px'; itemMinWidth[i] = equallySpaceMinWidth + 'px'; } } } }else{ if(isEquallySpaceColumns){ var minWidth = 0; if(!rootInputProperties.isUseVerticalCaption) { for(var i = 0; i < controls.length; i++){ var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ minWidth = SPECIAL_CTRL_MIN_WIDTH; break; } var minCtrlWidth = getMinGridCtrlWidth(control); if(minWidth < minCtrlWidth){ minWidth = minCtrlWidth; } } for(var i = 0; i < colCount; i++){ itemWidth[i] = minWidth + 'px'; itemMinWidth[i] = itemWidth[i]; } } else { for(var i = 0; i < controls.length; i++){ var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } for(var i = 0; i < colCount; i++){ itemWidth[i] = headerVerticalWidth + 'px'; itemMinWidth[i] = itemWidth[i]; } } }/*else if(isColumnWeightCustom){ for(var i = 0; i < colCount; i++){ if(columnWeightCustomArr.length > i){ itemWidth[i] = jQuery.trim(columnWeightCustomArr[i]) + '%'; }else{ itemWidth[i] = CTRL_MIN_WIDTH + 'px'; } itemMinWidth[i] = CTRL_MIN_WIDTH + 'px'; } }*/else{ var colIndex = 0; var colSpecialMap = {}; if(!rootInputProperties.isUseVerticalCaption) { for(var i = 0; i < controls.length; i++){ var control = controls[i]; if(colIndex >= colCount){ colIndex = 0; } var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ colSpecialMap[colIndex] = true; } if(colSpecialMap[colIndex]){ itemWidth[colIndex] = SPECIAL_CTRL_MIN_WIDTH; }else{ var minCtrlWidth = getMinGridCtrlWidth(control); if(itemWidth[colIndex] && itemWidth[colIndex] > minCtrlWidth){ }else{ itemWidth[colIndex] = minCtrlWidth; } } colIndex += 1; } for(var i = 0; i < colCount; i++){ if(!itemWidth[i]){ itemWidth[i] = CTRL_MIN_WIDTH; } itemWidth[i] += "px"; itemMinWidth[i] = itemWidth[i]; } } else { for(var i = 0; i < controls.length; i++){ var control = controls[i]; // var minCtrlHeight = getMinGridCtrlWidth(control); var minCtrlHeight = getMinWidthOfMultilineText(control.label.eng , rootInputProperties.captionHeight); if(headerHeight < minCtrlHeight) { headerHeight = minCtrlHeight; } } for(var i = 0; i < colCount; i++){ itemWidth[i] = headerVerticalWidth + 'px'; itemMinWidth[i] = itemWidth[i]; } } } } if(true == caseStackedSatisfied) { itemWidth[0] = '100%'; } var $tableBodyOddRow = $(''); var $tableBodyEvenRow = $(''); var ths = $tableHeader.find('th'); $tableBodyOddRow.css('word-wrap', 'break-word'); if(!rootInputProperties.isUseVerticalCaption) { $tableBodyOddRow.css('word-break', CONST_DEF_WORD_BREAK); } $tableBodyOddRow.css('white-space', 'normal'); $tableBodyEvenRow.css('word-wrap', 'break-word'); $tableBodyEvenRow.css('word-break', CONST_DEF_WORD_BREAK); $tableBodyEvenRow.css('white-space', 'normal'); if(controls.length > 0){ $control.find('.tblBody').append($tableBodyOddRow); $control.find('.tblBody').append($tableBodyEvenRow); } var $tableBodyCell; var $tableBodyHeaderCell; var $tableBodyLeftPaddingCell; var $tableBodyRightPaddingCell; if(colPadding){ $tableBodyLeftPaddingCell = $(''); if(equallySpaceMinWidth){ $tableBodyLeftPaddingCell.css('width', colPaddingLeftPercen);//.css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ /*var maxWidth = itemMinWidth[0]; if(maxWidth == '0px'){ if(colPaddingLeftPercen == '0px'){ maxWidth = '70px'; }else{ maxWidth = colPaddingLeftPercen; } }*/ $tableBodyLeftPaddingCell.css('width', colPaddingLeftPercen);//.css('min-width', itemMinWidth[0]).css('max-width', maxWidth); if(colPaddingLeftPercen == '0%'){ $tableBodyLeftPaddingCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } $tableBodyOddRow.append($tableBodyLeftPaddingCell.clone()); $tableBodyEvenRow.append($tableBodyLeftPaddingCell.clone()); $tableBodyRightPaddingCell = $(''); if(equallySpaceMinWidth){ $tableBodyRightPaddingCell.css('width', colPaddingRightPercen);//.css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ /*var maxWidth = itemMinWidth[0]; if(maxWidth == '0px'){ if(colPaddingRightPercen == '0px'){ maxWidth = '70px'; }else{ maxWidth = colPaddingRightPercen; } }*/ $tableBodyRightPaddingCell.css('width', colPaddingRightPercen);//.css('min-width', itemMinWidth[0]).css('max-width', maxWidth); if(colPaddingRightPercen == '0%'){ $tableBodyRightPaddingCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } } var isCellIndexChange = true; _.each(controls, function(control){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP && control.isRetrieve){ control.type = CONST_CTRL_TYPE_INPUTACTION; control.imgAction = CONST_ACTION_RETRIEVE; control.kind = control.btnKind; if( control.btnKind == CONST_TYPE_IMAGE ){ control.useImage = true; }else{ control.useImage = false; } /*if((control.isRetrieveDS == undefined && control.isModifyOnly == true) || control.isRetrieveDS == false || (control.retrieveKind == CONST_TYPE_AUTO_RUN && control.hideRetrieveButtonAuto == true)){ control.hideViewEdit = true; control.hideDispatchNew = true; control.hideDispatchEdit = true; control.hideFillAndSend = true; control.hideInMobile = true; control.hideWebAppGrp = true; control.hideViewNew = true; control.hideDispatchToEmail = true; control.hideFillAndSendEdit = true; control.hideWebApp = true; control.hideEmbeddedForm = true; control.hideFormLinks = true; control.hideInPDF = true; control.hidePdfWeb = true; control.hideInWeb = true; }*/ }else if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT && control.paymentType && (control.paymentType == CONST_PAYMENT_TYPE_AUTOMATED || control.paymentType == CONST_PAYMENT_TYPE_SQUARE || control.paymentType == CONST_PAYMENT_MIPOS)){ control.type = CONST_CTRL_TYPE_INPUTACTION; if(control.paymentType == CONST_PAYMENT_TYPE_SQUARE){ control.imgAction = CONST_ACTION_SQUARE; }else if(control.paymentType == CONST_PAYMENT_MIPOS){ control.imgAction = CONST_ACTION_MIPOD; }else{ control.imgAction = CONST_ACTION_PROPAY; } if(!isVersion(VERSION_PAYMENT_TYPE)){ control.actionBtnText = control.label.eng; control.hintLink = ''; control.useImage = false; control.imgJustify = 'Center'; }else{ if(control.kind == 'Button'){ control.useImage = false; control.hintLink = ''; } } }else if(control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ control.type = CONST_CTRL_TYPE_INPUTACTION; var defaultLabel = ''; if(control.transaction == CONST_CREATE_LABEL){ control.imgAction = CONST_ACTION_SHIPPING_CREATE_LABEL; defaultLabel = lbl_create_label; }else{ control.imgAction = CONST_ACTION_SHIPPING_GET_RATE; defaultLabel = lbl_get_rate; } if(control.kind == CONST_TYPE_IMAGE){ control.actionBtnText = control.imageText; }else{ control.actionBtnText = control.actionBtnText; } if(control.actionBtnText == undefined || control.actionBtnText == ''){ control.actionBtnText = defaultLabel; } }else{ // convert nfc, barcode to input action preview mode only /* CO-2067 Action button images in web forms not appearing if(isTabletPreview){*/ switch(control.type){ case CONST_CTRL_TYPE_INPUTNFC: case CONST_CTRL_TYPE_INPUTBARCODE: if(control.parse && control.isUseActionButton){ control.imgAction = control.type; control.type = CONST_CTRL_TYPE_INPUTACTION; control.kind = control.btnKind; } break; } /*}*/ } if(fvDataNS && fvDataNS.currentForm && fvDataNS.currentForm.formVersion && (parseFloat(fvDataNS.currentForm.formVersion) < parseFloat(FORM_VERSION))){ if(control.autoStamp){ if(control.isAllowEdit == undefined){ control.isAllowEdit = false; } }else{ control.isAllowEdit = true; } }else{ if(control.isAllowEdit == undefined){ control.isAllowEdit = true; } } if(cellIndex > colCount){ if(colPadding){ $tableBodyOddRow.append($tableBodyRightPaddingCell.clone()); $tableBodyEvenRow.append($tableBodyRightPaddingCell.clone()); } appendEmptyCell($tableBodyOddRow); appendEmptyCell($tableBodyEvenRow); $tableBodyOddRow = $(''); $tableBodyEvenRow = $(''); $tableBodyOddRow.css('word-wrap', 'break-word'); $tableBodyOddRow.css('word-break', CONST_DEF_WORD_BREAK); $tableBodyOddRow.css('white-space', 'normal'); $tableBodyEvenRow.css('word-wrap', 'break-word'); $tableBodyEvenRow.css('word-break', CONST_DEF_WORD_BREAK); $tableBodyEvenRow.css('white-space', 'normal'); $tableBody.append($tableBodyOddRow); $tableBody.append($tableBodyEvenRow); if(colPadding){ $tableBodyOddRow.append($tableBodyLeftPaddingCell.clone()); $tableBodyEvenRow.append($tableBodyLeftPaddingCell.clone()); } cellIndex = 1; rowIndex += 1; } if(isCellIndexChange){ $tableBodyCell = $(''); $tableBodyHeaderCell = $(''); if(itemWidth[cellIndex - 1]){ if(equallySpaceMinWidth){ /*$tableBodyHeaderCell.css('width', itemWidth[cellIndex-1]).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); $tableBodyCell.css('width', itemWidth[cellIndex-1]).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth);*/ $tableBodyHeaderCell.css('width', itemWidth[cellIndex-1]).css('min-width', equallySpaceMinWidth).css('max-width', itemWidth[cellIndex-1]); $tableBodyCell.css('width', itemWidth[cellIndex-1]).css('min-width', equallySpaceMinWidth).css('max-width', itemWidth[cellIndex-1]); }else{ var maxWidth = itemMinWidth[cellIndex-1]; if(maxWidth == '0px'){ if(itemWidth[cellIndex-1] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[cellIndex-1]; } } $tableBodyHeaderCell.css('width', itemWidth[cellIndex-1]).css('min-width', itemMinWidth[cellIndex-1]).css('max-width', maxWidth); $tableBodyCell.css('width', itemWidth[cellIndex-1]).css('min-width', itemMinWidth[cellIndex-1]).css('max-width', maxWidth); if(itemWidth[cellIndex-1] == '0%'){ $tableBodyHeaderCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $tableBodyCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } } if(rootInputProperties.isUseVerticalCaption) { var style = $tableBodyHeaderCell.attr('style'); if(isColumnWeightCustom){ style += 'padding-left:0px!important;'; } headerHeight = roundNum(headerHeight); $tableBodyHeaderCell.attr('style', style + 'height:' + headerHeight + 'px!important;' + 'padding-top:' + TABLE_GRID_VERRTICAL_HEADER_PADDING + 'px!important;' + 'padding-bottom:' + TABLE_GRID_VERRTICAL_HEADER_PADDING + 'px!important;'); // + 'padding-left:' + TABLE_GRID_VERRTICAL_HEADER_PADDING_LR + 'px!important;' // + 'padding-right:' + TABLE_GRID_VERRTICAL_HEADER_PADDING_LR + 'px!important;'); $tableBodyHeaderCell.css('text-align','center'); $tableBodyHeaderCell.css('position','relative'); } $tableBodyOddRow.append($tableBodyHeaderCell); $tableBodyEvenRow.append($tableBodyCell); } var properties = null; if ((control.type == CONST_CTRL_TYPE_GROUP) || (control.type == CONST_CTRL_TYPE_CTRLTABLE) || (control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) || (control.type == CONST_CTRL_TYPE_CTRLPOD) || (control.type == CONST_CTRL_TYPE_CTRLINV) || (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) || (control.type == CONST_CTRL_TYPE_CTRLGRID) || (control.type == 'branch') || (control.type == 'inputPageBreak') || (control.type == 'inputLabel') || (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY) || (control.type == CONST_CTRL_TYPE_INPUTNUMBERING) || (control.type == CONST_CTRL_TYPE_INPUTACTION) || (control.type == CONST_CTRL_TYPE_INPUTPAYMENT) || (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT) || (control.type == 'inputInstruction') || //(control.type == CONST_CTRL_TYPE_INPUTCALCULATE) || (control.type == CONST_CTRL_TYPE_INPUTLOOKUP) || (control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) || (control.type == 'inputFacingTable') || (control.type == 'inputLookupMulti') || (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) || (control.type == 'inputSaveAndSend') || (control.type == 'ctrlDataSource') || (control.type == 'ctrlHeaderGrid') || (control.type == 'ctrlDataFilter') || (control.type == 'ctrlReportBreakPoint') || (control.type == 'ctrlBreakPointData') || (control.type == 'ctrlBreakPointDataElement') || (control.type == 'ctrlFooterGrid') || (control.type == 'ctrlEmailSchedule')){ if(control.relevanceconds == undefined){ control.relevanceconds = []; } propertiesHeader = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties['inputLabel']); properties = $.extend(true, {}, $.fn.odkControl.controlProperties[control.type]); }else{ propertiesHeader = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties['inputLabel']); properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[control.type]); removeUnsupportProperty(properties, control.type); } removeUnuseVersion(properties); if(control.isAttachFormWidget === true){ appendProperties4AttachFormWidget(properties); } propertiesHeader.id.ctrlType = 'inputLabel'; properties.id.ctrlType = control.type; var ctrlPropretiesHeader = { name: control.name, parentName: rootInputProperties.name, classPath: 'data Header_' + control.name, id: 'Header_' + control.id, label: control.label, ctrlType: 'inputLabel', required: control.required || false, children: [] }; var ctrlPropreties = { name: control.name, parentName: rootInputProperties.name, //classPath: 'data ' + control.name, classPath: rootInputProperties.classPath + ' ' + control.name, id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [], parentKind: 'grid' }; if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropreties.hideWebApp = true; control.hideWebApp = true; }else{ ctrlPropreties.hideWebApp = false; control.hideWebApp = false; } } } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.isRetrieve){ ctrlPropreties.datasource = control.datasource; ctrlPropreties.destinationdataconds = control.destinationdataconds ctrlPropreties.modifyFields = control.modifyFields; ctrlPropreties.lookupValue = control.lookupValue; ctrlPropreties.lookupfield = control.lookupfield; ctrlPropreties.lookupConditionFields = control.lookupConditionFields; ctrlPropreties.notDisplayRecNotFound = control.notDisplayRecNotFound; ctrlPropreties.isModifyAllMatches = control.isModifyAllMatches; ctrlPropreties.isCaseSensitiveCmp = control.isCaseSensitiveCmp; ctrlPropreties.isRetrieveOldestRecord = control.isRetrieveOldestRecord; ctrlPropreties.retrieveRecordKind = control.retrieveRecordKind; ctrlPropreties.isModifyAdd = control.isModifyAdd; ctrlPropreties.modifyAddFields = control.modifyAddFields; } appendControlProperties4Widget(ctrlPropreties, control); //appendControlProperties4ShippingWidget(ctrlPropreties, control); if(control.displayCCIcon){ ctrlPropreties.displayCCIcon = control.displayCCIcon; } if(control.isDisplayAmountCharged != false){ ctrlPropreties.isDisplayAmountCharged = control.isDisplayAmountCharged; } if(control.addMessage){ ctrlPropreties.addMessage = control.addMessage; }else{ ctrlPropreties.addMessage = { check: true, text: lbl_default_add_msg }; } if(control.amountCharged){ ctrlPropreties.amountCharged = control.amountCharged; } if(control.totalAmountPaid){ ctrlPropreties.totalAmountPaid = control.totalAmountPaid; } if(control.transactionClientId){ ctrlPropreties.transactionClientId = control.transactionClientId; } if(control.requiredViewEdit != undefined){ // new enchance ctrlPropreties.requiredDispatchEdit = { value: control.requiredDispatchEdit}; ctrlPropreties.requiredDispatchNew = { value: control.requiredDispatchNew}; ctrlPropreties.requiredFillAndSend = { value: control.requiredFillAndSend}; if(isVersion(VERSION_FNS_EDIT)){ ctrlPropreties.requiredFillAndSendEdit = { value: control.requiredFillAndSendEdit}; } ctrlPropreties.requiredDispatchToEmail = { value: control.requiredDispatchToEmail}; ctrlPropreties.requiredViewNew = { value: control.requiredViewNew}; ctrlPropreties.requiredViewEdit = { value: control.requiredViewEdit}; ctrlPropreties.requiredWebApp = { value: control.requiredWebApp}; ctrlPropreties.requiredFormLinks = { value: control.requiredFormLinks}; ctrlPropreties.required = { value: control.required}; } if(control.kind != undefined){ ctrlPropreties.kind = control.kind; } if(control.length != undefined && control.length != false){ ctrlPropreties.length = { min: control.length.min || '', max: control.length.max || '', cannotExceedMaximum : control.length.cannotExceedMaximum || false } }else if(control.range != undefined && control.range != false){ ctrlPropreties.range = { min: control.range.min || '', max: control.range.max || '' } } if(control.validateValue != undefined && control.validateValue != false){ ctrlPropreties.validateValue = {}; ctrlPropreties.validateValue.value = control.validateValue; } if(control.dispatchRequired != undefined && control.dispatchRequired == true){ ctrlPropreties.dispatchRequired = true; if(isWebAppDispatch()){ control.required = true; ctrlPropreties.required = true; } } if(control.readOnlyDsp != undefined){ ctrlPropreties.readOnlyDsp = control.readOnlyDsp; } if(control.requiredForwarded != undefined){ ctrlPropreties.requiredForwarded = {value: control.requiredForwarded}; // CO-941 } if(control.requiredOnRetrieve != undefined){ // CO-4940: Required setting - Turned off for retrieve not working ctrlPropreties.requiredOnRetrieve = {value: control.requiredOnRetrieve}; } // CO-3852: New Retrieve Setting - Auto Run if(control.isRetrieveDS == true && control.autoActionStampTriggerRetrieve != undefined && (control.autoActionStampTriggerRetrieve == '2' // specific question || control.autoActionStampTriggerRetrieve == '8') // open form ){ ctrlPropreties.retrieveKind = control.retrieveKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerRetrieve = control.autoActionStampTriggerRetrieve; ctrlPropreties.autoActionStampQuestionTriggerRetrieve = control.autoActionStampQuestionTriggerRetrieve; ctrlPropreties.hideRetrieveButtonAuto = control.hideRetrieveButtonAuto; } // CO-3853 if(control.autoActionStampTriggerModify != undefined && (control.autoActionStampTriggerModify == '2' // specific question || control.autoActionStampTriggerModify == '8' || control.autoActionStampTriggerModify == '32') // on retrieve ){ ctrlPropreties.modifyKind = control.modifyKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerModify = control.autoActionStampTriggerModify; ctrlPropreties.autoActionStampQuestionTriggerModify = control.autoActionStampQuestionTriggerModify; ctrlPropreties.hideModifyButtonAuto = control.hideModifyButtonAuto; } // CO-3853 if(control.hideRetrieveButton){ ctrlPropreties.hideRetrieveButton = control.hideRetrieveButton; } if((control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTLOCATION) && control.iconColor){ // CO-4050 ctrlPropreties.iconColor = control.iconColor; } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.iconColor){ ctrlPropreties.applyScreenSize = control.applyScreenSize; ctrlPropreties.buttonSize = control.buttonSize; ctrlPropreties.ifScreenSmallerThan = control.ifScreenSmallerThan; ctrlPropreties.ifScreenSmallerSize = control.ifScreenSmallerSize; } if(fvDataNS.incomplete){ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : //case CONST_CTRL_TYPE_INPUTACTION : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: var tmp = ctrlPropreties; ctrlPropreties = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties); if(ctrlPropreties == undefined){ ctrlPropreties = tmp; rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } }else{ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: if(fvDataNS.currentForm.editRecordData){ getEditRecordData(ctrlPropreties, fvDataNS.currentForm.editRecordData, control); } rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } _.each(propertiesHeader, function(property, key) { if(control[key]){ property.value = control[key]; } if(key == 'relevanceconds'){ property.value = {}; } }); _.each(properties, function(property, key) { property.value = control[key]; if(key == 'relevanceconds' && property.value != undefined){ _.each(property.value, function(relevanceCond){ if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == '' || relevanceCond.text[CONST_VALUE_CTRLTYPE] == undefined){ return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_TEXT || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTLOCATION || relevanceCond.text[CONST_VALUE_CTRLTYPE] == mdi_kind_inputImage || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTBARCODE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTNFC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSECUREFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSCOREONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTMANY || relevanceCond.text[CONST_VALUE_CTRLTYPE] == 'inputRIF'){ if(relevanceCond.text[CONST_VAL]){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_EQUAL: case CONST_VALUE_NOT_EQUAL: case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } }else{ relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } } }); } }); var controlInGridHeader = getSelectedQuery4CloneObjectWA('#formview_templates .ctrlGrid_widgetHeader', 'inputLabel').clone(); if(rootInputProperties.isUseVerticalCaption) { // var style = $tableBodyHeaderCell.attr('style'); // $tableBodyHeaderCell.attr('style', style + 'height:' // + (TABLE_HEADER_HEIGHT*rootInputProperties.captionHeight) + 'px!important;'); $(controlInGridHeader).css('-ms-transform', 'rotate(270deg)'); /* IE 9 */ $(controlInGridHeader).css('-webkit-transform','rotate(270deg)'); /* Safari 3-8 */ $(controlInGridHeader).css('transform','rotate(270deg)'); $(controlInGridHeader).css('width', (headerHeight + 10) + 'px');//+10 because of .controlInfo padding $(controlInGridHeader).css('margin', 'auto'); $(controlInGridHeader).css('display', 'inline-block'); $(controlInGridHeader).css('vertical-align', 'middle'); $(controlInGridHeader).css('position', 'relative'); // $(controlInGridHeader).css('position','relative'); var width = 0; var minWidth = 0; if(itemWidth[cellIndex-1]) { width = parseInt(('' + itemWidth[cellIndex-1]).replace('px','')); minWidth = parseInt(('' + itemMinWidth[cellIndex-1]).replace('px','')); } if(width < minWidth) { width = minWidth; } if(isColumnWeightCustom){ // var tableWidth = columnWeightCustomArr.length * 70; // if(!tableWidth || tableWidth < fvDataNS.ctrlWidth) { // tableWidth = fvDataNS.ctrlWidth; // } // width = width * tableWidth / 100; width = width * fvDataNS.ctrlWidth / 100; if(rootInputProperties.adjustWidthNormal) { width = width * parseInt(rootInputProperties.adjustWidthNormal) / 100; } // if(width > headerHeight) { // //incase colum too large (80-90%) // //, => height before translate = max header height (5 lines) // width = headerHeight; // } } width -= 2;//remove 2 borders $(controlInGridHeader).css('overflow', 'hidden'); $(controlInGridHeader).css('word-wrap', 'break-word'); $(controlInGridHeader).css('line-height', '18px'); $(controlInGridHeader).css('vertical-align', 'middle'); var heightBeforeTran = 18*getNumOfLine(control.label.eng, headerHeight/* - 4border*/); if(heightBeforeTran> width) { heightBeforeTran = width; } $(controlInGridHeader).css('height', heightBeforeTran + 'px'); var style = $(controlInGridHeader).find('.controlLabel').attr('style'); style += 'padding-top:0px!important;'; $(controlInGridHeader).find('.controlLabel').attr('style', style); $(controlInGridHeader).find('.controlLabel').css('word-break', 'normal'); $(controlInGridHeader).find('.controlLabel').css('word-break', 'normal'); applyJustification($tableBodyHeaderCell, properties); var cal = ((heightBeforeTran - headerHeight) / 2) - TABLE_GRID_VERRTICAL_HEADER_PADDING; var fixAbsoluteCenter = false; if(cal > 0) { //$(controlInGridHeader).css('left', 'auto'); $(controlInGridHeader).css('position', 'absolute'); $(controlInGridHeader).css('top', '-' + cal + 'px'); fixAbsoluteCenter = true; } else if(width < headerHeight) { //$(controlInGridHeader).css('left', ((width - headerHeight) / 2) + 'px'); } applyJustificationVertical($(controlInGridHeader), properties, heightBeforeTran , headerHeight + 10, itemWidth[index], itemMinWidth[index], headerHeight , 1/*rootInputProperties.adjustWidthNormal / 100*/, false, fixAbsoluteCenter); } var $controlHeader = controlInGridHeader .clone() .attr('id', 'fvCtrlID_Header_' + control.id) .appendTo($tableBodyHeaderCell); // Get selected control for cloning object, using in WebApps // Apply task : https://doforms.atlassian.net/browse/PCA-145 (Implement Shading for webapp) var controlInGrid = getSelectedQuery4CloneObjectWA('#formview_templates .ctrlGrid_' + control.type, control.type, control); //var $control = $('#formview_templates .ctrlGrid_' + control.type) var $control = controlInGrid .clone() .attr('id', 'fvCtrlID_' + control.id) .addClass(control.type) .addClass('fvControl') .addClass('fvCtrlID_' + control.id) .addClass('fvCtrlName_' + control.name) //.odkControlFV(control.type, null, properties, ctrlPropreties) .appendTo($tableBodyCell) .on("fvCtrlShowHideChange", function(event, addToChangeList){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } var isHideCtrl = $(this).hasClass(CONST_CLASS_HIDE_CONTROL); var isStateChage = false; var isSetDefaultValueIfEmpty = false; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; } }else{ if(ctrlPropreties.isCtrlHidden){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; //CO-6062: Select Multiple changes value on edit //if(fvDataNS.isLoading == true && fvDataNS.isdispatch == true){ if(fvDataNS.isLoading == true){ isSetDefaultValueIfEmpty = true; } } }else{ if(isHideCtrl){ $(this).removeClass(CONST_CLASS_HIDE_CONTROL); resizeTextareaWhenUnhide($(this)); //reArrangeLayoutOfChooseOneWithShadingWALastAction($(this)); isStateChage = true; //isSetDefaultValueIfEmpty = true; } } } if(isStateChage){ if(isSetDefaultValueIfEmpty){ if((control.defaultValue != undefined && control.defaultValue != '') && (ctrlPropreties.val == undefined || ctrlPropreties.val == '')){ //ctrlPropreties.val = control.defaultValue; $(this).trigger('clearData', true); } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } } if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger("Control_Update"); } } if(isStateChage && $(this).find('img').length > 0){ $(this).find('img').trigger('onload'); } event.stopPropagation(); }) .on("fvParentCtrlShowHideChange", function(event, ctrlHidden, addToChangeList, triggerCtrlID){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } if(triggerCtrlID && this.id !== triggerCtrlID){ event.stopPropagation(); return; } ctrlPropreties.isParentCtrlHidden = ctrlHidden; if(addToChangeList){ if(ctrlHidden == false){ ctrlPropreties.isValueChange = true; } if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } //CO-6062: Select Multiple changes value on edit if(fvDataNS.isLoading){ $(this).trigger('clearData', true); //CO-6655: Records where one Employees EarnCode did not populate if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ ctrlPropreties.destinationNotFound = true; } } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger('Control_Update'); } event.stopPropagation(); }) // CO-4022 .on("fvContainerShowHideChange", function(event){ event.stopPropagation(); // Grid column base with caption processHideIf($(this), ctrlPropreties); }); fvDataNS.ctrlIndex++; //$control.find('.controlData').attr('id', 'ctrlDataId_' + fvDataNS.ctrlIndex); ctrlPropreties.ctrlDataId = fvDataNS.ctrlIndex; ctrlPropreties.row = rowIndex; ctrlPropreties.col = cellIndex; // PCA-265: Web AppPreview support for color option in Grids, questionnaires and Tables // Add specified property into ctrlPropretiesHeader propertiesHeader.isLabel4RowColBase = true; propertiesHeader.isShowingBorder = true; // Copy shade headings information of main item into dummy Label if (properties.shadedHeadings !== undefined) { propertiesHeader.shadedHeadings = properties.shadedHeadings; } fillDataControlGridFV($controlHeader, 'inputLabel', propertiesHeader, ctrlPropretiesHeader); fillDataControlGridFV($control, control.type, properties, ctrlPropreties); if(control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(isVersion(VERSION_CHOOSE_ONE_SLIDER)) { if(properties.optionKind != undefined && properties.optionKind.value == CONST_CHOOSE_ONE_SWITCH){ $tableBodyCell.addClass(CONST_VALIGN_MIDDLE); } } } if($control.hasClass('hideOnMobileApp')){ /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? $tableBodyCell.find('.fvControl').addClass('hideOnMobileApp'); */ $controlHeader.addClass('hideOnMobileApp'); isCellIndexChange = false; } else if(isWebAppDispatch() && $control.hasClass(CONST_CLASS_HIDE_CONTROL)){ /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? $tableBodyCell.find('.fvControl').addClass(CONST_CLASS_HIDE_CONTROL); */ $controlHeader.addClass(CONST_CLASS_HIDE_CONTROL); isCellIndexChange = false; } else{ cellIndex++; isCellIndexChange = true; } }); /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? */ if(!isCellIndexChange){ if(cellIndex == 1){ if($tableBodyCell.find('.fvControl:visible').length == 0){ $tableBodyOddRow.addClass(CONST_CLASS_HIDE_CONTROL); $tableBodyEvenRow.addClass(CONST_CLASS_HIDE_CONTROL); } } cellIndex++; } if(controls.length > 0 && cellIndex <= colCount){ for(var i=cellIndex; i<=colCount; i++){ // Draw border for last cells (fix layout) //var $tableBodyCell = $(''); //var $tableBodyHeaderCell = $(''); var $tableBodyCell = $(''); var $tableBodyHeaderCell = $(''); /*if(!isColumnWeightCustom){ if (rootInputProperties.equallySpaceColumns !== undefined && rootInputProperties.equallySpaceColumns === true){ $tableBodyCell.attr('style', 'width:' + colPercen + '%;'); $tableBodyHeaderCell.attr('style', 'width:' + colPercen + '%;'); } }else{ if(columnWeightCustomArr.length >= i){ $tableBodyHeaderCell.attr('style', 'width:' + columnWeightCustomArr[i-1] + '%;'); $tableBodyCell.attr('style', 'width:' + columnWeightCustomArr[i-1] + '%;'); } }*/ if(itemWidth[i - 1]){ var maxWidth = itemMinWidth[cellIndex-1]; if(maxWidth == '0px'){ if(itemWidth[i-1] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[i-1]; } } $tableBodyHeaderCell.css('width', itemWidth[i-1]).css('min-width', itemMinWidth[cellIndex-1]).css('max-width', maxWidth); $tableBodyCell.css('width', itemWidth[i-1]).css('min-width', itemMinWidth[cellIndex-1]).css('max-width', maxWidth); if(itemWidth[i-1] == '0%'){ $tableBodyHeaderCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $tableBodyCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } $tableBodyOddRow.append($tableBodyHeaderCell); $tableBodyEvenRow.append($tableBodyCell); } } appendEmptyCell($tableBodyOddRow); appendEmptyCell($tableBodyEvenRow); if(colPadding){ $tableBodyOddRow.append($tableBodyRightPaddingCell.clone()); $tableBodyEvenRow.append($tableBodyRightPaddingCell.clone()); } } var loadRecurseGridFV_ColBase = function($control, controls, parentPath, rootInputProperties){ var $tableHeader = $control.find('.tblHeader'); var $tableBody = $control.find('.tblBody'); $tableHeader.empty(); $tableBody.find('.tblBody').empty(); var cellIndex = 1; var rowIndex = 1; var colCount = rootInputProperties.colCount; var colPercen = eval(100/colCount); var itemWidth = {}; var itemMinWidth = {}; var equallySpaceMinWidth = undefined; /*var isFixToScreen = $control.find('.controlData').hasClass('fitToWidth');*/ /* hqkhanh in col base isFixToScreen = true*/ var isFixToScreen = true; var captionColPercen = undefined; var isEquallySpaceColumns = $control.find('.controlData').hasClass('equallySpaceColumns'); var isColumnWeightCustom = false; var columnWeightCustomArr; if(isVersion(VERSION_GRID_TYPE_FUNCTION_WEBAPP)){ if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ isColumnWeightCustom = rootInputProperties.isColumnWeightCustom; }else{ if(rootInputProperties.columnsSpaceType == '2'){ isColumnWeightCustom = true; } } if(isColumnWeightCustom){ columnWeightCustomArr = rootInputProperties.withFormat4ColumnWeight.split('|'); } } var colCount = rootInputProperties.colCount; if(isFixToScreen){ if(isEquallySpaceColumns){ /*var per = 100 / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + '%'; }*/ var per = fvDataNS.ctrlWidth / colCount; for(var i = 0; i < colCount; i++){ itemWidth[i] = per + 'px'; } equallySpaceMinWidth = 0; for(var i = 0; i < controls.length; i++){ var control = controls[i]; var minCtrlWidth = getMinGridCtrlWidth(control); if(equallySpaceMinWidth < minCtrlWidth){ equallySpaceMinWidth = minCtrlWidth; } } for(var i = 0; i < colCount; i++){ itemMinWidth[i] = equallySpaceMinWidth + 'px'; } }else if(isColumnWeightCustom){ for(var i = 0; i < colCount; i++){ if(columnWeightCustomArr.length > i){ itemWidth[i] = jQuery.trim(columnWeightCustomArr[i]) + '%'; }else{ itemWidth[i] = CTRL_MIN_WIDTH + 'px'; } itemMinWidth[i] = CTRL_MIN_WIDTH + 'px'; } }else{ var colIndex = 0; var ctrlDetailWidth = CTRL_MIN_WIDTH; for(var i = 0; i < controls.length; i++){ if(colIndex*2 >= colCount){ colIndex = 0; } var control = controls[i]; if(isSpecialControl(control.type) && control.type != CONST_CTRL_TYPE_INPUTACTION){ ctrlDetailWidth = SPECIAL_CTRL_MIN_WIDTH; } var minCtrlWidth = getWidthOfText(control.label.eng, 'Arial, Helvetica, sans-serif', '14', 'bold') + 20; if(minCtrlWidth < CTRL_MIN_WIDTH){ minCtrlWidth = CTRL_MIN_WIDTH; } if(!itemWidth[colIndex*2] || (itemWidth[colIndex*2] < minCtrlWidth)){ itemWidth[colIndex*2] = minCtrlWidth; } if(!itemWidth[colIndex*2 + 1] || (itemWidth[colIndex*2 + 1] < minCtrlWidth)){ itemWidth[colIndex*2 + 1] = minCtrlWidth; } colIndex += 1; } var i=0; while(i'); if(controls.length > 0){ $control.find('.tblBody').append($tableBodyRow); } var $tableBodyCell; var $tableBodyHeaderCell; var isCellIndexChange = true; _.each(controls, function(control){ if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP && control.isRetrieve){ control.type = CONST_CTRL_TYPE_INPUTACTION; control.imgAction = CONST_ACTION_RETRIEVE; control.kind = control.btnKind; if( control.btnKind == CONST_TYPE_IMAGE ){ control.useImage = true; }else{ control.useImage = false; } /*if((control.isRetrieveDS == undefined && control.isModifyOnly == true) || control.isRetrieveDS == false || (control.retrieveKind == CONST_TYPE_AUTO_RUN && control.hideRetrieveButtonAuto == true)){ control.hideViewEdit = true; control.hideDispatchNew = true; control.hideDispatchEdit = true; control.hideFillAndSend = true; control.hideInMobile = true; control.hideWebAppGrp = true; control.hideViewNew = true; control.hideDispatchToEmail = true; control.hideFillAndSendEdit = true; control.hideWebApp = true; control.hideEmbeddedForm = true; control.hideFormLinks = true; control.hideInPDF = true; control.hidePdfWeb = true; control.hideInWeb = true; }*/ }else if(control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT && control.paymentType && (control.paymentType == CONST_PAYMENT_TYPE_AUTOMATED || control.paymentType == CONST_PAYMENT_TYPE_SQUARE || control.paymentType == CONST_PAYMENT_MIPOS)){ control.type = CONST_CTRL_TYPE_INPUTACTION; if(control.paymentType == CONST_PAYMENT_TYPE_SQUARE){ control.imgAction = CONST_ACTION_SQUARE; }else if(control.paymentType == CONST_PAYMENT_MIPOS){ control.imgAction = CONST_ACTION_MIPOD; }else{ control.imgAction = CONST_ACTION_PROPAY; } if(!isVersion(VERSION_PAYMENT_TYPE)){ control.actionBtnText = control.label.eng; control.hintLink = ''; control.useImage = false; control.imgJustify = 'Center'; }else{ if(control.kind == 'Button'){ control.useImage = false; control.hintLink = ''; } } }else if(control.type == CONST_CTRL_TYPE_INPUT_SHIPPING){ control.type = CONST_CTRL_TYPE_INPUTACTION; var defaultLabel = ''; if(control.transaction == CONST_CREATE_LABEL){ control.imgAction = CONST_ACTION_SHIPPING_CREATE_LABEL; defaultLabel = lbl_create_label; }else{ control.imgAction = CONST_ACTION_SHIPPING_GET_RATE; defaultLabel = lbl_get_rate; } if(control.kind == CONST_TYPE_IMAGE){ control.actionBtnText = control.imageText; }else{ control.actionBtnText = control.actionBtnText; } if(control.actionBtnText == undefined || control.actionBtnText == ''){ control.actionBtnText = defaultLabel; } }else{ // convert nfc, barcode to input action preview mode only /* CO-2067 Action button images in web forms not appearing if(isTabletPreview){*/ switch(control.type){ case CONST_CTRL_TYPE_INPUTNFC: case CONST_CTRL_TYPE_INPUTBARCODE: if(control.parse && control.isUseActionButton){ control.imgAction = control.type; control.type = CONST_CTRL_TYPE_INPUTACTION; control.kind = control.btnKind; } break; } /*}*/ } if(fvDataNS && fvDataNS.currentForm && fvDataNS.currentForm.formVersion && (parseFloat(fvDataNS.currentForm.formVersion) < parseFloat(FORM_VERSION))){ if(control.autoStamp){ if(control.isAllowEdit == undefined){ control.isAllowEdit = false; } }else{ control.isAllowEdit = true; } }else{ if(control.isAllowEdit == undefined){ control.isAllowEdit = true; } } if(cellIndex > colCount){ appendEmptyCell($tableBodyRow); $tableBodyRow = $(''); $tableBody.append($tableBodyRow); cellIndex = 1; rowIndex += 1; } if(isCellIndexChange){ $tableBodyCell = $(''); $tableBodyHeaderCell = $(''); if(itemWidth[cellIndex - 1]){ if(equallySpaceMinWidth){ $tableBodyHeaderCell.css('width', itemWidth[cellIndex-1]).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ var maxWidth = itemMinWidth[cellIndex-1]; if(maxWidth == '0px'){ if(itemWidth[cellIndex-1] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[cellIndex-1]; } } $tableBodyHeaderCell.css('width', itemWidth[cellIndex-1]).css('min-width', itemMinWidth[cellIndex-1]).css('max-width', maxWidth); if(itemWidth[cellIndex-1] == '0%'){ $tableBodyHeaderCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } } if(itemWidth[cellIndex]){ var width; if(captionColPercen){ width = captionColPercen; }else{ width = itemWidth[cellIndex]; } if(equallySpaceMinWidth){ $tableBodyCell.css('width', width).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ var maxWidth = itemMinWidth[cellIndex]; if(maxWidth == '0px'){ if(width == '0px'){ maxWidth = '70px'; }else{ maxWidth = width; } } $tableBodyCell.css('width', width).css('min-width', itemMinWidth[cellIndex]).css('max-width', maxWidth); if(width == '0%'){ $tableBodyCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } } $tableBodyHeaderCell.css('word-wrap', 'break-word'); $tableBodyHeaderCell.css('word-break', CONST_DEF_WORD_BREAK); $tableBodyHeaderCell.css('white-space', 'normal'); $tableBodyRow.append($tableBodyHeaderCell); $tableBodyRow.append($tableBodyCell); } var properties = null; if ((control.type == CONST_CTRL_TYPE_GROUP) || (control.type == CONST_CTRL_TYPE_CTRLTABLE) || (control.type == CONST_CTRL_TYPE_CTRLSCHEDULE) || (control.type == CONST_CTRL_TYPE_CTRLPOD) || (control.type == CONST_CTRL_TYPE_CTRLINV) || (control.type == CONST_CTRL_TYPE_CTRLSCORETABLE) || (control.type == CONST_CTRL_TYPE_CTRLGRID) || (control.type == 'branch') || (control.type == 'inputPageBreak') || (control.type == 'inputLabel') || (control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY) || (control.type == CONST_CTRL_TYPE_INPUTNUMBERING) || (control.type == CONST_CTRL_TYPE_INPUTACTION) || (control.type == CONST_CTRL_TYPE_INPUTPAYMENT) || (control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT) || (control.type == 'inputInstruction') || //(control.type == CONST_CTRL_TYPE_INPUTCALCULATE) || (control.type == CONST_CTRL_TYPE_INPUTLOOKUP) || (control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) || (control.type == 'inputFacingTable') || (control.type == 'inputLookupMulti') || (control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTFAX) || (control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT) || (control.type == CONST_CTRL_TYPE_INPUTAPPROVAL) || (control.type == 'inputSaveAndSend') || (control.type == 'ctrlDataSource') || (control.type == 'ctrlHeaderGrid') || (control.type == 'ctrlDataFilter') || (control.type == 'ctrlReportBreakPoint') || (control.type == 'ctrlBreakPointData') || (control.type == 'ctrlBreakPointDataElement') || (control.type == 'ctrlFooterGrid') || (control.type == 'ctrlEmailSchedule')){ if(control.relevanceconds == undefined){ control.relevanceconds = []; } propertiesHeader = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties['inputLabel']); properties = $.extend(true, {}, $.fn.odkControl.controlProperties[control.type]); }else{ propertiesHeader = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties['inputLabel']); properties = $.extend(true, $.extend(true, {}, $.fn.odkControl.defaultProperties), $.fn.odkControl.controlProperties[control.type]); removeUnsupportProperty(properties, control.type); } removeUnuseVersion(properties); if(control.isAttachFormWidget === true){ appendProperties4AttachFormWidget(properties); } propertiesHeader.id.ctrlType = 'inputLabel'; properties.id.ctrlType = control.type; var ctrlPropretiesHeader = { name: control.name, parentName: rootInputProperties.name, classPath: 'data Header_' + control.name, id: 'Header_' + control.id, label: control.label, ctrlType: 'inputLabel', required: control.required || false, children: [] }; var ctrlPropreties = { name: control.name, parentName: rootInputProperties.name, //classPath: 'data ' + control.name, classPath: rootInputProperties.classPath + ' ' + control.name, id: control.id, label: control.label, ctrlType: control.type, required: control.required || false, children: [], parentKind: 'grid' }; if(fvDataNS.isRetrieve){ if(isVersion(VERSION_TABLE_CLEAR_ON_RETRIEVE) && control.clearOnRetrieve === true){ ctrlPropreties.clearOnRetrieve = true; } if(isVersion(VERSION_READ_ONLY_REQUIRED_HIDE_OPTION_RETRIEVE)){ if(control.hideOnRetrieve === true){ ctrlPropreties.hideWebApp = true; control.hideWebApp = true; }else{ ctrlPropreties.hideWebApp = false; control.hideWebApp = false; } } } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.isRetrieve){ ctrlPropreties.datasource = control.datasource; ctrlPropreties.destinationdataconds = control.destinationdataconds ctrlPropreties.modifyFields = control.modifyFields; ctrlPropreties.lookupValue = control.lookupValue; ctrlPropreties.lookupfield = control.lookupfield; ctrlPropreties.lookupConditionFields = control.lookupConditionFields; ctrlPropreties.notDisplayRecNotFound = control.notDisplayRecNotFound; ctrlPropreties.isModifyAllMatches = control.isModifyAllMatches; ctrlPropreties.isCaseSensitiveCmp = control.isCaseSensitiveCmp; ctrlPropreties.isRetrieveOldestRecord = control.isRetrieveOldestRecord; ctrlPropreties.retrieveRecordKind = control.retrieveRecordKind; ctrlPropreties.isModifyAdd = control.isModifyAdd; ctrlPropreties.modifyAddFields = control.modifyAddFields; } appendControlProperties4Widget(ctrlPropreties, control); //appendControlProperties4ShippingWidget(ctrlPropreties, control); if(control.displayCCIcon){ ctrlPropreties.displayCCIcon = control.displayCCIcon; } if(control.isDisplayAmountCharged != false){ ctrlPropreties.isDisplayAmountCharged = control.isDisplayAmountCharged; } if(control.addMessage){ ctrlPropreties.addMessage = control.addMessage; }else{ ctrlPropreties.addMessage = { check: true, text: lbl_default_add_msg }; } if(control.amountCharged){ ctrlPropreties.amountCharged = control.amountCharged; } if(control.totalAmountPaid){ ctrlPropreties.totalAmountPaid = control.totalAmountPaid; } if(control.transactionClientId){ ctrlPropreties.transactionClientId = control.transactionClientId; } if(control.requiredViewEdit != undefined){ // new enchance ctrlPropreties.requiredDispatchEdit = { value: control.requiredDispatchEdit}; ctrlPropreties.requiredDispatchNew = { value: control.requiredDispatchNew}; ctrlPropreties.requiredFillAndSend = { value: control.requiredFillAndSend}; if(isVersion(VERSION_FNS_EDIT)){ ctrlPropreties.requiredFillAndSendEdit = { value: control.requiredFillAndSendEdit}; } ctrlPropreties.requiredDispatchToEmail = { value: control.requiredDispatchToEmail}; ctrlPropreties.requiredViewNew = { value: control.requiredViewNew}; ctrlPropreties.requiredViewEdit = { value: control.requiredViewEdit}; ctrlPropreties.requiredWebApp = { value: control.requiredWebApp}; ctrlPropreties.requiredFormLinks = { value: control.requiredFormLinks}; ctrlPropreties.required = { value: control.required}; } if(control.kind != undefined){ ctrlPropreties.kind = control.kind; } if(control.length != undefined && control.length != false){ ctrlPropreties.length = { min: control.length.min || '', max: control.length.max || '', cannotExceedMaximum : control.length.cannotExceedMaximum || false } }else if(control.range != undefined && control.range != false){ ctrlPropreties.range = { min: control.range.min || '', max: control.range.max || '' } } if(control.validateValue != undefined && control.validateValue != false){ ctrlPropreties.validateValue = {}; ctrlPropreties.validateValue.value = control.validateValue; } if(control.dispatchRequired != undefined && control.dispatchRequired == true){ ctrlPropreties.dispatchRequired = true; if(isWebAppDispatch()){ control.required = true; ctrlPropreties.required = true; } } if(control.requiredForwarded != undefined){ ctrlPropreties.requiredForwarded = {value: control.requiredForwarded}; // CO-941 } if(control.requiredOnRetrieve != undefined){ // CO-4940: Required setting - Turned off for retrieve not working ctrlPropreties.requiredOnRetrieve = {value: control.requiredOnRetrieve}; } if(control.readOnlyDsp != undefined){ ctrlPropreties.readOnlyDsp = control.readOnlyDsp; } // CO-3852: New Retrieve Setting - Auto Run if(control.isRetrieveDS == true && control.autoActionStampTriggerRetrieve != undefined && (control.autoActionStampTriggerRetrieve == '2' // specific question || control.autoActionStampTriggerRetrieve == '8') // open form ){ ctrlPropreties.retrieveKind = control.retrieveKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerRetrieve = control.autoActionStampTriggerRetrieve; ctrlPropreties.autoActionStampQuestionTriggerRetrieve = control.autoActionStampQuestionTriggerRetrieve; ctrlPropreties.hideRetrieveButtonAuto = control.hideRetrieveButtonAuto; } // CO-3853 if(control.autoActionStampTriggerModify != undefined && (control.autoActionStampTriggerModify == '2' // specific question || control.autoActionStampTriggerModify == '8' || control.autoActionStampTriggerModify == '32') // on retrieve ){ ctrlPropreties.modifyKind = control.modifyKind; ctrlPropreties.isModifyOnly = control.isModifyOnly; ctrlPropreties.autoActionStampTriggerModify = control.autoActionStampTriggerModify; ctrlPropreties.autoActionStampQuestionTriggerModify = control.autoActionStampQuestionTriggerModify; ctrlPropreties.hideModifyButtonAuto = control.hideModifyButtonAuto; } // CO-3853 if(control.hideRetrieveButton){ ctrlPropreties.hideRetrieveButton = control.hideRetrieveButton; } if((control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTLOCATION) && control.iconColor){ // CO-4050 ctrlPropreties.iconColor = control.iconColor; } if(control.type == CONST_CTRL_TYPE_INPUTACTION && control.iconColor){ ctrlPropreties.applyScreenSize = control.applyScreenSize; ctrlPropreties.buttonSize = control.buttonSize; ctrlPropreties.ifScreenSmallerThan = control.ifScreenSmallerThan; ctrlPropreties.ifScreenSmallerSize = control.ifScreenSmallerSize; } if(fvDataNS.incomplete){ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : //case CONST_CTRL_TYPE_INPUTACTION : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: var tmp = ctrlPropreties; ctrlPropreties = getCtrlIncompleteProperties(rootInputProperties, ctrlPropreties); if(ctrlPropreties == undefined){ ctrlPropreties = tmp; rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } }else{ switch (control.type) { //case 'inputLabel' : //case CONST_CTRL_TYPE_INPUTSCORESUMMARY : //case CONST_CTRL_TYPE_INPUTNUMBERING : case 'inputPageBreak' : case CONST_CTRL_TYPE_INPUTAPPROVAL : //case 'inputSaveAndSend' : case 'inputInstruction' : break; default: if(fvDataNS.currentForm.editRecordData){ getEditRecordData(ctrlPropreties, fvDataNS.currentForm.editRecordData, control); } rootInputProperties.children.push(ctrlPropreties); ctrlPropreties.parrentProperties = rootInputProperties.classPath; } } _.each(propertiesHeader, function(property, key) { if(control[key]){ property.value = control[key]; } if(key == 'relevanceconds'){ property.value = {}; } }); _.each(properties, function(property, key) { property.value = control[key]; if(key == 'relevanceconds' && property.value != undefined){ _.each(property.value, function(relevanceCond){ if(relevanceCond.text['eng'] == undefined || jQuery.trim(relevanceCond.text['eng']) == '' || relevanceCond.text[CONST_VALUE_CTRLTYPE] == undefined){ return false; } if(relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUT_TEXT || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTLOCATION || relevanceCond.text[CONST_VALUE_CTRLTYPE] == mdi_kind_inputImage || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTBARCODE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTNFC || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSECUREFORWARD || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSCOREONE || relevanceCond.text[CONST_VALUE_CTRLTYPE] == CONST_CTRL_TYPE_INPUTSELECTMANY || relevanceCond.text[CONST_VALUE_CTRLTYPE] == 'inputRIF'){ if(relevanceCond.text[CONST_VAL]){ switch(relevanceCond.text[CONST_VAL]){ case CONST_VALUE_EQUAL: case CONST_VALUE_NOT_EQUAL: case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } }else{ relevanceCond.text[CONST_VAL] = CONST_VALUE_EQUAL; } } }); } }); var controlInGridHeader = getSelectedQuery4CloneObjectWA('#formview_templates .ctrlGrid_widgetHeader', 'inputLabel'); var $controlHeader = controlInGridHeader .clone() .attr('id', 'fvCtrlID_Header_' + control.id) .appendTo($tableBodyHeaderCell); // Get selected control for cloning object, using in WebApps // Apply task : https://doforms.atlassian.net/browse/PCA-145 (Implement Shading for webapp) var controlInGrid = getSelectedQuery4CloneObjectWA('#formview_templates .ctrlGrid_' + control.type, control.type, control); //var $control = $('#formview_templates .ctrlGrid_' + control.type) var $control = controlInGrid .clone() .attr('id', 'fvCtrlID_' + control.id) .addClass(control.type) .addClass('fvControl') .addClass('fvCtrlID_' + control.id) .addClass('fvCtrlName_' + control.name) //.odkControlFV(control.type, null, properties, ctrlPropreties) .appendTo($tableBodyCell) .on("fvCtrlShowHideChange", function(event, addToChangeList){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } var isHideCtrl = $(this).hasClass(CONST_CLASS_HIDE_CONTROL); var isStateChage = false; var isSetDefaultValueIfEmpty = false; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; } }else{ if(ctrlPropreties.isCtrlHidden){ if(!isHideCtrl){ $(this).addClass(CONST_CLASS_HIDE_CONTROL); isStateChage = true; //CO-6062: Select Multiple changes value on edit //if(fvDataNS.isLoading == true && fvDataNS.isdispatch == true){ if(fvDataNS.isLoading == true){ isSetDefaultValueIfEmpty = true; } } }else{ if(isHideCtrl){ $(this).removeClass(CONST_CLASS_HIDE_CONTROL); resizeTextareaWhenUnhide($(this)); //reArrangeLayoutOfChooseOneWithShadingWALastAction($(this)); //isSetDefaultValueIfEmpty = true; isStateChage = true; } } } if(isStateChage){ if(isSetDefaultValueIfEmpty){ if((control.defaultValue != undefined && control.defaultValue != '') && (ctrlPropreties.val == undefined || ctrlPropreties.val == '')){ //ctrlPropreties.val = control.defaultValue; $(this).trigger('clearData', true); } } if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ if(!$(this).hasClass(CONST_CLASS_HIDE_CONTROL)){ $(this).trigger('Calculate_Data_Change_New', true); } } if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger("Control_Update"); } } if(isStateChage && $(this).find('img').length > 0){ $(this).find('img').trigger('onload'); } event.stopPropagation(); }) .on("fvParentCtrlShowHideChange", function(event, ctrlHidden, addToChangeList, triggerCtrlID){ if(ctrlPropreties == undefined){ event.stopPropagation(); return; } if(triggerCtrlID && this.id !== triggerCtrlID){ event.stopPropagation(); return; } ctrlPropreties.isParentCtrlHidden = ctrlHidden; if(addToChangeList){ if(ctrlHidden == false){ ctrlPropreties.isValueChange = true; } if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } //CO-6062: Select Multiple changes value on edit if(fvDataNS.isLoading){ $(this).trigger('clearData', true); //CO-6655: Records where one Employees EarnCode did not populate if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ ctrlPropreties.destinationNotFound = true; } } var ctrlChangeIndex = fvDataNS.inputCtrlsSrt.indexOf(ctrlPropreties.classPath); setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); }else{ $(this).trigger('Control_Update'); } event.stopPropagation(); }) // CO-4022 .on("fvContainerShowHideChange", function(event){ event.stopPropagation(); // Grid row base processHideIf($(this), ctrlPropreties); }); ; fvDataNS.ctrlIndex++; //$control.find('.controlData').attr('id', 'ctrlDataId_' + fvDataNS.ctrlIndex); ctrlPropreties.ctrlDataId = fvDataNS.ctrlIndex; ctrlPropreties.row = rowIndex; ctrlPropreties.col = cellIndex; // PCA-265: Web AppPreview support for color option in Grids, questionnaires and Tables // Add specified property into ctrlPropretiesHeader propertiesHeader.isLabel4RowColBase = true; // Copy shade headings information of main item into dummy Label if (properties.shadedHeadings !== undefined) { propertiesHeader.shadedHeadings = properties.shadedHeadings; } fillDataControlGridFV($controlHeader, 'inputLabel', propertiesHeader, ctrlPropretiesHeader); fillDataControlGridFV($control, control.type, properties, ctrlPropreties); if(control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(isVersion(VERSION_CHOOSE_ONE_SLIDER)) { if(properties.optionKind != undefined && properties.optionKind.value == CONST_CHOOSE_ONE_SWITCH){ $tableBodyCell.addClass(CONST_VALIGN_MIDDLE); $tableBodyHeaderCell.addClass(CONST_VALIGN_MIDDLE); } } } if($control.hasClass('hideOnMobileApp')){ /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? $tableBodyCell.find('.fvControl').addClass('hideOnMobileApp'); */ $controlHeader.addClass('hideOnMobileApp'); isCellIndexChange = false; } else if(isWebAppDispatch() && $control.hasClass(CONST_CLASS_HIDE_CONTROL)){ /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? $tableBodyCell.find('.fvControl').addClass(CONST_CLASS_HIDE_CONTROL); */ $controlHeader.addClass(CONST_CLASS_HIDE_CONTROL); isCellIndexChange = false; } else{ cellIndex+=2; isCellIndexChange = true; } }); /* hqkhanh fix bug There’s a bug in preview that’s showing blank fields in a grid. In the account “partnerapp” form “5 ROI 0.2” you’ll notice in the last grid on the first page in preview it shows blank boxes when it shouldn’t be. See my screenshot below. The numeric with “40” in is the last field in that grid besides a hidden calculation. So I don’t know why this would put 3 blank spaces? */ if(!isCellIndexChange){ if(cellIndex == 1){ if($tableBodyCell.find('.fvControl:visible').length == 0){ $tableBodyRow.addClass(CONST_CLASS_HIDE_CONTROL); } } cellIndex+=2; } if(controls.length > 0 && cellIndex <= colCount){ for(var i=cellIndex; i<=colCount; i+=2){ // Draw border for last cells (fix layout) //var $tableBodyCell = $(''); //var $tableBodyHeaderCell = $(''); var $tableBodyCell = $(''); var $tableBodyHeaderCell = $(''); /*if(!isColumnWeightCustom){ if (rootInputProperties.equallySpaceColumns !== undefined && rootInputProperties.equallySpaceColumns === true){ $tableBodyCell.attr('style', 'width:' + colPercen + '%;'); $tableBodyHeaderCell.attr('style', 'width:' + colPercen + '%;'); } }else{ if(columnWeightCustomArr.length >= i){ $tableBodyHeaderCell.attr('style', 'width:' + columnWeightCustomArr[i-1] + '%;'); $tableBodyCell.attr('style', 'width:' + jQuery.trim(columnWeightCustomArr[i]) + '%;'); } }*/ if(equallySpaceMinWidth){ $tableBodyHeaderCell.css('width', equallySpaceMinWidth).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); $tableBodyCell.css('width', equallySpaceMinWidth).css('min-width', equallySpaceMinWidth).css('max-width', equallySpaceMinWidth); }else{ if(itemWidth[i - 1]){ var maxWidth = itemMinWidth[i-1]; if(maxWidth == '0px'){ if(itemWidth[i-1] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[i-1]; } } $tableBodyHeaderCell.css('width', itemWidth[i-1]).css('min-width', itemMinWidth[i-1]).css('max-width', maxWidth); if(itemWidth[i-1] == '0%'){ $tableBodyHeaderCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } if(itemWidth[i]){ var maxWidth = itemMinWidth[i]; if(maxWidth == '0px'){ if(itemWidth[i] == '0px'){ maxWidth = '70px'; }else{ maxWidth = itemWidth[i]; } } $tableBodyCell.css('width', itemWidth[i]).css('min-width', itemMinWidth[i]).css('max-width', maxWidth); if(itemWidth[i] == '0%'){ $tableBodyCell.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } } $tableBodyHeaderCell.css('word-wrap', 'break-word'); $tableBodyHeaderCell.css('word-break', CONST_DEF_WORD_BREAK); $tableBodyHeaderCell.css('white-space', 'normal'); $tableBodyRow.append($tableBodyHeaderCell); $tableBodyRow.append($tableBodyCell); } } appendEmptyCell($tableBodyRow); } var loadCtrlMap = function(controls, ctrlMap, saveAndSendCtrlMap) { if(controls == undefined){ return; } _.each(controls, function(control) { ctrlMap[control.id] = control.name; ctrlMap[control.name] = control.id; switch (control.type) { case 'inputSaveAndSend' : saveAndSendCtrlMap.push(control.name); break; case CONST_CTRL_TYPE_INPUTACTION : if(control.imgAction == CONST_ACTION_SAVE_AND_SEND || control.imgAction == CONST_ACTION_SAVE_AS_COMPLETE){ saveAndSendCtrlMap.push(control.name); } break; case CONST_CTRL_TYPE_INPUTSCORESUMMARY : fvDataNS.scoreSum.summary = control; break; } // CO-1305: Add dispatch data source to POD try{ if(control.type == CONST_CTRL_TYPE_CTRLPOD && isWebAppDispatch() && fvDataNS.currentForm.editRecordData == undefined){ // Not edit case if('dispatch' == control.podDataSource){ control.type = CONST_CTRL_TYPE_CTRLTABLE; control.loop = '5'; // set default loop num try{ // hide Deliver button control.children[4].hideDispatchNew = true; control.children[4].hideDispatchEdit = true; } catch(e){} } } } catch(e){} if (control.type == CONST_CTRL_TYPE_GROUP || control.type == CONST_CTRL_TYPE_CTRLTABLE || control.type == CONST_CTRL_TYPE_CTRLSCHEDULE || control.type == CONST_CTRL_TYPE_CTRLPOD || control.type == CONST_CTRL_TYPE_CTRLINV || control.type == CONST_CTRL_TYPE_CTRLSCORETABLE || control.type == CONST_CTRL_TYPE_CTRLGRID || control.type == 'ctrlBreakPointData'){ loadCtrlMap(control.children, ctrlMap, saveAndSendCtrlMap); } }); }; var toLooupCountValue = function(inputValue){ if(isNaN(inputValue)){ inputValue = inputValue.replace('&&&', ''); } var val = Math.abs(inputValue, 10); if(isNaN(val)){ return 10; }else{ return val; } }; var containsString = function(value, cmpStr){ if(value && value.indexOf(cmpStr) >= 0){ return true; } return false; } function generateIfThenElseCondition(control, binding, root){ if(!isVersion(VERSION_IF_THEN_ELSE) || isFreeAccount()){ return binding; } if(!control.isShowITE || !control.iteConditions){ return binding; } if(true){ var iteCondString = ""; var i = 0; var condString = ""; var condValue = ""; var space = " "; var iteCondEndString = ")"; _.each(control.iteConditions.conditions, function(iteCond){ var fieldId = iteCond.text['eng']; if(fieldId == ''){ return true; } var isPreviousField = false; if(fieldId && fieldId.myIncludes(CONST_PREVIOUS)){ isPreviousField = true; fieldId = fieldId.replace(CONST_PREVIOUS + ' ', ''); } var iteControl = getControlById(fieldId, root); if(iteControl == undefined){ return true; } var fieldPath = getControlXPath(root, "/data/", fieldId); if(isPreviousField){ fieldPath = "previous('" + fieldPath + "')"; } condString = iteCond.text[CONST_VAL]; condValue = iteCond.value[CONST_VAL]; if(condValue == undefined){ condValue = ''; } condValue = HtmlEncode(condValue, true); if(i != 0){ var joinString = iteCond.text[CONST_VALUE_JOIN]; if(joinString == undefined){ joinString = CONST_VALUE_AND_LOWERCASE; } switch(joinString){ case CONST_VALUE_OR_LOWERCASE: case CONST_VALUE_AND_LOWERCASE: iteCondString = iteCondString + space + joinString + space; break; case CONST_VALUE_ELSE_LOWERCASE: var thenResult = ''; if(iteCond.text[CONST_VALUE_THENTYPE] == CONST_VALUE_OTHER){ var thenOtherId = iteCond.text[CONST_VALUE_THENOTHERVALUE]; if(thenOtherId && thenOtherId.myIncludes(CONST_PREVIOUS)){ thenOtherId = thenOtherId.replace(CONST_PREVIOUS + ' ', ''); thenResult = getControlXPath(root, "/data/", thenOtherId); thenResult = "previous('" + thenResult + "')"; }else if(thenOtherId.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ thenResult = thenOtherId; }else{ thenResult = getControlXPath(root, "/data/", thenOtherId); } }else{ thenResult = iteFormatResultValue(control, xmlEncode(iteCond.text[CONST_VALUE_THEN])); } joinString = ', '+ thenResult + ', if('; iteCondEndString += ')'; iteCondString = iteCondString + joinString; break; default: joinString = CONST_VALUE_AND_LOWERCASE; iteCondString = iteCondString + space + joinString + space; } } var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else if(condString == CONST_VALUE_CLICK){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } var isNewCompareType = false; if(isVersion(VERSION_REL_TYPE)){ if(iteCond.value != undefined && iteCond.value.cmpType == CONST_VALUE_OTHER){ isNewCompareType = true; var iteCondFiledId = iteCond.value.val; var isPreviousIteCondFiled = false; if(iteCondFiledId && iteCondFiledId.myIncludes(CONST_PREVIOUS)){ isPreviousIteCondFiled = true; iteCondFiledId = iteCondFiledId.replace(CONST_PREVIOUS + ' ', ''); } if(isVersion(VERSION_USE_VARIABLE_BF)){ // CO-560 Use variables by text calcs, numeric calc, relevance, and IF THEN ELSE in Build forms if(iteCond.value.val && iteCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ condValue = iteCondFiledId; }else{ if(isVersion(VERSION_ADD_TRIP_VAIABLES)){ switch(iteCondFiledId){ case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: condValue = iteCondFiledId; break; default: condValue = getControlXPath(root, "/data/", iteCondFiledId); } }else{ condValue = getControlXPath(root, "/data/", iteCondFiledId); } } }else{ condValue = getControlXPath(root, "/data/", iteCondFiledId); } if(isPreviousIteCondFiled){ condValue = "previous('" + condValue + "')"; } } } if(condString == "contains"){ iteCondString = iteCondString + condString + "(" + fieldPath + ", '" + condValue + "')"; }else if(condString == "startsWith"){ iteCondString = iteCondString + condString + "(" + fieldPath + ", '" + condValue + "')"; }else if(condString == "string-length"){ iteCondString = iteCondString + condString + '(' + fieldPath + ') = ' + condValue; }else if(isNewEmptyType){ iteCondString = iteCondString + condString + '(' + fieldPath + ')'; }else if(isNewCompareType){ iteCondString = iteCondString + fieldPath + condString + condValue; }else if(iteControl.type == CONST_CTRL_TYPE_INPUT_TEXT){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUT_NUMERIC || iteControl.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } iteCondString = iteCondString + fieldPath + condString + condValue; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } iteCondString = iteCondString + fieldPath + condString + condValue; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(iteControl.kind == CONST_VALUE_TIME){ iteCondString = iteCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, iteControl.kind) + '\')')); }else if(iteControl.kind == CONST_VALUE_DATE_SPACE_TIME){ iteCondString = iteCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, iteControl.kind) + '\')')); }else{ iteCondString = iteCondString + fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, iteControl.kind) + '\')')); } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(iteControl.isCtrlInScoreTable != undefined && iteControl.isCtrlInScoreTable){ if(condString == ' = '){ iteCondString = iteCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ iteCondString = iteCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(iteControl.isCtrlInScoreTable != undefined && iteControl.isCtrlInScoreTable){ if(condString == ' = '){ iteCondString = iteCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ iteCondString = iteCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(iteControl.isCtrlInScoreTable != undefined && iteControl.isCtrlInScoreTable){ if(condString == ' = '){ iteCondString = iteCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ iteCondString = iteCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ if(condString == ' = '){ iteCondString = iteCondString + 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ iteCondString = iteCondString + 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTLOCATION){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == mdi_kind_inputImage){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == mdi_kind_inputAudio){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == mdi_kind_inputVideo){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTMEDIA){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == mdi_kind_inputSketch){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == mdi_kind_inputSignature){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == 'inputDraw'){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTBARCODE){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTNFC){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTFORWARD || iteControl.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == 'inputPageBreak' || iteControl.type == 'inputLabel' || iteControl.type == CONST_CTRL_TYPE_INPUTACTION || iteControl.type == CONST_CTRL_TYPE_INPUTPAYMENT || iteControl.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || iteControl.type == 'inputInstruction' || iteControl.type == 'inputSaveAndSend'){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ //iteCondString = iteCondString + 'totalScore(' + fieldPath + ')' + condString + "'" + condValue + "'"; //CO-1274: If Then Else Logic Adherence Issue if(!condValue || condValue == ''){ iteCondString = iteCondString + 'totalScore(' + fieldPath + ')' + condString + "''"; }else{ iteCondString = iteCondString + 'totalScore(' + fieldPath + ')' + condString + condValue; } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTNUMBERING){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || iteControl.type == CONST_CTRL_TYPE_INPUTFAX || iteControl.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(iteControl.kind != null && (iteControl.kind == CONST_VALUE_DATE || iteControl.kind == 'String')){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else{ if(condValue == ''){ condValue = '0'; } iteCondString = iteCondString + fieldPath + condString + condValue; } }else if(iteControl.type == CONST_CTRL_TYPE_INPUTLOOKUP){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == 'inputFacingTable'){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == 'inputLookupMulti'){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; }else if(iteControl.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ iteCondString = iteCondString + fieldPath + condString + "'" + condValue + "'"; } i++; }); if(iteCondString != undefined && iteCondString != ''){ var thenResult = ''; if(control.iteConditions.thenType == CONST_VALUE_OTHER){ var isPreviousThenOtherValue = false; var thenOtherValue = control.iteConditions.thenOtherValue; if(thenOtherValue && thenOtherValue.myIncludes(CONST_PREVIOUS)){ isPreviousThenOtherValue = true; thenOtherValue = thenOtherValue.replace(CONST_PREVIOUS + ' ', ''); } if(isVersion(VERSION_USE_VARIABLE_BF)){ // CO-560 Use variables by text calcs, numeric calc, relevance, and IF THEN ELSE in Build forms if(thenOtherValue && thenOtherValue.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ thenResult = thenOtherValue; }else if(thenOtherValue && thenOtherValue.endsWith(CONST_CHOOSE_ONE_CAPTION)){ thenOtherValue = thenOtherValue.replace(CONST_CHOOSE_ONE_CAPTION, ''); thenResult = 'captionValue(' + getControlXPath(root, "/data/", thenOtherValue) + ')'; }else{ if(isVersion(VERSION_ADD_TRIP_VAIABLES)){ switch(thenOtherValue){ case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: thenResult = thenOtherValue; break; default: thenResult = getControlXPath(root, "/data/", thenOtherValue); } }else{ thenResult = getControlXPath(root, "/data/", thenOtherValue); } } }else{ if(thenOtherValue && thenOtherValue.endsWith(CONST_CHOOSE_ONE_CAPTION)){ thenOtherValue = thenOtherValue.replace(CONST_CHOOSE_ONE_CAPTION, ''); thenResult = 'captionValue(' + getControlXPath(root, "/data/", thenOtherValue) + ')'; }else{ thenResult = getControlXPath(root, "/data/", thenOtherValue); } } if(isPreviousThenOtherValue){ thenResult = "previous('" + thenResult + "')"; } }else{ thenResult = iteFormatResultValue(control, xmlEncode(control.iteConditions.resultTrue)); } if(control.iteConditions.hasResultElse){ var elseResult = ''; if(control.iteConditions.elseType == CONST_VALUE_OTHER){ var isPreviousElseOtherValue = false; var elseOtherValue = control.iteConditions.elseOtherValue; if(elseOtherValue && elseOtherValue.myIncludes(CONST_PREVIOUS)){ isPreviousElseOtherValue = true; elseOtherValue = elseOtherValue.replace(CONST_PREVIOUS + ' ', ''); } if(isVersion(VERSION_USE_VARIABLE_BF)){ // CO-560 Use variables by text calcs, numeric calc, relevance, and IF THEN ELSE in Build forms if(elseOtherValue && elseOtherValue.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ elseResult = elseOtherValue; }else if(elseOtherValue && elseOtherValue.endsWith(CONST_CHOOSE_ONE_CAPTION)){ elseOtherValue = elseOtherValue.replace(CONST_CHOOSE_ONE_CAPTION, ''); elseResult = 'captionValue(' + getControlXPath(root, "/data/", elseOtherValue) + ')'; }else{ if(isVersion(VERSION_ADD_TRIP_VAIABLES)){ switch(elseOtherValue){ case CONST_LAST_TRIP_MILES: case CONST_LAST_TRIP_KM: case CONST_LAST_TRIP_START_TIME: case CONST_LAST_TRIP_STOP_TIME: elseResult = elseOtherValue; break; default: elseResult = getControlXPath(root, "/data/", elseOtherValue); } }else{ elseResult = getControlXPath(root, "/data/", elseOtherValue); } } }else{ if(elseOtherValue && elseOtherValue.endsWith(CONST_CHOOSE_ONE_CAPTION)){ elseOtherValue = elseOtherValue.replace(CONST_CHOOSE_ONE_CAPTION, ''); elseResult = 'captionValue(' + getControlXPath(root, "/data/", elseOtherValue) + ')'; }else{ elseResult = getControlXPath(root, "/data/", elseOtherValue); } } if(isPreviousElseOtherValue){ elseResult = "previous('" + elseResult + "')"; } }else{ elseResult = iteFormatResultValue(control, xmlEncode(control.iteConditions.resultFalse)); } iteCondString = "if(" + iteCondString + ", " + thenResult + ", " + elseResult + iteCondEndString; }else{ iteCondString = "if(" + iteCondString + ", " + thenResult + iteCondEndString; } } if(binding != null){ if(binding.attrs.calculate == undefined || binding.attrs.calculate == ''){ binding.attrs.calculate = iteCondString; }else{ if(iteCondString != undefined && iteCondString != ''){ // truong hop da co bieu thuc calculate binding.attrs.calculate = iteCondString; } } } } return binding; } function generateSkipIfCondition(control, binding, root){ if(!isVersion(VERSION_IF_THEN_ELSE) || isFreeAccount()){ return binding; } if(!control.isShowSkipIf || !control.skipIfConditions){ return binding; } if(true){ var skipIfCondString = ""; var i = 0; var condString = ""; var condValue = ""; var space = " "; var skipIfCondEndString = ")"; var fieldPath = getControlXPath(root, "/data/", control.id); var skipIfControl = control; _.each(control.skipIfConditions.conditions, function(skipIfCond){ condString = skipIfCond.text[CONST_VAL]; condValue = skipIfCond.value[CONST_VAL]; if(condValue == undefined){ condValue = ''; } condValue = HtmlEncode(condValue, true); if(i != 0){ var joinString = skipIfCond.text[CONST_VALUE_JOIN]; if(joinString == undefined){ joinString = CONST_VALUE_AND_LOWERCASE; } switch(joinString){ case CONST_VALUE_OR_LOWERCASE: case CONST_VALUE_AND_LOWERCASE: skipIfCondString = skipIfCondString + space + joinString + space; break; case CONST_VALUE_ELSE_LOWERCASE: var thenResult = getControlXPath(root, "/data/", skipIfCond.text[CONST_VALUE_THENOTHERVALUE]); if(thenResult == ''){ thenResult = skipIfCond.text[CONST_VALUE_THENOTHERVALUE]; if(thenResult == CONST_JUMP_EOF_VAL){ if(control.parentCtrlType == CONST_CTRL_TYPE_GROUP){ thenResult = CONST_JUMP_EOG_TEXT; }else{ thenResult = CONST_JUMP_EOF_TEXT; } } } joinString = ', \''+ thenResult + '\', if('; skipIfCondEndString += ')'; skipIfCondString = skipIfCondString + joinString; break; default: joinString = CONST_VALUE_AND_LOWERCASE; skipIfCondString = skipIfCondString + space + joinString + space; } } var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } var isNewCompareType = false; if(isVersion(VERSION_REL_TYPE)){ if(skipIfCond.value != undefined && skipIfCond.value.cmpType == CONST_VALUE_OTHER){ isNewCompareType = true; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(skipIfCond.value.val && skipIfCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ condValue = skipIfCond.value.val; }else{ condValue = getControlXPath(root, "/data/", skipIfCond.value.val); } }else{ condValue = getControlXPath(root, "/data/", skipIfCond.value.val); } } } if(isNewEmptyType){ skipIfCondString = skipIfCondString + condString + '(' + fieldPath + ')'; }else if(isNewCompareType){ skipIfCondString = skipIfCondString + fieldPath + condString + condValue; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUT_TEXT){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUT_NUMERIC || skipIfControl.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } skipIfCondString = skipIfCondString + fieldPath + condString + condValue; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } skipIfCondString = skipIfCondString + fieldPath + condString + condValue; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(skipIfControl.kind == CONST_VALUE_TIME){ skipIfCondString = skipIfCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, skipIfControl.kind) + '\')')); }else if(skipIfControl.kind == CONST_VALUE_DATE_SPACE_TIME){ skipIfCondString = skipIfCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, skipIfControl.kind) + '\')')); }else{ skipIfCondString = skipIfCondString + fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, skipIfControl.kind) + '\')')); } }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(skipIfControl.isCtrlInScoreTable != undefined && skipIfControl.isCtrlInScoreTable){ if(condString == ' = '){ skipIfCondString = skipIfCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ skipIfCondString = skipIfCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(skipIfControl.isCtrlInScoreTable != undefined && skipIfControl.isCtrlInScoreTable){ if(condString == ' = '){ skipIfCondString = skipIfCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ skipIfCondString = skipIfCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(skipIfControl.isCtrlInScoreTable != undefined && skipIfControl.isCtrlInScoreTable){ if(condString == ' = '){ skipIfCondString = skipIfCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ skipIfCondString = skipIfCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ if(condString == ' = '){ skipIfCondString = skipIfCondString + 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ skipIfCondString = skipIfCondString + 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } } }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTLOCATION){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == mdi_kind_inputImage){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == mdi_kind_inputAudio){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == mdi_kind_inputVideo){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTMEDIA){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == mdi_kind_inputSketch){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == mdi_kind_inputSignature){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == 'inputDraw'){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTBARCODE){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTNFC){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTFORWARD || skipIfControl.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == 'inputPageBreak' || skipIfControl.type == 'inputLabel' || skipIfControl.type == CONST_CTRL_TYPE_INPUTACTION || skipIfControl.type == CONST_CTRL_TYPE_INPUTPAYMENT || skipIfControl.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || skipIfControl.type == 'inputInstruction' || skipIfControl.type == 'inputSaveAndSend'){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ //skipIfCondString = skipIfCondString + 'totalScore(' + fieldPath + ')' + condString + "'" + condValue + "'"; //CO-1274: If Then Else Logic Adherence Issue if(!condValue || condValue == ''){ skipIfCondString = skipIfCondString + 'totalScore(' + fieldPath + ')' + condString + "''"; }else{ skipIfCondString = skipIfCondString + 'totalScore(' + fieldPath + ')' + condString + condValue; } }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTNUMBERING){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || skipIfControl.type == CONST_CTRL_TYPE_INPUTFAX || skipIfControl.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(skipIfControl.kind != null && (skipIfControl.kind == CONST_VALUE_DATE || skipIfControl.kind == 'String')){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else{ if(condValue == ''){ condValue = '0'; } skipIfCondString = skipIfCondString + fieldPath + condString + condValue; } }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTLOOKUP){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == 'inputFacingTable'){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == 'inputLookupMulti'){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; }else if(skipIfControl.type == CONST_CTRL_TYPE_INPUTATTACHMENT){ skipIfCondString = skipIfCondString + fieldPath + condString + "'" + condValue + "'"; } i++; }); if(skipIfCondString != undefined && skipIfCondString != ''){ var thenResult = getControlXPath(root, "/data/", control.skipIfConditions.thenOtherValue); if(thenResult == ''){ thenResult = control.skipIfConditions.thenOtherValue; if(thenResult == CONST_JUMP_EOF_VAL){ if(control.parentCtrlType == CONST_CTRL_TYPE_GROUP){ thenResult = CONST_JUMP_EOG_TEXT; }else{ thenResult = CONST_JUMP_EOF_TEXT; } } } if(control.skipIfConditions.hasResultElse){ var elseResult = getControlXPath(root, "/data/", control.skipIfConditions.elseOtherValue); if(elseResult == ''){ elseResult = control.skipIfConditions.elseOtherValue; if(elseResult == CONST_JUMP_EOF_VAL){ if(control.parentCtrlType == CONST_CTRL_TYPE_GROUP){ elseResult = CONST_JUMP_EOG_TEXT; }else{ elseResult = CONST_JUMP_EOF_TEXT; } } } skipIfCondString = "if(" + skipIfCondString + ", '" + thenResult + "', '" + elseResult + "'" + skipIfCondEndString; }else{ skipIfCondString = "if(" + skipIfCondString + ", '" + thenResult + "'" + skipIfCondEndString; } } if(binding != null && skipIfCondString != undefined && skipIfCondString != ''){ binding.attrs.skip = skipIfCondString; if(control.type != CONST_CTRL_TYPE_INPUTACTION){ binding.attrs.action = CONST_ACTION_ID_JUMP; } } } return binding; } function iteFormatResultValue(control, value){ if(!control){ return value; } var ret = ""; switch(control.type){ case CONST_CTRL_TYPE_INPUTDATE: if(value == undefined || value.trim() == ""){ ret = "''"; }else{ if(value==='today'){ ret = 'today()'; }else{ if(control.kind == CONST_VALUE_TIME || control.kind == CONST_VALUE_DATE_SPACE_TIME){ ret = "dateTime('" + toJavaRosaFormat(value, control.kind) + "')"; }else{ ret = "date('" + toJavaRosaFormat(value, control.kind) + "')"; } } } if(value == "" || ret.indexOf('NaN')>=0){ ret = "''"; } break; default: ret = "'" + value + "'"; } return ret; } var createHideIfCondition = function(root, control) { var ret = ''; if(isVersion(VERSION_HIDE_IF)){ if(control.isHideIfClick == true || control.isHideIfChecked == true || control.isHideIfCmpVal == true){ var isCompareConstant = false; var fieldPath = getControlXPath(root, "/data/", control.id); var cmpType = control.hideIfCmpVal.cmpType; var condValue; if( cmpType == CONST_VALUE_OTHER){ if(control.hideIfCmpVal.val && control.hideIfCmpVal.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ condValue = control.hideIfCmpVal.val; }else{ condValue = getControlXPath(root, "/data/", control.hideIfCmpVal.val); } }else{ condValue = control.hideIfCmpVal.val; isCompareConstant = true; } var condString = control.hideIfCmpVal.condition; var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } if(isNewEmptyType){ ret = ret + condString + '(' + fieldPath + ')'; }else if(!isCompareConstant){ ret = fieldPath + condString + condValue; }else if(control.type == CONST_CTRL_TYPE_INPUT_TEXT){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUT_NUMERIC || control.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } ret = fieldPath + condString + condValue; }else if(control.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } ret = fieldPath + condString + condValue; }else if(control.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(control.kind == CONST_VALUE_TIME){ ret = fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); }else if(control.kind == CONST_VALUE_DATE_SPACE_TIME){ ret = fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); }else{ ret = fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, control.kind) + '\')')); } }else if(control.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(control.isCtrlInScoreTable != undefined && control.isCtrlInScoreTable){ if(condString == ' = '){ ret = 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ ret = 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ ret = fieldPath + condString + "'" + condValue + "'"; } }else if(control.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(control.isCtrlInScoreTable != undefined && control.isCtrlInScoreTable){ if(condString == ' = '){ ret = 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ ret = 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ ret = fieldPath + condString + "'" + condValue + "'"; } }else if(control.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(control.isCtrlInScoreTable != undefined && control.isCtrlInScoreTable){ if(condString == ' = '){ ret = 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ ret = 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ if(condString == ' = '){ ret = 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ ret = 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } } }else if(control.type == CONST_CTRL_TYPE_INPUTLOCATION){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputImage){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputAudio){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputVideo){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTMEDIA){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputSketch){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == mdi_kind_inputSignature){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputDraw'){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTBARCODE){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTNFC){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputPageBreak' || control.type == 'inputLabel' || control.type == CONST_CTRL_TYPE_INPUTACTION || control.type == CONST_CTRL_TYPE_INPUTPAYMENT || control.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || control.type == 'inputInstruction' || control.type == 'inputSaveAndSend'){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ if(!condValue || condValue == ''){ ret = 'totalScore(' + fieldPath + ')' + condString + "''"; }else{ ret = 'totalScore(' + fieldPath + ')' + condString + condValue; } }else if(control.type == CONST_CTRL_TYPE_INPUTNUMBERING){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || control.type == CONST_CTRL_TYPE_INPUTFAX || control.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(control.kind != null && (control.kind == CONST_VALUE_DATE || control.kind == 'String')){ ret = fieldPath + condString + "'" + condValue + "'"; }else{ if(condValue == ''){ condValue = '0'; } ret = fieldPath + condString + condValue; } }else if(control.type == CONST_CTRL_TYPE_INPUTLOOKUP){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputFacingTable'){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == 'inputLookupMulti'){ ret = fieldPath + condString + "'" + condValue + "'"; }else if(control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ ret = fieldPath + condString + "'" + condValue + "'"; }/*else if (control.type == 'inputRIF'){ }*/ } } return ret; }; })(jQuery); /** * Process mode OnlyView in WebAppGUI */ function processModeOnlyView4DPWebAppGUI(plusReadOnlyFlg) { var urlStringQuery = window.location.toString(); console.log('WE are in Dispatch Plus ... : ' + urlStringQuery); if (urlStringQuery.indexOf('&isModeViewReadOnly=true') > 0 || plusReadOnlyFlg) { console.log('&isModeViewReadOnly=true'); setTimeout(function() { // Disabled all input items $('textarea,input,select,a,img,div') .not('#fvmain_menu .fvCancel, #fvmain_menu .fvPrint') .prop('disabled', true) .off('click').off('change').die('click').die('change'); $('a').attr('href', '#no_target_dummy'); $('.ctrl_selected').removeClass(CONST_CSS_CLASS_CTRL_SELECTED); $('.selected_border').removeClass('selected_border'); $('.' + CONST_CSS_CLASS_CTRL_SELECTED_HEDER).removeClass(CONST_CSS_CLASS_CTRL_SELECTED_HEDER); }, 500); } } function xmlEncode(value){ return value.replace(/&/g,"&") .replace(//g,">") .replace(/"/g,""") .replace(/'/g,"‘"); } function fixButtonTypeForNFCBacodeInGridTable(control){ if(isVersion(VERSION_SHOW_ICON_BUTTON) && (control.type == CONST_CTRL_TYPE_INPUTBARCODE || control.type == CONST_CTRL_TYPE_INPUTNFC)){ if(control.parentCtrlType == CONST_CTRL_TYPE_CTRLGRID || control.parentCtrlType == CONST_CTRL_TYPE_CTRLTABLE || control.parentCtrlType == CONST_CTRL_TYPE_CTRLSCHEDULE){ if(!control.ctrlDesc || !isCtrlVersion(control.ctrlDesc[CONST_VALUE_VERSION])){ control.btnType = CONST_TYPE_IMAGE; } } } } function fixHidePrintPDF(control){ if(isVersion(VERSION_HIDE_PDF_WEB)){ if(control.hideInPDF == true && control.hidePdfWeb == undefined){ control.hidePdfWeb = true; } } } function isNotDelivered(statusObj) { if(typeof statusObj === "string" ) { status = parseInt(statusObj, 10); }else{ status = statusObj; } if ((status & POD_RECORD_STATUS_NOT_DELIVERED) == POD_RECORD_STATUS_NOT_DELIVERED) { return true; } return false; } function isDelivered(statusObj) { if(typeof statusObj === "string" ) { status = parseInt(statusObj, 10); }else{ status = statusObj; } if ((status & POD_RECORD_STATUS_DELIVERED) == POD_RECORD_STATUS_DELIVERED) { return true; } return false; } function isDamaged(statusObj) { if(typeof statusObj === "string" ) { status = parseInt(statusObj, 10); }else{ status = statusObj; } if ((status & POD_RECORD_STATUS_DAMAGED) == POD_RECORD_STATUS_DAMAGED) { return true; } return false; } function isRejected(statusObj) { if(typeof statusObj === "string" ) { status = parseInt(statusObj, 10); }else{ status = statusObj; } if ((status & POD_RECORD_STATUS_REJECT) == POD_RECORD_STATUS_REJECT) { return true; } return false; } function isHidden(statusObj) { if(typeof statusObj === "string" ) { status = parseInt(statusObj, 10); }else{ status = statusObj; } if ((status & POD_RECORD_STATUS_HIDDEN) == POD_RECORD_STATUS_HIDDEN) { return true; } return false; } function fillSendDataOfPreviousForm(){ if(!actionOpenFormStack || actionOpenFormStack.length <= 0){ return; } var previousFormDataInfo = actionOpenFormStack[actionOpenFormStack.length - 1]; if(previousFormDataInfo.noResult == true){ actionOpenFormStack.pop(); } if(previousFormDataInfo && previousFormDataInfo.sendValues){ if(previousFormDataInfo.sendValuesFinished){ return; } var sendValues = previousFormDataInfo.sendValues; for(var i=0; i 0){ ctrl.find('textarea').trigger('setLookupValue', [fieldValue, true]); }else{ ctrl.find('input').trigger('setLookupValue', [fieldValue, true]); } } previousFormDataInfo.sendValuesFinished = true; } } function fillReturnDataOfPreviousForm(){ var returnValues = $(CONST_JQUERY_ID_FORMVIEW).data(CONST_RETURN_DATA_FORM); $(CONST_JQUERY_ID_FORMVIEW).data(CONST_RETURN_DATA_FORM, undefined); if(!returnValues || returnValues.length <= 0){ return; } for(var i=0; i 0){ ctrl.find('textarea').trigger('setLookupValue', [value, true]); }else{ ctrl.find('input').trigger('setLookupValue', [value, true]); } } } function runWaitForDataLoaded(){ if(fvDataNS.waitForDataLoadedData){ for(var i=0; i0){ var i=fvDataNS.hasSkipConditionArray.length var stop=false; while(i>0 && !stop){ i--; var ctrlClassPath = fvDataNS.hasSkipConditionArray[i]; var ctrlPropreties = fvDataNS.dataArray[ctrlClassPath]; setFocusCtrlMap(ctrlPropreties.classPath); stop = executeSkipChange(ctrlPropreties); resetFocusCtrlMap(); } } } } function cloneJSON(obj, controls) { // basic type deep copy if (obj === null || obj === undefined || typeof obj !== 'object') { return obj } // array deep copy if (obj instanceof Array) { var cloneA = []; for (var i = 0; i < obj.length; ++i) { cloneA[i] = cloneJSON(obj[i], controls); } return cloneA; } // object deep copy var cloneO = {}; var ctrlPath = ''; for (var i in obj) { switch(i){ case 'destinationField': ctrlPath = getControlXPath(controls, "/data/", obj[i]); if(!ctrlPath){ ctrlPath = ''; } cloneO[i] = ctrlPath; break; default: cloneO[i] = cloneJSON(obj[i], controls); } } return cloneO; } function keywordCheck(control){ var cdata_keyword = ']]>'; if(!control){ return {error:0}; } if(control.label && control.label.eng && control.label.eng.indexOf(cdata_keyword)>=0){ return {error: 103, message: msg_bf_cdata_kw_error}; }else if(control.hint && control.hint.eng && control.hint.eng.indexOf(cdata_keyword)>=0){ return {error: 103, message: msg_bf_cdata_kw_error}; } return {error:0}; } function convertInputAction(control){ if(control.imgAction == CONST_ACTION_SEND_STATUS){ if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(control.imgActionParamType == undefined){ if(valueOrEmpty(control.imgActionStatusCtrl) != ''){ control.imgActionParamType = CONST_VALUE_OTHER; }else{ control.imgActionParamType = ''; } } } }else if(control.imgAction == CONST_ACTION_OPEN_WEB_PAGE){ if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(control.imgOpenWebPageParamType == undefined){ var imgOpenWebPageQues = valueOrEmpty(control.imgOpenWebPageQues); if( imgOpenWebPageQues != '' && imgOpenWebPageQues != '__Constant__'){ control.imgOpenWebPageParamType = CONST_VALUE_OTHER; control.imgOpenWebPageQues = ''; }else{ control.imgOpenWebPageParamType = ''; } } } }else if(control.imgAction == CONST_ACTION_CALL){ if(isVersion(VERSION_CONSISTENCE_DROPDOWN)){ if(control.imgActionMobileNumberParamType == undefined){ var imgActionMobileNumberCtrl = valueOrEmpty(control.imgActionMobileNumberCtrl); if( imgActionMobileNumberCtrl != ''){ control.imgActionMobileNumberParamType = CONST_VALUE_OTHER; }else{ control.imgActionMobileNumberParamType = ''; } } } }else if(control.imgAction == CONST_ACTION_SEND_TEXT_MESSAGE){ if(isVersion(VERSION_SEND_TEXT_MESSAGE)){ if(control.imgActionMobileNumberParamType == undefined){ var imgActionMobileNumberCtrl = valueOrEmpty(control.imgActionMobileNumberCtrl); if( imgActionMobileNumberCtrl != ''){ control.imgActionMobileNumberParamType = CONST_VALUE_OTHER; }else{ control.imgActionMobileNumberParamType = ''; } } if(control.imgActionMessageType == undefined){ var imgActionMessageCtrl = valueOrEmpty(control.imgActionMessageCtrl); if( imgActionMessageCtrl != ''){ control.imgActionMessageType = CONST_VALUE_OTHER; }else{ control.imgActionMessageType = ''; } } } }else if(control.imgAction == CONST_ACTION_INCOMPLETE_STATUS){ control.imgAction = CONST_ACTION_SAVE_AND_EXIT; }else if(control.imgAction == CONST_ACTION_ZEBRA_PRINT){ if(!isVersion(VERSION_LABEL_GRAYSCALE)){ zebraPrintColumns = control.zebraPrintColumns; if(zebraPrintColumns != null){ for(var i=0; i 0){ control.isShowDestinationFields = true; }else{ control.isShowDestinationFields = false; } } if(control.imgAction == CONST_ACTION_SET_DESTINATION_FIELDS){ if(isVersion(VERSION_ACTION_SET_DESTINATION_FIELD)){ if(control.actionDestinationData4SDF == undefined && control.isShowDestinationFields == true){ control.actionDestinationData4SDF = control.actionDestinationData; control.actionDestinationData = []; } } } return control; } function checkHideIfFieldsRequired(control, requiredError, controlsOrg, retObj){ // CO-4022: Hide if start if(isVersion(VERSION_HIDE_IF) && !requiredError && control.isHideIfCmpVal == true){ var ctrlArr = []; var duplicateError = false; _.each(control.hideIfFields, function(item){ if(item.text && item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined){ retObj.error = 17; retObj.message = msg_bf_hide_if_ctrl_deleted; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_hide_if_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_hide_if_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } }); try{ // CO-5016: Able to publish form even the Hide if other question not selected if(control.hideIfCmpVal && 'other' === control.hideIfCmpVal.cmpType && '' === control.hideIfCmpVal.val){ retObj.error = 22; retObj.message = msg_bf_hide_if_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } catch(e){} } return requiredError; // CO-4022: Hide if end } function convertHideIfCmpVal(control){ if(control.isHideIfCmpVal == true){ if(control.hideIfCmpVal && control.hideIfCmpVal.length != undefined){ control.hideIfCmpVal = {}; } } return control; } function toRouteString(root, route){ var routeStr = ''; var itemPath = ''; if(route == undefined){ return routeStr; } if(route.start != undefined){ if(route.start == CONST_CUR_LOC){ routeStr += CONST_XML_FUNCTION_CUR_LOC; }else if(route.start.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ routeStr += route.stops[i].val; }else{ itemPath = getControlXPath(root, "/data/", route.start); if(itemPath != undefined){ routeStr += itemPath; } } } routeStr += ','; for(var i=0; i0){ routeStr += ','; } if(route.stops[i].val != undefined){ if(route.stops[i].val == CONST_CUR_LOC){ routeStr += CONST_XML_FUNCTION_CUR_LOC; }else if(route.stops[i].val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ routeStr += route.stops[i].val; }else{ itemPath = getControlXPath(root, "/data/", route.stops[i].val); if(itemPath != undefined){ routeStr += itemPath; } } } } return routeStr; } function processChecklistFilters(binding, control, root){ //todo if(isVersion(VERSION_CHECKLIST_CONDITION)){ if(control.checklistconds && control.checklistconds.length>0){ var checklistCondString = ''; var condString = ""; var condValue = ""; var space = " "; var i = 0; _.each(control.checklistconds, function(checklistCond){ if(checklistCond.text.checklistField == ''){ return true; } var checklistControl = getControlById(checklistCond.text.checklistField, root); if(checklistControl == undefined){ return true; } var fieldPath = getControlXPath(root, "/data/", checklistCond.text.checklistField); condString = checklistCond.text[CONST_VAL]; condValue = checklistCond.value[CONST_VAL]; if(condValue == undefined){ condValue = ''; } condValue = HtmlEncode(condValue, true); if(i != 0){ var joinString = checklistCond.text[CONST_VALUE_JOIN]; if(joinString == undefined || joinString != CONST_VALUE_OR_LOWERCASE){ joinString = CONST_VALUE_AND_LOWERCASE; } checklistCondString = checklistCondString + space + joinString + space; } var isNewEmptyType = false; if(condString == CONST_VALUE_EQUAL){ condString = " = "; }else if(condString == CONST_VALUE_NOT_EQUAL){ condString = " != "; }else if(condString == CONST_VALUE_LESS_THAN){ condString = " < "; }else if(condString == CONST_VALUE_LESS_THAN_OR_EQUAL){ condString = " <= "; }else if(condString == CONST_VALUE_GREATER_THAN){ condString = " > "; }else if(condString == CONST_VALUE_GREATER_THAN_OR_EQUAL){ condString = " >= "; }else if(condString == CONST_VALUE_IS_EMPTY){ isNewEmptyType = true; condString = "isEmpty"; }else if(condString == CONST_VALUE_NOT_IS_EMPTY){ isNewEmptyType = true; condString = "isNotEmpty"; }else{ if(isVersion(VERSION_NEW_ITE_CONDITION)){ switch(condString){ case CONST_COND_CONTAINS: condString = "contains"; break; case CONST_COND_START_WITH: condString = "startsWith"; break; case CONST_COND_LENGTH_IS: condString = "string-length"; break; default: condString = " = "; } }else{ condString = " = "; } } var isNewCompareType = false; if(isVersion(VERSION_REL_TYPE)){ if(checklistCond.value != undefined && checklistCond.value.cmpType == CONST_VALUE_OTHER){ isNewCompareType = true; if(isVersion(VERSION_USE_VARIABLE_BF)){ if(checklistCond.value.val && checklistCond.value.val.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ condValue = checklistCond.value.val; }else{ condValue = getControlXPath(root, "/data/", checklistCond.value.val); } }else{ condValue = getControlXPath(root, "/data/", checklistCond.value.val); } } } if(isNewEmptyType){ checklistCondString = checklistCondString + condString + '(' + fieldPath + ')'; }else if(isNewCompareType){ checklistCondString = checklistCondString + fieldPath + condString + condValue; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUT_TEXT){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUT_NUMERIC || checklistControl.type == CONST_CTRL_TYPE_INPUTTRENDS){ if(condValue == ''){ condValue = '0'; } checklistCondString = checklistCondString + fieldPath + condString + condValue; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTCOUNTER){ if(condValue == ''){ condValue = '0'; } checklistCondString = checklistCondString + fieldPath + condString + condValue; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTDATE){ if(condValue == ''){ condValue = 'today'; } if(checklistControl.kind == CONST_VALUE_TIME){ checklistCondString = checklistCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, checklistControl.kind) + '\')')); }else if(checklistControl.kind == CONST_VALUE_DATE_SPACE_TIME){ checklistCondString = checklistCondString + fieldPath + condString + (condValue==='today'?'today()':('dateTime(\'' + toJavaRosaFormat(condValue, checklistControl.kind) + '\')')); }else{ checklistCondString = checklistCondString + fieldPath + condString + (condValue==='today'?'today()':('date(\'' + toJavaRosaFormat(condValue, checklistControl.kind) + '\')')); } }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTSELECTONE){ if(checklistControl.isCtrlInScoreTable != undefined && checklistControl.isCtrlInScoreTable){ if(condString == ' = '){ checklistCondString = checklistCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ checklistCondString = checklistCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTSCOREONE){ if(checklistControl.isCtrlInScoreTable != undefined && checklistControl.isCtrlInScoreTable){ if(condString == ' = '){ checklistCondString = checklistCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ checklistCondString = checklistCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; } }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTSELECTMANY){ if(checklistControl.isCtrlInScoreTable != undefined && checklistControl.isCtrlInScoreTable){ if(condString == ' = '){ checklistCondString = checklistCondString + 'score_selected(' + fieldPath + ", '" + condValue + "')"; }else{ checklistCondString = checklistCondString + 'false()=score_selected(' + fieldPath + ", '" + condValue + "')"; } }else{ if(condString == ' = '){ checklistCondString = checklistCondString + 'selected(' + fieldPath + ", '" + condValue + "')"; }else{ checklistCondString = checklistCondString + 'false()=selected(' + fieldPath + ", '" + condValue + "')"; } } }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTLOCATION){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == mdi_kind_inputImage){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == mdi_kind_inputAudio){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == mdi_kind_inputVideo){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTMEDIA){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == mdi_kind_inputSketch){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == mdi_kind_inputSignature){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == 'inputDraw'){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTBARCODE){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTNFC){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTFORWARD || control.type == CONST_CTRL_TYPE_INPUTSECUREFORWARD){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == 'inputPageBreak' || checklistControl.type == 'inputLabel' || checklistControl.type == CONST_CTRL_TYPE_INPUTACTION || checklistControl.type == CONST_CTRL_TYPE_INPUTPAYMENT || checklistControl.type == CONST_CTRL_TYPE_INPUTNEWPAYMENT || checklistControl.type == 'inputInstruction' || checklistControl.type == 'inputSaveAndSend'){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ if(!condValue || condValue == ''){ checklistCondString = checklistCondString + 'totalScore(' + fieldPath + ')' + condString + "''"; }else{ checklistCondString = checklistCondString + 'totalScore(' + fieldPath + ')' + condString + condValue; } }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTNUMBERING){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTEMAILREPORT || checklistControl.type == CONST_CTRL_TYPE_INPUTFAX || checklistControl.type == CONST_CTRL_TYPE_INPUTSECUREEMAILREPORT){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTAPPROVAL){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTCALCULATE){ if(checklistControl.kind != null && (checklistControl.kind == CONST_VALUE_DATE || checklistControl.kind == 'String')){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else{ if(condValue == ''){ condValue = '0'; } checklistCondString = checklistCondString + fieldPath + condString + condValue; } }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTLOOKUP){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == 'inputFacingTable'){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == 'inputLookupMulti'){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; }else if(checklistControl.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ checklistCondString = checklistCondString + fieldPath + condString + "'" + condValue + "'"; } i++; }); if(checklistCondString && checklistCondString != ''){ binding.attrs.checklistCond = '(' + checklistCondString + ')'; }else{ binding.attrs.checklistCond = checklistCondString; } } } } function makeCtrlIdMap(controls, parentPath, level){ if(level == 0){ fvDataNS.widgetIdMap = {}; } _.each(controls, function(control){ fvDataNS.widgetIdMap[control.id] = control; if(fvDataNS.ctrlIdMap[control.id] == undefined){ fvDataNS.ctrlIdMap[control.id] = {}; } var classPath = parentPath + ' ' + control.name; fvDataNS.ctrlIdMap[control.id][classPath] = classPath; switch(control.type){ case CONST_CTRL_TYPE_CTRLTABLE: case CONST_CTRL_TYPE_CTRLSCHEDULE: case CONST_CTRL_TYPE_CTRLGRID: case CONST_CTRL_TYPE_GROUP: makeCtrlIdMap(control.children, classPath, level + 1); break; default: } }); } function validateSkipIfCondition(control, controlsOrg){ if(!isVersion(VERSION_IF_THEN_ELSE) || isFreeAccount()){ return {error:0}; } if(!control.isShowSkipIf || !control.skipIfConditions){ return {error:0}; } if(!control){ return {error:0}; } /* error = 104: condition is required, condition compare control is required, jump control is required */ if(control.skipIfConditions.thenOtherValue == undefined || control.skipIfConditions.thenOtherValue == ''){ return {error: 104, message: msg_bf_jump_to_cond_required}; }else{ switch(control.skipIfConditions.thenOtherValue){ case CONST_JUMP_EOF_VAL: case CONST_JUMP_EOG_VAL: break; default: var thenControl = getControlById(control.skipIfConditions.thenOtherValue, controlsOrg); if(thenControl == undefined){ return {error: 104, message: msg_bf_jump_to_cond_required}; } } if(control.skipIfConditions.hasResultElse == true){ switch(control.skipIfConditions.elseOtherValue){ case CONST_JUMP_EOF_VAL: case CONST_JUMP_EOG_VAL: break; default: var elseControl = getControlById(control.skipIfConditions.elseOtherValue, controlsOrg); if(elseControl == undefined){ return {error: 104, message: msg_bf_jump_to_cond_required}; } } } } var ret = ''; _.each(control.skipIfConditions.conditions, function(skipIfCond, index){ if(ret != ''){ return false; } var condString = skipIfCond.text[CONST_VAL]; var condValue = skipIfCond.value[CONST_VAL]; var cmpType = skipIfCond.value[CONST_CMP_TYPE]; var cmpValue = skipIfCond.value.val; if(condString == undefined || condString == ''){ ret = {error: 104, message: msg_bf_jump_to_cond_required}; return false; } switch(condString){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: break; default: if(cmpType == CONST_VALUE_OTHER){ if(cmpValue == undefined || cmpValue == ''){ ret = {error: 104, message: msg_bf_jump_to_cond_required}; return false; }else if(!cmpValue.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ var cmpControl = getControlById(cmpValue, controlsOrg); if(cmpControl == undefined){ ret = {error: 104, message: msg_bf_jump_to_cond_required}; return false; } } } } }); if(ret != ''){ return ret; } return {error:0}; } var validateGeofenceInfo = function(controlsOrg, control, retObj, requiredError) { var ret = {'requiredError': requiredError}; if(!isVersion(VERSION_GEOFENCE_WIDGET)){ return ret; } if(!ret.requiredError){ if(control.descriptionQuestion == undefined || jQuery.trim(control.descriptionQuestion) == ''){ retObj.error = 22; retObj.message = msg_bf_description_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } var ctrlPro = getControlById(control.descriptionQuestion, controlsOrg); if(ctrlPro == undefined){ retObj.error = 18; retObj.message = msg_bf_description_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } } if(!ret.requiredError){ if(control.inputType == undefined || jQuery.trim(control.inputType) == ''){ retObj.error = 22; retObj.message = msg_bf_input_type_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } } if(!ret.requiredError){ switch(control.inputType){ case CONST_INPUT_TYPE_ADD: if(control.addressQuestion == undefined || jQuery.trim(control.addressQuestion) == ''){ retObj.error = 22; retObj.message = msg_bf_address_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } var ctrlPro = getControlById(control.addressQuestion, controlsOrg); if(ctrlPro == undefined){ retObj.error = 18; retObj.message = msg_bf_address_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } break; case CONST_INPUT_TYPE_LAT_LON: if(control.latQuestion == undefined || jQuery.trim(control.latQuestion) == ''){ retObj.error = 22; retObj.message = msg_bf_lat_lon_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } var ctrlPro = getControlById(control.latQuestion, controlsOrg); if(ctrlPro == undefined){ retObj.error = 18; retObj.message = msg_bf_lat_lon_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } if(!ret.requiredError){ if(control.lonQuestion == undefined || jQuery.trim(control.lonQuestion) == ''){ retObj.error = 22; retObj.message = msg_bf_lat_lon_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } var ctrlPro = getControlById(control.lonQuestion, controlsOrg); if(ctrlPro == undefined){ retObj.error = 18; retObj.message = msg_bf_lat_lon_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } } break; } } /* //CO-4372: Geofence widget //We need to make the Arrive and Depart fields optional. They should not be required. if(!ret.requiredError){ if(control.arrivedTimeDes == undefined || jQuery.trim(control.arrivedTimeDes) == ''){ retObj.error = 22; retObj.message = msg_bf_arrived_time_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } var ctrlPro = getControlById(control.arrivedTimeDes, controlsOrg); if(ctrlPro == undefined){ retObj.error = 18; retObj.message = msg_bf_arrived_time_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } } if(!ret.requiredError){ if(control.departedTimeDes == undefined || jQuery.trim(control.departedTimeDes) == ''){ retObj.error = 22; retObj.message = msg_bf_departed_time_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } var ctrlPro = getControlById(control.departedTimeDes, controlsOrg); if(ctrlPro == undefined){ retObj.error = 18; retObj.message = msg_bf_departed_time_field_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } }*/ return ret; } var createXmlPropertyShipping = function(root, control, binding, bodyTag){ var itemPath; if(control.parcelTemplate != undefined && control.parcelTemplate != ''){ itemPath = getControlXPath(root, "/data/", control.parcelTemplate); binding.attrs.parcelTemplate = itemPath; } itemPath = getControlXPath(root, "/data/", control.fromAddress); var shippingInfo = control.transaction + '|'; shippingInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.toAddress); shippingInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.length); shippingInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.width); shippingInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.height); shippingInfo += (itemPath || '') + '|'; //itemPath = getControlXPath(root, "/data/", control.shipDistanceUnit); shippingInfo += (control.shipDistanceUnit || '') + '|'; itemPath = getControlXPath(root, "/data/", control.weight); shippingInfo += (itemPath || '') + '|'; //itemPath = getControlXPath(root, "/data/", control.massUnit); shippingInfo += (control.massUnit || '') + '|'; if(control.transaction == 'CreateLabel'){ var serviceCarrier = undefined; if(control.serviceCarrier && control.serviceCarrier != ''){ var arr = control.serviceCarrier.split('|'); if(arr.length>1){ serviceCarrier = arr[1]; } } shippingInfo += (serviceCarrier || '') + '|'; shippingInfo += (control.serviceLevel || '') + '|'; /*itemPath = getControlXPath(root, "/data/", control.serviceCarrier); shippingInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.serviceLevel); shippingInfo += (itemPath || '') + '|';*/ } //itemPath = getControlXPath(root, "/data/", control.fileFormat); shippingInfo += (control.fileFormat || '') + '|'; itemPath = getControlXPath(root, "/data/", control.fromName); shippingInfo += (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.toName); shippingInfo += (itemPath || ''); binding.attrs.info = shippingInfo; var shippingDestinationInfo = ''; itemPath = getControlXPath(root, "/data/", control.carrier); shippingDestinationInfo += 'carrier=' + (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.level); shippingDestinationInfo += 'level=' + (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.trackingNumber); shippingDestinationInfo += 'trackingNumber=' + (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.trackingUrl); shippingDestinationInfo += 'trackingUrl=' + (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.rateAmount); shippingDestinationInfo += 'rateAmount=' + (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.rateCurrency); shippingDestinationInfo += 'rateCurrency=' + (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.estimatedDays); shippingDestinationInfo += 'estimatedDays=' + (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.labelUrl); shippingDestinationInfo += 'labelUrl=' + (itemPath || '') + '|'; switch(control.fileFormat){ case 'PNG': case 'PNG_2.3x7.5': itemPath = getControlXPath(root, "/data/", control.labelImage); shippingDestinationInfo += 'labelImage=' + (itemPath || ''); break; default: shippingDestinationInfo += 'labelImage='; } binding.attrs.destinationInfo = shippingDestinationInfo; } var validateShippingInfo = function(controlsOrg, control, retObj, requiredError) { var ret = {'requiredError': requiredError}; if(!isVersion(VERSION_INPUT_SHIPPING)){ return ret; } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.fromAddress, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.fromName, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.toAddress, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.toName, control.id, retObj, ret.requiredError); } if(control.parcelTemplate == undefined || control.parcelTemplate == ''){ if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.length, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.width, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.height, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.shipDistanceUnit, control.id, retObj, ret.requiredError); } }else{ if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.parcelTemplate, control.id, retObj, ret.requiredError); } } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.weight, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.massUnit, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ if(control.transaction == CONST_CREATE_LABEL){ ret = checkControlRequired(controlsOrg, control.serviceCarrier, control.id, retObj, ret.requiredError); } } if(!ret.requiredError){ if(control.transaction == CONST_CREATE_LABEL){ ret = checkControlRequired(controlsOrg, control.serviceLevel, control.id, retObj, ret.requiredError); } } if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.fileFormat, control.id, retObj, ret.requiredError); } if(!ret.requiredError && control.actionKind != "autoRun" && control.kind === 'Image' && (control.hintLink === undefined || jQuery.trim(control.hintLink) === '')){ retObj.error = 13; retObj.message = msg_bf_hintlink_required; $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } return ret; } var checkControlRequired = function(controlsOrg, controlId, cmpControlId, retObj, requiredError){ var ret = {'requiredError': requiredError}; if(!ret.requiredError){ if(controlId == undefined || jQuery.trim(controlId) == ''){ retObj.error = 22; retObj.message = msg_bf_from_address_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + cmpControlId).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } } return ret; } var checkControlRequiredNPositionUp = function(controlsOrg, controlId, cmpControlId, retObj, requiredError){ var ret = {'requiredError': requiredError}; if(!ret.requiredError){ if(controlId == undefined || jQuery.trim(controlId) == ''){ retObj.error = 22; retObj.message = msg_bf_from_address_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + cmpControlId).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } var ctrlPro = getControlById(controlId, controlsOrg); if(ctrlPro == undefined){ retObj.error = 18; retObj.message = msg_bf_from_address_required; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + cmpControlId).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } }else{ if (!checkCtrlPosIsCorrected(controlsOrg, controlId, cmpControlId)){ if(!checkControlByIdCorrectPos2(controlsOrg, controlId, cmpControlId, true)){ retObj.error = 18; retObj.message = msg_bf_ctrl_move_down; if(!ret.requiredError){ $('.controlErrorMessage.ctrlId_' + cmpControlId).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); ret.requiredError = true; } } } } } return ret; } var appendControlProperties4Widget = function(ctrlPropreties, control){ appendControlProperties4ImageViewerWidget(ctrlPropreties, control); appendControlProperties4ShippingWidget(ctrlPropreties, control); } var appendControlProperties4ImageViewerWidget = function(ctrlPropreties, control){ if(control.type == CONST_CTRL_TYPE_IMAGE_VIEWER){ ctrlPropreties.imageUrl = control.imageUrl; ctrlPropreties.isFitToScreen = control.isFitToScreen; ctrlPropreties.addAsSpace = control.addAsSpace; } } var appendControlProperties4ShippingWidget = function(ctrlPropreties, control){ if(control.type == CONST_CTRL_TYPE_INPUTACTION && (control.imgAction == CONST_ACTION_SHIPPING_GET_RATE || control.imgAction == CONST_ACTION_SHIPPING_CREATE_LABEL)){ ctrlPropreties.shipFromAddress = control.fromAddress; ctrlPropreties.shipToAddress = control.toAddress; ctrlPropreties.shipFromName = control.fromName; ctrlPropreties.shipToName = control.toName; ctrlPropreties.shipParcelTemplate = control.parcelTemplate; ctrlPropreties.shipLength = control.length; ctrlPropreties.shipWidth = control.width; ctrlPropreties.shipHeight = control.height; ctrlPropreties.shipDistanceUnit = control.shipDistanceUnit; ctrlPropreties.shipWeight = control.weight; ctrlPropreties.shipMassUnit = control.massUnit; ctrlPropreties.shipServiceCarrier = control.serviceCarrier; ctrlPropreties.shipServiceLevel = control.serviceLevel; ctrlPropreties.shipFileFormat = control.fileFormat; ctrlPropreties.shipCarrier = control.carrier; ctrlPropreties.shipLevel = control.level; ctrlPropreties.shipTrackingNumber = control.trackingNumber; ctrlPropreties.shipTrackingUrl = control.trackingUrl; ctrlPropreties.shipRateAmount = control.rateAmount; ctrlPropreties.shipRateCurrency = control.rateCurrency; ctrlPropreties.shipEstimatedDays = control.estimatedDays; ctrlPropreties.shipLabelUrl = control.labelUrl; ctrlPropreties.shipLabelImage = control.labelImage; if(control.purchaseBtnText != undefined || control.purchaseBtnText != ''){ ctrlPropreties.shipPurchaseBtnText = control.purchaseBtnText; } } } function convertInputLocation(control){ if(control.hasGPSDestination == undefined){ var lat = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_LAT}}; var lon = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_LON}}; var alt = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_ALT}}; var acc = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_ACC}}; var map = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_MAP}}; if(control.destinationdata != undefined && control.destinationdata.length > 0){ control.hasGPSDestination = true; _.each(control.destinationdata, function(element, i){ if(!element.value || !element.value.val){ return true; } switch(element.value.val){ case CONST_LOCATION_LAT: if(lat.active == true){ break; } lat.active = true; lat.text.val = element.text.val; break; case CONST_LOCATION_LON: if(lon.active == true){ break; } lon.active = true; lon.text.val = element.text.val; break; case CONST_LOCATION_ALT: if(alt.active == true){ break; } alt.active = true; alt.text.val = element.text.val; break; case CONST_LOCATION_ACC: if(acc.active == true){ break; } acc.active = true; acc.text.val = element.text.val; break; case CONST_LOCATION_MAP: if(map.active == true){ break; } map.active = true; map.text.val = element.text.val; break; } }) control.destinationdata = [lat, lon, alt, acc, map]; }else{ control.hasGPSDestination = false; control.destinationdata = [lat, lon, alt, acc, map]; } }else{ if(control.destinationdata != undefined && control.destinationdata.length > 0){ if(control.destinationdata[0].active == undefined || control.destinationdata.length == 4){ var lat = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_LAT}}; var lon = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_LON}}; var alt = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_ALT}}; var acc = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_ACC}}; var map = {active: false, text: {val: ''}, value: {val: CONST_LOCATION_MAP}}; _.each(control.destinationdata, function(element, i){ if(!element.value || !element.value.val){ return true; } switch(element.value.val){ case CONST_LOCATION_LAT: if(lat.active == true){ break; } lat.active = true; lat.text.val = element.text.val; break; case CONST_LOCATION_LON: if(lon.active == true){ break; } lon.active = true; lon.text.val = element.text.val; break; case CONST_LOCATION_ALT: if(alt.active == true){ break; } alt.active = true; alt.text.val = element.text.val; break; case CONST_LOCATION_ACC: if(acc.active == true){ break; } acc.active = true; acc.text.val = element.text.val; break; case CONST_LOCATION_MAP: if(map.active == true){ break; } map.active = true; map.text.val = element.text.val; break; } }) control.destinationdata = [lat, lon, alt, acc, map]; } } } if(control.addressData != undefined && control.addressData.length > 0){ if(control.addressData[0].active == undefined){ var address = {active: false, text: {val: ''}, value: {val: CONST_COMPLETE_ADDRESS}}; var street = {active: false, text: {val: ''}, value: {val: CONST_STREET}}; var city = {active: false, text: {val: ''}, value: {val: CONST_CITY}}; var state = {active: false, text: {val: ''}, value: {val: CONST_STATE}}; var zip = {active: false, text: {val: ''}, value: {val: CONST_ZIP}}; _.each(control.addressData, function(element, i){ if(!element.value || !element.value.val){ return true; } switch(element.value.val){ case CONST_COMPLETE_ADDRESS: if(address.active == true){ break; } address.active = true; address.text.val = element.text.val; break; case CONST_STREET: if(street.active == true){ break; } street.active = true; street.text.val = element.text.val; break; case CONST_CITY: if(city.active == true){ break; } city.active = true; city.text.val = element.text.val; break; case CONST_STATE: if(state.active == true){ break; } state.active = true; state.text.val = element.text.val; break; case CONST_ZIP: if(zip.active == true){ break; } zip.active = true; zip.text.val = element.text.val; break; } }) control.addressData = [address, street, city, state, zip]; } } return control; } var validateAuditInfo = function(controlsOrg, control, retObj, requiredError) { var ret = {'requiredError': requiredError}; if(!isVersion(VERSION_ACTION_AUDIT)){ return ret; } if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.auditInputQuestion, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.auditDataLookup, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ if(control.auditFoundInLU && control.auditFoundInLU.active){ ret = checkControlRequired(controlsOrg, control.auditFoundInLU.selectField, control.id, retObj, ret.requiredError); } } if(!ret.requiredError){ if(control.auditNotFoundInLU && control.auditNotFoundInLU.active){ ret = checkControlRequired(controlsOrg, control.auditNotFoundInLU.selectField, control.id, retObj, ret.requiredError); } } if(!ret.requiredError){ if(control.auditNotEnteredButInLU && control.auditNotEnteredButInLU.active){ ret = checkControlRequired(controlsOrg, control.auditNotEnteredButInLU.selectField, control.id, retObj, ret.requiredError); } } } var createXmlPropertyAudit = function(root, control, binding, bodyTag){ if(!isVersion(VERSION_ACTION_AUDIT)){ return; } var itemPath = getControlXPath(root, "/data/", control.auditInputQuestion); var auditInfo = (itemPath || '') + '|'; itemPath = getControlXPath(root, "/data/", control.auditDataLookup); auditInfo += (itemPath || '') + '|'; if(control.auditFoundInLU && control.auditFoundInLU.active == true){ auditInfo += CONST_XML_FUNCTION_TRUE + '|'; itemPath = getControlXPath(root, "/data/", control.auditFoundInLU.selectField); auditInfo += (itemPath || '') + '|'; }else{ auditInfo += CONST_XML_FUNCTION_FALSE + '||'; } if(control.auditNotFoundInLU && control.auditNotFoundInLU.active == true){ auditInfo += CONST_XML_FUNCTION_TRUE + '|'; itemPath = getControlXPath(root, "/data/", control.auditNotFoundInLU.selectField); auditInfo += (itemPath || '') + '|'; }else{ auditInfo += CONST_XML_FUNCTION_FALSE + '||'; } if(control.auditNotEnteredButInLU && control.auditNotEnteredButInLU.active == true){ auditInfo += CONST_XML_FUNCTION_TRUE + '|'; itemPath = getControlXPath(root, "/data/", control.auditNotEnteredButInLU.selectField); auditInfo += (itemPath || ''); }else{ auditInfo += CONST_XML_FUNCTION_FALSE + '|'; } var auditJsonPath = '/data/' + control.name + '__addInfo'; auditInfo += '|' + auditJsonPath; binding.attrs.destinationInfo = auditInfo; } var validateNewPaymentInfo = function(controlsOrg, control, retObj, requiredError) { var ret = {'requiredError': requiredError}; if(!isVersion(VERSION_NEW_PAYMENT)){ return ret; } if(control.paymentType == 'manual'){ return ret; } if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.imgActionParamPP_Amount, control.id, retObj, ret.requiredError); } if(control.paymentType == CONST_PAYMENT_MIPOS){ if(!ret.requiredError){ ret = checkControlRequiredNPositionUp(controlsOrg, control.imgActionParamMP_Tax, control.id, retObj, ret.requiredError); } } return ret; } function checkSetDestinationFieldsRequired(control, requiredError, controlsOrg, retObj){ if(control.isRetrieve == true && isVersion(VERSION_RETRIEVE_MODIFY_SET_DESTINATION_FIELD) && !requiredError){ if(control.actionDestinationData4SDF && control.actionDestinationData4SDF.length>0){ var ctrlArr = []; var duplicateError = false; _.each(control.actionDestinationData4SDF, function(item){ if(item.text && item.text.val != undefined){ var destinationControl = getControlById(item.text.val, controlsOrg); if(destinationControl == undefined && !(item.text.val && item.text.val.startsWith(CONST_USER_VARIABLE_START_PARTENT))){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(jQuery.inArray(item.text.val, ctrlArr) >= 0){ retObj.error = 22; retObj.message = msg_bf_destination_field_duplicate_error; if(!duplicateError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; duplicateError = true; } }else{ ctrlArr.push(item.text.val); } } if(item.text == undefined || item.text.val == undefined || jQuery.trim(item.text.val) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(item.value == undefined || item.value.val == undefined || jQuery.trim(item.value.val) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } }else if(item.value.val.startsWith('Other')){ if(item.value.val === 'Other value'){ }else{ if(item.value.other_ctrl_id == undefined || jQuery.trim(item.value.other_ctrl_id) == ''){ retObj.error = 22; retObj.message = msg_bf_destination_all_field_required; if(!requiredError){ $('.controlErrorMessage.ctrlId_' + control.id).addClass('show').find('ul').append( '
  • ' + retObj.message + '
  • '); errorCode = 1; requiredError = true; } } } } }); } } return requiredError; } var getFloatValue = function(value){ var numberVal = 0; var isNumberValue = false; try { // Parse number value into float type numberVal = parseFloat(value); if (!isNaN(numberVal) && isFinite(value)) { isNumberValue = true; } } catch (e) { } if(isNumberValue){ return numberVal; }else{ return 0; } } var createXmlPropertyCloseNRetrieve = function(root, control, binding, bodyTag, isAttachForm){ if(!isVersion(VERSION_CLOSE_AND_RETRIEVE)){ return; } var closeNRetrieveInfo = ''; if(!isAttachForm){ if(control.submitAction != undefined){ closeNRetrieveInfo += control.submitAction; }else{ closeNRetrieveInfo += CONST_SUBMIT_ACTION_UPD; } closeNRetrieveInfo += '|'; } if(control.retrieveProject != undefined){ closeNRetrieveInfo += control.retrieveProject; } closeNRetrieveInfo += '|'; if(control.retrieveForm != undefined){ closeNRetrieveInfo += control.retrieveForm; } closeNRetrieveInfo += '|'; var itemPath = ''; if(control.retrieveCondCreateDate != undefined){ closeNRetrieveInfo += control.retrieveCondCreateDate; switch(control.retrieveCondCreateDate){ case 'custom': if(control.retrieveCondCreateDateCustom == CONST_RETRIEVE_COND_EQUALS){ //equal closeNRetrieveInfo += ',' + CONST_RETRIEVE_COND_EQUALS + ','; itemPath = getControlXPath(root, "/data/", control.retrieveCondCreateDateCustomDate); closeNRetrieveInfo += itemPath; }else{ //between closeNRetrieveInfo += ',' + CONST_RETRIEVE_COND_BETWEEN + ','; itemPath = getControlXPath(root, "/data/", control.retrieveCondCreateDateCustomBegin); closeNRetrieveInfo += itemPath + ','; itemPath = getControlXPath(root, "/data/", control.retrieveCondCreateDateCustomEnd); closeNRetrieveInfo += itemPath; } break; } }else{ closeNRetrieveInfo += 'today'; } closeNRetrieveInfo += '|'; if(control.retrieveCondQues != undefined){ closeNRetrieveInfo += control.retrieveCondQues; } closeNRetrieveInfo += '|'; itemPath = getControlXPath(root, "/data/", control.retrieveCondAnsw); if(itemPath != undefined){ closeNRetrieveInfo += itemPath; } closeNRetrieveInfo += '|'; if(control.retrieveCondQues2 != undefined){ closeNRetrieveInfo += control.retrieveCondQues2; } closeNRetrieveInfo += '|'; itemPath = getControlXPath(root, "/data/", control.retrieveCondAnsw2); if(itemPath != undefined){ closeNRetrieveInfo += itemPath; } closeNRetrieveInfo += '|'; if(control.retrieveDisplayFields != undefined){ _.each(control.retrieveDisplayFields, function(item){ if(item != undefined && item.text != undefined){ closeNRetrieveInfo += item.text.val; } closeNRetrieveInfo += '|'; }); } return closeNRetrieveInfo; } var createXmlHideProperty4Mobile = function(root, control, binding, bodyTag){ if(control.hideOnRetrieve === true){ binding.attrs.hideOnRetrieve = CONST_XML_FUNCTION_TRUE; } if (control.hideInMobile !== undefined && control.hideInMobile === true){ binding.attrs.hideinmobile = CONST_XML_FUNCTION_TRUE; } if (control.hideForwarded !== undefined && control.hideForwarded === true){ binding.attrs.hideForwarded = CONST_XML_FUNCTION_TRUE; } if(isVersion(VERSION_HIDE_IN_PDF_4MOBILE)){ //co-5516 if(isVersion(VERSION_HIDE_PDF_WEB)){ if(control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } }else{ if(control.hideWebAppGrp == true && control.hideInPDF == true){ binding.attrs.hideInPDF = CONST_XML_FUNCTION_TRUE; } } } } var validateRetrieveInfo = function(controlsOrg, control, retObj, requiredError) { var ret = {'requiredError': requiredError}; if(!isVersion(VERSION_CLOSE_AND_RETRIEVE)){ return ret; } if(control.retrieveCondCreateDate == CONST_CREATE_DATE_CUSTOM){ if(control.retrieveCondCreateDateCustom == CONST_RETRIEVE_COND_BETWEEN){ if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.retrieveCondCreateDateCustomBegin, control.id, retObj, ret.requiredError); } if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.retrieveCondCreateDateCustomEnd, control.id, retObj, ret.requiredError); } }else{ if(!ret.requiredError){ ret = checkControlRequired(controlsOrg, control.retrieveCondCreateDateCustomDate, control.id, retObj, ret.requiredError); } } } } function processButtonSize(binding, control){ if(isVersion(VERSION_BUTTON_SCREEN_SIZE) && control.kind == 'Image'){ if(control.ifScreenSmallerThan == true){ var ifScreenSmallerSize; if(control.ifScreenSmallerSize == undefined){ ifScreenSmallerSize = CONST_SIZE_SMALL; }else{ ifScreenSmallerSize = control.ifScreenSmallerSize; } binding.attrs.isApplyForScreen = 'true()|' + control.applyScreenSize + '|' + control.buttonSize + '|' + ifScreenSmallerSize; }else{ binding.attrs.isApplyForScreen = 'false()||' + control.buttonSize + '|'; } } } function getSumCountInTableUseCheckList(control){ if(control == undefined || control.children == undefined){ return undefined; } var sumCountInTable = []; _.each(control.children, function(control1) { if(control1.type == CONST_CTRL_TYPE_INPUTCALCULATE){ var sumCountInExpression = getSumCountInExpression(control1.expression); if(sumCountInExpression != undefined){ for(var i=0; i 0){ var tmpArr = getSumCountInExpression(item.group); if(tmpArr != undefined){ for(var i=0; i0){ ctrlProperties = ctrlProperties.children[0]; } } var rowCount = ctrlProperties.tmpLoopCount; var repeatableSummary = $('.ctrlRepeatableSummary#fvCtrlID_' + control.id); var realIndex = 0; for(var j=0; j