var globalObjName = 'strg_meet_dcr_realtime_wiz';
//Added by Prasad on 15/01/18 [setting pitchSeq value in card view implementation]
var pitchSeq = 0;
//Added by Prasad on 19/12/19 [coaching related implementation]
var selectedTeam = "";
//Added by Amey W. [OT activity related implementation] on 18/02/2020
var selectedActivity = "";
var noOfAttchments = "";
var attachmentJson = {};

var attachmentFlag = false;
var attchments = 0;
var routeData = "", customerData ="", visitedCust = ""; // Added by Pankaj R on 15-JUL-21 to set the route by default if defined in sprs route for that day
function wfValData(hdrFormXml, currFormXml, objContext, action, objName, allFormXmlData)
{
	console.log('inside wfValData function in js file');
	return true;
}

function valData(objContext, action, objName, currentFormData, objFormName)
{
	console.log('inside valData function in js file');
	return true;
}

//called in offline mode
//added by mrunalini sinkar for offline validation on 16-feb-2018(start)

var teamFlg = true;
var orderFlg = true;
var brandFlg = true;
var displayFlg = true;
var surveyFlg = true;
var coachingFlg = true;
var invoiceFlg = true;
var collectionFlg = true;
var billAmountGlobal = 0;
var updateFlagVal = "";
var isAutoEdit = false;
var strgCustType = "";
var custFlag=false,DocsurveyTemp="";
var scCode="";
var teamGrdTyp="";
var pitchDetailArray=[];
var QualificationArray=[];//added by prachi
//Added by bhagyashri T 10-01-2023
var updateFlg= true;
var callOutCmGlobal ="";
var addModeCallOutCm ="";
var editInvoiceFlg =true;
var editCollectFlg =true;

var meetingStatus="";
var euinCntPers=""; //Added by bhagyashri for contact pers
//Changed by Pooja on 14-AUGUST-2020 [Coaching related detail form implementation]
//var visitedWithDesignCodeArr = ['FR', 'ESL', 'SFR', 'ABM', 'BDM', 'SABM', 'RSM', 'MR', 'REP','FLM','SLM'];
var visitedWithDesignCodeArr = "";
var isForuneAct="";
var teamDesignCode="",teamDocType="";

var itemFlg= true;
var itemFlgTr= true;
var itemFlgR= true;

function localWfValData(hdrFormXml, currentFormData, objContext, action, objName, objFormName, allFormData)
{
	globalObjName = objName;
	var StrgCodeArray=[];
	console.log("Inside localWfValData function having obj name is::["+objName+"]");
	console.log("Inside localWfValData allFormData ::["+allFormData+"]");
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		console.log("Inside localWfValData function having obj name is strg_meet_dcr_realtime_wiz");
		var isValidWfData = true;
		console.log('currentFormData is['+currentFormData+'] action is['+action+'] objFormName is['+objFormName+']');
		var currentFormData=currentFormData;
		var action=action;
		var allFormDetailData=allFormData;
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata");
		}
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
				}
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					allFormDetailData = parser.parseFromString(allFormDetailData,"text/xml");
				}
			}
			catch(ex)
			{
				console.log("Exception occurs while parsing xml data");
			}
			
			
		}
		else
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		if(xmlDoc != null )
		{
			if(objFormName === 'doctor')
			{
				
			   
				var oldActType = "",parentActVal="";
				var eventDateNew = "";
				var newActType = "";
				var newActCode = "";
				var newParentActCode= '';
				var newActivityTempl= '';
				var newActDescr = "";
				var newPlaceRequired = "";
				var newActivityPlace = ""; //Added by Bhagyashri T for Activity Place[28/JUL/21]
				var qualiList = "",strgCodeList=""; //added by prachi on 25-May-2022 [ W22AGOC002 ]
				var strgCode = "";
				var oldStrgCode = "";
				var empJoinDate = "",futureDateAct = "", activityCode = "",activityDescr="",listDesignCode="",designCodeList="",custTypeData="";
				var seqentialDar=true,activityTemplate="",stockCde="";
				var pitchList="",meetingStatusList="",meetCallOutcome="",subMeetingStatus="";
				var unlstScCode ="";  //Added by Bhagyashri T for contact_pers
				var cntPerson ="";   //Added by Bhagyashri T for contact_pers
				var cntPersonCd ="";   //Added by Bhagyashri T for contact person
				var salesType = "";
				var payMode = "";
				var collectionFormNo = "";
				var detailElement = xmlDoc.getElementsByTagName("Detail1");
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var actType="";
					var strgType="";
					var placeRequired="",memberPresent="",eveDate="",activityPlace=""; //Added by Bhagyashri T for Activity Place[28/JUL/21]
					var gradeType = "",allwDelayPrd="",holidayDate="",pendingDcr="",salesPerson="",futureDate="",routeType="",invoiceNoD="",isBangla="",branAval="",designCode="";
					if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
					{
						eveDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
					{
						actType=detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
						newActType = actType;
					}
					if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
					{
						strgType=detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("place_required")[0] != null && detail.getElementsByTagName("place_required")[0].childNodes[0] != null )
					{
						placeRequired=detail.getElementsByTagName("place_required")[0].childNodes[0].nodeValue;
						newPlaceRequired=placeRequired; //Added by mrunalini sinkar for set previous act descr
					}
					if( detail.getElementsByTagName("grade_type")[0] != null && detail.getElementsByTagName("grade_type")[0].childNodes[0] != null )
					{
						gradeType = detail.getElementsByTagName("grade_type")[0].childNodes[0].nodeValue;
						teamGrdTyp = gradeType;
					}
					// added by mrunalini sinkar for holidays ,pendinDcr validation on 06-03-2019(start)
					if( detail.getElementsByTagName("holiday_dates")[0] != null && detail.getElementsByTagName("holiday_dates")[0].childNodes[0] != null )
					{
						holidayDate = detail.getElementsByTagName("holiday_dates")[0].childNodes[0].nodeValue;

					}
					if( detail.getElementsByTagName("allwd_delay_prd")[0] != null && detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0] != null )
					{
						allwDelayPrd = detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0].nodeValue;

					}
					if( detail.getElementsByTagName("pending_dcr")[0] != null && detail.getElementsByTagName("pending_dcr")[0].childNodes[0] != null )
					{
						pendingDcr = detail.getElementsByTagName("pending_dcr")[0].childNodes[0].nodeValue;

					}
					if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
					{
						salesPerson = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;

					}
					/*if( detail.getElementsByTagName("holi_length")[0] != null && detail.getElementsByTagName("holi_length")[0].childNodes[0] != null )
					{
						holiBetPen = detail.getElementsByTagName("holi_length")[0].childNodes[0].nodeValue;
					}*/

					// added by mrunalini sinkar for holidays ,pendinDcr validation on 06-03-2019(end)
					// added by mrunalini sinakr to allow future event for particulat event_type on 03-april-2019(star)
					if( detail.getElementsByTagName("future_date")[0] != null && detail.getElementsByTagName("future_date")[0].childNodes[0] != null )
					{
						futureDate = detail.getElementsByTagName("future_date")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("route_type")[0] != null && detail.getElementsByTagName("route_type")[0].childNodes[0] != null )
					{
						routeType = detail.getElementsByTagName("route_type")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("invoice_no")[0] != null && detail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
					{
						invoiceNoD = detail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
					}
					// added by mrunalini sinakr to allow future event for particulat event_type on 03-april-2019(end)
					// added by rupali on 16/07/19 to validate survey question [start]
					if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
					{
						strgCustType = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
						teamDocType=strgCustType;
					}
					if( detail.getElementsByTagName("cust_type_list")[0] != null && detail.getElementsByTagName("cust_type_list")[0].childNodes[0] != null )
					{
						strgTypeList = detail.getElementsByTagName("cust_type_list")[0].childNodes[0].nodeValue;
						strgTypeList = strgTypeList.substring(1, strgTypeList.length-1);

					}
					if( detail.getElementsByTagName("emp_design")[0] != null && detail.getElementsByTagName("emp_design")[0].childNodes[0] != null )
					{
						designCode = detail.getElementsByTagName("emp_design")[0].childNodes[0].nodeValue;
						teamDesignCode=designCode;

					}
					if( detail.getElementsByTagName("survey_templ")[0] != null && detail.getElementsByTagName("survey_templ")[0].childNodes[0] != null )
					{
						DocsurveyTemp = detail.getElementsByTagName("survey_templ")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
					{
						scCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						scCode = scCode.trim();
					}
					//Added by Bhagyashri T for contact_pers[start]
					if( detail.getElementsByTagName("contact_pers")[0] != null && detail.getElementsByTagName("oth_participant")[0].childNodes[0] != null )
					{
						euinCntPers = detail.getElementsByTagName("contact_pers")[0].childNodes[0].nodeValue;
						euinCntPers = euinCntPers.trim();
					}
					//Added by Bhagyashri T for contact_pers[end]
					//Added by mrunalini sinkar for banglasdesh user validation(start)
					if( detail.getElementsByTagName("is_bangla")[0] != null && detail.getElementsByTagName("is_bangla")[0].childNodes[0] != null )
					{
						isBangla = detail.getElementsByTagName("is_bangla")[0].childNodes[0].nodeValue;

					}
					if( detail.getElementsByTagName("bradn_aval")[0] != null && detail.getElementsByTagName("bradn_aval")[0].childNodes[0] != null )
					{
						branAval = detail.getElementsByTagName("bradn_aval")[0].childNodes[0].nodeValue;

					}
					//Added by mrunalini sinkar for banglasdesh user validation(end)
					if( detail.getElementsByTagName("future_date_act")[0] != null && detail.getElementsByTagName("future_date_act")[0].childNodes[0] != null )
					{
						futureDateAct = detail.getElementsByTagName("future_date_act")[0].childNodes[0].nodeValue;
					}
					// added by shweta m for validaiton invalid custType started
					if( detail.getElementsByTagName("cust_type_data")[0] != null && detail.getElementsByTagName("cust_type_data")[0].childNodes[0] != null )
					{
						custTypeData = detail.getElementsByTagName("cust_type_data")[0].childNodes[0].nodeValue;
					} 
					// added by shweta m for validaiton invalid custType ended
					if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
					{
						activityCode = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
						newActCode=activityCode; //Added by mrunalini sinkar for set previous act code
					}
					if( detail.getElementsByTagName("activity_descr")[0] != null && detail.getElementsByTagName("activity_descr")[0].childNodes[0] != null )
					{
						activityDescr = detail.getElementsByTagName("activity_descr")[0].childNodes[0].nodeValue;
						newActDescr=activityDescr; //Added by mrunalini sinkar for set previous act descr
					}
					//added by mrunalini sinkar for member present in unlisted customer (start)
					if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
					{
						memberPresent = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
					}
					//added by mrunalini sinkar for member present in unlisted customer (end)
					//added by shraddha M for stockist[03-09-19:start]
					if( detail.getElementsByTagName("allow_stockist_dar")[0] != null && detail.getElementsByTagName("allow_stockist_dar")[0].childNodes[0] != null )
					{
						realparamdata = detail.getElementsByTagName("allow_stockist_dar")[0].childNodes[0].nodeValue;
					}
					//added by shraddha M for stockist[03-09-19:end]
					var totAllwCallList = 0, listCnt = 0;
					var parentActCode = '',custConf="",custConfProof="";
					if( detail.getElementsByTagName("tot_allow_call_list")[0] != null && detail.getElementsByTagName("tot_allow_call_list")[0].childNodes[0] != null )
					{
						totAllwCallList = detail.getElementsByTagName("tot_allow_call_list")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("tot_call_list")[0] != null && detail.getElementsByTagName("tot_call_list")[0].childNodes[0] != null )
					{
						listCnt = detail.getElementsByTagName("tot_call_list")[0].childNodes[0].nodeValue;
					}
					//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm Start
					if( detail.getElementsByTagName("activity_templ")[0] != null && detail.getElementsByTagName("activity_templ")[0].childNodes[0] != null )
					{
						activityTemplate = detail.getElementsByTagName("activity_templ")[0].childNodes[0].nodeValue;
						newActivityTempl = activityTemplate;
					}
					if( detail.getElementsByTagName("parent_act_code")[0] != null && detail.getElementsByTagName("parent_act_code")[0].childNodes[0] != null )
					{
						parentActCode = detail.getElementsByTagName("parent_act_code")[0].childNodes[0].nodeValue;
						newParentActCode = parentActCode;
					}
					//Added by mrunalini sinkar for remove sequntial DAR validation in case of RSM & CA activity(start)
					if( detail.getElementsByTagName("list_design_code")[0] != null && detail.getElementsByTagName("list_design_code")[0].childNodes[0] != null )
					{
						listDesignCode = detail.getElementsByTagName("list_design_code")[0].childNodes[0].nodeValue;
					}
					//Added by Amey W. [OT activity related implementation] on 18/02/2020OfAttchments
					if( detail.getElementsByTagName("cust_conf")[0] != null && detail.getElementsByTagName("cust_conf")[0].childNodes[0] != null )
					{
						custConf = detail.getElementsByTagName("cust_conf")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("cust_conf_proof")[0] != null && detail.getElementsByTagName("cust_conf_proof")[0].childNodes[0] != null )
					{
						custConfProof = detail.getElementsByTagName("cust_conf_proof")[0].childNodes[0].nodeValue;
					}
					//Added by mrunalini sinkar for fortune (Start)
					if( detail.getElementsByTagName("meeting_status")[0] != null && detail.getElementsByTagName("meeting_status")[0].childNodes[0] != null )
					{
						meetingStatus = detail.getElementsByTagName("meeting_status")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_fortune_activity")[0] != null && detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0] != null )
					{
						isForuneAct = detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("call_outcome")[0] != null && detail.getElementsByTagName("call_outcome")[0].childNodes[0] != null )
					{
						meetCallOutcome = detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
						callOutCmGlobal=meetCallOutcome;
					}
					if( detail.getElementsByTagName("subform_meeting_status")[0] != null && detail.getElementsByTagName("subform_meeting_status")[0].childNodes[0] != null )
					{
						subMeetingStatus = detail.getElementsByTagName("subform_meeting_status")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("pitch_detail_data")[0] != null && detail.getElementsByTagName("pitch_detail_data")[0].childNodes[0] != null )
					{
						pitchList = detail.getElementsByTagName("pitch_detail_data")[0].childNodes[0].nodeValue;
						pitchList = pitchList.substring(1, pitchList.length-1);

					}

					//added by prachi on 25-May-2022 [ W22AGOC002 ]
					if( detail.getElementsByTagName("qualification_list")[0] != null && detail.getElementsByTagName("qualification_list")[0].childNodes[0] != null )
					{
						qualiList = detail.getElementsByTagName("qualification_list")[0].childNodes[0].nodeValue;
						qualiList = qualiList.substring(1, qualiList.length-1);

					}
					
					if( detail.getElementsByTagName("strg_code_list")[0] != null && detail.getElementsByTagName("strg_code_list")[0].childNodes[0] != null )
					{
						strgCodeList = detail.getElementsByTagName("strg_code_list")[0].childNodes[0].nodeValue;
						strgCodeList = strgCodeList.substring(1, strgCodeList.length-1);

					}

					if( detail.getElementsByTagName("meeting_status_data")[0] != null && detail.getElementsByTagName("meeting_status_data")[0].childNodes[0] != null )
					{
						meetingStatusList = detail.getElementsByTagName("meeting_status_data")[0].childNodes[0].nodeValue;
						meetingStatusList = meetingStatusList.substring(1, meetingStatusList.length-1);

					}
					if( detail.getElementsByTagName("unlst_sccode_data")[0] != null && detail.getElementsByTagName("unlst_sccode_data")[0].childNodes[0] != null )
					{
						unlstScCode = detail.getElementsByTagName("unlst_sccode_data")[0].childNodes[0].nodeValue;
						unlstScCode = unlstScCode.substring(1, unlstScCode.length-1);
					}
					if( detail.getElementsByTagName("cnt_pers_data")[0] != null && detail.getElementsByTagName("cnt_pers_data")[0].childNodes[0] != null )
					{
						cntPerson = detail.getElementsByTagName("cnt_pers_data")[0].childNodes[0].nodeValue;
						cntPerson = cntPerson.substring(1, cntPerson.length-1);
					}
					if( detail.getElementsByTagName("cnt_pers_code")[0] != null && detail.getElementsByTagName("cnt_pers_code")[0].childNodes[0] != null )
					{
						cntPersonCd = detail.getElementsByTagName("cnt_pers_code")[0].childNodes[0].nodeValue;
						cntPersonCd = cntPersonCd.substring(1, cntPersonCd.length-1);
					}
					if( detail.getElementsByTagName("stockist_code")[0] != null && detail.getElementsByTagName("stockist_code")[0].childNodes[0] != null )
					{
						stockCde = detail.getElementsByTagName("stockist_code")[0].childNodes[0].nodeValue;
					}
					//Added by Bhagyashri T for Activity Place[28/JUL/21][start]
					if( detail.getElementsByTagName("activity_place")[0] != null && detail.getElementsByTagName("activity_place")[0].childNodes[0] != null )
					{
						activityPlace=detail.getElementsByTagName("activity_place")[0].childNodes[0].nodeValue;
						newActivityPlace=activityPlace;
					}
					//Added by Bhagyashri T for Activity Place[28/JUL/21][end]
					
					//Added by Hariom S for Sales Type validation [21/APR/23][Start]
					if( detail.getElementsByTagName("sales_type")[0] != null && detail.getElementsByTagName("sales_type")[0].childNodes[0] != null )
					{
						salesType=detail.getElementsByTagName("sales_type")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("collection_form_no")[0] != null && detail.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
					{
						collectionFormNo = detail.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
					}
					console.log("salesType :- --"+salesType);
					if(salesType == "C")
					{				
						payMode= getCollectionPayMode(collectionFormNo, allFormDetailData)
					}
										 
					console.log("payMode :- --"+payMode);
					if(action == 'finish')
					{
						if(payMode != "C" && salesType == "C")
						{
							alert("Sales type has been change, Please go to Collection form");
							isValidWfData=false;
							return isValidWfData;
						}
					}
					//Added by Hariom S for Sales Type validation [21/APR/23][End]

					var pitchFinalList = pitchList.split(',');
					for(var p=0;p < pitchFinalList.length;p++)
					{
						var statusPitch = pitchFinalList[p].trim();
						pitchDetailArray.push(statusPitch);
					}

					//Added by prachi on 25/04/2022 start [ W22AGOC002 ]
					var qualFinalList = qualiList.split(',');
					for(var q=0;q < qualFinalList.length;q++)
					{
						var qualifData = qualFinalList[q].trim();
						QualificationArray.push(qualifData);

					}
					console.log("Qualification array"+QualificationArray);
					//Added by prachi on 25/04/2022 end [ W22AGOC002 ]
					
					var strgFinalList = strgCodeList.split(',');
					for(var q=0;q < strgFinalList.length;q++)
					{
						var strgData = strgFinalList[q].trim();
						StrgCodeArray.push(strgData);

					}
					console.log("StrgCodeArray ::"+StrgCodeArray);

					var meetStatusFinalList = meetingStatusList.split(',');
					var meetingStatusArray=[];

					for(var m=0;m < meetStatusFinalList.length;m++)
					{
						var statusMeet = meetStatusFinalList[m].trim();
						meetingStatusArray.push(statusMeet);
					}
					//Added by mrunalini sinkar for fortune (End)
					//Added by Bhagyashri T for Contact_pers(start)[14/02/22]
					var eunlstScCodeFinalList = unlstScCode.split(',');
					var unlstScCodeArray=[];

					for(var p=0;p < eunlstScCodeFinalList.length;p++)
					{
						var unlstSc = eunlstScCodeFinalList[p].trim();
						unlstScCodeArray.push(unlstSc);
					}
					//console.log("inside the unlstScCodeArray arry :::"+unlstScCodeArray) ;
					//Added by Bhagyashri T for contact_pers(end)[14/02/22]
					//Added by Bhagyashri T for contact_pers(start)[15/02/22]
					var cntPersFinalList = cntPerson.split(',');
					var cntPersArray=[];

					for(var q=0;q < cntPersFinalList.length;q++)
					{
						var cntPers = cntPersFinalList[q].trim();
						cntPersArray.push(cntPers);
					}
					var cntPersCodeList = cntPersonCd.split(',');
					var cntPersCdArray=[];

					for(var r=0;r < cntPersCodeList.length;r++)
					{
						var cntPersCd = cntPersCodeList[r].trim();
						cntPersCdArray.push(cntPersCd);
					}
					//console.log("inside the cntPerson arry :::"+cntPersArray) ;
					//console.log("inside the cntPersCdArray arry for euin no :::"+cntPersCdArray) ;
					//Added by Bhagyashri T for contact_pers(end)[15/02/22]
					// added by shweta m for cust_type valdiation (start)
					var custTypeDataArray = [];
					custTypeData = custTypeData.substring(1, custTypeData.length-1);

					var custTypeDataList = custTypeData.split(',');
					for(var j=0;j< custTypeDataList.length;j++)
					{
						var custAct = custTypeDataList[j].trim();
						custTypeDataArray.push(custAct);
					} 
					// alert("inside the cust_type field arry :::"+custTypeDataArray) ;
					// added by shweta m for cust_type valdiation (end)

					designCodeList = listDesignCode.split(',');
					if(designCodeList.indexOf(designCode) != -1 && activityCode=='CA')
					{
						seqentialDar=false;
					}
					//Added by mrunalini sinkar for remove sequntial DAR validation in case of RSM & CA activity(end)
					//alert("totAllwCallList::"+totAllwCallList+" listCnt::"+listCnt);
					//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm Start
					if( activityCode == 'MI' || activityCode == 'OT' )
					{
						DocsurveyTemp = activityTemplate;
					}
					console.log("activityCode ["+ activityCode+"] activityTemplate ["+ activityTemplate +"]");
					//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm End
					//Added by Amey W. [OT activity related implementation] on 18/02/2020OfAttchments
					if( activityCode == 'OT' && ( custConf == 'Y' || custConf == 'y' ) )
					{
						if( !attachmentFlag )
						{
							console.log("Attachment is mendatory!");
							alert("Consent attachment is mendatory!");
							isValidWfData=false;
							return isValidWfData;
						}
					}
					var listGroup=strgTypeList.split(",");
					for(var i=0; i<listGroup.length; i++)
					{
						var dcrGrouplist = listGroup[i].trim();

						if(dcrGrouplist == strgCustType)
						{

							custFlag=true;
						}
					}
					// added by rupali on 16/07/19 to validate survey question [end]
					//alert("gradeType:::::"+gradeType);
					if(action == 'finish' || action == 'DEFAULT_DATA_WIZ')
					{
						if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
						{
							var defSalesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
							if(defSalesPers == 'null' || defSalesPers.trim().length == 0)
							{
								alert("Blank Sales Person! Sales person cannot be blank");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
						{
							var eventDate=detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
							var currentDate = new Date();

							eventDateNew = eventDate;
							if(eventDate=='null' || eventDate.trim().length == 0)
							{
								//alert("Blank Event Date! Event Date Cannot Be Null");
								alert("Blank Meeting Date! Meeting Date Cannot Be Null");
								isValidWfData=false;
								return isValidWfData;
							}

							if(eventDate.indexOf("-")!=-1 || eventDate.indexOf("/")!=-1)
							{
								var diffDays = getDaysBetweenTwoDates(eventDate,currentDate);

								var futureActArray = [];
								futureDateAct = futureDateAct.substring(1, futureDateAct.length-1);

								var futureDateActList = futureDateAct.split(',');
								for(var j=0;j < futureDateActList.length;j++)
								{
									var futureAct = futureDateActList[j].trim();
									futureActArray.push(futureAct);
								}
								//if(diffDays < 0 && (futureDate == 0 || futureDate.trim().length == 0)) // futureDate condition added by mrunalini sinakr to allow future event for particulat event_type on 03-april-2019(star)
								if(diffDays < 0 && futureActArray.indexOf(activityCode) == -1) // futureDate condition added by mrunalini sinakr to allow future event for particulat event_type on 03-april-2019(star)
								{
									alert("Future event! You can not create future Event");
									isValidWfData=false;
									return isValidWfData;
								}

								if(diffDays > allwDelayPrd)
								{
									//alert("Not Allow! Not Allow To Enter Report");
									alert("Reporting not allowed! You are not allowed to add report after allowed period");
									isValidWfData=false;
									return isValidWfData;
								}
							}

						}
						//added by mrunalini sinkar on 26-june-2018 (start)
						//Added by mrunalini sinkar for next plan date validation (start)
						if( detail.getElementsByTagName("next_plan_date")[0] != null && detail.getElementsByTagName("next_plan_date")[0].childNodes[0] != null )
						{
							var nextPlanDate=detail.getElementsByTagName("next_plan_date")[0].childNodes[0].nodeValue;
							if((eventDate.indexOf("-")!=-1 || eventDate.indexOf("/")!=-1) && (nextPlanDate.indexOf("-")!=-1 || nextPlanDate.indexOf("/")!=-1))
							{
								var daysDiff = getDiffDaysBwtDates(nextPlanDate,eveDate);
								if(daysDiff <= 0)
								{
									//alert("Invalid Plan Date! Plan date is less than event date");
									alert("Invalid Next Plan Meeting Date! Next Plan Meeting Date is less than event date");
									isValidWfData=false;
									return isValidWfData;
								}
							}
						}
						//Added by mrunalini sinkar for next plan date validation (end)

						if(placeRequired == 'Y')
						{				
							if( detail.getElementsByTagName("locality_code")[0] != null && detail.getElementsByTagName("locality_code")[0].childNodes[0] != null )
							{
								var localityCode=detail.getElementsByTagName("locality_code")[0].childNodes[0].nodeValue;
								if(localityCode=='null' || localityCode.trim().length == 0)
								{
									alert("Blank Locality! Locality Code Cannot Be Null");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if(gradeType == 'M')
							{
								if( detail.getElementsByTagName("visited_with")[0] != null && detail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
								{
									var visitedWith = detail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
									if(visitedWith == 'null' || visitedWith.trim().length == 0)
									{
										//alert("Blank Team! Worked with field can not be blank");
										alert("Blank Join Call with! Joint call with field can not be blank");
										isValidWfData=false;
										return isValidWfData;
									}
								}
							}
						}
						//added by mrunalini sinkar on 26-june-2018 (end)
						//if(strgType != "LISTED" && memberPresent!='Y' && routeType != 'M') 
						if(strgType != "LISTED" && memberPresent!='Y') // condition added bY mrunalini sinkar to throw the validation in case of unlisted customer on 23-01-2019
						{
							if(totAllwCallList != 0 && listCnt >= totAllwCallList && (strgType == 'UNLISTED-RETAILER' || strgType == 'UNLISTED-WHOLESALER'))
							{
								//alert("List of existing active customers is exceed! You are not allowed to add new customer");
								//alert("You are not allowed to add New Customer as you are already having 435 customers (Chemist + Wholesalers) in your outlet list. You need to deactivate few customers to add new one in your Outlet list");
								alert("You are not allowed to add New Customer as you are already having "+totAllwCallList+" customers (Chemist + Wholesalers) in your outlet list. You need to deactivate few customers to add new one in your Outlet list");
								isValidWfData=false;
								return isValidWfData;
							}
							if( detail.getElementsByTagName("strg_name")[0] != null && detail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
							{
								var strgNm = detail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
								if(strgNm == 'null' || strgNm.trim().length == 0)
								{
									alert("Blank Customer Name! Customer Name Cannot Be Null");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if( detail.getElementsByTagName("address_as")[0] != null && detail.getElementsByTagName("address_as")[0].childNodes[0] != null )
							{
								var addressAs=detail.getElementsByTagName("address_as")[0].childNodes[0].nodeValue;

								if(addressAs=='null' || addressAs.trim().length == 0)
								{
									//alert("Address As cannot be null! Please enter the address as");
									alert("Short/Friendly Name cannot be null! Please enter the Short/Friendly Name");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if( detail.getElementsByTagName("addr1")[0] != null && detail.getElementsByTagName("addr1")[0].childNodes[0] != null )
							{
								var addr1 = detail.getElementsByTagName("addr1")[0].childNodes[0].nodeValue;
								if(addr1 == 'null' || addr1.trim().length == 0)
								{
									//alert("Blank Address 1! Address 1 Cannot Be Null");
									alert("Blank Customer Address! Customer Address Cannot Be Null");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							//Added by prachi on 25/04/2022 start [ W22AGOC002 ]
							if( detail.getElementsByTagName("qualification")[0] != null && detail.getElementsByTagName("qualification")[0].childNodes[0] != null )
							{

								var qualification = detail.getElementsByTagName("qualification")[0].childNodes[0].nodeValue;
								console.log("Qualification value: ["+qualification.trim()+"] strgType["+strgType+"]");
								if(qualification == 'null' || qualification.trim().length == 0)
								{
									if(strgType=='UNLISTED-DOCTOR')
									{
										alert("Qualification Cannot Be Null For UNLISTED-DOCTOR");
										isValidWfData=false;
										return isValidWfData;
									}
								}
								else
								{
									console.log("qualification validation for : ["+qualification.trim()+"]");

									if((qualification.trim().length > 0) && QualificationArray.indexOf(qualification.trim()) == -1)
									{
										alert(" Entered Qualification Is Invalid ");
										isValidWfData=false;
										return isValidWfData;
									}	
								}
							}
							//Added by prachi on 25/04/2022 end [ W22AGOC002 ]

							//added by mrunalini sinkar to validation of invalid email_address[05-01-2019](start)
							if( detail.getElementsByTagName("email_addr")[0] != null && detail.getElementsByTagName("email_addr")[0].childNodes[0] != null)
							{
								var emailAddr=detail.getElementsByTagName("email_addr")[0].childNodes[0].nodeValue;
								if(emailAddr=='null' || emailAddr.trim().length == 0)
								{
									//commeneted by mrunalini sinkar to remove email id chanegs (start)
									/*alert("Blank Email Address! Email Address Cannot Be Null");
									isValidWfData=false;
									return isValidWfData;*/
									//commeneted by mrunalini sinkar to remove email id chanegs (end)
								}
								else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailAddr)))
								{
									alert("Invalid Email Address! Email Address is not valid");
									isValidWfData=false;
									return isValidWfData;
								}

							}
							//added by mrunalini sinkar to validation of invalid email_address[05-01-2019](end)

							if( detail.getElementsByTagName("mobile_no")[0] != null && detail.getElementsByTagName("mobile_no")[0].childNodes[0] != null )
							{
								var mobileNo = detail.getElementsByTagName("mobile_no")[0].childNodes[0].nodeValue;
								if(mobileNo == 'null' || mobileNo.trim().length == 0)
								{
									alert("Blank Mobile Number! Mobile Number Cannot Be Null");
									isValidWfData=false;
									return isValidWfData;
								}
								if(mobileNo.length < 10 || mobileNo.length > 10 || mobileNo.startsWith("0"))
								{
									alert("Invalid Mobile Number! Mobile Number is not valid");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if( detail.getElementsByTagName("strg_class_code")[0] != null && detail.getElementsByTagName("strg_class_code")[0].childNodes[0] != null )
							{
								var classCode = detail.getElementsByTagName("strg_class_code")[0].childNodes[0].nodeValue;

								if(classCode == 'null' || classCode.trim().length == 0)
								{
									alert("Class code cannot be null! Please enter the class code");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if( detail.getElementsByTagName("spl_code")[0] != null && detail.getElementsByTagName("spl_code")[0].childNodes[0] != null )
							{
								var speciality=detail.getElementsByTagName("spl_code")[0].childNodes[0].nodeValue;
								var customerType=detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								console.log("speciality is: ["+speciality+"] customerType is: ["+customerType+"]");
								if((speciality=='null' || speciality.trim().length == 0) && customerType=='D')
								{
									alert("Speciality is blank! Please select the speciality code");
									isValidWfData=false;
									return isValidWfData;
								}
							}
						}
						else if(strgType != "LISTED" && memberPresent=='Y')
						{
							if( detail.getElementsByTagName("member_present")[0] != null && detail.getElementsByTagName("member_present")[0].childNodes[0] != null )
							{
								var memberPr=detail.getElementsByTagName("member_present")[0].childNodes[0].nodeValue;

								if(memberPr=='null' || memberPr.trim().length == 0)
								{
									//alert("Member Present is blank! Please enter the Member Present");
									alert("No of Participants is blank! Please enter the No of Participants");
									isValidWfData=false;
									return isValidWfData;
								}
							}
						}
						if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
						{
							var eventType=detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;

							if(eventType=='null' || eventType.trim().length == 0)
							{
								//alert("Blank Activity! Activity Cannot Be Null");
								alert("Blank Activity  Type!Activity  Type Cannot Be Null");
								isValidWfData=false;
								return isValidWfData;
							}
							if(eventType.trim().length > 2)
							{
								alert("Invalid Activity  Type! Activity type should not be greater than 2 character");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						if( detail.getElementsByTagName("apply_stp_val")[0] != null && detail.getElementsByTagName("apply_stp_val")[0].childNodes[0] != null )
						{
							var applyStpVal = detail.getElementsByTagName("apply_stp_val")[0].childNodes[0].nodeValue;

							if(applyStpVal == 'Y')
							{
								alert("Resubmit STP! STP in draft mode, Please get the STP approved first.");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						if( detail.getElementsByTagName("emp_join_date")[0] != null && detail.getElementsByTagName("emp_join_date")[0].childNodes[0] != null )
						{
							empJoinDate = detail.getElementsByTagName("emp_join_date")[0].childNodes[0].nodeValue;
							var daysDiff = getDiffDaysBwtDates(eventDateNew,empJoinDate);
							if(daysDiff < 0)
							{
								//alert("Invalid event date! You cannot submit report before joining date");
								alert("Invalid Meeting date! You cannot submit report before joining date");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						if( detail.getElementsByTagName("allow_dar_rep")[0] != null && detail.getElementsByTagName("allow_dar_rep")[0].childNodes[0] != null )
						{
							var allowDarRep = detail.getElementsByTagName("allow_dar_rep")[0].childNodes[0].nodeValue;
							if(allowDarRep == 'INVLIDMODE')
							{
								alert("Not allowed from mobile! You are not allowed to submit report from mobile");
								isValidWfData=false;
								return isValidWfData;
							}
							else if (allowDarRep == 'MOBNETNA')
							{
								alert("Reporting not allowed!	You are not allowed for the net reporting");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						if( detail.getElementsByTagName("meeting_status")[0] != null && detail.getElementsByTagName("meeting_status")[0].childNodes[0] != null )
						{
							var meetStatus = detail.getElementsByTagName("meeting_status")[0].childNodes[0].nodeValue;

							if(isForuneAct == 'Y')
							{
								if(actType == 'FW')
								{

									if(meetStatus == 'null' || meetStatus.trim().length == 0)
									{

										alert("Please Select Meeting Status");
										isValidWfData=false;
										return isValidWfData;
									}
									else
									{

										var valMeetingStatus=meetCallOutcome+"@"+activityCode;



										if(meetingStatusArray.indexOf(valMeetingStatus) == -1)
										{
											alert("Invalid Meeting Status! Please select proper one");
											isValidWfData=false;
											return isValidWfData;
										}

										if(subMeetingStatus != 'null' && subMeetingStatus.trim().length != 0)
										{
											if(meetStatus != subMeetingStatus)
											{
												alert("Meeting status is changed ! So Plese Again Select The Product Agsinst New Meeting Type");
												isValidWfData=false;
												return isValidWfData;
											}

										}
									}
								}
							}

						}
						if( detail.getElementsByTagName("contact_pers")[0] != null && detail.getElementsByTagName("contact_pers")[0].childNodes[0] != null )
						{
							var contactPerson = detail.getElementsByTagName("contact_pers")[0].childNodes[0].nodeValue;

							if(isForuneAct == 'Y')
							{

								if(contactPerson == 'null' || contactPerson.trim().length == 0)
								{

									//console.log("CONTACT_PERSON IS NULL");
								}
								else
								{

									var valEuinNoScCnt=scCode+"@"+euinCntPers;
									//console.log("valEuinNoScCnt validation of CONTACT_PERS::"+valEuinNoScCnt);
									//console.log("valEuinNoScCnt validation of strgType::"+strgType);
									//console.log("cntPersArray.indexOf(valEuinNoScCnt) Oth_participant::"+cntPersArray.indexOf(valEuinNoScCnt));
									//console.log("unlstScCodeArray.indexOf(scCode) Oth_participant::"+unlstScCodeArray.indexOf(scCode));
									//console.log("cntPersCdArray.indexOf(euinCntPers) for val::"+cntPersCdArray.indexOf(euinCntPers));
									if(cntPersArray.indexOf(valEuinNoScCnt) == -1 && (strgType == "LISTED" || unlstScCodeArray.indexOf(scCode) !== -1))
									{
										alert("Invalid Contact Person! Please select proper From pophelp");
										isValidWfData=false;
										return isValidWfData;
									}
									if(strgType != "LISTED" && unlstScCodeArray.indexOf(scCode) == -1)
									{
										if(euinCntPers !='null' && cntPersCdArray.indexOf(euinCntPers) !== -1 && euinCntPers.trim().length == 7)
										{
											alert("Duplicate EUIN no!EUIN no already exist against other customer.Please select other.");
											isValidWfData=false;
											return isValidWfData;
										}
										if(euinCntPers !='null' && euinCntPers.trim().length <7)
										{
											alert("Contact Person Invalid! contact person length should be 7");
											isValidWfData=false;
											return isValidWfData;
										}
										else if(euinCntPers !='null' && euinCntPers.trim().length > 7)
										{
											alert("Contact Person Invalid! contact person length should be 7");
											isValidWfData=false;
											return isValidWfData;

										}
										else if(!(/^([E][0-9]{1,6})+$/.test(euinCntPers)))
										{
											alert("Contact Person Invalid! Should be start with E and followed by 6 digit");
											isValidWfData=false;
											return isValidWfData;
										}

									}
								}
							}

						}
						if(action == 'finish')
						{
							var callOutcome="";
							var meetSumm="";
							var docType="",customerType="",eventTypeValue="",totalAmount="";
							var formMandatory = "", mandatoryFormList = "",pobItem= 0;
							// added by rupali on 23/08/18 for applying E-detailing validation for vacant team only in case of manager reporting [start]
							var gradeType = "",genralRemark="";
							var visitedWith = "", routeId = "",planChgReason="",planChgReasonDescr="";
							// added by rupali on 23/08/18 for applying E-detailing validation for vacant team only in case of manager reporting [end]
							if( detail.getElementsByTagName("call_outcome")[0] != null && detail.getElementsByTagName("call_outcome")[0].childNodes[0] != null )
							{
								callOutcome=detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("meet_summ")[0] != null && detail.getElementsByTagName("meet_summ")[0].childNodes[0] != null )
							{
								meetSumm=detail.getElementsByTagName("meet_summ")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
							{
								docType=detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								teamDocType=docType;
							}
							// added by rupali on 23/08/18 for applying E-detailing validation for vacant team only in case of manager reporting [start]
							if( detail.getElementsByTagName("grade_type")[0] != null && detail.getElementsByTagName("grade_type")[0].childNodes[0] != null )
							{
								gradeType = detail.getElementsByTagName("grade_type")[0].childNodes[0].nodeValue;
								console.log("gradeType is:::"+gradeType);
							}
							if( detail.getElementsByTagName("visited_with")[0] != null && detail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
							{
								visitedWith = detail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
								console.log("visited with is:::"+visitedWith);
							}
							if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
							{
								customerType=detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
							{
								eventTypeValue=detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
							}
							// added by rupali on 23/08/18 for applying E-detailing validation for vacant team only in case of manager reporting [end]
							if( detail.getElementsByTagName("form_mandatory")[0] != null && detail.getElementsByTagName("form_mandatory")[0].childNodes[0] != null )
							{
								formMandatory = detail.getElementsByTagName("form_mandatory")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("pob_item")[0] != null && detail.getElementsByTagName("pob_item")[0].childNodes[0] != null )
							{
								pobItem = detail.getElementsByTagName("pob_item")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cust_conf")[0] != null && detail.getElementsByTagName("cust_conf")[0].childNodes[0] != null )
							{
								custConf = detail.getElementsByTagName("cust_conf")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cust_conf_proof")[0] != null && detail.getElementsByTagName("cust_conf_proof")[0].childNodes[0] != null )
							{
								custConfProof = detail.getElementsByTagName("cust_conf_proof")[0].childNodes[0].nodeValue;
							}
							//Added by Pankaj R
							if( detail.getElementsByTagName("route_id")[0] != null && detail.getElementsByTagName("route_id")[0].childNodes[0] != null )
							{
								routeId=detail.getElementsByTagName("route_id")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("plan_chg_reas")[0] != null && detail.getElementsByTagName("plan_chg_reas")[0].childNodes[0] != null )
							{
								planChgReason=detail.getElementsByTagName("plan_chg_reas")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("plan_chg_reason_descr")[0] != null && detail.getElementsByTagName("plan_chg_reason_descr")[0].childNodes[0] != null )
							{
								planChgReasonDescr=detail.getElementsByTagName("plan_chg_reason_descr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("remarks")[0] != null && detail.getElementsByTagName("remarks")[0].childNodes[0] != null )
							{
								genralRemark=detail.getElementsByTagName("remarks")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("amount")[0] != null && detail.getElementsByTagName("amount")[0].childNodes[0] != null )
							{
								totalAmount=detail.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
							}


							//Added by Pankaj R			
							console.log('custConf is['+custConf+'] custConfProof ['+custConfProof);
							if(( custConf != null && custConf == 'Y' ) && (custConfProof == null  || custConfProof.trim().length == 0))
							{
								console.log('custConfProof is['+custConfProof+'] ');
								alert( "Consent attachment is mendatory!" );
								isValidWfData=false;
								return isValidWfData;
							}
							mandatoryFormList = formMandatory.split(',');
							if( eventTypeValue == 'OT' )
							{
								console.log('attchments ['+ attchments +'] pobItem['+ pobItem +']');
								if( attchments != pobItem )
								{
									alert( "Meter purchased are not match with details." );
									isValidWfData=false;
									return isValidWfData;
								}
							}
							//added by mrunalini sinkar on 11-june-2018 To remove blank call note validation(start)
							if(actType == 'FW' && action == 'finish')
							{
								if(callOutcome != '0' && callOutcome != '9')
								{
									if(meetSumm.trim().length == 0)
									{
										//alert("Blank Call Notes! Call Notes Can Not Be Blank");
										//isValidWfData=false;
										//return isValidWfData;

									}
								}
							}
							//added by mrunalini sinkar on 11-june-2018 To remove blank call note validation(end)
							if(updateFlg==true)
							{
								//console.log("Inside updateFlg is true");
								if((callOutcome ==='0' || callOutcome ==='9') && (teamFlg == false || orderFlg == false || brandFlg == false ||displayFlg== false || surveyFlg == false || collectionFlg== false || invoiceFlg==false))
								{
									alert("Delete subform ! For refused call outcome can not select subform");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							else
							{
								//console.log("Inside updateFlg is false");
								if((addModeCallOutCm !='0' && addModeCallOutCm !='9') && (collectionFlg== true || invoiceFlg==true) && (editCollectFlg== true || editInvoiceFlg==true))
								{
									if(callOutcome ==='0' || callOutcome ==='9')
									{
										alert("Delete subform ! For refused call outcome can not select subform");
										isValidWfData=false;
										return isValidWfData;
									}
								}
								else if(((callOutcome ==='0' || callOutcome ==='9') && (teamFlg == false || orderFlg == false || brandFlg == false ||displayFlg== false || surveyFlg == false || collectionFlg== false || invoiceFlg==false) && updateFlg==false))
								{
									alert("Delete subform ! For refused call outcome can not select subform");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if((stockCde =='null' || stockCde.trim().length == 0) && orderFlg == false)
							{
								//alert("Blank Preffered Stockist! Preffered Stockist Can not Be Blank");
								alert("Blank Preferred Stockist for Supply! Preferred Stockist for Supply Can not Be Blank");
								isValidWfData=false;
								return isValidWfData;
							}
							if(planChgReason!=null && planChgReason.trim().length > 0)
							{
								//planChgReasonDescr=planChgReasonDescr.toUpperCase();
								if(planChgReason == "5")
								{
									if(genralRemark==null || genralRemark.trim().length == 0)
									{
										alert("Remark field is mandatory for reason of beat change is other");
										isValidWfData=false;
										return isValidWfData;
									}

								}
							}
							if(mandatoryFormList.indexOf("brand") !== -1)
							{
								if((callOutcome != '0' && callOutcome != '9') && docType== 'D' && actType == 'FW' && brandFlg== true && routeType != 'M')
								{
									if( ((gradeType != 'M') || (gradeType == 'M' && visitedWith == 'SELF')) && eventTypeValue != 'OT' ) // added by rupali on 23/08/18 for applying E-detailing validation for vacant team only in case of manager reporting
									{
										alert("E-detailing form is mandatory ! Please select the E-Detaling form");
										isValidWfData=false;
										return isValidWfData;
									}
								}
							}
							//Added by Pooja on 14-AUGUST-2020 [Coaching related detail form implementation] start
							if( (actType == 'FW' || actType == 'CA') && gradeType == 'M' && visitedWith != 'SELF' && coachingFlg == true && action == 'finish' )
							{
								if( mandatoryFormList.indexOf("coaching") !== -1 )
								{
									alert("Coaching form is mandatory ! Please select the Coaching form");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							//Added by Pooja on 14-AUGUST-2020 [Coaching related detail form implementation] End
							if(actType == 'CA' && action == 'finish' && coachingFlg == true )
							{
								if( gradeType == 'M' && visitedWith != 'SELF' )
								{
									alert("Coaching form is mandatory ! Please select the Coaching form");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if(mandatoryFormList.indexOf("survey") !== -1)
							{
								if((callOutcome != '0' && callOutcome != '9') && surveyFlg== true)
								{
									if(customerType!=null && customerType.indexOf("-")!=-1)
									{
										customerType=customerType.substring(0,customerType.indexOf("-"));
									}
									var toChkSurv = designCode+":"+docType;
									var ismandatory=isTeamSubformMandatory(toChkSurv);
									if(ismandatory == true)
									{
										alert("Survey form is mandatory ! Please select the Survey form");
										isValidWfData=false;
										return isValidWfData;
									}
								}
							}

							if(mandatoryFormList.indexOf("team") !== -1)
							{
								if((callOutcome != '0' && callOutcome != '9') && teamFlg== true)
								{
									var toChkSurv = designCode+":"+docType;

									var ismandatory=isTeamSubformMandatory(toChkSurv);
									if(ismandatory == true)
									{
										alert("Team form is mandatory ! Please select the Team form");
										isValidWfData=false;
										return isValidWfData;
									}
								}
							}
							//start added by prachi on 14-sep-2022
							if(mandatoryFormList.indexOf("invoice") !== -1)
							{
								if(updateFlg == true)
								{
									//console.log("inside invoice1");
									if(invoiceFlg== true && updateFlg == true) 
									{
										if(callOutcome != '0' && callOutcome != '9')
										{
											//console.log("inside invoice2");
											alert("Invoice form is mandatory ! Please select the Invoice form");
											isValidWfData=false;
											return isValidWfData;
										}
									}
								}
								else
								{
									//console.log("inside invoice3");
									if((addModeCallOutCm =='0' || addModeCallOutCm =='9') && invoiceFlg== true && updateFlg == false) 
									{
										if(callOutcome != '0' && callOutcome != '9')
										{
											//console.log("inside invoice4");
											alert("Invoice form is mandatory ! Please select the Invoice form");
											isValidWfData=false;
											return isValidWfData;
										}
									}
								}
								
							}

							//console.log("before coll mandatory validation");

							if(mandatoryFormList.indexOf("collection") !== -1)
							{
								if(updateFlg == true)
								{
									//console.log("inside collection1");
									if(collectionFlg== true && updateFlg == true) 
									{
										if(callOutcome != '0' && callOutcome != '9')
										{
											//console.log("inside collection2");
											alert("Collection form is mandatory ! Please select the Collection form");
											isValidWfData=false;
											return isValidWfData;
										}
									}
								}
								else
								{
									//console.log("inside collection3");
									if((addModeCallOutCm =='0' || addModeCallOutCm =='9') && collectionFlg== true && updateFlg == false) 
									{
										if(callOutcome != '0' && callOutcome != '9')
										{
										//console.log("inside collection4");
										alert("Collection form is mandatory ! Please select the Collection form");
										isValidWfData=false;
										return isValidWfData;
									}
									}
									//console.log("before coll mandatory validation2");
									if(editCollectFlg== false && updateFlg == false) 
									{
										if(callOutcome != '0' && callOutcome != '9')
										{
											//console.log("inside collection4");
											alert("Collection form is mandatory ! Please select the Collection form before click on finish");
											isValidWfData=false;
											return isValidWfData;
										}
									}
								}
								
							}
							console.log("collectionFlg:"+collectionFlg+" totalAmount:"+totalAmount+" billAmountGlobal:"+billAmountGlobal);
							if(updateFlg == true)
							{
								//console.log("inside totalAmount");
								if(collectionFlg==false && (totalAmount!=null && totalAmount.trim().length>0) && updateFlg == true)
								{
									//console.log("inside totalAmount1");
									if(totalAmount!=billAmountGlobal)
									{
										console.log("inside totalAmount2");
										alert("Amount entered in Collection form should be same as Bill Amount");
										isValidWfData=false;
										return isValidWfData;
									}
								}
							}
							else
							{
								//console.log("inside totalAmount3");
								if(totalAmount!=billAmountGlobal && updateFlg == true)
								{
									if(callOutcome != '0' && callOutcome != '9')
									{
										//console.log("inside totalAmount4");
										alert("Amount entered in Collection form should be same as Bill Amount");
										isValidWfData=false;
										return isValidWfData;
									}
								}

							}
							//end added by prachi on 14-sep-2022
						}
						// added by rupali on 11/09/18 for applying validation for distance limit variance [start]
						var taggedLoc = "";
						var reportingLoc = "";
						var varDistance = "";
						var allwDelyPrd = "";
						var eventDate = "";
						var locReq = "";
						var eventTypeVal = "";
						var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
						console.log("attributeVal is:::"+attributeVal);
						if( detail.getElementsByTagName("variance_distance")[0] != null && detail.getElementsByTagName("variance_distance")[0].childNodes[0] != null )
						{
							varDistance = detail.getElementsByTagName("variance_distance")[0].childNodes[0].nodeValue;
							console.log("varDistance is:::"+varDistance);
						}
						//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(start)
						if( detail.getElementsByTagName("allwd_delay_prd")[0] != null && detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0] != null )
						{
							allwDelyPrd = detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0].nodeValue;
							console.log("allwDelyPrd is:::"+allwDelyPrd);
						}
						if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
						{
							eventDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
							console.log("eventDate is:::"+eventDate);
						}
						//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] START
						if( detail.getElementsByTagName("loc_req")[0] != null && detail.getElementsByTagName("loc_req")[0].childNodes[0] != null )
						{
							locReq = detail.getElementsByTagName("loc_req")[0].childNodes[0].nodeValue;
						}
						console.log( "751 locReq is::: ["+ locReq +"], actType : ["+ actType +"]" );
						if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
						{
							eventTypeVal = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
						}
						console.log( "eventTypeVal ::: ["+ eventTypeVal +"]" );
						//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] END
						//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(end)
						// changes made by rupali on 28-02-19 as suggested by gulzar sir
						//if(varDistance.trim().length > 0 && actType == 'FW' && attributeVal != 'E' )
						var currentDate = new Date();
						var diffDays = getDaysBetweenTwoDates(eventDate,currentDate);
						//Added by mrunalini sinkar for banglasdesh user validation(start)
						if(isBangla== 'Y' && diffDays== 0 && branAval== 'false')
						{
							alert("Not allow to submit Dar! \nYou are not Allow to submit DAR for This Month");
							isValidWfData=false;
							return isValidWfData;
						}
						//Added by mrunalini sinkar for banglasdesh user validation(end)
						//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table]
						if(varDistance.trim().length > 0 && actType == 'FW' && locReq != "0" && eventTypeVal != "TC" )
						{
							//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(start)

							//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(end)
							if( detail.getElementsByTagName("tag_geopos")[0] != null && detail.getElementsByTagName("tag_geopos")[0].childNodes[0] != null )
							{
								taggedLoc = detail.getElementsByTagName("tag_geopos")[0].childNodes[0].nodeValue;
								console.log("Tagged Location is:::"+taggedLoc);
							}
							if( detail.getElementsByTagName("add_geopos")[0] != null && detail.getElementsByTagName("add_geopos")[0].childNodes[0] != null )
							{
								reportingLoc = detail.getElementsByTagName("add_geopos")[0].childNodes[0].nodeValue;
								console.log("Reporting Location is:::"+reportingLoc);
							}

							if( taggedLoc.trim().length == 0)
							{
								alert("Customer Not Tagged! \nThis customer is not tagged,Please do the customer tagging first");
								isValidWfData=false;
								return isValidWfData;
							}
							//Modified by Mrunalini Sinkar for allw_delay_prd on 03-10-2018
							//else if( taggedLoc.trim().length > 0 && reportingLoc.trim().length > 0 )
							else if( taggedLoc.trim().length > 0 && reportingLoc.trim().length > 0  && (allwDelyPrd < diffDays || diffDays==0))
							{
								var distanceinMtr = getDistanceFromLatLonInMtr( taggedLoc.split(",")[0], taggedLoc.split(",")[1], reportingLoc.split(",")[0], reportingLoc.split(",")[1] );
								console.log("distanceinMtr is:::"+distanceinMtr);
								if(distanceinMtr > varDistance)
								{
									alert("Invalid Reporting Location! \nYou are reporting greater than the expected limit (500 meter)");
									isValidWfData=false;
									return isValidWfData;
								}
							}
						}
						// added by rupali on 11/09/18 for applying validation for distance limit variance [end]

						if(actType == 'FW')
						{
							if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
							{
								var custType=detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
								if(custType=='null' || custType.trim().length == 0)
								{
									alert("Null Cust Type! Customer type can not be blank");
									isValidWfData=false;
									return isValidWfData;
								}
								//added by shraddha M for stockist [03-09-19:start]
								else if(custType!=null && custType.trim().length > 0)
								{
									if(strgCustType=='S' &&  realparamdata=='N')
									{
										alert("Not Allow! Not allow to select Stockist");
										isValidWfData=false;
										break;
									}
									if(custTypeDataArray.indexOf(custType)==-1)
									{
										alert("Invalid Customer Type! Please Enter valid Customer Type");
										isValidWfData=false;
										return isValidWfData;
									} 
								}
								//added by shraddha M for stockist [03-09-19:end]
							}
							//commented by mrunalini sinkar on 26-june-2018 (start)
							/*if( detail.getElementsByTagName("locality_code")[0] != null && detail.getElementsByTagName("locality_code")[0].childNodes[0] != null )
							{
								var localityCode=detail.getElementsByTagName("locality_code")[0].childNodes[0].nodeValue;
								if(localityCode=='null' || localityCode.trim().length == 0)
								{
									alert("Blank Locality! Locality Code Cannot Be Null");
									isValidWfData=false;
									return isValidWfData;
								}
							}*/
							//commented by mrunalini sinkar on 26-june-2018 (end)

							if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
							{
								strgCode=detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
								if(strgCode=='null' || strgCode.trim().length == 0)
								{
									//if condition of route_type not 'H' and 'M' removed by prachi on 08-06-2022 [W22BGOC003]
									alert("Blank Customer Code! Customer Code Cannot Be Null");
									isValidWfData=false;
									return isValidWfData;

								}
								//added by shraddha M for stockist [03-09-19:start]
								else if(strgCode!=null && strgCode.trim().length > 0)
								{
									if(strgCustType=='S' &&  realparamdata=='N')
									{
										alert("Not Allow! Not allow to select Stockist");
										isValidWfData=false;
										break;
									}
								}
								//added by shraddha M for stockist [03-09-19:end]
							}
							if( detail.getElementsByTagName("visit_time_from")[0] != null && detail.getElementsByTagName("visit_time_from")[0].childNodes[0] != null )
							{
								var visitTimeFrom=detail.getElementsByTagName("visit_time_from")[0].childNodes[0].nodeValue;
								if(visitTimeFrom=='null' || visitTimeFrom.trim().length == 0)
								{
									alert("Blank visit time from! Visit time from cannot be blank");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if( detail.getElementsByTagName("event_time_start")[0] != null && detail.getElementsByTagName("event_time_start")[0].childNodes[0] != null )
							{
								var eventTimeStart=detail.getElementsByTagName("event_time_start")[0].childNodes[0].nodeValue;
								if(eventTimeStart=='null' || eventTimeStart.trim().length == 0)
								{
									alert("Blank visit time from! Visit time from cannot be blank");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if( detail.getElementsByTagName("event_time_end")[0] != null && detail.getElementsByTagName("event_time_end")[0].childNodes[0] != null )
							{
								var eventTimeEnd=detail.getElementsByTagName("event_time_end")[0].childNodes[0].nodeValue;
								if(eventTimeEnd=='null' || eventTimeEnd.trim().length == 0)
								{
									alert("Blank visit time to! Visit time to cannot be blank:");
									isValidWfData=false;
									return isValidWfData;
								}
								else
								{
									var retFlag = true;
									var startTimeStr = detail.getElementsByTagName("event_time_start")[0].childNodes[0].nodeValue;
									retFlag = validateEndTime(startTimeStr, eventTimeEnd);
									if (!retFlag)
									{
										alert("Invalid Time! Visit Start Time can not be Greater Visit End Time");
										isValidWfData = false;
										return isValidWfData;
									}
								}
							}
							if( detail.getElementsByTagName("oth_participant")[0] != null && detail.getElementsByTagName("oth_participant")[0].childNodes[0] != null )
							{
								var otherParticipant=detail.getElementsByTagName("oth_participant")[0].childNodes[0].nodeValue;

								if(otherParticipant.trim().length > 120)
								{
									//alert("Invalid Work With Other Name! Work with other Name should not be more than 120 Character");
									alert("Invalid Other Participants! Other Participants should not be more than 120 Character");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							/*if( detail.getElementsByTagName("address_as")[0] != null && detail.getElementsByTagName("address_as")[0].childNodes[0] != null )
							{
								var addressAs=detail.getElementsByTagName("address_as")[0].childNodes[0].nodeValue;

								if(addressAs=='null' || addressAs.trim().length == 0)
								{
									alert("Address As cannot be null! Please enter the address as");
									isValidWfData=false;
									return isValidWfData;
								}
							}*/
							if( detail.getElementsByTagName("spl_code")[0] != null && detail.getElementsByTagName("spl_code")[0].childNodes[0] != null )
							{
								var specialityListed=detail.getElementsByTagName("spl_code")[0].childNodes[0].nodeValue;
								var customerTypeListed=detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								console.log("speciality is: ["+specialityListed+"] customerType is: ["+customerTypeListed+"]");
								if((specialityListed=='null' || specialityListed.trim().length == 0) && customerTypeListed=='D' && strgType=="LISTED")
								{
									alert("Speciality is blank! Please select the speciality code");
									isValidWfData=false;
									return isValidWfData;
								}
							}
						}
						if(!isAutoEdit)
						{
							oldActType = localStorage.getItem(eventDateNew+'_ActivityType');
							parentActVal = localStorage.getItem(eventDateNew+'_ParentActivityCode');
							if((oldActType == null || oldActType.trim().length == 0) && action == 'finish')
							{
								//Added by Bhagyashri T for Activity Place[28/JUL/21][start]
								if(activityPlace != 'R')
								{	
									localStorage.setItem(eventDateNew+'_ActivityType', newActType);
									//Added by mrunalini sinkar for showing previous code and activity descr(start)
									localStorage.setItem(eventDateNew+'_ActivityCode', newActCode);
									localStorage.setItem(eventDateNew+'_ActivityDescr', newActDescr);
									localStorage.setItem(eventDateNew+'_ActivityPlaceReq', newPlaceRequired);
									//Added by mrunalini sinkar for showing previous code and activity descr(end)
									localStorage.setItem(eventDateNew+'_ParentActivityCode', newParentActCode);
									localStorage.setItem(eventDateNew+'_ActivityTemplate', newActivityTempl);
									//Added by Sadique on 27/06/2020 [loc_req related implementation]
									localStorage.setItem(eventDateNew+'_LocReq', locReq);
									localStorage.setItem(eventDateNew+'_ActivityActPlace', newActivityPlace);  //Added by Bhagyashri T for Activity Place[28/JUL/21]
								}
								//Added by Bhagyashri T for Activity Place[28/JUL/21][end]                          						
							}
							else if(oldActType != null && oldActType.trim().length != 0  && oldActType != actType)
							{
								alert("Different Activity ! You can not change Activity. You have already reported calls on this day for some other Activity");
								isValidWfData=false;
								return isValidWfData;
							}
							else if(parentActVal != null && parentActVal.trim().length != 0  && parentActVal != parentActCode )
							{
								alert("Different Parent Activity ! You can not change Activity. You have already reported calls on this day for some other Activity");
								isValidWfData=false;
								return isValidWfData;
							}
							else if(oldActType != "FW" && oldActType == actType)
							{
								if(oldActType == "LEAVE")
								{
									alert("Aleready Enter Leave ! Not Allow To Enter Leave On Same Day");
									isValidWfData=false;
									return isValidWfData;
								}
								else
								{
									alert("Aleready Enter NFW ! Not Allow To Enter NFW On Same Day");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							// added by mrunalini sinkar for pending dcr date validation 05-april-2019(start)
							if(seqentialDar)
							{
								var diffoldtDays ="";
								oldEventDate = localStorage.getItem(salesPerson+'_eventDate');
								if(oldEventDate != null && oldEventDate.trim().length != 0)
								{

									if(pendingDcr != null && pendingDcr.length > 0)
									{
										var dateList = oldEventDate.split(',');
										pendingDcr = pendingDcr.substring(1, pendingDcr.length-1);
										var pendDaysList = pendingDcr.split(',');
										var pendingList=[];
										for(var c=0;c<pendDaysList.length;c++)
										{
											pendingList.push(pendDaysList[c].trim());
										}
										for(var pen = 0;pen < dateList.length;pen++)
										{

											var index = pendingList.indexOf(dateList[pen]);


											if (index > -1)
											{
												pendingList.splice(index, 1);
											}
										}

										/*holiBetPen = holiBetPen.substring(1, holiBetPen.length-1);
										var holiList = holiBetPen.split(',');


										var hollArry=[];
										for(var j=0;j<holiList.length;j++)
										{
											hollArry.push(holiList[j].trim());
										}*/
										if(pendingList != null && pendingList.length > 0)
										{
											/*if(hollArry.indexOf(pendingList[0]) >-1)
											{
												pendingList.splice(pendingList[0], 1);
											}
											for(var i=0;i< hollArry.length;i++)
											{
												if(pendingList.indexOf(hollArry[i]))
												{
													var penIndex = pendingList.indexOf(hollArry[i]);
													if (penIndex > -1)
													{
														pendingList.splice(penIndex, 1);
													}
												}

											}*/
											var firstEle=pendingList[0];
											diffoldtDays = getDiffDaysBwtDates(eventDate,firstEle);
										}

										var arrayPen = [];
										for(var d=0;d < diffoldtDays;d++)
										{
											if(pendingList[d]!=null)
											{
												arrayPen.push(pendingList[d]);

											}
										}



										if(arrayPen != null && arrayPen.length > 0)
										{
											alert("Previous DCR is pending ! Sequential DCR is allowed , please do the report for pending DCR ["+arrayPen+"]");
											isValidWfData=false;
											return isValidWfData;
										}


									}

								}
								else
								{
									if(pendingDcr!=null && pendingDcr.trim().length != 0)
									{
										pendingDcr = pendingDcr.substring(1, pendingDcr.length-1);
										var pendingDaysList = pendingDcr.split(',');
										var pending = pendingDaysList[0].trim();
										var diffIntDays = getDiffDaysBwtDates(eventDate,pending);



										var arrayPen = [];
										for(var d=0;d < diffIntDays;d++)
										{
											if(pendingDaysList[d]!=null)
											{
												arrayPen.push(pendingDaysList[d].trim());
											}

										}
										/*holiBetPen = holiBetPen.substring(1, holiBetPen.length-1);
										var holArray=[];
										var holiList = holiBetPen.split(',');

										for(var i=0;i<holiList.length;i++)
										{
											if(arrayPen.indexOf(holiList[i].trim()))
											{
												var penIndex = arrayPen.indexOf(holiList[i].trim());
												if (penIndex > -1)
												{
													arrayPen.splice(penIndex, 1);
												}
											}

										}*/
										if(arrayPen != null && arrayPen.length > 0)
										{
											alert("Previous DCR is pending ! Sequential DCR is allowed , please do the report for pending DCR ["+arrayPen+"]");
											isValidWfData=false;
											return isValidWfData;
										}

									}
								}
							}
							// added by mrunalini sinkar for pending dcr date validation 05-april-2019(end)

							oldStrgCode = localStorage.getItem(eventDateNew+'_StrgCode');
							var oldStrgCodeRouteWise = localStorage.getItem(eventDateNew+'_'+routeId+'_StrgCode');
							if(oldStrgCode != null && oldStrgCode.trim().length != 0)
							{
								var custList = oldStrgCode.split(',');
								for(var i=0; i<custList.length; i++)
								{
									var customerCode = custList[i];
									if(customerCode == strgCode)
									{
										if( activityCode != 'CA' )
										{
											//alert("Customer already visited ! Selected customer is already visited");
											//isValidWfData=false;
											//return isValidWfData;
										}
									}
								}
							}
                           console.log("pk scCode::"+scCode+" StrgCodeArray:"+StrgCodeArray);
                           if( activityCode != 'CA' )
							{
							  if((scCode.trim().length > 0) && StrgCodeArray.indexOf(scCode.trim()) != -1)
							  {
							    // alert("Customer already visited ! Selected customer is already visited for today");
								 //isValidWfData=false;
								 //return isValidWfData;
							  }
							}
							//added by mrunalini sinkar for holiday validation 04-april-2019(start)
							var array =[];
							var isHoliday =true;
							if(holidayDate!=null && holidayDate.trim().length != 0)
							{
								holidayDate = holidayDate.substring(1, holidayDate.length-1);

								var holiList = holidayDate.split(',');
								for(var j=0;j < holiList.length;j++)
								{
									var holiday =holiList[j].trim();
									array.push(holiday);

								}
								if(array.indexOf(eventDate) != -1)
								{

									isHoliday = confirm("Today is Holiday ! Are you sure want to submit ");
									if(isHoliday == false)
									{
										isValidWfData=false;
										return isValidWfData;
									}

								}

							}
							//added by mrunalini sinkar for holiday validation 04-april-2019(end)
							if(action == 'finish')
							{
								if(oldStrgCode != null && oldStrgCode.trim().length != 0)
								{
									oldStrgCode = oldStrgCode + "," + strgCode;
									localStorage.setItem(eventDateNew+'_StrgCode', oldStrgCode);

								}
								else
								{
									localStorage.setItem(eventDateNew+'_StrgCode', strgCode);

								}

								if(oldStrgCodeRouteWise != null && oldStrgCodeRouteWise.trim().length != 0)
								{
									oldStrgCodeRouteWise = oldStrgCodeRouteWise + "," + strgCode;
									localStorage.setItem(eventDateNew+'_'+routeId+'_StrgCode', oldStrgCodeRouteWise); // Added by Pankaj R on 15-JUL-21 to store customer date and route wise in localstorage
								}
								else{
									localStorage.setItem(eventDateNew+'_'+routeId+'_StrgCode', strgCode); // Added by Pankaj R on 15-JUL-21 to store customer date and route wise in localstorage
								}

								if(oldEventDate != null && oldEventDate.trim().length != 0)
								{
									oldEventDate = oldEventDate + "," + eventDateNew;
									localStorage.setItem(salesPerson+'_eventDate', oldEventDate);
								}
								else
								{
									localStorage.setItem(salesPerson+'_eventDate', eventDateNew);

								}
							}
							if(action == 'finish')
							{
								var locCode = "", locDescr = "", custClassInput = "", stockistCode = "", stockistName = "", locDetails = "",routeId="",stationType="",stationdescr="",routeType="",invoiceNoD="";
								if( detail.getElementsByTagName("oth_participant")[0] != null && detail.getElementsByTagName("oth_participant")[0].childNodes[0] != null )
								{
									var othParticipant = detail.getElementsByTagName("oth_participant")[0].childNodes[0].nodeValue;
									localStorage.setItem(eventDateNew+'_OthParticipant', othParticipant);
								}
								if( detail.getElementsByTagName("locality_code")[0] != null && detail.getElementsByTagName("locality_code")[0].childNodes[0] != null )
								{
									locCode = detail.getElementsByTagName("locality_code")[0].childNodes[0].nodeValue;
								}
								if( detail.getElementsByTagName("locality_descr")[0] != null && detail.getElementsByTagName("locality_descr")[0].childNodes[0] != null )
								{
									locDescr = detail.getElementsByTagName("locality_descr")[0].childNodes[0].nodeValue;
								}
								if( detail.getElementsByTagName("cust_class_input")[0] != null && detail.getElementsByTagName("cust_class_input")[0].childNodes[0] != null )
								{
									custClassInput = detail.getElementsByTagName("cust_class_input")[0].childNodes[0].nodeValue;
								}
								if( detail.getElementsByTagName("stockist_code")[0] != null && detail.getElementsByTagName("stockist_code")[0].childNodes[0] != null )
								{
									stockistCode = detail.getElementsByTagName("stockist_code")[0].childNodes[0].nodeValue;
								}
								if( detail.getElementsByTagName("stockist_name")[0] != null && detail.getElementsByTagName("stockist_name")[0].childNodes[0] != null )
								{
									stockistName = detail.getElementsByTagName("stockist_name")[0].childNodes[0].nodeValue;
								}
								//added by mrunalini sinkar to set route id 27-04-2019 (start)
								if( detail.getElementsByTagName("route_id")[0] != null && detail.getElementsByTagName("route_id")[0].childNodes[0] != null )
								{
									routeId = detail.getElementsByTagName("route_id")[0].childNodes[0].nodeValue;
								}
								if( detail.getElementsByTagName("station_type")[0] != null && detail.getElementsByTagName("station_type")[0].childNodes[0] != null )
								{
									stationType = detail.getElementsByTagName("station_type")[0].childNodes[0].nodeValue;
								}
								//added by mrunalini sinkar to set route id 27-04-2019 (end)
								//added by mrunalini sinakr on 20-05-2019 for showing staion_descr on summary page(start)
								if( detail.getElementsByTagName("station_descr")[0] != null && detail.getElementsByTagName("station_descr")[0].childNodes[0] != null )
								{
									stationdescr = detail.getElementsByTagName("station_descr")[0].childNodes[0].nodeValue;
								}
								//added by mrunalini sinakr on 20-05-2019 for showing staion_descr on summary page(end)
								// added by mrunalini sinkar for getting route type 24-05-2019(start)
								if( detail.getElementsByTagName("route_type")[0] != null && detail.getElementsByTagName("route_type")[0].childNodes[0] != null )
								{
									routeType = detail.getElementsByTagName("route_type")[0].childNodes[0].nodeValue;
								}
								// added by mrunalini sinkar for getting route type 24-05-2019(end)
								// added by bhagyashri T for getting invoiceno29-11-2022(start)
								if( detail.getElementsByTagName("invoice_no")[0] != null && detail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
								{
									invoiceNoD = detail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
								}
								// added by bhagyashri T for getting invoiceno29-11-2022(end)
								locDetails = locCode +"|"+ locDescr +"|"+ custClassInput +"|"+ stockistCode +"|"+ stockistName +"|"+routeId+"|"+stationType+"|"+stationdescr+"|"+routeType+"|"+invoiceNoD;
								//alert("locDetails :::"+locDetails);
								//Added by Bhagyashri T for Activity Place[28/JUL/21][start]
								if(activityPlace != 'R')
								{
									localStorage.setItem(eventDateNew+'_LocalityDetails', locDetails);
								}
								//Added by Bhagyashri T for Activity Place[28/JUL/21][end]
								// added by rupali on 07/03/19 to set order of visit on summary screen [start]
								var maxOrderVisit = 0;
								maxOrderVisit = localStorage.getItem(eventDateNew+'_OrderOfVisit');
								maxOrderVisit++;
								var localtyCode = localStorage.getItem(eventDateNew+'_LocalityCode');
								var locDetail = "";
								var flag = false;

								//alert("localtyCode:::"+localtyCode);
								if(localtyCode != null && localtyCode.trim().length != 0)
								{
									var locList = localtyCode.split(',');
									for(var i=0; i<locList.length; i++)
									{
										var locCodeNew = locList[i].split('@')[0];
										var locOrder = locList[i].split('@')[1];
										if(locCodeNew == locCode)
										{
											flag = true;
											maxOrderVisit = locOrder;
										}
									}
									if(!flag)
									{
										locDetail = locCode+"@"+maxOrderVisit;
										localtyCode = localtyCode + "," + locDetail;
										localStorage.setItem(eventDateNew+'_LocalityCode', localtyCode);
										localStorage.setItem(eventDateNew+'_OrderOfVisit', maxOrderVisit);
									}
								}
								else
								{
									locDetail = locCode+"@"+maxOrderVisit;
									localStorage.setItem(eventDateNew+'_LocalityCode', locDetail);
									localStorage.setItem(eventDateNew+'_OrderOfVisit', maxOrderVisit);
								}
								// added by rupali on 07/03/19 to set order of visit on summary screen [end]
							}
						}
					}//antother if
				} //for
			} //if
			else if(objFormName === 'sampleorder')
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var elmSelected=0;
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					console.log("attributeVal is: ["+attributeVal+"]");

					if(attributeVal != 'D')
					{
						var quantity="",minQuantity="",remark="";
						var quan=0;
						var minQuan=0;
						var itemDescr="";
						var rate="";
						var rateInt=0;
						var orderQty="";
						var discount="";
						var promoPerc="";
						var stockQuan="",stockInfo="";
						var focusDeviRes="",remarksRes="";

						if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity=detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
						{
							itemDescr=detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
						{
							rate=detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("order_qty")[0] != null && detail.getElementsByTagName("order_qty")[0].childNodes[0] != null )
						{
							orderQty=detail.getElementsByTagName("order_qty")[0].childNodes[0].nodeValue;
						}
						//added by mrunalini sinkar on 10/04/2019 for  discoun & promo perc changes (start)
						if( detail.getElementsByTagName("disc_perc")[0] != null && detail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
						{
							discount=detail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("promo_perc")[0] != null && detail.getElementsByTagName("promo_perc")[0].childNodes[0] != null )
						{
							promoPerc=detail.getElementsByTagName("promo_perc")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("stock_qty")[0] != null && detail.getElementsByTagName("stock_qty")[0].childNodes[0] != null )
						{
							stockQuan=detail.getElementsByTagName("stock_qty")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("is_stock_info")[0] != null && detail.getElementsByTagName("is_stock_info")[0].childNodes[0] != null )
						{
							stockInfo = detail.getElementsByTagName("is_stock_info")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("min_quantity")[0] != null && detail.getElementsByTagName("min_quantity")[0].childNodes[0] != null )
						{
							minQuantity = detail.getElementsByTagName("min_quantity")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("remark_descr")[0] != null && detail.getElementsByTagName("remark_descr")[0].childNodes[0] != null )
						{
							remark = detail.getElementsByTagName("remark_descr")[0].childNodes[0].nodeValue;
						}
						//Added by Bhagyashri T on [21/08/21][start]
						if( detail.getElementsByTagName("focus_devi_reas")[0] != null && detail.getElementsByTagName("focus_devi_reas")[0].childNodes[0] != null )
						{
							focusDeviRes=detail.getElementsByTagName("focus_devi_reas")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("remarks_ord")[0] != null && detail.getElementsByTagName("remarks_ord")[0].childNodes[0] != null )
						{
							remarksRes=detail.getElementsByTagName("remarks_ord")[0].childNodes[0].nodeValue;
						}
						//Added by Bhagyashri T on [21/08/21][start]
						//added by mrunalini sinkar on 10/04/2019 for  discoun & promo perc changes (end)
						if(action == 'done')
						{
							if((quantity=='null' || quantity.trim().length == 0) && orderQty=="Y")
							{
								alert("Quantity can not null! Quantity is null for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							//alert("quantity : ["+ quantity +"], rate : ["+ rate +"], minQuantity : ["+ minQuantity +"]");
							quan= parseInt(quantity);
							rateInt=parseInt(rate);
							minQuan=parseInt(minQuantity);
							//alert("quan : ["+ quan +"], rateInt : ["+ rateInt +"], minQuan : ["+ minQuan +"]");
							if(quan<0)
							{
								alert("Invalid Quantity! Please enter valid quantity for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							if(quan==0 && (remark==null || remark.trim().length == 0))
							{
								alert("Invalid Quantity! Please select the appropriate focus deviation reason for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							if(quan!=null && quantity.trim().length >0)
							{
								if(quan<minQuan && (remark==null || remark.trim().length == 0))
								{
									alert("Order quantity is less than the defined quantity ["+minQuan+"],please select the reason for the deviation of "+itemDescr+" item");
									isValidWfData=false;
									return isValidWfData;
								}
								if(stockInfo === 'Y')
								{
									if(stockQuan =='null' || stockQuan.trim().length == 0)
									{
										alert("Blank Stock! Stock not entered for "+itemDescr+" item");
										isValidWfData=false;
										return isValidWfData;

									}
									else if(stockQuan<0)
									{
										alert("Invalid Stock Quantity! Please enter valid stock quantity for "+itemDescr+" item");
										isValidWfData=false;
										return isValidWfData;
									}
								}

							}
							if(rate=='null' || rate.trim().length == 0)
							{
								alert("Blank Rate ! Rate can not be blank for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							if(rateInt<=0)
							{
								alert("Invalid Rate! Rate can not be equal to or less than 0 for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							if(discount!=null && discount.trim().length > 0)
							{
								var discountFloat =parseFloat(discount);

								if(discountFloat > "100")
								{
									alert("Invalid Discount! Discount is greater than 100% for "+itemDescr+" item");
									isValidWfData=false;
									return isValidWfData;
								}

							}
							if(promoPerc!=null && promoPerc.trim().length > 0)
							{
								var promoPercFloat = parseFloat(promoPerc);

								if(promoPercFloat > "100")
								{
									alert("Invalid Scheme! Scheme is greater than 100% for "+itemDescr+" item");
									isValidWfData=false;
									return isValidWfData;
								}

							}
							//Added by bhagyashri t on [21/08/21][start]
							if(focusDeviRes!=null && focusDeviRes.trim().length > 0)
							{
								if(focusDeviRes == "6")
								{
									if(remarksRes==null || remarksRes.trim().length == 0)
									{
										alert("Remarks is mandatory for the selected reason 'Others'. Please put valid remarks for the "+itemDescr+" item");
										isValidWfData=false;
										return isValidWfData;
									}

								}
							}
							//Added by bhagyashri t on [21/08/21][end]
						}

						var childNode= detailElement[i];
						console.log("childNode sample order is:"+childNode);
						if(childNode.childNodes != null)
						{
							orderFlg=false;
							//break;
						}
						elmSelected++;
					}
				}
				if(elmSelected==0)
				{
					orderFlg=true;
				}
			}
			else if(objFormName === 'team')
			{
				console.log("Inside the team in wfval");
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var elmSelected=0;
				var teamHierarchy="";
				var membercodeArray=[];
				console.log("Inside team membercodeArray::"+membercodeArray);
				var contFlag=false;
				//var MemCodeList="";
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					if(attributeVal != 'D')
					{
						console.log("Inside the team in wfval of attribute not D");
						var memCode="",memName="",memType="",mobNo="",strgCd="",salespers="";
						if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							strgCd=detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
							strgCd=strgCd.trim();
							console.log("Inside the team strg_code is::"+strgCd);
						}
						if( detail.getElementsByTagName("team_hierarchy_list")[0] != null && detail.getElementsByTagName("team_hierarchy_list")[0].childNodes[0] != null )
						{
							teamHierarchy=detail.getElementsByTagName("team_hierarchy_list")[0].childNodes[0].nodeValue;


						}
						if( detail.getElementsByTagName("member_type")[0] != null && detail.getElementsByTagName("member_type")[0].childNodes[0] != null )
						{
							memType=detail.getElementsByTagName("member_type")[0].childNodes[0].nodeValue;
							memType=memType.trim();
						}
						if( detail.getElementsByTagName("mem_code")[0] != null && detail.getElementsByTagName("mem_code")[0].childNodes[0] != null )
						{
							memCode=detail.getElementsByTagName("mem_code")[0].childNodes[0].nodeValue;
							memCode=memCode.trim();
						}
						if( detail.getElementsByTagName("member_name")[0] != null && detail.getElementsByTagName("member_name")[0].childNodes[0] != null )
						{
							memName=detail.getElementsByTagName("member_name")[0].childNodes[0].nodeValue;
							memName=memName.trim();
						}
						if( detail.getElementsByTagName("team_mobile_no")[0] != null && detail.getElementsByTagName("team_mobile_no")[0].childNodes[0] != null )
						{
							mobNo=detail.getElementsByTagName("team_mobile_no")[0].childNodes[0].nodeValue;
							mobNo=mobNo.trim();
						}
						if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
						{
							salespers=detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
							salespers=salespers.trim();


						}
						/*if( detail.getElementsByTagName("mem_code_data")[0] != null && detail.getElementsByTagName("mem_code_data")[0].childNodes[0] != null )
						{
							MemCodeList = detail.getElementsByTagName("mem_code_data")[0].childNodes[0].nodeValue;
							MemCodeList = MemCodeList.substring(1, MemCodeList.length-1);
							console.log("inside MemCodeList field arry :::"+MemCodeList) ;
						}
						var memCodeFinalList = MemCodeList.split(',');
						var memCodeCntArray=[];

						for(var n=0;n < memCodeFinalList.length;n++)
						{
							var MemTypeCd = memCodeFinalList[n].trim();
							memCodeCntArray.push(MemTypeCd);
						}
						console.log("inside the memCodeCntArray arry for validation:::"+memCodeCntArray) ;*/
						var hierarchyList = teamHierarchy.split(',');

						if(hierarchyList.indexOf(salespers) == -1)
						{
							contFlag=true;
						}

						if(action == 'done')
						{
							console.log("GRADE teamGrdTyp subform Team==> "+teamGrdTyp);
							if(teamGrdTyp !='M')
							{
								if(memCode=='null' || memCode.trim().length == 0)
								{
									if(memType =="C" || memType =="E")
									{
										alert("Member code should not null! MemberCode is null for "+memType+" member Type");
										isValidWfData=false;
										return isValidWfData;
									}
								}
								else
								{
									if(memType =="C" || memType =="E")
									{
										if(membercodeArray.indexOf(memCode) == -1)
										{
											console.log("Inside membercodeArray before::"+membercodeArray);
											membercodeArray.push(memCode);	
										}
										else
										{
											alert("Duplicate member code for "+memType+" member Type and "+memCode+" Member code");
											isValidWfData=false;
											return isValidWfData;
										}
										console.log("Inside membercodeArray after::"+membercodeArray);
									}
								}
								if(memName==null || memName.trim().length == 0)
								{
									if(memType.trim() =="R" || memType.trim() =="O")
									{

										alert("Member Name should not null! MemberName is null for "+memType+" member Type");
										isValidWfData=false;
										return isValidWfData;
									}

								}
								if(mobNo==null || mobNo.trim().length == 0)
								{
									if(hierarchyList.indexOf(salespers) == -1)
									{
										alert("Mobile Number should not null! Mobile Number is null for["+memName+"]");
										isValidWfData=false;
										return isValidWfData;
									}
								}

								if(mobNo !=null && mobNo.trim().length > 0)
								{
									if(mobNo.length < 10 || mobNo.length > 10)
									{
										alert("Invalid Mobile Number! Mobile Number is not valid for "+memType+" member Type");
										isValidWfData=false;
										return isValidWfData;
									}
								}
							}
						}
						var childNode= detailElement[i];
						console.log("childNode team is as in last:"+childNode);
						/*if(childNode.childNodes != null)
						{
							teamFlg=false;
							//break;
						}*/
						//Added by bhagyashri T for team cancel issue[12/07/22]
						if(childNode.childNodes != null && contFlag==true)
						{
							console.log("contFlag team is true and teamFlg is false");
							teamFlg=false;
							//break;
						}
						elmSelected++;
					}
				}
				var toTeamMan = teamDesignCode+":"+teamDocType;
				var ismandatoryStaff=isTeamSubformMandatory(toTeamMan);

				if(ismandatoryStaff == true)
				{
					if(contFlag==false)
					{
						alert("Please select the staff name ");
						isValidWfData=false;
						return isValidWfData;
					}
				}

				if(elmSelected==0)
				{
					teamFlg=true;
				}
			}
			else if(objFormName === 'brand')
			{

				var brandWorkDate = "", brandScCode = "", brandSalesPers = "";
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					if(attributeVal != 'D')
					{
						if( detail.getElementsByTagName("work_date")[0] != null && detail.getElementsByTagName("work_date")[0].childNodes[0] != null )
						{
							brandWorkDate = detail.getElementsByTagName("work_date")[0].childNodes[0].nodeValue;
							if(brandWorkDate =='null' || brandWorkDate.trim().length == 0)
							{
								alert("Work date is blank! Work date can not be blank");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						if( detail.getElementsByTagName("sc_code")[0] != null && detail.getElementsByTagName("sc_code")[0].childNodes[0] != null )
						{
							brandScCode = detail.getElementsByTagName("sc_code")[0].childNodes[0].nodeValue;
							if(brandScCode =='null' || brandScCode.trim().length == 0)
							{
								alert("Customer is blank! Customer can not be blank");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
						{
							brandSalesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
							if(brandSalesPers =='null' || brandSalesPers.trim().length == 0)
							{
								alert("Sales person is blank! Sales person can not be blank");
								isValidWfData=false;
								return isValidWfData;
							}
						}
						//Added by mrunalini sinkar on 10-May-2021(Start)
						var pitchDetail="";
						if( detail.getElementsByTagName("pitch_detail")[0] != null && detail.getElementsByTagName("pitch_detail")[0].childNodes[0] != null )
						{

							if( detail.getElementsByTagName("pitch_detail")[0] != null && detail.getElementsByTagName("pitch_detail")[0].childNodes[0] != null )
							{
								pitchDetail = detail.getElementsByTagName("pitch_detail")[0].childNodes[0].nodeValue;
							}

						}
						if(action == 'done' && isForuneAct == 'Y')
						{
							if(pitchDetail =='null' || pitchDetail.trim().length == 0)
							{
								alert("Status is blank! Status can not be blank");
								isValidWfData=false;
								return isValidWfData;
							}
							else
							{
								var formPitch=pitchDetail+"@"+meetingStatus;


								if(pitchDetailArray.indexOf(formPitch) == -1)
								{
									alert("Invalid Pitch Detail! Please select proper one");
									isValidWfData=false;
									return isValidWfData;
								}
							}

						}
						//Added by mrunalini sinkar on 10-May-2021(End)

						var childNode= detailElement[i];
						if(childNode.childNodes != null)
						{
							brandFlg=false;
							//break;
						}
					}




				}
			}
			else if(objFormName === 'coaching')
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					if(attributeVal != 'D')
					{
						var childNode= detailElement[i];
						if(childNode.childNodes != null)
						{
							coachingFlg=false;
							//break;
						}
					}
					//Changes made by Sameer to add validation on coaching sub form on 11/02/2022(Start's from here).
					if (action == 'done')
					{
						console.log("Inside action Done");

						var surveyMandatory = "";
						var surveDescr = "";
						var result1="",result2="",result3="";
						var result4="",result5="",resultType="",resultFormat="";
						if( detail.getElementsByTagName("survey_mandatory")[0] != null && detail.getElementsByTagName("survey_mandatory")[0].childNodes[0] != null )
						{
							surveyMandatory = detail.getElementsByTagName("survey_mandatory")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("survey_descr")[0] != null && detail.getElementsByTagName("survey_descr")[0].childNodes[0] != null )
						{
							surveDescr = detail.getElementsByTagName("survey_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result1")[0] != null && detail.getElementsByTagName("result1")[0].childNodes[0] != null )
						{
							result1 = detail.getElementsByTagName("result1")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result2")[0] != null && detail.getElementsByTagName("result2")[0].childNodes[0] != null )
						{
							result2 = detail.getElementsByTagName("result2")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result3")[0] != null && detail.getElementsByTagName("result3")[0].childNodes[0] != null )
						{
							result3 = detail.getElementsByTagName("result3")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result4")[0] != null && detail.getElementsByTagName("result4")[0].childNodes[0] != null )
						{
							result4 = detail.getElementsByTagName("result4")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result5")[0] != null && detail.getElementsByTagName("result5")[0].childNodes[0] != null )
						{
							result5 = detail.getElementsByTagName("result5")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result_type")[0] != null && detail.getElementsByTagName("result_type")[0].childNodes[0] != null )
						{
							resultType = detail.getElementsByTagName("result_type")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result_format")[0] != null && detail.getElementsByTagName("result_format")[0].childNodes[0] != null )
						{
							resultFormat = detail.getElementsByTagName("result_format")[0].childNodes[0].nodeValue;
						}
						console.log("survey_mandatory:::["+surveyMandatory+"]surveDescr["+surveDescr+"]result1["+result1+"]result2["+result2+"]");
						console.log("result3:::["+result3+"]result4["+result4+"]result5["+result5+"]resultType["+resultType+"]resultFormat["+resultFormat+"]");

						if(surveyMandatory == 'Y')
						{

							if(resultType == 'N')
							{
								if(result1 =='null' || result1.trim().length == 0)
								{
									alert("Coaching question is compulsory  for '"+surveDescr+"' Coaching");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							else if(resultType == 'L' && resultFormat=='D')
							{
								if(result4 =='null' || result4.trim().length == 0)
								{
									alert("Coaching question is compulsory  for '"+surveDescr+"' Coaching");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							else if(resultType == 'L')
							{
								if(result2 =='null' || result2.trim().length == 0)
								{
									alert("Coaching question is compulsory  for '"+surveDescr+"' Coaching");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							else if(resultType == 'T')
							{
								if(result3 =='null' || result3.trim().length == 0)
								{
									alert("Coaching question is compulsory  for '"+surveDescr+"' Coaching");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							else if(resultType == 'D')
							{
								if(result2 =='null' || result2.trim().length == 0)
								{
									alert("Coaching question is compulsory  for '"+surveDescr+"' Coaching");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							else if(resultType == 'A')
							{
								if(result5 =='null' || result5.trim().length == 0)
								{
									alert("Coaching question is compulsory  for '"+surveDescr+"' Coaching");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							else
							{
								if(result3 =='null' || result3.trim().length == 0)
								{
									alert("Coaching question is compulsory  for '"+surveDescr+"' Coaching");
									isValidWfData=false;
									return isValidWfData;
								}
							}




						}
						console.log("Finish");

					}
					//Changes made by Sameer to add validation on coaching sub form on 11/02/2022(ends here).
				}
			}
			else if(objFormName === 'display')
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					if(attributeVal != 'D')
					{
						var childNode= detailElement[i];
						console.log("childNode display is:"+childNode);
						if(childNode.childNodes != null)
						{
							displayFlg=false;
							//break;
						}
					}


				}

			}
			// added by rupali on 28/09/18 for applying validation on survey in auto mode [start]
			else if(objFormName === 'survey')
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var elmSelected=0;
				var elmTrueFlagCnt=detailElement.length;
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					console.log("attributeVal is: ["+attributeVal+"]");
					var domIDVal = detail.getAttribute("domID");
					var maxRange = "", minRange = "";
					if( detail.getElementsByTagName("result_range_max")[0] != null && detail.getElementsByTagName("result_range_max")[0].childNodes[0] != null )
					{
						maxRange = detail.getElementsByTagName("result_range_max")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result_range_min")[0] != null && detail.getElementsByTagName("result_range_min")[0].childNodes[0] != null )
					{
						minRange = detail.getElementsByTagName("result_range_min")[0].childNodes[0].nodeValue;
					}
					// Added by Pankaj P on 04 Jul 2022 for Min-Max Validation [Start]
					if(minRange.length == 0)
					{
						minRange = 0;
					}
					if(minRange.length == 0)
					{
						maxRange = 0;
					}
					// Added by Pankaj P on 04 Jul 2022 for Min-Max Validation [End]
					if(attributeVal != 'D')
					{
						var result1 = "";
						var result2 = "";
						var result3 = "";
						var result5 = "";
						var result = "";
						var resultType = "";
						var surveyDescr = "";
						var attachOpt = "";
						var docID = "";
						var meterPurchased = "",meterName="";
						var surManFirst = "";
						if(action == 'done')
						{
							if( detail.getElementsByTagName("survey_mandatory")[0] != null && detail.getElementsByTagName("survey_mandatory")[0].childNodes[0] != null )
							{
								surManFirst = detail.getElementsByTagName("survey_mandatory")[0].childNodes[0].nodeValue;
							}
							console.log("survey_mandatory surManFirst:::"+surManFirst);
							if( detail.getElementsByTagName("survey_descr")[0] != null && detail.getElementsByTagName("survey_descr")[0].childNodes[0] != null )
							{
								surveyDescr=detail.getElementsByTagName("survey_descr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("result_type")[0] != null && detail.getElementsByTagName("result_type")[0].childNodes[0] != null )
							{
								resultType = detail.getElementsByTagName("result_type")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("result1")[0] != null && detail.getElementsByTagName("result1")[0].childNodes[0] != null )
							{
								result1 = detail.getElementsByTagName("result1")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("result2")[0] != null && detail.getElementsByTagName("result2")[0].childNodes[0] != null )
							{
								result2 = detail.getElementsByTagName("result2")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("result3")[0] != null && detail.getElementsByTagName("result3")[0].childNodes[0] != null )
							{
								result3 = detail.getElementsByTagName("result3")[0].childNodes[0].nodeValue;
							}
							//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm Start
							if( detail.getElementsByTagName("result5")[0] != null && detail.getElementsByTagName("result5")[0].childNodes[0] != null )
							{
								result5 = detail.getElementsByTagName("result5")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("result")[0] != null && detail.getElementsByTagName("result")[0].childNodes[0] != null )
							{
								result = detail.getElementsByTagName("result")[0].childNodes[0].nodeValue;
							}
							//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm End
							if( detail.getElementsByTagName("attach_opt")[0] != null && detail.getElementsByTagName("attach_opt")[0].childNodes[0] != null )
							{
								attachOpt = detail.getElementsByTagName("attach_opt")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("doc_id_2")[0] != null && detail.getElementsByTagName("doc_id_2")[0].childNodes[0] != null )
							{
								docID = detail.getElementsByTagName("doc_id_2")[0].childNodes[0].nodeValue;
							}
							try {
								var obj = JSON.parse(result5);
								console.log('meterPurchased is['+obj.meter_purchased+'] docID'+docID);
								if(( obj.meter_purchased != null && obj.meter_purchased.trim().length > 0 ) && (docID == null  || docID.trim().length == 0))
								{
									alert( "Attachment is mandatory for '"+obj.meter_name+"'" );
									isValidWfData=false;
									return isValidWfData;
								}
							}
							catch(e){ console.log(e) }

							if(  minRange != null || maxRange != null && action == 'done')
							{
								if( minRange.length > 0 )
								{
									if(result1 != null && result1.length > 0)
									{
										if(minRange > result1.length)
										{
											alert("Entered result length is less than defined minimum range ["+minRange+"]");
											isValidWfData=false;
											return isValidWfData;
										}
									}
									if(result3 != null && result3.length > 0)
									{
										if(minRange > result3.length)
										{
											alert("Entered result length is less than defined minimum range ["+minRange+"]");
											isValidWfData=false;
											return isValidWfData;
										}
									}

								}

								if( maxRange!=null && maxRange.length > 0 )
								{
									if(result1 != null && result1.trim().length > 0)
									{
										if(maxRange < result1.length)
										{
											alert("Entered result length is more than defined maximum range ["+maxRange+"]");
											isValidWfData=false;
											return isValidWfData;
										}
									}
									if(result3 != null && result3.trim().length > 0)
									{
										if(maxRange < result3.length)
										{
											alert("Entered result length is more than defined maximum range ["+maxRange+"]");
											isValidWfData=false;
											return isValidWfData;
										}
									}

								}
							}

							if((resultType == 'N' && result1.trim().length == 0) || (resultType == 'T' && result3.trim().length == 0) || ((resultType == 'D' || resultType == 'L')  && result2.trim().length == 0))
							{
								alert("Null Survey Result! Please enter survey result for '"+surveyDescr+"' survey");
								isValidWfData=false;
								return isValidWfData;
							}
							if(attachOpt =='1' && (docID =='null' || docID.trim().length == 0))
							{
								alert("Attachment is compulsory  for '"+surveyDescr+"' survey");
								isValidWfData=false;
								return isValidWfData;
							}
							//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm Start
							if((resultType == 'A' && result5.trim().length == 0) )
							{
								alert("Null Survey Result! Please enter survey result for '"+surveyDescr+"' survey");
								isValidWfData=false;
								return isValidWfData;
							}
							//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm End
							//Added by Amey W. [OT activity related implementation] on 18/02/2020OfAttchments
							try
							{
								meterPurchased = "";
								var validatekey = "";

								var result5Obj = JSON.parse( result5 );
								meterPurchased = result5Obj[ "meter_purchased" ];
								console.log("meterPurchased:"+meterPurchased);

								validatekey = "survey_"+domIDVal;

								var attachmentMeterPurchased = attachmentJson[ validatekey ];
								console.log("attachmentMeterPurchased:"+attachmentMeterPurchased);

								if( meterPurchased != attachmentMeterPurchased )
								{
									console.log("Invalid number of Attachments! ");
									alert("Invalid number of Attachments! Please enter attachment as per Meter purchased");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							catch(ex)
							{
								console.log("amy noOfAttchments Exception "+ex);
							}
						}
						var childNode= detailElement[i];
						console.log("childNode sample order is:"+childNode);
						/*if(childNode.childNodes != null)
						{
							surveyFlg=false;
							//break;
						}*/
						//Added by bhagyashri T for Survey cancel issue[12/07/22] [start]
						if(surManFirst != 'Y')
						{
							elmTrueFlagCnt--;
						}
						//console.log("Inside survey elmTrueFlag after not survey  Y::"+elmTrueFlagCnt);
						if(childNode.childNodes != null && surManFirst == 'Y')
						{
							elmSelected++;
						}
						console.log("When Done then elmSelected ::"+elmSelected);
						console.log("When Done then elmTrueFlagCnt ::"+elmTrueFlagCnt);
						if(elmSelected==elmTrueFlagCnt)
						{
							console.log("Inside suvyey form flag false");
							surveyFlg=false;
						}
						//Added by bhagyashri T for Survey cancel issue[12/07/22][end]
					}
					else if(  minRange != null || maxRange != null && action == 'done')
					{
						if( minRange.length > 0 )
						{
							console.log("Inside minimum range");
							if(result1 != null && result1.length > 0)
							{
								if(minRange > result1.length)
								{
									alert("Entered result length is less than defined minimum range ["+minRange+"]");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if(result3 != null && result3.length > 0)
							{
								if(minRange > result3.length)
								{
									alert("Entered result length is less than defined minimum range ["+minRange+"]");
									isValidWfData=false;
									return isValidWfData;
								}
							}

						}

						if( maxRange!=null && maxRange.length > 0 )
						{
							console.log("inside maximum range");
							if(result1 != null && result1.trim().length > 0)
							{
								if(maxRange < result1.length)
								{
									alert("Entered result length is more than defined maximum range ["+maxRange+"]");
									isValidWfData=false;
									return isValidWfData;
								}
							}
							if(result3 != null && result3.trim().length > 0)
							{
								if(maxRange < result3.length)
								{
									alert("Entered result length is more than defined maximum range ["+maxRange+"]");
									isValidWfData=false;
									return isValidWfData;
								}
							}

						}
					}
					// added by rupali on 16/07/19 to validate survey question [start]
					else if (attributeVal == 'D' && action == 'done')
					{
						var surveyMandatory = "";
						var surveDescr = "";
						if( detail.getElementsByTagName("survey_mandatory")[0] != null && detail.getElementsByTagName("survey_mandatory")[0].childNodes[0] != null )
						{
							surveyMandatory = detail.getElementsByTagName("survey_mandatory")[0].childNodes[0].nodeValue;
						}
						console.log("survey_mandatory:::"+surveyMandatory);
						if( detail.getElementsByTagName("survey_descr")[0] != null && detail.getElementsByTagName("survey_descr")[0].childNodes[0] != null )
						{
							surveDescr = detail.getElementsByTagName("survey_descr")[0].childNodes[0].nodeValue;
						}
						if(surveyMandatory == 'Y' && custFlag==true)
						{
							alert("Survey question is compulsory  for '"+surveDescr+"' survey");
							isValidWfData=false;
							return isValidWfData;
						}
					}
					// added by rupali on 16/07/19 to validate survey question [end]
				}
			}
			// added by rupali on 28/09/18 for applying validation on survey in auto mode [end]
			//added by Bhagyashri T for Invoice subform[START]
			else if(objFormName === 'invoice')
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var elmSelected=0;
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");

					if(attributeVal != 'D')
					{
						var quantity="",remark="";
						var quan=0;
						var currentStock=0;
						var itemDescr="";
						var rate="";
						var rateInt=0;
						var stockQuan="0";
						var orgStock="0";
						var netamount ="";
						var taxamount ="";
						var itemCode="";
						var stockBreak="";
						if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
						{
							itemCode=detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity=detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
						{
							itemDescr=detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
						{
							rate=detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("net_amt")[0] != null && detail.getElementsByTagName("net_amt")[0].childNodes[0] != null )
						{
							netamount=detail.getElementsByTagName("net_amt")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
						{
							stockQuan=detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
						{
							orgStock=detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
						{
							taxamount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("remarks_inv")[0] != null && detail.getElementsByTagName("remarks_inv")[0].childNodes[0] != null )
						{
							remark = detail.getElementsByTagName("remarks_inv")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("stock_break")[0] != null && detail.getElementsByTagName("stock_break")[0].childNodes[0] != null )
						{
							stockBreak=detail.getElementsByTagName("stock_break")[0].childNodes[0].nodeValue;
						}
						console.log("after declare condi 8");
						console.log("action:"+action);
						if(action == 'done')
						{

							if((quantity=='null' || quantity.trim().length == 0))
							{
								alert("Quantity can not null! Quantity is null for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							quan= parseInt(quantity);
							rateInt=parseInt(rate);
							console.log("quantity after parse:"+quan+" rate after parse:"+rateInt);
							/*if(quan<0)
							{
								alert("Invalid Quantity! Please enter valid quantity for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}*/

							console.log("stockBreak is: ["+stockBreak+"]");
							if(quan < 1 && stockBreak != "Y")
							{
								alert("Invalid Quantity! Please enter valid quantity for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}

							if(rate=='null' || rate.trim().length == 0)
							{
								alert("Blank Rate ! Rate can not be blank for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							if(rateInt<=0)
							{
								alert("Invalid Rate! Rate can not be equal to or less than 0 for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							//console.log("currentStock before val:"+currentStock);
							currentStock=parseInt(orgStock);
							//console.log("currentStock after val:"+currentStock);
							if(quan > currentStock)
							{
								alert("Invalid Quantity! Quntity can not be greater than Stock for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
						}



						var childNode= detailElement[i];
						if(childNode.childNodes != null)
						{
							invoiceFlg=false;
						}
						elmSelected++;
					}
					else if (attributeVal == 'D' && action == 'done')
					{
						var isBroken="",itemDescr="",stockBreak="";

						if( detail.getElementsByTagName("is_broken")[0] != null && detail.getElementsByTagName("is_broken")[0].childNodes[0] != null )
						{
							isBroken=detail.getElementsByTagName("is_broken")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
						{
							itemDescr=detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("stock_break")[0] != null && detail.getElementsByTagName("stock_break")[0].childNodes[0] != null )
						{
							stockBreak=detail.getElementsByTagName("stock_break")[0].childNodes[0].nodeValue;
						}

						if(isBroken== 'Y')
						{
							alert("Broken Child Item not selected for "+itemDescr+" item");
							isValidWfData=false;
							return isValidWfData;
						}
						if(stockBreak == 'Y')
						{
							alert("Broken Parent Item not selected for "+itemDescr+" item");
							isValidWfData=false;
							return isValidWfData;
						}
					}
				}
				if(elmSelected==0)
				{
					invoiceFlg=true;
					editInvoiceFlg =false;
				}
				
				if(elmSelected==0 && (callOutCmGlobal !=0 && callOutCmGlobal !=9))
				{
					alert("Please select item for next procedure for Invoice");
					isValidWfData=false;
					return isValidWfData;
				}

			}
			//Added by bhagyashri T For Invoice subform[END]

			//start prachi 14-sep-2022
			else if(objFormName === 'collection')
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var elmSelected=0;

				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					console.log("attributeVal is in collection subform validation: ["+attributeVal+"]");

					if(attributeVal != 'D')
					{
						var amountColl="";
						var MaxCashSalesAmt="";
						var billAmt="";
						var refDate="";
						var BillDate="";
						var payMode="";

						if( detail.getElementsByTagName("pay_mode")[0] != null && detail.getElementsByTagName("pay_mode")[0].childNodes[0] != null )
						{
							payMode=detail.getElementsByTagName("pay_mode")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("amount")[0] != null && detail.getElementsByTagName("amount")[0].childNodes[0] != null )
						{
							amountColl=detail.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("bill_amt")[0] != null && detail.getElementsByTagName("bill_amt")[0].childNodes[0] != null )
						{
							billAmt=detail.getElementsByTagName("bill_amt")[0].childNodes[0].nodeValue;
							billAmountGlobal = billAmt;
						}
						if( detail.getElementsByTagName("ref_date")[0] != null && detail.getElementsByTagName("ref_date")[0].childNodes[0] != null )
						{
							refDate=detail.getElementsByTagName("ref_date")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("bill_date")[0] != null && detail.getElementsByTagName("bill_date")[0].childNodes[0] != null )
						{
							BillDate=detail.getElementsByTagName("bill_date")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("max_amount")[0] != null && detail.getElementsByTagName("max_amount")[0].childNodes[0] != null )
						{
							MaxCashSalesAmt=detail.getElementsByTagName("max_amount")[0].childNodes[0].nodeValue;
						}
						
						if(action == 'done')
						{
							console.log("before collection validation");
							console.log("amountColl:: "+amountColl+"MaxCashSalesAmt: "+MaxCashSalesAmt);
							if((amountColl==null || amountColl.trim().length == 0))
							{
								alert("Amount cannot be blank. Please enter the amount.");
								isValidWfData=false;
								return isValidWfData;
							}
							/*if(amountColl!=null && amountColl.trim().length>0)
							{
								var amtCol= parseFloat(amountColl);
								var billAmount = parseFloat(billAmt);

								if(amtCol<billAmount)
								{
									alert("Amount entered is less then the Bill amount");
									isValidWfData=false;
									return isValidWfData;
								}

							}*/
							if(amountColl!=null && amountColl.trim().length>0)
							{
								var amtCol= parseFloat(amountColl);
								var maxAmt = parseFloat(MaxCashSalesAmt);						    
								if(amtCol > maxAmt)
								{
									alert("Amount entered exceeds the permitted limit");
									isValidWfData=false;
									return isValidWfData;
								}

							}
							console.log("refDate::"+refDate +"payMode::"+payMode);
							if((refDate==null || refDate.trim().length==0) && (payMode=='Q' || payMode=='O'))
							{
								alert("Cheque/DD/UPR Date cannot be blank");
								isValidWfData=false;
								return isValidWfData;
							}
							if((refDate!=null && refDate.trim().length > 0) && (payMode=='Q' || payMode=='O'))
							{
								var currentDate = new Date();
								if(refDate.indexOf("-")!=-1 || refDate.indexOf("/")!=-1)
								{
									var diffDays = getDaysBetweenTwoDates(refDate,currentDate);
									console.log("refDate:"+refDate+" currentDate:"+currentDate+" diffDays:"+diffDays);
									if(diffDays > 0)
									{
										alert("Cheque/DD/UPR Date cannot not be smaller then today's date");
										isValidWfData=false;
										return isValidWfData;
									}
								}
							}
						}
						var childNode= detailElement[i];
						console.log("childNode collection subform is:"+childNode);
						if(childNode.childNodes != null)
						{
							collectionFlg=false;
							editCollectFlg =true;
							
						}
						elmSelected++;

					}
				}
				if(elmSelected==0)
				{
					collectionFlg=true;
					editCollectFlg =false;
				}
				/*if(elmSelected==0 && callOutCmGlobal !=0)
				{
					alert("Please select Collection detail for next procedure");
					isValidWfData=false;
					return isValidWfData;
				}*/
				}
			//end
		}

		return isValidWfData;
	}
	else if(objName ==='stocks_transfer_wiz')
	{

		console.log('inside localWfValData function in stocks js file **************************');
		var isValidWfData = true;
		var stockArray=[],locToArray=[];
		console.log('currentFormData is['+currentFormData+'] action is['+action+'] objFormName is['+objFormName+']');
		var currentFormData=currentFormData;
		var action=action;
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata");
		}
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
				}
			}
			catch(ex)
			{
				console.log("Exception occurs while parsing xml data");
			}
		}
		else
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}

		if(xmlDoc != null )
		{
			if(objFormName === 'stock')
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var elmSelected=0;
				var locCodeFR="",locCodeTO="", locList="", locTolist="";
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
					{
						locCodeFR = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
					{
						locCodeTO=detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("loc_code_list")[0] != null && detail.getElementsByTagName("loc_code_list")[0].childNodes[0] != null )
					{
						locList = detail.getElementsByTagName("loc_code_list")[0].childNodes[0].nodeValue;
						locList = locList.substring(1, locList.length-1);

					}
					if( detail.getElementsByTagName("loc_code_to_list")[0] != null && detail.getElementsByTagName("loc_code_to_list")[0].childNodes[0] != null )
					{
						locTolist = detail.getElementsByTagName("loc_code_to_list")[0].childNodes[0].nodeValue;
						locTolist = locTolist.substring(1, locTolist.length-1);

					}

					var locFinalList = locList.split(',');
					console.log("lotFinalList::"+locFinalList);
					for(var q=0;q < locFinalList.length;q++)
					{
						var Data1 = locFinalList[q].trim();
						stockArray.push(Data1);
					}
					console.log("loc fr array:: "+stockArray);

					var locToFinalList = locTolist.split(',');
					console.log("locToFinalList::"+locToFinalList);
					for(var q=0;q < locToFinalList.length;q++)
					{
						var Data1 = locToFinalList[q].trim();
						locToArray.push(Data1);
					}
					console.log("loc to array:: "+locToArray);

					if(action == 'finish' || action == 'DEFAULT_DATA_WIZ')
					{
						if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
						{
							var locCodeFrm = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
							console.log("locCodeFrm in validation ::"+locCodeFrm);
							if(locCodeFrm == null || locCodeFrm.trim().length == 0)
							{
								alert("Blank Location From! Location From cannot be blank");
								isValidWfData=false;
								return isValidWfData;
							}
							else
							{
								if((stockArray.length > 0) && stockArray.indexOf(locCodeFrm.trim()) == -1)
								{
									alert(" Entered Location From is Invalid");
									isValidWfData=false;
									return isValidWfData;
								}
							}
						}
						if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
						{
							var localCTo = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
							var locCodeFrm = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
							console.log("localCTo in validation ::"+localCTo);
							if(localCTo == null || localCTo.trim().length == 0)
							{
								alert("Blank Location To! Location To cannot be blank");
								isValidWfData=false;
								return isValidWfData;
							}
							else
							{
								if(localCTo.trim()==locCodeFrm.trim())
								{
									alert("Location To and Location From cannot be same");
									isValidWfData=false;
									return isValidWfData;
								}
								if((locToArray.length > 0) && locToArray.indexOf(localCTo.trim()) == -1)
								{
									alert(" Entered Location To is Invalid ");
									isValidWfData=false;
									return isValidWfData;
								}
							}
						}
					}
					if(action == 'finish')
					{
						if(itemFlgTr== true)
						{
							alert("Please Select only One Item");
							isValidWfData=false;
							return isValidWfData;
						}
					}
				}	
			}
			else if(objFormName === 'item')
			{

				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var elmSelected=0,currentStock=0;
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					console.log("attributeVal is: ["+attributeVal+"]");

					if(attributeVal != 'D')
					{
						var quantity="";
						var quan=0;
						var minQuan=0;
						var itemDescr="";
						var stockQuan="";
						var OrgQuan="";

						if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity=detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
						{
							itemDescr=detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
						}

						if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
						{
							stockQuan=detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
						{
							OrgQuan=detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
						}

						console.log("action:"+action);

						if(action == 'done')
						{
							if((quantity==null || quantity.trim().length == 0))
							{
								alert("Quantity cannot be blank! Quantity is blank for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							console.log("quantity : ["+ quantity +"], stockQuan : ["+ stockQuan +"]");
							quan= parseInt(quantity);
							console.log("quan:: "+quan);
							if(quan<1)
							{
								alert("Invalid Quantity! Please enter valid quantity for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
							/*
							if((stockQuan!=null && stockQuan.trim().length > 0))
							{
								currentStock=parseInt(stockQuan);
							}
							 */
							if((OrgQuan!=null && OrgQuan.trim().length > 0))
							{
								currentStock=parseInt(OrgQuan);
							}
							console.log("currentStock::"+currentStock);
							if(quan > currentStock)
							{
								alert("Invalid Quantity! Quantity cannot be greater than Stock for "+itemDescr+" item");
								isValidWfData=false;
								return isValidWfData;
							}
						}

						var childNode= detailElement[i];
						console.log("childNode item is:"+childNode);
						if(childNode.childNodes != null)
						{
							itemFlgTr=false;
						}
						elmSelected++;
					}
				}
				if(elmSelected==0 || elmSelected > 1)
				{
					itemFlgTr=true;
				}
				if(action == 'finish')
				{
					if(itemFlgTr== true)
					{
						alert("Please Select only One Item");
						isValidWfData=false;
						return isValidWfData;
					}
				}
			}	
		}	
		console.log("isValidWfData::"+isValidWfData);
		return isValidWfData;

	}
	else if(objName ==='stocks_receive_wiz')
	{
		var userId = localStorage.getItem('userName');
		console.log('inside localWfValData function in stocks receive  file userId**'+userId);
		var isValidWfData = true;
		console.log('currentFormData is['+currentFormData+'] action is['+action+'] objFormName is['+objFormName+']');
		var currentFormData=currentFormData;
		var action=action;
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata");
		}
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
				}
			}
			catch(ex)
			{
				console.log("Exception occurs while parsing xml data");
			}
		}
		else
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}

		if(xmlDoc != null )
		{
			if(objFormName == 'stock')
			{		
				if(action == 'finish')
				{
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					console.log("detailElement in validation of receive ::"+detailElement.length);
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						console.log("detail in validation of receive ::"+detail);
						if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
						{
							var locCodeTo = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
							console.log("locCodeTo in validation of receive ::"+locCodeTo);

							if(locCodeTo.trim() != userId.trim())
							{
								alert("Invalid Location To,Location To and LoginCode Cannot be Different");
								isValidWfData=false;
								return isValidWfData;
							}
						}
					}

				}
			}
		}	
		console.log("isValidWfData::"+isValidWfData);
		return isValidWfData;
	}

}
//added by mrunalini sinkar for offline validation on 16-feb-2018(end)

function localValData(objContext, action, objName, currentFormData, objFormName)
{
	globalObjName = objName;
	console.log("Inside localValData function having obj name is::["+objName+"]");
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		//alert("inside localValData action:::"+action);
		console.log("Inside localValData function having obj name is strg_meet_dcr_realtime_wiz");
		var isValidData = true;
		console.log('objFormName is'+objFormName);
		console.log('objContext is'+objContext);
		console.log('action is'+action);
		console.log('inside localValData function in js file **************************'+currentFormData);
		var currentFormData=currentFormData;
		var action=action;
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			console.log("cureentform data is not null"+currentFormData);
			if(xmlVersion == 0)
			{
				//console.log("inside if");
				currentFormData = currentFormData;
			}
			else
			{
				//console.log("inside else");
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata");
		}
		if (window.DOMParser)
		{
			//alert("inside window.DOMParser");
			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
					//console.log("xmlDoc =["+xmlDoc+"]");
				}
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		if(xmlDoc != null )
		{
			/*if(objFormName === 'sampleorder')
			{
				console.log("inside condtion");
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				console.log("detailElement.length =["+detailElement.length+"]");
				for (var i = 0; i < detailElement.length; i++)
				{
					console.log("inside for");
					var detail = detailElement[i];
					var stkInf = "";
					var stock = "";
					var jsonKey = "";
					var jsonValue = "";
					var stockQty = ""
					var stockSum = 0;
					if( detail.getElementsByTagName("stock_info")[0] != null && detail.getElementsByTagName("stock_info")[0].childNodes[0] != null )
					{
						stkInf = detail.getElementsByTagName("stock_info")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("stock_qty")[0] != null && detail.getElementsByTagName("stock_qty")[0].childNodes[0] != null )
					{
						stock = detail.getElementsByTagName("stock_qty")[0].childNodes[0].nodeValue;
					}
					stkInf = JSON.parse(stkInf);

					for(var key in stkInf)
					{
						if(!(key === 'name' || key === 'disp_name' || key === 'type' || key === 'protect'))
						{
							jsonKey = key;
							jsonValue = stkInf[key]
							stockQty = jsonValue.substring(jsonValue.indexOf("|")+1,jsonValue.lastIndexOf("|"));
							stockSum = parseInt(stockSum) + parseInt(stockQty);
						}
					}
					console.log("stockSum outside::::" +stockSum);
					var TotlStockSum = parseInt(stockSum);
					if(stock != 'null' && stock.trim().length != 0)
					{
						if( Number(stock) != Number(stockSum) )
						{
							alert("Invalid Stock! Stocked entered is not matched");
							isValidData=false;
						}
					}
					else if( (stock == 'null' || stock.trim().length == 0) && (TotlStockSum != 0 ))
					{
						if(isNaN(TotlStockSum))
						{
							isValidData = true;
						}
						else
						{
							alert("Blank Stock! Stock not entered");
							isValidData=false;
						}
					}
				}
			}*/
			if(objFormName === 'sampleorder')
			{
				console.log("inside condtion");
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				console.log("detailElement.length =["+detailElement.length+"]");
				for (var i = 0; i < detailElement.length; i++)
				{
					console.log("inside for");
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					console.log("attributeVal is"+attributeVal+"objFormName["+objFormName+"]");
					if(attributeVal != 'D')
					{
						var stkInf = "";
						var stock = "";
						var jsonKey = "";
						var jsonValue = "";
						var stockQty = "";
						var stockInfo= "";
						var stockSum = 0;
						if( detail.getElementsByTagName("stock_info")[0] != null && detail.getElementsByTagName("stock_info")[0].childNodes[0] != null )
						{
							stkInf = detail.getElementsByTagName("stock_info")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("stock_qty")[0] != null && detail.getElementsByTagName("stock_qty")[0].childNodes[0] != null )
						{
							stock = detail.getElementsByTagName("stock_qty")[0].childNodes[0].nodeValue;
						}
						//addded by mrunalini sinkar to add the stock info changes in case of sfaparam(start)
						if( detail.getElementsByTagName("is_stock_info")[0] != null && detail.getElementsByTagName("is_stock_info")[0].childNodes[0] != null )
						{
							stockInfo = detail.getElementsByTagName("is_stock_info")[0].childNodes[0].nodeValue;
						}
						console.log("stockInfo is:["+stockInfo+"]");
						//addded by mrunalini sinkar to add the stock info changes in case of sfaparam(start)
						if(stockInfo === 'Y') //addded by mrunalini sinkar
						{
							console.log("inside stockInfo");

							stkInf = JSON.parse(stkInf);

							for(var key in stkInf)
							{
								if(!(key === 'name' || key === 'disp_name' || key === 'type' || key === 'protect'))
								{
									jsonKey = key;
									jsonValue = stkInf[key]
											/*stockQty = jsonValue.substring(jsonValue.indexOf("|")+1,jsonValue.lastIndexOf("|"));
									stockSum = parseInt(stockSum) + parseInt(stockQty);*/

											stockQty = jsonValue.substring(0,jsonValue.indexOf("|"));
									console.log("stockQty outside issss::::" +stockQty);
									if(stockQty == null || stockQty.trim().length == 0 || stockQty == '0')
									{
										console.log("inside condition::::" +stockQty);
										alert("Invalid Stock");
										isValidData=false;
										return isValidData;
									}
									stockSum = parseInt(stockSum) + parseInt(stockQty);
								}
							}
							console.log("stockSum outside::::" +stockSum);
							var TotlStockSum = parseInt(stockSum);
							if(stock != 'null' && stock.trim().length != 0)
							{
								if( Number(stock) != Number(stockSum) )
								{
									alert("Invalid Stock! Stocked entered is not matched");
									isValidData=false;
								}
							}
							else if( (stock == 'null' || stock.trim().length == 0) && (TotlStockSum != 0 ))
							{
								if(isNaN(TotlStockSum))
								{
									isValidData = true;
								}
								else
								{
									alert("Blank Stock! Stock not entered");
									isValidData=false;
								}
							}
						}
					}
				}
			} 

			else if(objFormName === 'doctor')
			{
				console.log("inside condtion");
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				console.log("detailElement.length =["+detailElement.length+"]");
				for (var i = 0; i < detailElement.length; i++)
				{
					console.log("inside for"+objFormName);
					var detail = detailElement[i];
					var meetSumm = "";
					var actType = "",actCode="",actDescr="",placeReq="",parentActCode= '',activityTemplate= '',actPlace="";  //Added by Bhagyashri T for Activity Place[28/JUL/21]
					var callOutcome = "";
					var customerName="",visitTimeFrom="",eventTimeStart="",eventTimeEnd="";
					if( detail.getElementsByTagName("meet_summ")[0] != null && detail.getElementsByTagName("meet_summ")[0].childNodes[0] != null )
					{
						meetSumm = detail.getElementsByTagName("meet_summ")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
					{
						actType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("call_outcome")[0] != null && detail.getElementsByTagName("call_outcome")[0].childNodes[0] != null )
					{
						callOutcome = detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
					}
					console.log("meetSumm:::"+meetSumm+"actType:::::"+actType+"callOutcome::::"+callOutcome);
					//Added by Prasad on 27/09/18 [to set speciality code and class code] START
					if( detail.getElementsByTagName("spl_code")[0] != null && detail.getElementsByTagName("spl_code")[0].childNodes[0] != null )
					{
						splCode = detail.getElementsByTagName("spl_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("strg_class_code")[0] != null && detail.getElementsByTagName("strg_class_code")[0].childNodes[0] != null )
					{
						strgClassCode = detail.getElementsByTagName("strg_class_code")[0].childNodes[0].nodeValue;
					}
					//Added by Prasad on 27/09/18 [to set speciality code and class code] END
					//Added by mrunalini sinkar for activity code,place required ,activity description (start)
					if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
					{
						actCode = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("activity_descr")[0] != null && detail.getElementsByTagName("activity_descr")[0].childNodes[0] != null )
					{
						actDescr = detail.getElementsByTagName("activity_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("place_required")[0] != null && detail.getElementsByTagName("place_required")[0].childNodes[0] != null )
					{
						placeReq = detail.getElementsByTagName("place_required")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("parent_act_code")[0] != null && detail.getElementsByTagName("parent_act_code")[0].childNodes[0] != null )
					{
						parentActCode = detail.getElementsByTagName("parent_act_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("activity_templ")[0] != null && detail.getElementsByTagName("activity_templ")[0].childNodes[0] != null )
					{
						activityTemplate = detail.getElementsByTagName("activity_templ")[0].childNodes[0].nodeValue;
					}
					//Added by mrunalini sinkar for activity code,place required ,activity description(end)

					//added by shraddha M for validation on time field[17/07/2020]
					if( detail.getElementsByTagName("strg_name")[0] != null && detail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
					{
						customerName = detail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("visit_time_from")[0] != null && detail.getElementsByTagName("visit_time_from")[0].childNodes[0] != null )
					{
						visitTimeFrom = detail.getElementsByTagName("visit_time_from")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("event_time_start")[0] != null && detail.getElementsByTagName("event_time_start")[0].childNodes[0] != null )
					{
						eventTimeStart = detail.getElementsByTagName("event_time_start")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("event_time_end")[0] != null && detail.getElementsByTagName("event_time_end")[0].childNodes[0] != null )
					{
						eventTimeEnd = detail.getElementsByTagName("event_time_end")[0].childNodes[0].nodeValue;
					}
					//Added by Bhagyashri T for Activity Place[28/JUL/21][start]
					if( detail.getElementsByTagName("activity_place")[0] != null && detail.getElementsByTagName("activity_place")[0].childNodes[0] != null )
					{
						actPlace = detail.getElementsByTagName("activity_place")[0].childNodes[0].nodeValue;
					}
					//Added by Bhagyashri T for Activity Place[28/JUL/21][end]
					console.log("visitTimeFrom is:::"+visitTimeFrom);
					console.log("eventTimeStart is:::"+eventTimeStart);
					console.log("eventTimeEnd is:::"+eventTimeEnd);
					if(visitTimeFrom == 'null' || visitTimeFrom.trim().length == 0)
					{
						alert("Invalid Time!<br>Start time can not be blank for any meeting for customer "+customerName);
						isValidWfData=false;
						return isValidWfData;
					}
					if(eventTimeStart == 'null' || eventTimeStart.trim().length == 0)
					{

						alert("Invalid Time!<br>Please select Visit Time for "+customerName);
						isValidWfData=false;
						return isValidWfData;
					}
					if(eventTimeEnd == 'null' || eventTimeEnd.trim().length == 0)
					{
						alert("End Time can not blank!<br>Meeting End Time can not be blank for any meeting for "+customerName);
						isValidWfData=false;
						return isValidWfData;
					}
					else
					{
						var retFlag = true;
						retFlag = validateEndTime(eventTimeStart, eventTimeEnd);
						if (!retFlag)
						{
							alert("Invalid Time! Visit Start Time can not be Greater Visit End Time");
							isValidWfData = false;
							return isValidWfData;
						}
					}
					//added by shraddha M for validation on time field[17/07/2020]


					if(actType == 'FW' && action == 'finish')
					{
						if(callOutcome != "0" && callOutcome != "9")
						{
							if(meetSumm.trim().length == 0)
							{
								//alert("Blank call notes! call notes can not be blank");
								//isValidData = false;
							}
						}
					}
					// added by rupali on 11/09/18 for applying validation for distance limit variance [start]
					var taggedLoc = "";
					var locReq = "";
					var reportingLoc = "";
					var varDistance = "";
					var allwDelyPrd="";
					var eventDate="";
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					console.log("attributeVal is:::"+attributeVal);
					if( detail.getElementsByTagName("variance_distance")[0] != null && detail.getElementsByTagName("variance_distance")[0].childNodes[0] != null )
					{
						varDistance = detail.getElementsByTagName("variance_distance")[0].childNodes[0].nodeValue;
						console.log("varDistance is:::"+varDistance);
					}
					//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(start)
					if( detail.getElementsByTagName("allwd_delay_prd")[0] != null && detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0] != null )
					{
						allwDelyPrd = detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
					{
						eventDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
						console.log("eventDate is:::"+eventDate);
					}
					//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] 20-06-2020
					if( detail.getElementsByTagName("loc_req")[0] != null && detail.getElementsByTagName("loc_req")[0].childNodes[0] != null )
					{
						locReq = detail.getElementsByTagName("loc_req")[0].childNodes[0].nodeValue;
					}
					console.log( "locReq is:::["+ locReq +"], actCode ["+ actCode +"]" );
					//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] END
					//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(end)
					// changes made by rupali on 28-02-19 as suggested by gulzar sir
					//if(varDistance.trim().length > 0 && actType == 'FW' && attributeVal != 'E' ) if(varDistance.trim().length > 0 && actType == 'FW' && locreq !=0)
					//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table]
					if( varDistance.trim().length > 0 && actType == 'FW' && locReq != "0" && actCode != "TC" )
					{
						//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(start)
						var currentDate = new Date();
						var diffDays = getDaysBetweenTwoDates(eventDate,currentDate);
						//added by mrunalini sinkar for allw_delay_prd on 3-10-2018(end)
						var reportingLoc = localStorage.getItem( 'CURRENT_GEO_POS' );
						if( detail.getElementsByTagName("tag_geopos")[0] != null && detail.getElementsByTagName("tag_geopos")[0].childNodes[0] != null )
						{
							taggedLoc = detail.getElementsByTagName("tag_geopos")[0].childNodes[0].nodeValue;
						}
						if( taggedLoc.trim().length == 0)
						{
							alert("Customer Not Tagged! \nThis customer is not tagged,Please do the customer tagging first");
							isValidWfData=false;
							return isValidWfData;
						}
						//Modified by Mrunalini Sinkar for allw_delay_prd on 03-10-2018
						//else if( taggedLoc.trim().length > 0 && reportingLoc.trim().length > 0)
						else if( taggedLoc.trim().length > 0 && reportingLoc.trim().length > 0 && (allwDelyPrd < diffDays || diffDays==0))
						{
							var distanceinMtr = getDistanceFromLatLonInMtr( taggedLoc.split(",")[0], taggedLoc.split(",")[1], reportingLoc.split(",")[0], reportingLoc.split(",")[1] );
							if(distanceinMtr > varDistance )
							{
								alert("Invalid Reporting Location! \nYou are reporting greater than the expected limit (500 meter)");
								isValidWfData=false;
								return isValidWfData;
							}
						}
					}
					// added by rupali on 11/09/18 for applying validation for distance limit variance [end]
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					console.log("attributeVal is"+attributeVal+"objFormName["+objFormName+"]");
					if(attributeVal != 'E')
					{
						if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
						{
							var eventDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
						{
							var actType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							var strgCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						}
						var oldActType = localStorage.getItem(eventDate+'_ActivityType');
						if((oldActType == null || oldActType.trim().length == 0) && action == 'finish')
						{
							//Added by Bhagyashri T for Activity Place[28/JUL/21][start]
							if(activityPlace != 'R')
							{ 
								localStorage.setItem(eventDate+'_ActivityType', actType);
								localStorage.setItem(eventDate+'_ActivityCode', actCode);
								localStorage.setItem(eventDate+'_ActivityDescr', actDescr);
								localStorage.setItem(eventDate+'_ActivityPlaceReq', placeReq);
								localStorage.setItem(eventDate+'_ParentActivityCode', parentActCode);
								localStorage.setItem(eventDate+'_ActivityTemplate', activityTemplate);
								//Added by Sadique on 27/06/2020 [loc_req related implementation]
								localStorage.setItem(eventDate+'_LocReq', locReq);
								localStorage.setItem(eventDate+'_ActivityActPlace', ActPlace);  //Added by Bhagyashri T for Activity Place[28/JUL/21]
							}
							//Added by Bhagyashri T for Activity Place[28/JUL/21][end]
						}

						var oldStrgCode = localStorage.getItem(eventDate+'_StrgCode');
						if(oldStrgCode != null && oldStrgCode.trim().length != 0 && action == 'finish')
						{
							oldStrgCode = oldStrgCode + "," + strgCode;
							localStorage.setItem(eventDate+'_StrgCode', oldStrgCode);
						}
						else if(action == 'finish')
						{
							localStorage.setItem(eventDate+'_StrgCode', strgCode);
						}
						oldEventDate = localStorage.getItem(salesPerson+'_eventDate');

						if(oldEventDate != null && oldEventDate.trim().length != 0 && action == 'finish')
						{
							oldEventDate = oldEventDate + "," + eventDate;
							localStorage.setItem(SalesPers+'_eventDate', oldEventDate);
						}
						else if(action == 'finish')
						{
							localStorage.setItem(SalesPers+'_eventDate', eventDate);

						}
						if(action == 'finish')
						{
							var locCode = "", locDescr = "", custClassInput = "", stockistCode = "", stockistName = "", locDetails = "",routeId="",stationType="",stationdescr="",routeType="",invoiceNoD="";
							if( detail.getElementsByTagName("oth_participant")[0] != null && detail.getElementsByTagName("oth_participant")[0].childNodes[0] != null )
							{
								var othParticipant = detail.getElementsByTagName("oth_participant")[0].childNodes[0].nodeValue;
								localStorage.setItem(eventDateNew+'_OthParticipant', othParticipant);
							}
							if( detail.getElementsByTagName("locality_code")[0] != null && detail.getElementsByTagName("locality_code")[0].childNodes[0] != null )
							{
								locCode = detail.getElementsByTagName("locality_code")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("locality_descr")[0] != null && detail.getElementsByTagName("locality_descr")[0].childNodes[0] != null )
							{
								locDescr = detail.getElementsByTagName("locality_descr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cust_class_input")[0] != null && detail.getElementsByTagName("cust_class_input")[0].childNodes[0] != null )
							{
								custClassInput = detail.getElementsByTagName("cust_class_input")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("stockist_code")[0] != null && detail.getElementsByTagName("stockist_code")[0].childNodes[0] != null )
							{
								stockistCode = detail.getElementsByTagName("stockist_code")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("stockist_name")[0] != null && detail.getElementsByTagName("stockist_name")[0].childNodes[0] != null )
							{
								stockistName = detail.getElementsByTagName("stockist_name")[0].childNodes[0].nodeValue;
							}
							//added by mrunalini sinkar to set route id 27-04-2019 (start)
							if( detail.getElementsByTagName("route_id")[0] != null && detail.getElementsByTagName("route_id")[0].childNodes[0] != null )
							{
								routeId = detail.getElementsByTagName("route_id")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("station_type")[0] != null && detail.getElementsByTagName("station_type")[0].childNodes[0] != null )
							{
								stationType = detail.getElementsByTagName("station_type")[0].childNodes[0].nodeValue;
							}
							//added by mrunalini sinkar to set route id 27-04-2019 (end)
							//added by mrunalini sinakr on 20-05-2019 for showing staion_descr on summary page(start)
							if( detail.getElementsByTagName("station_descr")[0] != null && detail.getElementsByTagName("station_descr")[0].childNodes[0] != null )
							{
								stationdescr = detail.getElementsByTagName("station_descr")[0].childNodes[0].nodeValue;
							}
							//added by mrunalini sinakr on 20-05-2019 for showing staion_descr on summary page(end)
							// added by mrunalini sinkar for getting route type 24-05-2019(start)
							if( detail.getElementsByTagName("route_type")[0] != null && detail.getElementsByTagName("route_type")[0].childNodes[0] != null )
							{
								routeType = detail.getElementsByTagName("route_type")[0].childNodes[0].nodeValue;
							}
							// added by mrunalini sinkar for getting route type 24-05-2019(end)
							// added by bhagyashri T for getting invoiceno29-11-2022(start)
							if( detail.getElementsByTagName("invoice_no")[0] != null && detail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
							{
								invoiceNoD = detail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
							}
							// added by bhagyashri T for getting invoiceno29-11-2022(end)
							locDetails = locCode +"|"+ locDescr +"|"+ custClassInput +"|"+ stockistCode +"|"+ stockistName +"|"+routeId+"|"+stationType+"|"+stationdescr+"|"+routeType+"|"+invoiceNoD;
							//alert("locDetails inside:::"+locDetails);
							//Added by Bhagyashri T for Activity Place[28/JUL/21][start]
							if(activityPlace != 'R')
							{
								localStorage.setItem(eventDateNew+'_LocalityDetails', locDetails);
							}
							//Added by Bhagyashri T for Activity Place[28/JUL/21][end]
							// added by rupali on 07/03/19 to set order of visit on summary screen [start]
							var maxOrderVisit = 0;
							maxOrderVisit = localStorage.getItem(eventDateNew+'_OrderOfVisit');
							maxOrderVisit++;
							var localtyCode = localStorage.getItem(eventDateNew+'_LocalityCode');
							var locDetail = "";
							var flag = false;

							//alert("localtyCode:::"+localtyCode);
							if(localtyCode != null && localtyCode.trim().length != 0)
							{
								var locList = localtyCode.split(',');
								for(var i=0; i<locList.length; i++)
								{
									var locCodeNew = locList[i].split('@')[0];
									var locOrder = locList[i].split('@')[1];
									if(locCodeNew == locCode)
									{
										flag = true;
										maxOrderVisit = locOrder;
									}
								}
								if(!flag)
								{
									locDetail = locCode+"@"+maxOrderVisit;
									localtyCode = localtyCode + "," + locDetail;
									localStorage.setItem(eventDateNew+'_LocalityCode', localtyCode);
									localStorage.setItem(eventDateNew+'_OrderOfVisit', maxOrderVisit);
								}
							}
							else
							{
								locDetail = locCode+"@"+maxOrderVisit;
								localStorage.setItem(eventDateNew+'_LocalityCode', locDetail);
								localStorage.setItem(eventDateNew+'_OrderOfVisit', maxOrderVisit);
							}
							// added by rupali on 07/03/19 to set order of visit on summary screen [end]
						}
					}
				}
				console.log("Inside localValData function having obj name is in calling localValData::["+objName+"]");
				isValidWfData = localWfValData('', currentFormData, objContext, action, objName, objFormName);
				console.log("after all val localValData function having obj name is in calling localValData::["+objName+"]");
			}
		}

		return isValidData;
	}
	else if(objName ==='stocks_transfer_wiz' || objName ==='stocks_receive_wiz')
	{
		var isValidWfData = true;
		console.log('inside localValData function in js file EDIT when click on subform**************************');
		return isValidWfData;
	}
}

/*
      function itemchangeData( objContext, action, objName, currentFormData, fieldName, domId, objFormName, fieldValue )
      {
	      //alert('call function itemchangeData');
	      var isItemchangeData = "";
	      if(objContext == 1)
	      {
		      //alert('savex_ria_wiz js called for itemchangeData objContext['+objContext+']');
		      isItemchangeData = "";
	      }
	      else if(objContext == 2)
	      {
		      //alert('savex_ria_wiz js called for itemchangeData objContext['+objContext+']');
		      isItemchangeData = "";
	      }
	      else if(objContext == 3)
	      {
		      //alert('savex_ria_wiz js called for itemchangeData objContext['+objContext+']');
		      if( fieldName === 'call_outcome' )
		      {
			      if( fieldValue === '0' || fieldValue === '0' )
			      {
				      isItemchangeData = "<Detail3 protectSubform=\"4,5,6,7\"><protect_subform><![CDATA[4,5,6,7]]></protect_subform></Detail3>";
			      }
			      else
			      {
				      isItemchangeData = "<Detail3 protectSubform=\"\"></Detail3>";
			      }

		      }
		      else
		      {
			      isItemchangeData = "";
		      }
	      }
	      else if(objContext == 8)
	      {
		      //alert('savex_ria_wiz js called for itemchangeData objContext['+objContext+']');
		      if( fieldName === 'call_outcome' )
		      {
			      if( fieldValue === '0' || fieldValue === '0' )
			      {
				      isItemchangeData = "<Detail8 protectSubform=\"9,10,11,12\"><protect_subform><![CDATA[9,10,11,12]]></protect_subform></Detail8>";
			      }
			      else
			      {
				      isItemchangeData = "<Detail8 protectSubform=\"\"></Detail8>";
			      }

		      }
		      else
		      {
			      isItemchangeData = "";
		      }
	      }
	      else
	      {
		      //alert('savex_ria_wiz js called for itemchangeData objContext['+objContext+'] \nNo locality selected');
		      isItemchangeData = "";
	      }
	      return isItemchangeData;
      }
 */
function localAutoNumberChange(editorObjName, currentFormNo, offlineRefVal, freeFormDataMap, fldName, fldValue, maxDomValue , isDoneSucess)
{
	globalObjName = editorObjName;
	
	console.log('inside localAutoNumberChange function in js file **************************');
	var checkitemchangeData = 1;
	console.log("Testing editorObjName ["+editorObjName+"] currentFormNo ["+currentFormNo+"] offlineRefVal ["+offlineRefVal+"] fldName ["+fldName+"] freeFormDataMap ["+freeFormDataMap+"] fldValue ["+fldValue+"] maxDomValue ["+maxDomValue+"] isDoneSucess ["+isDoneSucess+"]");
	if( maxDomValue != "" && maxDomValue.length > 0 )
	{
		console.log("Testing maxDomValue ["+maxDomValue+"]");
		if( isDoneSucess )
		{
			checkitemchangeData = parseInt(maxDomValue)+1;
		}
		else
		{
			checkitemchangeData = parseInt(maxDomValue)-1;
		}
	}
	console.log("Testing final fldValue ["+fldValue+"] checkitemchangeData ["+checkitemchangeData+"]");
	return checkitemchangeData;
}

var workDate="";
var SalesPers="";
var splCode = "", strgClassCode = "", regNo = "";
var itmDispTyp="";
//var totalPOBValue = 0;
var nMemCode ="";
var salesTypeGlobal = "";

function localItemChange(objContext, action, objName, currentFormData, fieldName, domId, objFormName, fieldValue, parentFormNo , parentDomID,buttonId , prevValue, itemCode, allFormDetaildata, dataModelJson)
{
	globalObjName = objName;
	console.log("Inside localItemChange function having obj name is::["+objName+"]");
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		console.log("dataModelJson in localItemChange: "+dataModelJson);
		console.log("Inside localItemChange function having obj name is strg_meet_dcr_realtime_wiz");
		var currentFormData=currentFormData;
		var objcon=objContext;
		console.log('inside localItemChange function in js file **************************'+currentFormData);
		//console.log('objContext ['+objcon+']');
		var checkitemchangeData = "";
		var allFormDetaildataDom = "";
		console.log("inside localItemChange allFormDetaildata "+allFormDetaildata);

		var itemChangeStr = "";
		//console.log('inside itemchangeData function in js file');
		//alert("fieldName =["+fieldName+"]");
		//added by prathamesh Jangam for calculation of POB and order value on client side--started
		//currentFormData = "<Root>"+currentFormData+"</Root>";
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		console.log("xmlVersion is in localItemChange: "+xmlVersion)
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			console.log("cureentform data is not null");

			if(xmlVersion == 0)
			{
				console.log("inside if");
				currentFormData = currentFormData;


			}
			else
			{
				console.log("inside else");
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}

		}
		else
		{
			console.log("nul currentformdata");
		}
		if (window.DOMParser)
		{
			//alert("inside window.DOMParser");
			parser = new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
					console.log("xmlDoc =["+currentFormData+"]");
					//added by mrunalini sinkar for sample management realted changes in realtime report(start)
					if(allFormDetaildata != null && allFormDetaildata.trim().length > 0)
					{
						var xmlVersionAll = allFormDetaildata.indexOf("<?xml version");
						console.log("xmlVersionAll is in localItemChange: "+xmlVersionAll)
						if(xmlVersionAll == 0)
						{
							allFormDetaildata = allFormDetaildata;
						}
						else
						{
							console.log("inside else");
							allFormDetaildata = "<Root>"+allFormDetaildata+"</Root>";
						}
						try
						{
							allFormDetaildataDom = parser.parseFromString(allFormDetaildata, "text/xml");
						}
						catch (e)
						{
							alert("XML parsing error.");
						}
					}
					else
					{
						console.log("nul currentformdata");
					}
					//added by mrunalini sinkar for sample management realted changes in realtime report(end)
					//Added by Pankaj R on 25-Sept-17 to hide the field or column which does not have any value in that field on itemchange
					console.log("fieldName ["+fieldName+"]");
					//console.log("xmlDoc in itemchange=["+currentFormData+"]");
					//console.log("allFormDetaildataDom in itemchange =["+allFormDetaildata+"]");
					if ( fieldName === 'strg_code')
					{
						var elemByTag = xmlDoc.getElementsByTagName('Detail1');
						var elemByItm = elemByTag.item(0);
						var noOfChild = elemByItm.childNodes.length

								for(var i = 0; i < noOfChild; i++)
								{
									var childElem = elemByItm.childNodes[i];
									if(childElem.nodeType === Node.ELEMENT_NODE)
									{
										if(childElem.getAttribute('id'))
										{
											var id = childElem.getAttribute('id').substr(20);
											var elemTohide = document.getElementById(id);
											if(elemTohide)
											{
												elemTohide.style.display = '';
											}
										}
										else
										{
											var id = childElem.nodeName;
											var elemTohide = document.getElementById(id);
											if(elemTohide)
											{
												elemTohide.style.display = '';
											}
										}
									}
								}
						if ( window.loadAutoInvokeLinkInMobile )
						{
							console.log( "window.loadAutoInvokeLinkInMobile" );
							window.loadAutoInvokeLinkInMobile( fieldName );
						}
					}
					//Added by Pankaj R on 25-Sept-17 to hide the field or column which does not have any value in that field on itemchange
					//added by vishal pathare on 24.1.18 for[stock related calculation on itemChange]Start.
					else if( fieldName === 'stock' || fieldName === 'remove' )
					{
						try
						{
							var totalStockValue = 0;

							var fieldId = objName+"Detail" + objContext + "." + parentDomID + "." + 'stock_info';
							var hiddenField = document.getElementById( fieldId );

							var jsonValue = hiddenField.value;

							var stockInfoJson = JSON.parse( jsonValue );

							for( var key in stockInfoJson )
							{
								if(!(key === 'name' || key === 'disp_name' || key === 'type' || key === 'protect'))
								{
									jsonValue = stockInfoJson[key];
									var currentLineData =jsonValue.split('|');
									var stkValue = currentLineData[0];
									if( (stkValue.trim()).length > 0 )
									{
										totalStockValue += parseInt( stkValue );
									}
								}
							}

							var stockQtyFieldId = "Detail" + objContext + "." + parentDomID + "." +'stock_qty';
							var stockQtyField = document.getElementById( stockQtyFieldId );
							if( totalStockValue == 0 )
							{
								stockQtyField.value = "";
							}
							else
							{
								stockQtyField.value = totalStockValue;
							}
						}
						catch(e)
						{
							console.log('Exception occured in itemchange js['+e+']');
						}
					}
					//added by vishal pathare on 24.1.18 for[stock related calculation on itemChange]End.
				}

			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		var totalPOBValue = 0;
		var totalGSTValue =0;
		var totalAmount =0;
		var invoiceItem="";
		var totalBasicAmt =0;
		var totalSGSTValue =0;
		var totalCGSTValue =0;
		var invoiceAmount =0;
		var roundOff=0;
		var amountWrd="";
		var amountInWrd="";
		if(xmlDoc != null )
		{
			//if(objContext == 3)
			if(objFormName == 'doctor')
			{
				var activityType="";
				var eventType="";
				var activityDescr="";
				var subformProtect="";
				var placeRequired="";
				var activityPlace=""; //Added by Bhagyashri T for Activity Place[28/JUL/21]
				var custType="";
				var stockistCode="";
				//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
				var activityTempl ="";
				var stockistName="",gradeTypes="",visitedWithDesignCode="";
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				var time = getStartTime();
				var setVisitTime = "";
				//Added by sadique shaikh on 18-02-2020 [For Event Type 'OT' [For attachment of images if users signed consent yes]]Start
				var signedConsents = "";
				var planBeats="",planRoute="";
				var locReq = "",displayTimeField="";
				var isFortuneActivity="";
				var allowVisitTime="";
				var custTypeDetail="";			// added by shweta for cust_type itemchange 		
				var docRandomNo = Math.floor(Math.random()*1000000);
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					// added by rupali on 23/02/18 for edit mode of realtime report [start]
					if( detail.getElementsByTagName("attribute")[0] != null )
					{
						updateFlagVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					}
					console.log("updateFlagVal is"+updateFlagVal);
					// added by rupali on 23/02/18 for edit mode of realtime report [end]
					if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
					{
						activityType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
						console.log("activity type is:"+activityType);
					}
					//added by mrunalini sinkar for offline changes on 16-feb-2018[start]
					if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
					{
						eventType = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
						console.log("eventType type is:"+eventType);
						//Added by Amey W. [OT activity related implementation] on 18/02/2020
						selectedActivity = eventType;
						console.log( "Amy localItemchange() selectedActivity ["+ selectedActivity +"]" );
					}
					if( detail.getElementsByTagName("activity_descr")[0] != null && detail.getElementsByTagName("activity_descr")[0].childNodes[0] != null )
					{
						activityDescr = detail.getElementsByTagName("activity_descr")[0].childNodes[0].nodeValue;
						console.log("activity descr  is:"+eventType);
					}
					if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
					{
						workDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
					{
						SalesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
						console.log("sales_pers descr  is:"+SalesPers);
					}
					if( detail.getElementsByTagName("subform_protect")[0] != null && detail.getElementsByTagName("subform_protect")[0].childNodes[0] != null )
					{
						subformProtect = detail.getElementsByTagName("subform_protect")[0].childNodes[0].nodeValue;
						console.log("subformProtect is:"+subformProtect);
					}
					//added by mrunalini sinkar for offline changes on 16-feb-2018[end]

					// added by rupali on 23/02/18 for edit mode of realtime report [start]
					if( detail.getElementsByTagName("call_outcome")[0] != null && detail.getElementsByTagName("call_outcome")[0].childNodes[0] != null )
					{
						callOutcome = detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
						console.log("callOutcome is:"+callOutcome);
					}
					// added by rupali on 23/02/18 for edit mode of realtime report [end]
					//added by mrunalini sinkar on 09-sep-2018 for place required changes (start)
					if( detail.getElementsByTagName("place_required")[0] != null && detail.getElementsByTagName("place_required")[0].childNodes[0] != null )
					{
						placeRequired = detail.getElementsByTagName("place_required")[0].childNodes[0].nodeValue;
						console.log("placeRequired type is:"+placeRequired);
					}
					//added by mrunalini sinkar on 09-sep-2018 for place required changes (end)
					if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
					{
						custType = detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
						console.log("cust_type is:"+custType);
					}
					if( detail.getElementsByTagName("stockist_code")[0] != null && detail.getElementsByTagName("stockist_code")[0].childNodes[0] != null )
					{
						stockistCode = detail.getElementsByTagName("stockist_code")[0].childNodes[0].nodeValue;
						//alert("stockist_code  is:"+stockistCode);
					}
					if( detail.getElementsByTagName("stockist_name")[0] != null && detail.getElementsByTagName("stockist_name")[0].childNodes[0] != null )
					{
						stockistName = detail.getElementsByTagName("stockist_name")[0].childNodes[0].nodeValue;
						//alert("stockist_name  is:"+stockistName);
					}
					if( detail.getElementsByTagName("grade_type")[0] != null && detail.getElementsByTagName("grade_type")[0].childNodes[0] != null )
					{
						gradeTypes = detail.getElementsByTagName("grade_type")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("survey_templ")[0] != null && detail.getElementsByTagName("survey_templ")[0].childNodes[0] != null )
					{
						DocsurveyTemp = detail.getElementsByTagName("survey_templ")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("visited_with_design_code")[0] != null && detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0] != null )
					{
						visitedWithDesignCode = detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0].nodeValue;
						console.log("visited_with_design_code type is:"+visitedWithDesignCode);
					}
					//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm Start
					if( detail.getElementsByTagName("activity_templ")[0] != null && detail.getElementsByTagName("activity_templ")[0].childNodes[0] != null )
					{
						activityTempl = detail.getElementsByTagName("activity_templ")[0].childNodes[0].nodeValue;
						console.log("activityTempl  is:"+activityTempl);
					}
					//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm End
					if( detail.getElementsByTagName("set_visit_time")[0] != null && detail.getElementsByTagName("set_visit_time")[0].childNodes[0] != null )
					{
						setVisitTime = detail.getElementsByTagName("set_visit_time")[0].childNodes[0].nodeValue;
					}
					//Added by sadique shaikh on 18-02-2020 [For Event Type 'OT' [For attachment of images if users signed consent yes]]
					if( detail.getElementsByTagName("cust_conf")[0] != null && detail.getElementsByTagName("set_visit_time")[0].childNodes[0] != null )
					{
						signedConsents = detail.getElementsByTagName("cust_conf")[0].childNodes[0].nodeValue;
					}
					//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] START
					if( detail.getElementsByTagName("loc_req")[0] != null && detail.getElementsByTagName("loc_req")[0].childNodes[0] != null )
					{
						locReq = detail.getElementsByTagName("loc_req")[0].childNodes[0].nodeValue;
					}
					//added by shraddha M[17/07/2020]
					if( detail.getElementsByTagName("display_time_fld")[0] != null && detail.getElementsByTagName("display_time_fld")[0].childNodes[0] != null )
					{
						displayTimeField = detail.getElementsByTagName("display_time_fld")[0].childNodes[0].nodeValue;
					}
					//added by shraddha M[17/07/2020]
					//added by Hariom S for fortune [18/05/2021]
					if( detail.getElementsByTagName("allow_chg_visittime")[0] != null && detail.getElementsByTagName("allow_chg_visittime")[0].childNodes[0] != null )
					{
						allowVisitTime = detail.getElementsByTagName("allow_chg_visittime")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_fortune_activity")[0] != null && detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0] != null )
					{
						isFortuneActivity = detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("cust_type_detail")[0] != null && detail.getElementsByTagName("cust_type_detail")[0].childNodes[0] != null )
					{
						custTypeDetail = detail.getElementsByTagName("cust_type_detail")[0].childNodes[0].nodeValue;
					}
					//Added by Bhagyashri T for Activity Place[28/JUL/21][start]
					if( detail.getElementsByTagName("activity_place")[0] != null && detail.getElementsByTagName("activity_place")[0].childNodes[0] != null )
					{
						activityPlace = detail.getElementsByTagName("activity_place")[0].childNodes[0].nodeValue;
						console.log("activityPlace type is:"+activityPlace);
					}
					if( detail.getElementsByTagName("visited_with")[0] != null && detail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
					{
						team = detail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
					}
					
					if( detail.getElementsByTagName("sales_type")[0] != null && detail.getElementsByTagName("sales_type")[0].childNodes[0] != null )
					{
					var	salesType = detail.getElementsByTagName("sales_type")[0].childNodes[0].nodeValue;
						console.log("salestype is:"+salesType);
						
						if(salesType == 'C')
						{
							salesTypeGlobal = salesType;
						}
						
					}
					
					//Added by Bhagyashri T for Activity Place[28/JUL/21][end]
					console.log("allowVisitTime allowVisitTime "+allowVisitTime);
					console.log("isFortuneActivity isFortuneActivity "+isFortuneActivity);
					//added by Hariom S for fortune [18/05/2021]
					console.log("displayTimeField displayTimeField "+displayTimeField);
					//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] END
					//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm Start
					if( eventType == 'MI' || eventType == 'OT' )
					{
						DocsurveyTemp = activityTempl;
					}
					//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm End
				}
				var currentDate = new Date();
				var diffDays = getDaysBetweenTwoDates(workDate,currentDate);
				
				
				if( fieldName === 'event_date')
				{
					//Added by mrunalini sinkar for protect fields on event date item change(start)
					var actTypes = localStorage.getItem(fieldValue+'_ActivityType');
					var eventCode = localStorage.getItem(fieldValue+'_ActivityCode');
					var eventDescr = localStorage.getItem(fieldValue+'_ActivityDescr');
					var actPlaceReq = localStorage.getItem(fieldValue+'_ActivityPlaceReq');
					var parentActCode = localStorage.getItem(fieldValue+'_ParentActivityCode');
					var activityTempl = localStorage.getItem(fieldValue+'_ActivityTemplate');
					//Added by Sadique on 27/06/2020 [loc_req related implementation]
					var locReqStorage = localStorage.getItem(fieldValue+'_LocReq');
					var activityPlc = localStorage.getItem(fieldValue+'_ActivityActPlace'); //Added by Bhagyashri T for Activity Place[28/JUL/21]


					if(actTypes != null && actTypes.trim().length != 0)
					{
						activityType=actTypes;
						placeRequired=actPlaceReq;
						eventCode=eventCode;
						eventDescr=eventDescr;
						parentActCode = parentActCode;
						activityTempl = activityTempl;
						activityPlace = activityPlc; //Added by Bhagyashri T for Activity Place[28/JUL/21]
					}
					else
					{
						activityType=localStorage.getItem('_defActType');
						eventCode=localStorage.getItem('_defActCode');
						eventDescr=localStorage.getItem('_defActDescr');
						placeRequired=localStorage.getItem('_defActPlaceReq');
						parentActCode=localStorage.getItem('_defParentActCode');
						activityTempl =localStorage.getItem('_defActivityTempl');
						activityPlace =localStorage.getItem('_defActivityPlace'); //Added by Bhagyashri T for Activity Place[28/JUL/21]
					}
					//var currentDate = new Date();
					//var diffDays = getDaysBetweenTwoDates(workDate,currentDate);
					console.log('fieldName === event_date activityType['+activityType+'] updateFlagVal['+updateFlagVal+']' );
					//Added by Prasad on 19/12/19 [coaching related implementation]

					// Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [START]
					var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
					prefixes = ['1st', '2nd', '3rd', '4th', '5th'];

					let splitDate = workDate.split('/');
					var modifiedEvenDate = splitDate[1]+'/'+splitDate[0]+'/'+splitDate[2];
					var d1 = new Date(modifiedEvenDate);
					var dayName = days[d1.getDay()];
					var weekAndDay = '';
					if(d1.getDate() % 7 == 0)
					{
						weekAndDay = prefixes[Math.floor((d1.getDate() / 7) - 1)] + ' ' + days[d1.getDay()];
					}
					else
					{
						weekAndDay = prefixes[Math.floor(d1.getDate() / 7)] + ' ' + days[d1.getDay()];
					}
					console.log('New WeekDay'+weekAndDay);
					var empCode1 = localStorage.getItem( 'EMP_CODE' );
					empCode1 = getUserInfo( "empCode" );
					if(empCode1)
					{
						empCode1 = empCode1.trim();
					}

					if(! Array.isArray(routeData))
					{
						routeData = JSON.parse(routeData);
					}
					if(! Array.isArray(customerData))
					{
						customerData = JSON.parse(customerData);
						console.log('customerData Cust:'+customerData);
					}
					if(! Array.isArray(visitedCust))
					{
						visitedCust = JSON.parse(visitedCust);
						console.log('Visited Cust New:'+visitedCust[0]);
					}
					var selectedEmpId = "";
					if(Array.isArray(routeData))
					{
						locCode = "";
						locDescr = "";
						routeId = "";
						const resSuper = routeData.filter(word => {
							return (selectedEmpId) ? (Object.keys(word)[0].includes(selectedEmpId)) : (Object.keys(word)[0].includes(empCode1))
						});
						console.log('resSuper itemchg:: ',resSuper);

						const result = resSuper.filter(word => {return Object.values(word)[0].PLAN_DAYS.includes(weekAndDay)});
						for (const res of result) 
						{
							console.log('res ::: ',res);

							routeId = Object.values(res)[0].ROUTE_ID;

							let resVal = '';
							visitedCust.forEach(e => {
								console.log('Object.keys(e)[0] : ',Object.keys(e)[0],Object.keys(e)[0] == parseInt(routeId));
								if(Object.keys(e)[0] == parseInt(routeId)){
									resVal = Object.values(e)[0];
									console.log('resval ::: ',resVal);
								}
							});

							let resValArr = resVal.split(",");
							// alert(workDate+'_'+routeId+'_StrgCode');
							let localStorageCust = localStorage.getItem(workDate+'_'+routeId+'_StrgCode');
							let localStorageCustArr = localStorageCust ? localStorageCust.split(",") : [];

							const allVisitedNames = new Set([
							                                 ...resValArr,
							                                 ...localStorageCustArr
							                                 ]);
							allVisitedNames.delete("");
							const allVisitedNamesArr = [...allVisitedNames];
							console.log('allVisitedNamesArr :: ',allVisitedNamesArr);

							const plannedV = customerData.find(element => element.hasOwnProperty(routeId));
							console.log('plannedV : ',plannedV);
							let plannedVArr = Object.values(plannedV)[0].split(",");
							console.log('plannedVArr : ',plannedVArr);

							let allVisited = false;
							if(plannedVArr.every(item => allVisitedNamesArr.includes(item)) && allVisitedNamesArr.every(item => plannedVArr.includes(item)))
							{
								allVisited = true;
							}
							console.log('allVisited ::: ',allVisited);

							if(!allVisited) 
							{
								locCode = Object.values(res)[0].LOCALITY_CODE;
								locDescr = Object.values(res)[0].DESCR;
								stockistCode = Object.values(res)[0].STOCKIST_CODE;
								stockistName = Object.values(res)[0].STOCKIST_NAME;
								itemSer = Object.values(res)[0].ITEM_SER;
								stationdescr = Object.values(res)[0].STATION_DESCR;
								routeType = Object.values(res)[0].ROUTE_TYPE;
								invoiceNoD = Object.values(res)[0].INVOICE_NO;
								break;
								// alert('Not All viisted...');
							}
							else{
								routeId = "";
							}
						}

						for (const res of result) 
						{
							console.log('res ::: ',res);

							var route = Object.values(res)[0].ROUTE_ID;

							let resVal = '';
							visitedCust.forEach(e => {
								console.log('Object.keys(e)[0] : ',Object.keys(e)[0],Object.keys(e)[0] == parseInt(route));
								if(Object.keys(e)[0] == parseInt(route)){
									resVal = Object.values(e)[0];
									console.log('resval ::: ',resVal);
								}
							});

							let resValArr = resVal.split(",");
							// alert(workDate+'_'+routeId+'_StrgCode');
							let localStorageCust = localStorage.getItem(workDate+'_'+route+'_StrgCode');
							let localStorageCustArr = localStorageCust ? localStorageCust.split(",") : [];

							const allVisitedNames = new Set([
							                                 ...resValArr,
							                                 ...localStorageCustArr
							                                 ]);
							allVisitedNames.delete("");
							const allVisitedNamesArr = [...allVisitedNames];
							console.log('allVisitedNamesArr :: ',allVisitedNamesArr);

							const plannedV = customerData.find(element => element.hasOwnProperty(route));
							console.log('plannedV : ',plannedV);
							let plannedVArr = Object.values(plannedV)[0].split(",");
							console.log('plannedVArr : ',plannedVArr);

							let allVisited = false;
							if(plannedVArr.every(item => allVisitedNamesArr.includes(item)) && allVisitedNamesArr.every(item => plannedVArr.includes(item)))
							{
								allVisited = true;
							}
							console.log('allVisited ::: ',allVisited);

							var beatDescr = Object.values(res)[0].DESCR;
							if(planBeats==null ||planBeats.trim().length==0)
							{
								planBeats=beatDescr;
							}
							else
							{
								planBeats=planBeats+", "+beatDescr;

							}
							if(planRoute==null ||planRoute.trim().length==0)
							{
								planRoute=route;
							}
							else
							{
								planRoute=planRoute+","+route;
							}
						}
					}
					// Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [END]

					//if( activityType !='FW'  && updateFlagVal != 'E')
					if( ( activityType !='FW'  && updateFlagVal != 'E') || eventType  == 'CA' )
					{
						//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
						if( gradeTypes == 'M' )
						{
							if( eventType == 'CA' )
							{
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() )  && team!='SELF')
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code>";
								}
							}
							if(placeRequired == 'Y')
							{
								itemChangeStr +="<visited_with protect = '0' visible = '1'></visited_with>";
							}
						}
						else
						{
							itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code>";
							if(placeRequired == 'Y')
							{
								itemChangeStr +="<visited_with protect = '0' visible = '0'></visited_with>";
							}
						}
						//Change by sadique shaikh on 18-02-2020 [For Event Type 'OT' ]] Start
						// Commented and // Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [START]
						itemChangeStr +="<strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
								//"<locality_code protect = '0' visible = '1'></locality_code><route_id protect = '0' visible = '1'></route_id><locality_descr protect = '1' visible = '1'></locality_descr>" +
								//"<next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
								"<locality_code protect = '0' visible = '1'><![CDATA["+locCode+"]]></locality_code><route_id protect = '0' visible = '1'><![CDATA["+routeId+"]]></route_id><locality_descr protect = '1' visible = '1'><![CDATA["+locDescr+"]]></locality_descr>" +
								"<next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name><stockist_code protect = '1' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code>" +
								"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'>" +
								"</strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>"
								"<cust_conf visible = '0'><![CDATA[]]></cust_conf>" +
								"<cust_conf_proof visible = '0'><![CDATA[]]></cust_conf_proof>" +
								"<member_present visible = '0'><![CDATA[]]></member_present>" +
								"<pob_item visible = '0'><![CDATA[]]></pob_item>" +
								"<strg_type protect = '1' visible = '0'></strg_type>";
						//Change by sadique shaikh on 18-02-2020 [For Event Type 'OT' ]] End
						//added by Hariom S for fortune [18/05/2021]
						if( isFortuneActivity  == 'Y')
						{
							if( allowVisitTime  == 'Y')
							{
								itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
							else if( allowVisitTime  == 'N')
							{

								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'B'  && diffDays > 0)
							{

								itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
							else
							{

								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}


						}
						//added by Hariom S for fortune [18/05/2021]
					}
					else
					{
						/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
						if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
						{
							//Changed by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
							if( gradeTypes != 'M' && ( eventType == 'MI' || eventType == 'OT' ) )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform>";
							}
							else if(team=='SELF')
							{
								itemChangeStr= "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' ><protect_subform><![CDATA[coaching]]></protect_subform>";
							}
							else
							{
								itemChangeStr= "<Detail1 domID='"+domId+"' protectSubform=\'\'>";
							}
						}
						else
						{
							//Changed by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
							if( gradeTypes != 'M' && ( eventType == 'MI' || eventType == 'OT' ) )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform>";
							}
							else
							{
								itemChangeStr= "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' ><protect_subform><![CDATA[coaching]]></protect_subform>";
							}
						}
						// Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [START]
						//itemChangeStr += "<strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '0' visible = '0'></address_as>" +
						//"<route_id protect = '0' visible = '1'></route_id><next_plan_date visible = '1'></next_plan_date><gender protect = '0' visible = '0'></gender><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><locality_code protect = '0' visible = '1'></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
						itemChangeStr += "<strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '1' visible = '1'></address_as>" +
								"<route_id protect = '0' visible = '1'><![CDATA["+routeId+"]]></route_id><next_plan_date visible = '1'></next_plan_date><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust><locality_code protect = '0' visible = '1'><![CDATA["+locCode+"]]></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
								"<addr3 protect = '0' visible = '0'></addr3><age protect = '0' visible = '0'></age><gender protect='0' visible = '0'><![CDATA[M]]></gender><qualification protect = '0' visible = '0'></qualification><spl_code protect = '0' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><remarks protect = '0' visible = '1'></remarks><strg_class_code protect = '0' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><visited_with protect = '0' visible = '1'></visited_with>" +
								//"<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code><locality_descr protect = '1' visible = '1'></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr>" +
								"<stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name><stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><locality_descr protect = '1' visible = '1'><![CDATA["+locDescr+"]]></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr>" +
								"<copy_plan protect='1' visible = '1'><![CDATA[N]]></copy_plan><oth_participant protect = '0' visible = '1'></oth_participant>"
								"<cust_conf visible = '0'><![CDATA[]]></cust_conf>" +
								"<cust_conf_proof visible = '0'><![CDATA[]]></cust_conf_proof>" +
								"<member_present visible = '0'><![CDATA[]]></member_present>" +
								"<pob_item visible = '0'><![CDATA[]]></pob_item>" +
								"<strg_type protect = '1' visible = '0'></strg_type>";
						//added by Hariom S for fortune [18/05/2021]
						if( isFortuneActivity  == 'Y')
						{
							if( allowVisitTime  == 'Y')
							{
								itemChangeStr +="<event_time_start><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
							else if( allowVisitTime  == 'N')
							{

								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'B'  && diffDays > 0)
							{

								itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
							else
							{

								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
						}
						//added by Hariom S for fortune [18/05/2021]
					}
					console.log("diffDays are::["+diffDays+"]");
					console.log("setVisitTime is::["+setVisitTime+"]");
					console.log("displayTimeField is::["+displayTimeField+"]");
					//added by Hariom S for fortune [18/05/2021]
					if( isFortuneActivity  == 'Y')
					{
						if( allowVisitTime  == 'Y')
						{
							itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

						}
						else if( allowVisitTime  == 'N')
						{
							itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
						}
						else if( allowVisitTime  == 'B'  && diffDays > 0)
						{
							itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

						}
						else
						{
							itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

						}


					}
					else
					{
						if(diffDays > 0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
						{
							if(displayTimeField == "Y")
							{
								if(custType == "LISTED")
								{
									itemChangeStr +="<event_time_start visible = '1'><![CDATA[]]></event_time_start>" +
											"<event_time_end visible = '0'><![CDATA[]]></event_time_end><visit_time_from visible = '0'><![CDATA[]]></visit_time_from>" ;
								}
								else
								{
									itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
											"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;
								}

							}
							else
							{
								itemChangeStr +="<event_time_start visible = '1'><![CDATA[]]></event_time_start>" +
										"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '0'><![CDATA[]]></visit_time_from>" ;
							}

						}
						else
						{
							itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
						}
					}
					if(actTypes != null && actTypes.trim().length != 0)
					{
						if(eventCode == "CA")
						{
							itemChangeStr +="<protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><event_type protect = '1'><![CDATA["+eventCode+"]]></event_type><activity_descr protect = '1'><![CDATA["+eventDescr+"]]></activity_descr>" +
									"<activity_type protect = '1'><![CDATA["+activityType+"]]></activity_type><place_required protect = '1'><![CDATA["+placeRequired+"]]></place_required><route_id protect = '0' visible = '1'></route_id><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><visited_with protect = '0' visible = '1'></visited_with>" +
									"<strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type>" +
									"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>" +
									"<next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant>" +
									"<stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
									"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'>" +
									"</strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><strg_type protect = '1' visible = '0'></strg_type><visited_with_design_code></visited_with_design_code><reg_no visible = '0'></reg_no><meeting_status visible = '0'></meeting_status><last_meet_summ visible = '0'></last_meet_summ><last_meet_date visible = '0'></last_meet_date><contact_pers visible = '0'></contact_pers><contact_pers_name visible = '0'></contact_pers_name><member_present visible = '0'><![CDATA[]]></member_present><pob_item visible = '0'><![CDATA[]]></pob_item><sku_value visible = '0'><![CDATA[]]></sku_value><qualification visible = '0'></qualification>";
						}
						else
						{
							itemChangeStr += "<event_type protect = '1'><![CDATA["+eventCode+"]]></event_type><activity_descr protect = '1'><![CDATA["+eventDescr+"]]></activity_descr>" +
									"<activity_type protect = '1'><![CDATA["+activityType+"]]></activity_type><place_required protect = '1'><![CDATA["+placeRequired+"]]></place_required>" ;
						}
					}
					else
					{
						itemChangeStr += "<event_type protect = '0'><![CDATA["+eventCode+"]]></event_type><activity_descr protect = '0'><![CDATA["+eventDescr+"]]></activity_descr>" +
								"<activity_type protect = '0'><![CDATA["+activityType+"]]></activity_type><place_required protect = '0'><![CDATA["+placeRequired+"]]></place_required>" ;
					}
					itemChangeStr +="<plan_days visible = '0'><![CDATA["+weekAndDay+"]]></plan_days>"; // Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [START]
					itemChangeStr +="<event_week_day><![CDATA["+ weekAndDay +"]]></event_week_day><route_plan><![CDATA["+ planRoute +"]]></route_plan><beat_plan><![CDATA["+ planBeats +"]]></beat_plan>";
					itemChangeStr +="</Detail1>";
					//Added by mrunalini sinkar for protect fields on event date item change(end)
				}
				else if( fieldName === 'event_type')
				{
					console.log("fieldName is"+fieldName);
					// commented by rupali on 23/02/18 for edit mode of realtime report [start]
					/*if( fieldValue === 'null' || fieldValue.trim().length == 0 )
					{
						itemChangeStr = "<Detail1 domID='"+domId+"'><activity_descr protect = '1'></activity_descr></Detail1>";
					}*/
					// commented by rupali on 23/02/18 for edit mode of realtime report [end]
					//added by mrunalini sinkar for protect and visible the field as per activity type16-feb-2018(start)
					// commented by rupali on 23/02/18 for edit mode of realtime report [start]
					/*if( activityType == 'NCW' ||  activityType == 'LEAVE')
					{
						itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type>" +
								"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr><event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'></meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
								"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
								"</Detail1>";
					}
					else
					{
						itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\'><activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr><event_type protect = '0'><![CDATA["+eventType+"]]></event_type><activity_type><![CDATA["+activityType+"]]></activity_type><strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '0' visible = '1'></strg_name><address_as protect = '0' visible = '0'></address_as>" +
								"<gender protect = '0' visible = '0'></gender><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><locality_code protect = '0' visible = '1'></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
								"<addr3 protect = '0' visible = '0'></addr3><spl_code protect = '0' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><remarks protect = '0' visible = '1'></remarks><strg_class_code protect = '0' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><visited_with protect = '0' visible = '1'></visited_with>" +
								"<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code><locality_descr protect = '1' visible = '1'></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr><event_time_start visible = '1'></event_time_start><event_time_end visible = '1'></event_time_end><copy_plan protect='1' visible = '1'><![CDATA[N]]></copy_plan><oth_participant protect = '0' visible = '1'></oth_participant>" +
								"</Detail1>";
					}*/
					// commented by rupali on 23/02/18 for edit mode of realtime report [end]
					// added by rupali on 23/02/18 for edit mode of realtime report [start]
					// commented by Mrunaini sinkar on 11/06/18 to set --NA-- in leave of realtime report [start]
					/*if( activityType == 'NCW' ||  activityType == 'LEAVE' && updateFlagVal != 'E') // added condition of updateFlagVal by rupali on 23/02/18 for edit mode of realtime report
					{
						itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching,survey\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type>" +
										"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr><event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'></meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
										"</Detail1>";
					}*/
					// commented by Mrunaini sinkar on 11/06/18 to set --NA-- in leave of realtime report [end]
					//added & commenetd by mrunalini sinkar for NFE not found 13-02-2019(start)
					//if( activityType == 'NFW' ||  activityType == 'LEAVE' && updateFlagVal != 'E') // added by mrunalini S. to set --NA-- into meetsumm
					//Added by Prasad on 19/12/19 [coaching related implementation]
					//if( activityType !='FW'  && updateFlagVal != 'E')
					console.log("eventType ["+ eventType +"] activityType ["+ activityType +"] gradeTypes ["+ gradeTypes+"] placeRequired ["+ placeRequired +"]");
					if( (activityType !='FW'  && updateFlagVal != 'E') || eventType  == 'CA')
					{
						//if(activityType == 'NFW')
						if( gradeTypes == 'M' )
						{
							if(placeRequired == 'Y')
							{
								if( eventType  == 'CA' )
								{
									console.log("4105 team::["+team)
									if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) && team!='SELF' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\'  ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><route_id protect = '0' visible = '1'></route_id><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><route_id protect = '0' visible = '1'></route_id><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
									}
								}
								else if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:PeopleTrained\'  ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><route_id protect = '0' visible = '0'></route_id><strg_code protect = '1' visible = '0'></strg_code><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:Receipt\'  ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><route_id protect = '0' visible = '0'></route_id><strg_code protect = '1' visible = '0'></strg_code><call_outcome protect = '1' visible = '1'></call_outcome><meet_summ protect = '1' visible = '1'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									//Change member_presentby sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]]Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'></strg_code><route_id protect = '0' visible = '1'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}
								itemChangeStr +="<visited_with protect = '0' visible = '1'></visited_with><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
										"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>" +
										//"<event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end>" +
										"<next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant>" +
										"<stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'>" +
										"</strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><strg_type protect = '1' visible = '0'></strg_type><visited_with_design_code></visited_with_design_code>";
							}
							else
							{
								if( eventType  == 'CA' )
								{
									/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
									if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) && team!='SELF')
									{
										//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] STart
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><route_id protect = '0' visible = '1'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><route_id protect = '0' visible = '1'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
									}
								}
								else if( eventType == 'MI' )
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]]Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\'  changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><strg_code protect = '1' visible = '0'></strg_code><route_id protect = '0' visible = '0'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'></strg_code><route_id protect = '0' visible = '0'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}
								itemChangeStr +="<strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
										"<locality_code protect = '0' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr>" +
										"<next_plan_date protect='1' visible = '0'></next_plan_date><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'>" +
										"</class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><strg_type protect = '1' visible = '0'></strg_type><visited_with_design_code></visited_with_design_code>";
								//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]]ENd
							}
						}
						else
						{
							console.log ("placeRequired ["+ placeRequired +"] eventType ["+ eventType +"]");
							if(placeRequired == 'Y')
							{
								console.log ("placeRequired part",eventType);
								if( eventType == 'MI' )
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><route_id protect = '0' visible = '1'></route_id><strg_code protect = '1' visible = '0'></strg_code>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><route_id protect = '0' visible = '1'></route_id><strg_code protect = '1' visible = '0'></strg_code><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									//Change member_presentby sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]]Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'></strg_code><route_id protect = '0' visible = '1'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}

								itemChangeStr +="<visited_with protect = '0' visible = '0'></visited_with><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
										"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>" +
										//"<event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end>" +
										"<next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant>" +
										"<stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'>" +
										"</strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><strg_type protect = '1' visible = '0'></strg_type><visited_with_design_code></visited_with_design_code>";
							}
							else
							{
								if( eventType == 'MI' )
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]]Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><strg_code protect = '1' visible = '0'></strg_code><route_id protect = '0' visible = '1'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><strg_code protect = '1' visible = '0'></strg_code><route_id protect = '0' visible = '1'></route_id><call_outcome protect = '1' visible = '1'></call_outcome><meet_summ protect = '1' visible = '1'><![CDATA[---NA---]]></meet_summ>";
								}
								//Added by sadique shaikh on 18-02-2020 [ for even type == OT ]]End
								//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm End
								else
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'></strg_code><route_id protect = '0' visible = '1'></route_id><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
								}
								itemChangeStr +="<strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
										"<locality_code protect = '0' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr>" +
										"<next_plan_date protect='1' visible = '0'></next_plan_date><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'>" +
										"</class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><strg_type protect = '1' visible = '0'></strg_type><visited_with_design_code></visited_with_design_code>";
								//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]]ENd
							}
						}
						if( eventType == 'OT' )
						{
							itemChangeStr +="<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
									"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
									"<member_present visible = '1'><![CDATA[]]></member_present>" +
									"<pob_item visible = '1'><![CDATA[]]></pob_item>";
						}
						else
						{
							itemChangeStr +="<cust_conf visible = '0'><![CDATA[]]></cust_conf>" +
									"<cust_conf_proof visible = '0'><![CDATA[]]></cust_conf_proof>" +
									"<member_present visible = '0'><![CDATA[]]></member_present>" +
									"<pob_item visible = '0'><![CDATA[]]></pob_item>";
						}
						//added by Hariom S for fortune [18/05/2021]
						if( isFortuneActivity  == 'Y')
						{
							if( allowVisitTime  == 'Y')
							{
								itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
							else if( allowVisitTime  == 'N')
							{
								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'B'  && diffDays > 0)
							{
								itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else
							{
								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}


						}
						itemChangeStr+="<reg_no visible = '0'></reg_no><beat_plan visible = '0'></beat_plan><meeting_status visible = '0'></meeting_status><last_meet_summ visible = '0'></last_meet_summ><last_meet_date visible = '0'></last_meet_date><contact_pers visible = '0'></contact_pers><contact_pers_name visible = '0'></contact_pers_name><sku_value visible = '0'><![CDATA[]]></sku_value><qualification visible = '0'></qualification>";
						itemChangeStr+="</Detail1>";
					}
					else if(activityType == 'FW' && updateFlagVal != 'E') // added condition of updateFlagVal by rupali on 23/02/18 for edit mode of realtime report
					{
						/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
						if( gradeTypes == 'M' )
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ))
							{
								if( eventType == 'MI')
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
								}
								else if( eventType == 'OT' )
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
								}
								else if(team=='SELF')
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if(eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
						}
						else
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else if(team=='SELF')
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] End
								}
							}
							//added by shraddha M[03/09/2020] START
							console.log("diffDays value is::::["+diffDays+"] setVisitTime["+setVisitTime+"]displayTimeField ["+displayTimeField+"]custType["+custType+"]");
							//added by Hariom S for fortune [18/05/2021]
							if( isFortuneActivity  == 'Y')
							{

								if( allowVisitTime  == 'Y')
								{

									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else if( allowVisitTime  == 'N')
								{

									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B'  && diffDays > 0)
								{

									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else
								{

									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}


							}
							else
							{
								if(diffDays > 0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
								{
									if(displayTimeField == "Y")
									{
										if(custType == "LISTED")
										{
											itemChangeStr +="<event_time_start visible = '1'><![CDATA[]]></event_time_start>" +
													"<event_time_end visible = '0'><![CDATA[]]></event_time_end><visit_time_from visible = '0'><![CDATA[]]></visit_time_from>" ;

										}
										else
										{
											itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
													"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;
										}
									}
									else
									{
										itemChangeStr +="<event_time_start visible = '1'><![CDATA[]]></event_time_start>" +
												"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '0'><![CDATA[]]></visit_time_from>" ;
									}
								}
							}
							//added by shraddha M[03/09/2020] END
						}
						if(  eventType == 'OT' )
						{
							itemChangeStr += "<activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr><event_type protect = '0'><![CDATA["+eventType+"]]></event_type><activity_type><![CDATA["+activityType+"]]></activity_type><strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '1' visible = '1'></address_as>" +
									"<route_id protect = '0' visible = '1'></route_id><next_plan_date visible = '1'></next_plan_date><gender protect='0' visible = '0'><![CDATA[M]]></gender><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust><locality_code protect = '0' visible = '1'></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
									"<place_required protect = '0' visible = '0'><![CDATA["+placeRequired+"]]></place_required><addr3 protect = '0' visible = '0'></addr3><age protect = '0' visible = '0'></age><qualification protect = '0' visible = '0'></qualification><spl_code protect = '0' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><remarks protect = '0' visible = '1'></remarks><strg_class_code protect = '0' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><visited_with protect = '0' visible = '1'></visited_with>" +
									"<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code><locality_descr protect = '1' visible = '1'></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr>" +
									//"<event_time_start visible = '1'></event_time_start><event_time_end visible = '1'></event_time_end>" +
									"<copy_plan protect='1' visible = '1'><![CDATA[N]]></copy_plan><oth_participant protect = '0' visible = '1'></oth_participant>" +
									"<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
									"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
									"<member_present visible = '1'><![CDATA[]]></member_present>" +
									"<pob_item visible = '1'><![CDATA[]]></pob_item>" +
									"<strg_type protect = '1' visible = '0'></strg_type>" ;

							if( isFortuneActivity  == 'Y')
							{

								if( allowVisitTime  == 'Y')
								{
									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else if( allowVisitTime  == 'N')
								{

									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B'  && diffDays > 0)
								{

									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else
								{

									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}


							}

							"</Detail1>";
							//"<resign_emp protect = '0' visible = '1'></resign_emp></Detail1>";
						}
						else
						{
							itemChangeStr += "<activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr><event_type protect = '0'><![CDATA["+eventType+"]]></event_type><activity_type><![CDATA["+activityType+"]]></activity_type><strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '1' visible = '1'></address_as>" +
									"<route_id protect = '0' visible = '1'></route_id><next_plan_date protect='0' visible = '1'></next_plan_date><gender protect='0' visible = '0'><![CDATA[M]]></gender><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust><locality_code protect = '0' visible = '1'></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
									"<place_required protect = '0' visible = '0'><![CDATA["+placeRequired+"]]></place_required><addr3 protect = '0' visible = '0'></addr3><age protect = '0' visible = '0'></age><qualification protect = '0' visible = '0'></qualification><spl_code protect = '0' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><remarks protect = '0' visible = '1'></remarks><strg_class_code protect = '0' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><visited_with protect = '0' visible = '1'></visited_with>" +
									"<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code><locality_descr protect = '1' visible = '1'></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr>" +
									//"<event_time_start visible = '1'></event_time_start><event_time_end visible = '1'></event_time_end>" +
									"<copy_plan protect='1' visible = '1'><![CDATA[N]]></copy_plan><oth_participant protect = '0' visible = '1'></oth_participant>" +
									"<cust_conf visible = '0'><![CDATA[]]></cust_conf>" +
									"<cust_conf_proof visible = '0'><![CDATA[]]></cust_conf_proof>" +
									"<member_present visible = '0'><![CDATA[]]></member_present>" +
									"<pob_item visible = '0'><![CDATA[]]></pob_item>" +
									"<strg_type protect = '1' visible = '0'></strg_type><visited_with_design_code></visited_with_design_code>" ;

							if( isFortuneActivity  == 'Y')
							{

								if( allowVisitTime  == 'Y')
								{
									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else if( allowVisitTime  == 'N')
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B'  && diffDays > 0)
								{
									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}


							}

							"</Detail1>";
						}
					}
					
					else if(callOutcome === '0' || callOutcome === '9')
					{
						itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,invoice,display,team,coaching,survey\" ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ></Detail1>";
					}
					else
					{
						console.log("inside else is:::::"+callOutcome);
						itemChangeStr = "<Detail1 protectSubform=\"brand,display\"><protect_subform><![CDATA[brand,display]]></protect_subform><meet_summ protect = '0' visible = '1'></meet_summ></Detail1>";
					}
					// added by rupali on 23/02/18 for edit mode of realtime report [end]
				}
				else if( fieldName === 'call_outcome' )
				{
					console.log("fieldName is"+fieldName);
					if( fieldValue === '0' || fieldValue === '9' )
					{
						if( gradeTypes == 'M' )
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( eventType == 'MI' )
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
								}
								else if( eventType == 'OT' )
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if(eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
							}
						}
						else
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey,collection\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey,collection]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey,collection\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey,collection]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] End
								}
							}
						}
						if(  eventType == 'OT' )
						{
							itemChangeStr += "<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
									"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
									"<member_present visible = '1'><![CDATA[]]></member_present>" +
									"<pob_item visible = '1'><![CDATA[]]></pob_item>" +
									"</Detail1>";
							//"<resign_emp protect = '0' visible = '1'></resign_emp></Detail1>";
						}
						//added by mrunalini sinkar to set ---NA--- in case of call outcome is refused(start)
						//itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching,survey\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1'></meet_summ></Detail1>";

						//added by mrunalini sinkar to set ---NA--- in case of call outcome is refused(end)
					}
					else if(fieldValue === '0' || fieldValue === '9')
					{

						if( gradeTypes == 'M' )
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( eventType == 'MI' )
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
								}
								else if( eventType == 'OT' )
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if(eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey,collection\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey,collection]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
							}
						}
						else
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey,collection\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey,collection]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey,collection\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey,collection]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] End
								}
							}
						}
						if(  eventType == 'OT' )
						{
							itemChangeStr += "<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
									"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
									"<member_present visible = '1'><![CDATA[]]></member_present>" +
									"<pob_item visible = '1'><![CDATA[]]></pob_item>" +
									"</Detail1>";
							//"<resign_emp protect = '0' visible = '1'></resign_emp></Detail1>";
						}
						//added by mrunalini sinkar to set ---NA--- in case of call outcome is refused(start)
						//itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching,survey\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1'></meet_summ></Detail1>";

						//added by mrunalini sinkar to set ---NA--- in case of call outcome is refused(end)
					
					}
					// added by rupali on 23/02/18 for edit mode of realtime report [start]
					else if(updateFlagVal == 'E')
					{
						console.log("inside else if is:::::"+fieldValue);
						//added by mrunalini sinakr to remove hard code number(start)
						//itemChangeStr = "<Detail1 protectSubform=\"2,4\"><protect_subform><![CDATA[2,4]]></protect_subform></Detail1>";
						//added by mrunalini sinakr to remove hard code number(end)
						if( fieldValue === '0' || fieldValue === '9')
						{

							if( gradeTypes == 'M' )
							{
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if( eventType == 'MI' )
									{
										if(team!='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
										}
									}
									else if( eventType == 'OT' )
									{
										if(team!='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
										}
									}
									else
									{
										itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
								}
								else
								{
									if( eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
									else if(eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
								}
							}
							else
							{
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if( eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
									else if( eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
								}
								else
								{
									if( eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
									else if( eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
										itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
										//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] End
									}
								}
							}
							if(  eventType == 'OT' )
							{
								itemChangeStr += "<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
										"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
										"<member_present visible = '1'><![CDATA[]]></member_present>" +
										"<pob_item visible = '1'><![CDATA[]]></pob_item>" +
										"</Detail1>";
								//"<resign_emp protect = '0' visible = '1'></resign_emp></Detail1>";
							}

						}
						else
						{
							if( gradeTypes == 'M' )
							{
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if(team!='SELF')
									{
										if( eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName></Detail1>";
										}
										else if( eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform></Detail1>";
										}
									}
									else
									{
										if( eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName></Detail1>";
										}
										else if( eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform></Detail1>";
										}
									}	
								}
								else
								{
									if( eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName></Detail1>";
									}
									else if(eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform></Detail1>";
									}
								}
							}
							else
							{
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if( eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName></Detail1>";
									}
									else if( eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform></Detail1>";
									}
								}
								else
								{
									if( eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName></Detail1>";
									}
									else if( eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
										itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform></Detail1>";
										//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] End
									}
								}
							}
							if(  eventType == 'OT' )
							{
								itemChangeStr += "<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
										"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
										"<member_present visible = '1'><![CDATA[]]></member_present>" +
										"<pob_item visible = '1'><![CDATA[]]></pob_item>" +
										"</Detail1>";
								//"<resign_emp protect = '0' visible = '1'></resign_emp></Detail1>";
							}

						}
					}
					// added by rupali on 23/02/18 for edit mode of realtime report [end]
					else
					{
						if( gradeTypes == 'M' )
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( eventType == 'MI' )
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
									}
								}
								else if( eventType == 'OT' )
								{
									if(team!='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
									}
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"'><meet_summ protect = '0' visible='1'></meet_summ></Detail1>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if(eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"'><meet_summ protect = '0' visible='1'></meet_summ></Detail1>";
								}
							}
						}
						else
						{
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"'><meet_summ protect = '0' visible='1'></meet_summ></Detail1>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ></Detail1>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><meet_summ protect = '1' visible='0'><![CDATA[---NA---]]></meet_summ>";
								}
								else
								{
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] Start
									itemChangeStr = "<Detail1 domID='"+domId+"'><meet_summ protect = '0' visible='1'></meet_summ></Detail1>";
									//Change by sadique shaikh on 18-02-2020 [To hide some field [cust_conf,cust_conf_proof,member_present,pob_item] for even type != OT ]] End
								}
							}
						}
						if(  eventType == 'OT' )
						{
							itemChangeStr += "<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
									"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
									"<member_present visible = '1'><![CDATA[]]></member_present>" +
									"<pob_item visible = '1'><![CDATA[]]></pob_item>" +
									"</Detail1>";
							//"<resign_emp protect = '0' visible = '1'></resign_emp></Detail1>";
						}
					}
				}
				else if(fieldName === 'meeting_status' )
				{
					meetingStatus=fieldValue;

				}
				else if(fieldName === 'sales_type' )
				{
					salesTypeGlobal=fieldValue;
					console.log("salesTypeGlobal["+salesTypeGlobal+"]");
					var isColUpdated = updateTableFormState("1", xmlDoc);
					//alert('28112022 isTBSUpdated:::',isTBSUpdated);
					console.log("isColUpdated INVOICE =["+itemChangeStr+"]");

				}
				else if( fieldName === 'route_id' )
				{
					console.log("Inside route id IC");
					var isDataInvalid;
					try
					{
						if( dataModelJson )
						{
							var exprFilter = "(value.route_id || '').trim() == '" + fieldValue.trim() +"'";
							console.log("Inside route id IC exprFilter::"+exprFilter);
							var jsonObj = JSON.parse( filterVisitedWithJSON( dataModelJson, exprFilter ) );
							if( jsonObj.route_id )
							{
								console.log("Inside If");
							}
							else
							{
								console.log("Inside else");
								alert("Invalid route. Please enter again.");
								isDataInvalid = true;
							}
						}
					}
					catch(e)
					{
						console.log("Exception is:::["+e+"]");
					}

					if( fieldValue === 'null' || fieldValue.trim().length == 0 || isDataInvalid )
					{
						itemChangeStr = "<Detail1 domID='"+domId+"'><route_id></route_id><locality_descr protect = '1'></locality_descr></Detail1>";
					}
					else
					{
						//added by mrunalini sinkar on 04/06/2018 to protect decsription on auto mode(start)
						var localityDescr="";var itemSer ="";var strgType=""; var cusClassInput="",team="",visitedWithDesignCode ="";
						var travelDate = "",locCodeNew = "",routeType="",invoiceNoD="",memberPresent="",customrType="",memType="",grade="",planRouteId="";
						var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
						for (var i = 0; i < detailElement.length; i++)
						{
							var detail = detailElement[i];
							if( detail.getElementsByTagName("locality_descr")[0] != null && detail.getElementsByTagName("locality_descr")[0].childNodes[0] != null )
							{
								localityDescr = detail.getElementsByTagName("locality_descr")[0].childNodes[0].nodeValue;
								console.log("localityDescr type is:"+localityDescr);
							}
							// added by mrunalini sinkar for class code pophelp changes (start)
							if( detail.getElementsByTagName("item_ser")[0] != null && detail.getElementsByTagName("item_ser")[0].childNodes[0] != null )
							{
								itemSer = detail.getElementsByTagName("item_ser")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
							{
								strgType = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								teamDocType=strgType;
							}
							if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
							{
								travelDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("locality_code")[0] != null && detail.getElementsByTagName("locality_code")[0].childNodes[0] != null )
							{
								locCodeNew = detail.getElementsByTagName("locality_code")[0].childNodes[0].nodeValue;
								locCodeNew = locCodeNew.trim();
							}
							//Added by mrunalini sinkar for route type M changes in case of unlisted customer(start)
							if( detail.getElementsByTagName("route_type")[0] != null && detail.getElementsByTagName("route_type")[0].childNodes[0] != null )
							{
								routeType = detail.getElementsByTagName("route_type")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("invoice_no")[0] != null && detail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
							{
								invoiceNoD = detail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
							{
								memberPresent = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
							{
								customrType = detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
							{
								memType = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								teamDocType=memType;
							}
							if( detail.getElementsByTagName("grade")[0] != null && detail.getElementsByTagName("grade")[0].childNodes[0] != null )
							{
								grade = detail.getElementsByTagName("grade")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("visited_with")[0] != null && detail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
							{
								team = detail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("visited_with_design_code")[0] != null && detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0] != null )
							{
								visitedWithDesignCode = detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("route_plan")[0] != null && detail.getElementsByTagName("route_plan")[0].childNodes[0] != null )
							{
								planRouteId = detail.getElementsByTagName("route_plan")[0].childNodes[0].nodeValue;
							}
							//Added by mrunalini sinkar for route type M changes in case of unlisted customer(end)
						}

						var planRouteIdArray =[];
						var isPlanChgReasonVisible =false;
						if(planRouteId!=null && planRouteId.trim().length != 0)
						{

							var planRouteIdList = planRouteId.split(',');
							for(var j=0;j < planRouteIdList.length;j++)
							{
								var planBeatOne =planRouteIdList[j].trim();
								planRouteIdArray.push(planBeatOne);

							}
							if(planRouteIdArray.indexOf(fieldValue) == -1)
							{

								isPlanChgReasonVisible=true;

							}
						}
						if(itemSer !=null && itemSer.trim().length > 0)
						{
							cusClassInput = 	itemSer;
						}
						else
						{
							cusClassInput =	 strgType;

						}
						// added by mrunalini sinkar for class code pophelp changes (end)

						// added by rupali on 07/03/19 to set order of visit on summary screen [start]
						var maxOrderVisit = 0;
						maxOrderVisit = localStorage.getItem(travelDate+'_OrderOfVisit');
						maxOrderVisit++;
						var localtyCode = localStorage.getItem(travelDate+'_LocalityCode');
						var locDetail = "";

						//alert("localtyCode:::"+localtyCode);
						if(localtyCode != null && localtyCode.trim().length != 0)
						{
							var locList = localtyCode.split(',');
							for(var i=0; i<locList.length; i++)
							{
								var locCode = locList[i].split('@')[0];
								var locOrder = locList[i].split('@')[1];
								if(locCode == locCodeNew)
								{
									maxOrderVisit = locOrder;
								}
							}
						}
						// added by rupali on 07/03/19 to set order of visit on summary screen [end]

						//added by mrunalini sinkar on 26-june-2018 for addin locality code in ncw(start)
						//if(activityType == 'NFW' && updateFlagVal != 'E')
						//if(placeRequired == 'Y' && updateFlagVal != 'E' && activityType != 'FW' )//added by mrunalini sinkar on 09-sep-2018 for place required changes
						if((placeRequired == 'Y' && updateFlagVal != 'E' && activityType != 'FW' ) || eventType  == 'CA')//added by mrunalini sinkar on 09-sep-2018 for place required changes
						{
							//Added by Prasad on 19/12/19 [coaching related implementation]
							//Changed by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
							if( grade == 'M')
							{
								if( eventType  == 'CA' )
								{
									/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
									if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) && team!='SELF' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code>";
									}
								}
								else if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:PeopleTrained\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:Receipt\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform>";
								}
							}
							if(isPlanChgReasonVisible)
							{
								itemChangeStr +="<plan_chg_reas visible = '1'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='1'><![CDATA[]]></plan_chg_reason_udf>";
							}
							else
							{
								itemChangeStr +="<plan_chg_reas visible = '0'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='0'><![CDATA[]]></plan_chg_reason_udf>";
							}
							itemChangeStr += "<locality_descr protect = '1'><![CDATA["+localityDescr+"]]></locality_descr>" +
									"<order_of_visit><![CDATA["+maxOrderVisit+"]]></order_of_visit><reg_no visible = '0'></reg_no><meeting_status visible = '0'></meeting_status><last_meet_summ visible = '0'></last_meet_summ><last_meet_date visible = '0'></last_meet_date></Detail1>";
						}
						else if(placeRequired == 'Y' && updateFlagVal != 'E' && activityType == 'FW' && customrType == 'LISTED')
						{

							if(isPlanChgReasonVisible || team=='SELF')
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><plan_chg_reas visible = '1'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='1'><![CDATA[]]></plan_chg_reason_udf></Detail1>";

							}
							else
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><protect_subform><![CDATA[]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><plan_chg_reas visible = '0'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='0'><![CDATA[]]></plan_chg_reason_udf></Detail1>";
							}
						}
						//added by mrunalini sinkar on 26-june-2018 for addin locality code in ncw(end)
						//Added by mrunalini sinkar for route type M changes in case of unlisted customer(end)

						//Added by Prasad on 19/12/19 [coaching related implementation]
						//if(routeType == 'M' && activityType == 'FW' && customrType != 'LISTED')
						// if condition commented by prachi to set customer detail mandatory for H and M [W22BGOC003]
						/*
						if(routeType == 'M' && activityType == 'FW' && customrType != 'LISTED' && eventType != 'CA' )
						{
							//Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								//Changed by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
								if( grade != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,survey\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[brand,sampleorder,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( grade != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,survey\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							else
							{
								//Changed by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
								if( grade != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[sampleorder,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching,survey\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( grade != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[sampleorder,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching,survey\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
	                        if( isFortuneActivity  == 'Y')
							{
	                                itemChangeStr += "<strg_code visible = '1'><![CDATA["+scCode+"]]></strg_code>";
	                        }
	                        else
	                        {
	                               itemChangeStr += "<strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code>"; 
	                        }
							itemChangeStr += "<uniq_strg_code protect = '1' visible = '0'><![CDATA["+scCode+"]]></uniq_strg_code><remarks protect = '1' visible = '0'></remarks>" +
							"<order_of_visit><![CDATA["+maxOrderVisit+"]]></order_of_visit><cust_class_input><![CDATA["+cusClassInput+"]]></cust_class_input><next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
							"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><gender protect='1' visible = '0'><![CDATA[M]]></gender><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'>" +
							"</strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
							"<promoter_name visible = '0'></promoter_name><man_power visible = '0'></man_power><image_id visible = '0'></image_id><gst_no visible = '0'></gst_no>" +
							"<subclass_code visible = '0'></subclass_code><pin visible = '0'></pin><subclass_descr visible = '0'></subclass_descr><reg_no visible = '0'></reg_no><meeting_status visible = '0'></meeting_status><last_meet_summ visible = '0'></last_meet_summ><last_meet_date visible = '0'></last_meet_date>" ;
							if(isPlanChgReasonVisible)
							{
								itemChangeStr +="<plan_chg_reas visible = '1'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='1'><![CDATA[]]></plan_chg_reason_udf>";
							}
							else
							{
								itemChangeStr +="<plan_chg_reas visible = '0'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='0'><![CDATA[]]></plan_chg_reason_udf>";
							}
							if(grade == 'M')
							{
								itemChangeStr+="<visited_with protect = '0' visible = '1'><![CDATA["+team+"]]></visited_with>";
							}
							else
							{
								itemChangeStr+="<visited_with protect = '1' visible = '0'></visited_with>";
							}

							if(memberPresent!='Y')
							{
								itemChangeStr+="<member_present visible = '0'></member_present>";
							}
							else
							{
								itemChangeStr+="<member_present visible = '1'></member_present>";
							}
							//added by Hariom S for fortune [18/05/2021]
							if( isFortuneActivity  == 'Y')
							{

								if( allowVisitTime  == 'Y')
								{
									itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else if( allowVisitTime  == 'N')
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B'  && diffDays > 0)
								{
									itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}


							}
							else
							{

								if(diffDays > 0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
								{
									itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
									"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;
								}
								else
								{

									itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
							}
							if(memType=="D")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Doctor Details]]></strg_name>";
							}
							else if(memType=="C")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Chemist Details]]></strg_name>";
							}
							else if(memType=="S")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Stockist Details]]></strg_name>";
							}
							else
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Other Details]]></strg_name>";
							}

							itemChangeStr+="</Detail1>";

						}
						 */
						//Added by Prasad on 19/12/19 [coaching related implementation]
						//else if(routeType != 'M' && activityType == 'FW' && customrType != 'LISTED')
						//else if(routeType != 'M' && activityType == 'FW' && customrType != 'LISTED' && eventType  != 'CA')
						if(activityType == 'FW' && customrType != 'LISTED' && eventType  != 'CA')
						{


							var currentDate = new Date();
							var diffDays = getDaysBetweenTwoDates(travelDate,currentDate);

							console.log("5340 memberPresent"+memberPresent)
							console.log("visitedWithDesignCodeArr"+visitedWithDesignCodeArr)
							console.log("visitedWithDesignCode"+visitedWithDesignCode)

							if(memberPresent!='Y')
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									//Changed by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( grade != 'M' && eventType == 'MI' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020 START
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( grade != 'M' && eventType == 'OT' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
									}
									else
									{
										console.log("team == "+team)
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
										else
										{

											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
									}
								}
								else
								{
									console.log("5397 else part")
									//Changed by Pooja S on [10-FEB-2020] MI Activity related changes for suborm
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{

										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
								}
								if( isFortuneActivity  == 'Y')
								{
									itemChangeStr += "<strg_code visible = '1'><![CDATA["+scCode+"]]></strg_code>";
								}
								else
								{
									itemChangeStr += "<strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code>"; 
								}
								itemChangeStr += "<order_of_visit><![CDATA["+maxOrderVisit+"]]></order_of_visit><cust_class_input><![CDATA["+cusClassInput+"]]></cust_class_input><uniq_strg_code visible = '0'><![CDATA["+scCode+"]]></uniq_strg_code><strg_name protect = '0' visible='1'></strg_name><address_as protect = '0' visible = '1'></address_as>" +
										"<addr1 protect = '0' visible = '1'></addr1><addr2 protect = '0' visible = '1'></addr2><addr3 protect = '0' visible = '1'></addr3><age protect = '0' visible = '1'></age><gender protect='0' visible = '1'><![CDATA[M]]></gender><qualification protect = '0' visible = '1'></qualification><email_addr protect = '0' visible = '1'>" +
										"</email_addr><mobile_no protect = '0' visible = '1'></mobile_no><strg_class_code protect = '0' visible = '1' ></strg_class_code><class_code_descr protect = '1' visible = '1'></class_code_descr>" +
										"<promoter_name protect = '0' visible = '1'></promoter_name><man_power protect = '0' visible = '1'></man_power><image_id visible = '1'></image_id><gst_no protect = '0' visible = '1'></gst_no>" +
										"<subclass_code visible = '1'></subclass_code><pin visible = '1'></pin><subclass_descr protect = '1' visible = '1'></subclass_descr>" +
										"<speciality_descr protect = '1' visible = '1'></speciality_descr><spl_code protect = '0' visible = '1'></spl_code>" +
										"<member_present visible = '1'></member_present><reg_no visible = '1'></reg_no><meeting_status visible = '1'></meeting_status><last_meet_summ visible = '1'></last_meet_summ><last_meet_date visible = '1'></last_meet_date>" +
										"<next_plan_date visible = '1'></next_plan_date><oth_participant protect = '0' visible = '1'></oth_participant><stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code>";
								if(isPlanChgReasonVisible)
								{
									itemChangeStr +="<plan_chg_reas visible = '1'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='1'><![CDATA[]]></plan_chg_reason_udf>";
								}
								else
								{
									itemChangeStr +="<plan_chg_reas visible = '0'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='0'><![CDATA[]]></plan_chg_reason_udf>";
								}
								if(grade == 'M')
								{
									itemChangeStr+="<visited_with protect = '0' visible = '1'><![CDATA["+team+"]]></visited_with>";
								}
								else
								{
									itemChangeStr+="<visited_with protect = '0' visible = '0'></visited_with>";
								}
								if( isFortuneActivity  == 'Y')
								{

									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else if( allowVisitTime  == 'N')
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B'  && diffDays > 0)
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								else
								{

									if(diffDays > 0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
									{
										itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
												"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;
									}
									else
									{

										itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								itemChangeStr+="</Detail1>";

							}
							else
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>" ;
									}
									else if( grade == 'M' && eventType == 'MI' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>" ;
									}
									else if( grade == 'M' && eventType == 'OT' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
									}
									else
									{
										console.log("5535 team:"+team)
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
									}
								}
								else
								{
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+omId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+omId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										console.log("5567")
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
								}
								itemChangeStr += "<strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code><uniq_strg_code visible = '0'><![CDATA["+scCode+"]]></uniq_strg_code><strg_name visible = '0'></strg_name><address_as visible = '0'></address_as>" +
										"<addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><age visible = '0'></age><gender visible = '0'><![CDATA[M]]></gender><qualification visible = '0'></qualification><email_addr visible = '0'>" +
										"</email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0' protect='0'></strg_class_code><class_code_descr visible = '0'></class_code_descr>" +
										"<promoter_name visible = '0'></promoter_name><man_power visible = '0'></man_power><image_id visible = '0'></image_id><gst_no visible = '0'></gst_no>" +
										"<subclass_code visible = '0'></subclass_code><pin visible = '0'></pin><subclass_descr visible = '0'></subclass_descr>" +
										"<speciality_descr protect = '1' visible = '0'></speciality_descr><spl_code protect = '0' visible = '0'></spl_code><reg_no visible = '0'></reg_no><meeting_status visible = '0'></meeting_status><last_meet_summ visible = '0'></last_meet_summ><last_meet_date visible = '0'></last_meet_date>" +
										"<strg_class_code visible = '0'></strg_class_code><call_outcome visible = '0'></call_outcome><class_code_descr visible = '0'></class_code_descr><copy_plan visible = '0'></copy_plan><resign_emp visible = '0'></resign_emp>" +
										"<oth_participant visible = '0'></oth_participant><stockist_code visible = '0'></stockist_code><stockist_name visible = '0'></stockist_name><remarks visible = '0'></remarks><next_plan_date visible = '0'></next_plan_date>";
								if(isPlanChgReasonVisible)
								{
									itemChangeStr +="<plan_chg_reas visible = '1'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='1'><![CDATA[]]></plan_chg_reason_udf>";
								}
								else
								{
									itemChangeStr +="<plan_chg_reas visible = '0'><![CDATA[1]]></plan_chg_reas><plan_chg_reason_udf visible ='0'><![CDATA[]]></plan_chg_reason_udf>";
								}


								if(grade == 'M')
								{
									itemChangeStr+="<visited_with protect = '0' visible = '1'><![CDATA["+team+"]]></visited_with>";
								}
								else
								{
									itemChangeStr+="<visited_with protect = '0' visible = '0'></visited_with>";
								}

								if( isFortuneActivity  == 'Y')
								{

									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else if( allowVisitTime  == 'N')
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B'  && diffDays > 0)
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								else
								{
									if(diffDays > 0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
									{
										itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
												"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;
									}
									else
									{

										itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								if(memType=="D")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Doctor Details]]></strg_name>";
								}
								else if(memType=="C")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Chemist Details]]></strg_name>";
								}
								else if(memType=="S")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Stockist Details]]></strg_name>";
								}
								else
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Other Details]]></strg_name>";
								}
								itemChangeStr = itemChangeStr + "</Detail1>";
								console.log('route id itemChangeStr '+itemChangeStr);
							}
						}
						//Added by mrunalini sinkar for route type M changes in case of unlisted customer(end)
					}
				}
				//added by mrunalini sinkar on 16/02/2018 for auto mode(end)
				else if( fieldName === 'locality_code' )
				{
					console.log("Inside locality_code");
					var isDataInvalid;
					try
					{
						if( dataModelJson )
						{
							var exprFilter = "(value.locality_code || '').trim() == '" + fieldValue.trim() +"'";
							console.log("Inside locality_code exprFilter::"+exprFilter);
							var jsonObj = JSON.parse( filterVisitedWithJSON( dataModelJson, exprFilter ) );
							if( jsonObj.locality_code )
							{
								console.log("Inside If");
							}
							else
							{
								console.log("Inside else");
								alert("Invalid locality. Please enter again.");
								isDataInvalid = true;
							}
						}
					}
					catch(e)
					{
						console.log("Exception is:::["+e+"]");
					}

					if( fieldValue === 'null' || fieldValue.trim().length == 0 || isDataInvalid )
					{
						itemChangeStr = "<Detail1 domID='"+domId+"'><locality_code></locality_code><locality_descr protect = '1'></locality_descr></Detail1>";
					}
					else
					{
						//added by mrunalini sinkar on 04/06/2018 to protect decsription on auto mode(start)
						var localityDescr="";var itemSer ="";var strgType=""; var cusClassInput="",team="",visitedWithDesignCode ="";
						var travelDate = "",routeCodeNew = "",routeType="",invoiceNoD="",memberPresent="",customrType="",memType="",grade="";
						var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
						for (var i = 0; i < detailElement.length; i++)
						{
							var detail = detailElement[i];
							if( detail.getElementsByTagName("locality_descr")[0] != null && detail.getElementsByTagName("locality_descr")[0].childNodes[0] != null )
							{
								localityDescr = detail.getElementsByTagName("locality_descr")[0].childNodes[0].nodeValue;
								console.log("localityDescr type is:"+localityDescr);
							}
							// added by mrunalini sinkar for class code pophelp changes (start)
							if( detail.getElementsByTagName("item_ser")[0] != null && detail.getElementsByTagName("item_ser")[0].childNodes[0] != null )
							{
								itemSer = detail.getElementsByTagName("item_ser")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
							{
								strgType = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								teamDocType=strgType;
							}
							if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
							{
								travelDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("route_id")[0] != null && detail.getElementsByTagName("route_id")[0].childNodes[0] != null )
							{
								routeCodeNew = detail.getElementsByTagName("route_id")[0].childNodes[0].nodeValue;
								routeCodeNew = routeCodeNew.trim();
							}
							console.log("routeCodeNew is:::["+routeCodeNew+"]");
							//Added by mrunalini sinkar for route type M changes in case of unlisted customer(start)
							if( detail.getElementsByTagName("route_type")[0] != null && detail.getElementsByTagName("route_type")[0].childNodes[0] != null )
							{
								routeType = detail.getElementsByTagName("route_type")[0].childNodes[0].nodeValue;
							}
							console.log("routeType is:::["+routeType+"]");
							if( detail.getElementsByTagName("invoice_no")[0] != null && detail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
							{
								invoiceNoD = detail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
							{
								memberPresent = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
							{
								customrType = detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
							{
								memType = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								teamDocType =memType;
							}
							if( detail.getElementsByTagName("grade")[0] != null && detail.getElementsByTagName("grade")[0].childNodes[0] != null )
							{
								grade = detail.getElementsByTagName("grade")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("visited_with")[0] != null && detail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
							{
								team = detail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("visited_with_design_code")[0] != null && detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0] != null )
							{
								visitedWithDesignCode = detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0].nodeValue;
							}
							console.log("visitedWithDesignCode is:::["+visitedWithDesignCode+"]");
							//Added by mrunalini sinkar for route type M changes in case of unlisted customer(end)
						}

						if(itemSer !=null && itemSer.trim().length > 0)
						{
							cusClassInput = itemSer;
						}
						else
						{
							cusClassInput =	strgType;
						}
						// added by mrunalini sinkar for class code pophelp changes (end)

						// added by rupali on 07/03/19 to set order of visit on summary screen [start]
						var maxOrderVisit = 0;
						maxOrderVisit = localStorage.getItem(travelDate+'_OrderOfVisit');
						maxOrderVisit++;
						console.log("localStorage is:::["+localStorage+"]");
						var routeId = localStorage.getItem(travelDate+'_RouteId');
						console.log("routeId is:::["+routeId+"]");
						var locDetail = "";

						//alert("routeId:::"+routeId);
						if(routeId != null && routeId.trim().length != 0)
						{
							var locList = routeId.split(',');
							for(var i=0; i<locList.length; i++)
							{
								var locCode = locList[i].split('@')[0];
								var locOrder = locList[i].split('@')[1];
								if(locCode == routeCodeNew)
								{
									maxOrderVisit = locOrder;
								}
							}
						}
						// added by rupali on 07/03/19 to set order of visit on summary screen [end]

						//added by mrunalini sinkar on 26-june-2018 for addin locality code in ncw(start)
						//if(activityType == 'NFW' && updateFlagVal != 'E')
						if(placeRequired == 'Y' && updateFlagVal != 'E' && activityType != 'FW')//added by mrunalini sinkar on 09-sep-2018 for place required changes
						{
							console.log("placeRequired is:::");
							//Added by Prasad on 19/12/19 [coaching related implementation]
							if( grade == 'M')
							{
								if( eventType  == 'CA' )
								{
									/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
									if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) && team!='SELF' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code>";
									}
								}
								else if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:PeopleTrained\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:Receipt\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							else
							{
								if( eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' visibleSubform ='YES' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							itemChangeStr +="<locality_descr protect = '1'><![CDATA["+localityDescr+"]]></locality_descr>" +
									"<order_of_visit><![CDATA["+maxOrderVisit+"]]></order_of_visit>";
						}
						//added by mrunalini sinkar on 26-june-2018 for addin locality code in ncw(end)
						//Added by mrunalini sinkar for route type M changes in case of unlisted customer(end)

						//Added by Prasad on 19/12/19 [coaching related implementation]
						//if(routeType == 'M' && activityType == 'FW' && customrType != 'LISTED')
						if(routeType == 'M' && activityType == 'FW' && customrType != 'LISTED' && eventType != 'CA' )
						{
							console.log("routeType is:::");
							/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) && team!='SELF')
							{
								if( grade != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( grade != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							else
							{
								if( grade != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( grade != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else if( grade == 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							itemChangeStr += "<strg_code protect = '1' visible = '0'><![CDATA["+scCode+"]]></strg_code><remarks protect = '1' visible = '0'></remarks>" +
									"<order_of_visit><![CDATA["+maxOrderVisit+"]]></order_of_visit><cust_class_input><![CDATA["+cusClassInput+"]]></cust_class_input><next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
									"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><gender protect='1' visible = '0'><![CDATA[M]]></gender><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'>" +
									"</strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
									"<promoter_name visible = '0'></promoter_name><man_power visible = '0'></man_power><image_id visible = '0'></image_id><gst_no visible = '0'></gst_no>" +
									"<subclass_code visible = '0'></subclass_code><pin visible = '0'></pin><subclass_descr visible = '0'></subclass_descr>" ;
							if(grade == 'M')
							{
								itemChangeStr+="<visited_with protect = '0' visible = '1'><![CDATA["+team+"]]></visited_with>";
							}
							else
							{
								itemChangeStr+="<visited_with protect = '1' visible = '0'></visited_with>";
							}
							//added by Hariom S for fortune [18/05/2021]
							if( isFortuneActivity  == 'Y')
							{

								if( allowVisitTime  == 'Y')
								{
									itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else if( allowVisitTime  == 'N')
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B'  && diffDays > 0)
								{
									itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
							}
							else
							{
								if(memberPresent!='Y')
								{
									itemChangeStr+="<member_present visible = '0'></member_present><event_time_start visible='0'><![CDATA["+time+"]]></event_time_start><event_time_end visible='0'><![CDATA["+time+"]]></event_time_end>";
								}
								else
								{
									itemChangeStr+="<member_present visible = '1'></member_present><event_time_start visible='1'><![CDATA["+time+"]]></event_time_start><event_time_end visible='1'><![CDATA["+time+"]]></event_time_end>";
								}
							}
							if(memType=="D")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Doctor Details]]></strg_name>";
							}
							else if(memType=="C")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Chemist Details]]></strg_name>";
							}
							else if(memType=="S")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Stockist Details]]></strg_name>";
							}
							else
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Other Details]]></strg_name>";
							}

							itemChangeStr+="</Detail1>";
						}
						//Added by Prasad on 19/12/19 [coaching related implementation]
						//else if(routeType != 'M' && activityType == 'FW' && customrType != 'LISTED')
						else if(routeType != 'M' && activityType == 'FW' && customrType != 'LISTED' && eventType  != 'CA')
						{
							var currentDate = new Date();
							var diffDays = getDaysBetweenTwoDates(travelDate,currentDate);

							if(memberPresent!='Y')
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'MI' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'OT' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
									}
									else
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\' ><protect_subform><![CDATA[]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";

										}
									}
								}
								else
								{
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>" ;
									}
									else if( grade == 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>" ;
									}
									else if( grade == 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
								}
								itemChangeStr += "<order_of_visit><![CDATA["+maxOrderVisit+"]]></order_of_visit><cust_class_input><![CDATA["+cusClassInput+"]]></cust_class_input><strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code><strg_name protect = '0' visible='1'></strg_name><address_as protect = '0' visible = '1'></address_as>" +
										"<addr1 protect = '0' visible = '1'></addr1><addr2 protect = '0' visible = '1'></addr2><addr3 protect = '0' visible = '1'></addr3><age protect = '0' visible = '1'></age><gender protect='0' visible = '1'><![CDATA[M]]></gender><qualification protect = '0' visible = '1'></qualification><email_addr protect = '0' visible = '1'>" +
										"</email_addr><mobile_no protect = '0' visible = '1'></mobile_no><strg_class_code protect = '0' visible = '1' ></strg_class_code><class_code_descr protect = '1' visible = '1'></class_code_descr>" +
										"<promoter_name protect = '0' visible = '1'></promoter_name><man_power protect = '0' visible = '1'></man_power><image_id visible = '1'></image_id><gst_no protect = '0' visible = '1'></gst_no>" +
										"<subclass_code visible = '1'></subclass_code><pin visible = '1'></pin><subclass_descr protect = '1' visible = '1'></subclass_descr>" +
										"<speciality_descr protect = '1' visible = '1'></speciality_descr><spl_code protect = '0' visible = '1'></spl_code>" +
										"<member_present visible = '1'></member_present>" +
										"<next_plan_date visible = '1'></next_plan_date><oth_participant protect = '0' visible = '1'></oth_participant><stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code>";
								if(grade == 'M')
								{
									itemChangeStr+="<visited_with protect = '0' visible = '1'><![CDATA["+team+"]]></visited_with>";
								}
								else
								{
									itemChangeStr+="<visited_with protect = '0' visible = '0'></visited_with>";
								}
								if( isFortuneActivity  == 'Y')
								{

									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else if( allowVisitTime  == 'N')
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B'  && diffDays > 0)
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								else
								{
									if(diffDays > 0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
									{
										itemChangeStr +="<event_time_start visible = '1'><![CDATA[]]></event_time_start>" +
												"<event_time_end visible = '1'><![CDATA[]]></event_time_end>" ;
									}
									else
									{
										itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end>" ;
									}
								}
								itemChangeStr+="</Detail1>";
							}
							else
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>" ;
									}
									else if( grade == 'M' && eventType == 'MI' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>" ;
									}
									else if( grade == 'M' && eventType == 'OT' )
									{
										if(team=='SELF')
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
									}
									else  if(team=='SELF')
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
								}
								else
								{
									if( grade != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( grade != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( grade == 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
								}
								itemChangeStr += "<event_time_start visible='1'><![CDATA["+time+"]]></event_time_start><event_time_end visible='1'><![CDATA["+time+"]]></event_time_end>" +
										"<strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code><strg_name visible = '0'></strg_name><address_as visible = '0'></address_as>" +
										"<addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><age visible = '0'></age><gender visible = '0'><![CDATA[M]]></gender><qualification visible = '0'></qualification><email_addr visible = '0'>" +
										"</email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0' protect='0'></strg_class_code><class_code_descr visible = '0'></class_code_descr>" +
										"<promoter_name visible = '0'></promoter_name><man_power visible = '0'></man_power><image_id visible = '0'></image_id><gst_no visible = '0'></gst_no>" +
										"<subclass_code visible = '0'></subclass_code><pin visible = '0'></pin><subclass_descr visible = '0'></subclass_descr>" +
										"<speciality_descr protect = '1' visible = '0'></speciality_descr><spl_code protect = '0' visible = '0'></spl_code>" +
										"<strg_class_code visible = '0'></strg_class_code><call_outcome visible = '0'></call_outcome><class_code_descr visible = '0'></class_code_descr><copy_plan visible = '0'></copy_plan><resign_emp visible = '0'></resign_emp>" +
										"<oth_participant visible = '0'></oth_participant><stockist_code visible = '0'></stockist_code><stockist_name visible = '0'></stockist_name><remarks visible = '0'></remarks><next_plan_date visible = '0'></next_plan_date>";

								if(grade == 'M')
								{
									itemChangeStr+="<visited_with protect = '0' visible = '1'><![CDATA["+team+"]]></visited_with>";
								}
								else
								{
									itemChangeStr+="<visited_with protect = '0' visible = '0'></visited_with>";
								}

								if(memType=="D")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Doctor Details]]></strg_name>";
								}
								else if(memType=="C")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Chemist Details]]></strg_name>";
								}
								else if(memType=="S")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Stockist Details]]></strg_name>";
								}
								else
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Other Details]]></strg_name>";
								}
								itemChangeStr = itemChangeStr + "</Detail1>";
							}
						}
						//Added by mrunalini sinkar for route type M changes in case of unlisted customer(end)
					}
				}
				else if( fieldName === 'strg_code' )
				{
					var isDataInvalid;
					try
					{
						if( dataModelJson )
						{
							var exprFilter = "(value.strg_code || '').trim() == '" + fieldValue.trim() +"'";
							console.log("Inside strg_code IC exprFilter::"+exprFilter);
							var jsonObj = JSON.parse( filterVisitedWithJSON( dataModelJson, exprFilter ) );
							if( jsonObj.route_id )
							{
								console.log("Inside If");
							}
							else
							{
								console.log("Inside else");
								alert("Invalid Customer. Please enter again.");
								isDataInvalid = true;
							}
						}
					}
					catch(e)
					{
						console.log("Exception is:::["+e+"]");
					}

					if( fieldValue === 'null' || fieldValue.trim().length == 0 || isDataInvalid )
					{
						itemChangeStr = "<Detail1 domID='"+domId+"'><strg_code></strg_code><strg_name protect = '1'></strg_name></Detail1>";
					}
					else
					{
						scCode=fieldValue;
						totalPOBValue = 0;
						totalGSTValue =0;
						totalAmount =0;
						invoiceItem="";
						totalBasicAmt =0;
						var totalSGSTValue =0;
						var totalCGSTValue =0;
						var invoiceAmount =0;
						var roundOff=0;
						var amountWrd="";
						var amountInWrd="";
						var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
						var type = "";
						var strgName="",grade="";
						for (var i = 0; i < detailElement.length; i++)
						{
							var detail = detailElement[i];
							if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
							{
								type = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								teamDocType=type;
								//alert("type type is:"+type);
							}
							if( detail.getElementsByTagName("grade_type")[0] != null && detail.getElementsByTagName("grade_type")[0].childNodes[0] != null )
							{
								grade = detail.getElementsByTagName("grade_type")[0].childNodes[0].nodeValue;
								console.log("gradeType  is:"+grade);
								//alert("type type is:"+type);
							}
							//added by mrunalini sinkar on 04/06/2018 to protect decsription on auto mode(start)
							if( detail.getElementsByTagName("strg_name")[0] != null && detail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
							{
								strgName = detail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
								console.log("strgName  is:"+strgName);
							}
							//added by mrunalini sinkar on 04/06/2018 to protect decsription on auto mode(end)
							//Added by Prasad on 19/08/2020 [to set spl_code value onchange] Start
							if( detail.getElementsByTagName("spl_code")[0] != null && detail.getElementsByTagName("spl_code")[0].childNodes[0] != null )
							{
								splCode = detail.getElementsByTagName("spl_code")[0].childNodes[0].nodeValue;
								console.log("spl_code is: ["+ splCode +"]");
							}
							//Added by Prasad on 19/08/2020 [to set spl_code value onchange] End
							//Added by Prasad on 19/08/2020 [to set spl_code value onchange] Start
							if( detail.getElementsByTagName("strg_class_code")[0] != null && detail.getElementsByTagName("strg_class_code")[0].childNodes[0] != null )
							{
								strgClassCode = detail.getElementsByTagName("strg_class_code")[0].childNodes[0].nodeValue;
								console.log("strg_class_code is:"+strgClassCode);
							}
							//Added by Prasad on 19/08/2020 [to set spl_code value onchange] End
							if( detail.getElementsByTagName("reg_no")[0] != null && detail.getElementsByTagName("reg_no")[0].childNodes[0] != null )
							{
								regNo = detail.getElementsByTagName("reg_no")[0].childNodes[0].nodeValue;
								console.log("reg_no is:"+regNo);
							}
							if( detail.getElementsByTagName("visited_with")[0] != null && detail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
							{
								team = detail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("tag_geopos")[0] != null && detail.getElementsByTagName("tag_geopos")[0].childNodes[0] != null )
							{
								taggedLoc = detail.getElementsByTagName("tag_geopos")[0].childNodes[0].nodeValue;
							}

							//tagged gepos
						}
						var time = getStartTime();
						console.log("time is:"+time);

						var reportingLocation = localStorage.getItem( 'CURRENT_GEO_POS' ); ;
						if( taggedLoc.trim().length > 0 && reportingLocation.trim().length > 0 )
						{
							var taggeolist = taggedLoc.split(',');					
							var taggeolist = taggedLoc.split(',');					
							var distanceinMtr = getDistanceFromLatLonInMtr( taggedLoc.split(",")[0], taggedLoc.split(",")[1], reportingLocation.split(",")[0], reportingLocation.split(",")[1] );
							var distanceinMtrNull = "";
						}
						//Added by Amey w. [To protect subform on MI activity] on 12-02-2020 START
						console.log("eventType [" +eventType+ "]");
						if( grade == 'M' )
						{
							if( eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
							}
							else if( eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
							}
							else if(team=='SELF')
							{
								console.log("line 5934")
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
							}
							else
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
							}
						}
						else
						{
							if( eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>" ;
							}
							else if( eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>" ;
							}
							else
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
							}
						}
						//Added by Amey w. [To protect subform on MI activity] on 12-02-2020 END
						console.log("isFortuneActivity is in strg_code:"+isFortuneActivity);
						//Added by Bhagyashri T for Fortune(Start)[15-FEB-2022]

						if (isNaN(distanceinMtr)){

							itemChangeStr += "<geo_distance><![CDATA["+distanceinMtrNull+"]]></geo_distance>";
						}
						else {

							itemChangeStr += "<geo_distance><![CDATA["+distanceinMtr+"]]></geo_distance>";
						}

						if( isFortuneActivity  == 'Y')
						{
							itemChangeStr += "<uniq_strg_code protect = '1' visible = '0'><![CDATA[\"+scCode+\"]]></uniq_strg_code>";
						}
						//Added by Bhagyashri T for Fortune(end)[15-FEB-2022]
						//Changed by Amey w. [To protect subform on MI activity] on 12-02-2020
						if(type == 'D')
						{
							itemChangeStr += "<sh_descr protect = '1'><![CDATA[DOCTOR]]></sh_descr>" +
									"<reg_no protect = '1'><![CDATA["+regNo+"]]></reg_no>" +
									//"<event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>" +
									"<strg_name protect = '1'><![CDATA["+strgName+"]]></strg_name><sku_value><![CDATA[]]></sku_value>";
							//Commented by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
							//"<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name></Detail1>";
						}
						else if(type == 'C' || type=='R')
						{
							itemChangeStr += "<sh_descr protect = '1'><![CDATA[CHEMIST]]></sh_descr>" +
									"<reg_no protect = '1'><![CDATA["+regNo+"]]></reg_no>" +
									//"<event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>" +
									"<strg_name protect = '1'><![CDATA["+strgName+"]]></strg_name><sku_value><![CDATA[]]></sku_value>";
							//Commented by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
							//"<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name></Detail1>";
						}
						else if(type == 'S')
						{
							itemChangeStr += "<sh_descr protect = '1'><![CDATA[STOCKIST]]></sh_descr>" +
									"<reg_no protect = '1'><![CDATA["+regNo+"]]></reg_no>" +
									//"<event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>" +
									"<strg_name protect = '1'><![CDATA["+strgName+"]]></strg_name><sku_value><![CDATA[]]></sku_value>";
							//Commented by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
							//"<stockist_code protect = '0' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name></Detail1>";
						}
						else
						{
							itemChangeStr += "<sh_descr protect = '1'><![CDATA[LISTED]]></sh_descr>" +
									"<reg_no protect = '1'><![CDATA["+regNo+"]]></reg_no>" +
									//"<event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>" +
									"<strg_name protect = '1'><![CDATA["+strgName+"]]></strg_name><sku_value><![CDATA[]]></sku_value>";
							//Commented by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
							//"<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name></Detail1>";
						}
						//Added by sadique shaikh on 18-02-2020 [For Event Type 'OT' Stocklist Name and  code must not be visible] Start
						if( eventType == 'OT' )
						{
							itemChangeStr +="<stockist_code protect = '0' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name></Detail1>";
						}
						else
						{
							itemChangeStr +="<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name></Detail1>";
						}
						//Added by sadique shaikh on 18-02-2020 [For Event Type 'OT' Stocklist Name and  code must not be visible] End
					}
				}			
				else if( fieldName === 'cust_type' )
				{
					var time = getStartTime();
					console.log("time is:"+time);
					//var randomNo = Math.floor(1000000 + Math.random() * 9999999);
					var randomNo = Math.floor(1000000 + Math.random() * 9000000);
					//var custCode = "UCO"+randomNo;
					scCode = "UCO"+randomNo;
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					var memType = "",callOutcome="",custDate="";
					var customerTypeEnter="",customerStrgTypeDetail="";    // added by shweta m 
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
						{
							memType = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
							teamDocType=memType;
						}
						if( detail.getElementsByTagName("call_outcome")[0] != null && detail.getElementsByTagName("call_outcome")[0].childNodes[0] != null )
						{
							callOutcome = detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("visited_with")[0] != null && detail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
						{
							team = detail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
						}

					}
					var currentDate = new Date();
					var diffDays = getDaysBetweenTwoDates(workDate,currentDate);
					if(custType == 'LISTED')
					{
						/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
						if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
						{
							if(team!='SELF')
							{
								if( gradeTypes != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>" ;
								}
								else if( gradeTypes != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( gradeTypes != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>" ;
								}
								else if( gradeTypes != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
								if( eventType == 'OT' )
								{
									itemChangeStr +="<stockist_code protect = '0' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name>";
								}
								else
								{
									itemChangeStr += "<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>";
								}
							}
							else
							{

								if( gradeTypes != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>" ;
								}
								else if( gradeTypes != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( gradeTypes != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>" ;
								}
								else if( gradeTypes != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
								if( eventType == 'OT' )
								{
									itemChangeStr +="<stockist_code protect = '0' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name>";
								}
								else
								{
									itemChangeStr += "<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>";
								}

							}		
						}
						else
						{
							if( gradeTypes != 'M' && eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
							}
							else if( gradeTypes == 'M' && eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
							}
							//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
							else if( gradeTypes != 'M' && eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
							}
							else if( gradeTypes == 'M' && eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
							}
							else
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
							}
							if( eventType == 'OT' )
							{
								itemChangeStr +="<stockist_code protect = '0' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name>";
							}
							else
							{
								itemChangeStr += "<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>";
							}
						}
						//added by Hariom S for fortune [18/05/2021]
						if( isFortuneActivity  == 'Y')
						{

							if( allowVisitTime  == 'Y')
							{
								itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
							else if( allowVisitTime  == 'N')
							{
								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'B'  && diffDays > 0)
							{
								itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

							}
							else
							{
								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
						}
						else
						{
							if(diffDays>0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
							{
								if(displayTimeField == "Y")
								{

									itemChangeStr +="<event_time_start visible = '1'><![CDATA[]]></event_time_start>" +
											"<event_time_end visible = '0'><![CDATA[]]></event_time_end><visit_time_from visible = '0'><![CDATA[]]></visit_time_from>" ;
								}
								else
								{
									itemChangeStr +="<event_time_start visible = '1'><![CDATA[]]></event_time_start>" +
											"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '0'><![CDATA[]]></visit_time_from>" ;
								}
							}
							else
							{
								itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
						}
						//"<event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>" +
						itemChangeStr += "<strg_code visible = '1' protect='0'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '1' visible = '1'></address_as><gender visible = '0'><![CDATA[M]]></gender>" +
								"<addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><age visible = '0'></age><qualification visible = '0'></qualification><email_addr visible = '0'></email_addr>" +
								"<mobile_no visible = '0'></mobile_no><strg_class_code visible = '0'></strg_class_code><spl_code visible = '0'></spl_code>" +
								"<call_outcome protect = '0' visible = '1'><![CDATA["+callOutcome+"]]></call_outcome><strg_class_code visible = '0' ></strg_class_code><class_code_descr visible = '0'></class_code_descr>" +
								"<type_cust protect = '1' visible = '0'><![CDATA[L]]></type_cust>";
						//Added by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
						//Commented by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
						//"<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>" +
						itemChangeStr += "<promoter_name visible = '0'></promoter_name><man_power visible = '0'></man_power><image_id visible = '0'></image_id><gst_no visible = '0'></gst_no>" +
								"<subclass_code visible = '0'></subclass_code><pin visible = '0'></pin><subclass_descr visible = '0'></subclass_descr><next_plan_date visible = '1' protect='0'></next_plan_date>" +
								"<visited_with protect = '0' visible = '1'></visited_with><oth_participant protect = '0' visible = '1'></oth_participant>" +
								"<strg_event_info visible = '0'></strg_event_info>" + //Added by sadique shaikh 02-03-2020 [For Event info of customer]
								"</Detail1>";
					}
					else
					{
						/*itemChangeStr = "<Detail1><event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>" +
						"<strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code><strg_name protect = '0'></strg_name><address_as visible = '1'></address_as>" +
						"<gender visible = '1'></gender><addr1 visible = '1'></addr1><addr2 visible = '1'></addr2><addr3 visible = '1'></addr3><email_addr visible = '1'>" +
						"</email_addr><mobile_no visible = '1'></mobile_no><strg_class_code visible = '1'></strg_class_code><spl_code visible = '1'></spl_code></Detail1>";*/
						//added by mrunalini sinkar for changes as per customer type on 28-jan-2019(start)
						var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);

						var unStrgType = "",memberPresent="",routeType="",invoiceNoD="";
						var lateStrgType="",customerTypeEnter="";
						console.log("Inside unlisted customer");
						for (var i = 0; i < detailElement.length; i++)
						{
							var detail = detailElement[i];
							if( detail.getElementsByTagName("strg_type")[0] != null && detail.getElementsByTagName("strg_type")[0].childNodes[0] != null )
							{
								unStrgType = detail.getElementsByTagName("strg_type")[0].childNodes[0].nodeValue;
								teamDocType=unStrgType;
							}
							//added by mrunalini sinkar for member present in unlisted customer (start)
							if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
							{
								memberPresent = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
							}
							//added by mrunalini sinkar for member present in unlisted customer (end)
							if( detail.getElementsByTagName("route_type")[0] != null && detail.getElementsByTagName("route_type")[0].childNodes[0] != null )
							{
								routeType = detail.getElementsByTagName("route_type")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("invoice_no")[0] != null && detail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
							{
								invoiceNoD = detail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
							}
							//added by shweta for entered custType data (started)
							if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
							{
								customerTypeEnter = detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
							}
							//added by shweta for entered custType data (end)
						}
						// added by shweta for cust_type unlisted itemchange (staretd)

						var custTypeDetailList = custTypeDetail.split(',');

						for(var i=0; i<custTypeDetailList.length; i++)
						{
							var customerTypeDetail = custTypeDetailList[i].split('@')[0];
							var custStrgType = custTypeDetailList[i].split('@')[1];

							if(customerTypeDetail.trim() == customerTypeEnter.trim())
							{
								lateStrgType = custStrgType;
							}

						}
						// added by shweta for cust_type unlisted itemchange (ended)

						//added by mrunalini sinkar for changes as per customer type on 28-jan-2019(end)
						if(routeType!="M")
						{

							if(memberPresent!='Y')//added by mrunalini sinkar for member present in unlisted custome
							{

								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if(team!='SELF')
									{ 
										if( gradeTypes != 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
										else if( gradeTypes != 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
										if( eventType == 'OT' )
										{
											itemChangeStr +="<stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '0' visible = '0'></stockist_code>";
										}
										else
										{
											itemChangeStr += "<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code>";
										}
										//<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code>
									}
									else
									{
										if( gradeTypes != 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
										else if( gradeTypes != 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
										if( eventType == 'OT' )
										{
											itemChangeStr +="<stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '0' visible = '0'></stockist_code>";
										}
										else
										{
											itemChangeStr += "<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code>";
										}
									}
								}
								else
								{
									if( gradeTypes != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( gradeTypes == 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( gradeTypes != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( gradeTypes == 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
									//Added by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
									if( eventType == 'OT' )
									{
										itemChangeStr +="<stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '0' visible = '0'></stockist_code>";
									}
									else
									{
										itemChangeStr += "<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code>";
									}
								}
								if( isFortuneActivity  == 'Y')
								{
									itemChangeStr += "<strg_code visible = '1'><![CDATA["+scCode+"]]></strg_code>";
								}
								else
								{
									itemChangeStr += "<strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code>"; 
								}
								itemChangeStr += "<uniq_strg_code visible = '0' protect='1'><![CDATA["+scCode+"]]></uniq_strg_code><strg_name protect = '0' visible='1'></strg_name><address_as protect = '1' visible = '1'></address_as>" +
										//"<event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>" +
										"<addr1 visible = '1'></addr1><addr2 visible = '1'></addr2><addr3 visible = '1'></addr3><age visible = '1'></age><gender visible = '1'><![CDATA[M]]></gender><qualification visible = '1'></qualification><email_addr visible = '1'>" +
										"</email_addr><mobile_no visible = '1'></mobile_no><strg_class_code visible = '1' protect='0'></strg_class_code><class_code_descr visible = '1'></class_code_descr>" +
										"<promoter_name visible = '1'></promoter_name><man_power visible = '1'></man_power><image_id visible = '1'></image_id><gst_no visible = '1'></gst_no>" +
										"<subclass_code visible = '1'></subclass_code><pin visible = '1'></pin><subclass_descr visible = '1'></subclass_descr>" +
										"<speciality_descr protect = '1' visible = '1'></speciality_descr><spl_code protect = '0' visible = '1'></spl_code><oth_participant protect = '0' visible = '1'></oth_participant>" +
										"<meet_summ protect = '0' visible = '1'></meet_summ><strg_class_code visible = '1'></strg_class_code><class_code_descr visible = '1'></class_code_descr><next_plan_date visible = '1' protect='0'></next_plan_date><call_outcome visible = '1' protect='0'><![CDATA["+callOutcome+"]]></call_outcome>" +
										"<strg_type visible = '1'><![CDATA["+lateStrgType+"]]></strg_type>" + //added by shweta
										"<strg_event_info visible = '1'></strg_event_info><reg_no protect = '0' visible='1'></reg_no><type_cust protect = '1' visible = '0'><![CDATA[U]]></type_cust>";////Added by sadique shaikh 02-03-2020 [For Event info for customer]
								//<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code>

								//commented by mrunalini sinkar for changes as per customer type on 28-jan-2019(start)
								/*if(custType == 'UNLISTED-DOCTOR')
								{
									itemChangeStr = itemChangeStr + "<sh_descr protect = '1'><![CDATA[DOCTOR]]></sh_descr>" +
									"<speciality_descr protect = '1' visible = '1'></speciality_descr><spl_code protect = '0' visible = '1'></spl_code>" +
									"<strg_class_code visible = '1'></strg_class_code><class_code_descr visible = '1'></class_code_descr>" +
									"<gender visible = '1'><![CDATA[M]]></gender>" ;
									//commented by mrunalini sinkar on 28-01-2019
									//"<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>" ;
								}
								else if(custType == 'UNLISTED-RETAILER')
								{
									itemChangeStr = itemChangeStr + "<sh_descr protect = '1'><![CDATA[CHEMIST]]></sh_descr>" +
									//"<speciality_descr visible = '0'><![CDATA[OTHER]]></speciality_descr><spl_code visible = '0'><![CDATA[OTH]]></spl_code>" +
									//"<strg_class_code visible = '0'><![CDATA[N]]></strg_class_code><class_code_descr visible = '0'></class_code_descr>" +
									"<gender visible = '0'><![CDATA[M]]></gender>" ;
									//commented by mrunalini sinkar on 28-01-2019
									//"<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>" ;
								}
								else if(custType == 'UNLISTED-STOCKIST')
								{
									itemChangeStr = itemChangeStr + "<sh_descr protect = '1'><![CDATA[STOCKIST]]></sh_descr>" +
									//"<speciality_descr visible = '0'><![CDATA[OTHER]]></speciality_descr><spl_code visible = '0'><![CDATA[OTH]]></spl_code>" +
									//"<strg_class_code visible = '0'><![CDATA[N]]></strg_class_code><class_code_descr visible = '0'></class_code_descr>" +
									"<gender visible = '0'><![CDATA[M]]></gender>" ;
									//commented by mrunalini sinkar on 28-01-2019
									//"<stockist_code protect = '0' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" ;
								}
								else if(custType == 'UNLISTED-OTHER')
								{
									itemChangeStr = itemChangeStr + "<sh_descr protect = '1'><![CDATA[OTHER]]></sh_descr>" +
									//"<speciality_descr protect = '1' visible = '1'><![CDATA[OTHER]]></speciality_descr><spl_code protect = '0' visible = '1'><![CDATA[OTH]]></spl_code>" +
									//"<strg_class_code visible = '1'></strg_class_code><class_code_descr visible = '1'></class_code_descr>" +
									"<gender visible = '0'><![CDATA[M]]></gender>" ;
									//commented by mrunalini sinkar on 28-01-2019
									//"<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>" ;
								}*/
								//commented by mrunalini sinkar for changes as per customer type on 28-jan-2019(end)
								//added by mrunalini sinkar for changes as per customer type on 28-jan-2019(start)
								//commented by mrunalini sinkar to show visited with in case of unlisted customer also (start)
								/*if(gradeTypes == 'M')
								{
									itemChangeStr+="<visited_with protect = '0' visible = '1'></visited_with>";
								}
								else
								{
									itemChangeStr+="<visited_with protect = '0' visible = '0'></visited_with>";
								}*/
								//commented by mrunalini sinkar to show visited with in case of unlisted customer also (end)
								//added by Hariom S for fortune [18/05/2021]
								if( isFortuneActivity  == 'Y')
								{

									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else if( allowVisitTime  == 'N')
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B'  && diffDays > 0)
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								else
								{
									if(diffDays>0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
									{

										itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
												"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;

									}
									else
									{
										itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								if( unStrgType== 'D')
								{
									itemChangeStr = itemChangeStr +
											"<speciality_descr protect = '1' visible = '1'></speciality_descr><spl_code protect = '0' visible = '1'></spl_code>";
									//Added by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
									if( eventType == 'OT' )
									{
										itemChangeStr +="<stockist_code protect = '0' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name>";
									}
									else
									{
										itemChangeStr += "<stockist_code protect = '0' visible = '1'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '1'><![CDATA["+stockistName+"]]></stockist_name>";
									}
								}
								else if(unStrgType== 'C')
								{
									//itemChangeStr = itemChangeStr + "<gender visible = '0'><![CDATA[M]]></gender>";
									//Added by sadique shaikh on 18-02-2020 [For Event Type Ot Stocklist Name and  code must not be visible]
									if( eventType == 'OT' )
									{
										itemChangeStr +="<stockist_code protect = '0' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>";
									}
									else
									{
										itemChangeStr += "<stockist_code protect = '0' visible = '1'></stockist_code><stockist_name protect = '1' visible = '1'></stockist_name>";
									}
								}
								else
								{
									//itemChangeStr = itemChangeStr + "<gender visible = '0'><![CDATA[M]]></gender><stockist_code protect = '0' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name>";
									itemChangeStr = itemChangeStr + "<stockist_code protect = '0' visible = '0'><![CDATA["+stockistCode+"]]></stockist_code><stockist_name protect = '1' visible = '0'><![CDATA["+stockistName+"]]></stockist_name>";

								}
								//added by mrunalini sinkar for changes as per customer type on 28-jan-2019(end)
								itemChangeStr = itemChangeStr + "</Detail1>";
							}
							//added by mrunalini sinkar for member present in unlisted customer(start)
							else
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
								{
									if(team!='SELF')
									{ 
										if( gradeTypes != 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
										else if( gradeTypes != 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
									}
									else
									{
										if( gradeTypes != 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'MI' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
										}
										//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
										else if( gradeTypes != 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else if( gradeTypes == 'M' && eventType == 'OT' )
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
										}
										else
										{
											itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
										}
									}
								}
								else
								{
									if( gradeTypes != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( gradeTypes == 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( gradeTypes != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( gradeTypes == 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
								}
								itemChangeStr += "<strg_code visible = '0'><![CDATA["+scCode+"]]></strg_code><strg_name visible = '0'></strg_name><address_as visible = '0'></address_as>" +
										"<addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><age visible = '0'></age><gender visible = '0'><![CDATA[M]]></gender><qualification visible = '0'></qualification><email_addr visible = '0'>" +
										"</email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0' protect='0'></strg_class_code><class_code_descr visible = '0'></class_code_descr>" +
										"<promoter_name visible = '0'></promoter_name><man_power visible = '0'></man_power><image_id visible = '0'></image_id><gst_no visible = '0'></gst_no>" +
										"<subclass_code visible = '0'></subclass_code><pin visible = '0'></pin><subclass_descr visible = '0'></subclass_descr>" +
										"<speciality_descr protect = '1' visible = '0'></speciality_descr><spl_code protect = '0' visible = '0'></spl_code>" +
										"<strg_class_code visible = '0'></strg_class_code><call_outcome visible = '0'><![CDATA["+callOutcome+"]]></call_outcome><class_code_descr visible = '0'></class_code_descr><copy_plan visible = '0'></copy_plan><resign_emp visible = '0'></resign_emp>" +
										"<oth_participant visible = '0'></oth_participant><meet_summ protect = '0' visible = '1'></meet_summ><stockist_code visible = '0'></stockist_code><stockist_name visible = '0'></stockist_name><remarks visible = '0'></remarks><next_plan_date visible = '0'></next_plan_date><reg_no protect = '0' visible='1'></reg_no>";

								//commented by mrunalini sinkar to show visited with in case of unlisted customer also (start)
								/*if(gradeTypes == 'M')
								{
									itemChangeStr+="<visited_with protect = '0' visible = '1'></visited_with>";
								}
								else
								{
									itemChangeStr+="<visited_with protect = '0' visible = '0'></visited_with>";
								}*/
								//commented by mrunalini sinkar to show visited with in case of unlisted customer also (end)
								if(memType=="D")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Doctor Details]]></strg_name>";
								}
								else if(memType=="C")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Chemist Details]]></strg_name>";
								}
								else if(memType=="S")
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Stockist Details]]></strg_name>";
								}
								else
								{
									itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Other Details]]></strg_name>";
								}
								//added by Hariom S for fortune [18/05/2021]
								if( isFortuneActivity  == 'Y')
								{

									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else if( allowVisitTime  == 'N')
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B'  && diffDays > 0)
									{
										itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

									}
									else
									{
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								else
								{
									if(diffDays>0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
									{

										itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
												"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;

									}
									else
									{
										itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
								}
								//added by Hariom S for fortune [18/05/2021]
								itemChangeStr = itemChangeStr + "</Detail1>";


							}
							//added by mrunalini sinkar for member present in unlisted customer(end)
						}
						else
						{

							/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
							if( visitedWithDesignCodeArr.includes( visitedWithDesignCode.trim() ) )
							{
								if( gradeTypes != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( gradeTypes == 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( gradeTypes != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else if( gradeTypes == 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							else
							{
								if( gradeTypes != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								else if( gradeTypes == 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( gradeTypes != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else if( gradeTypes == 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
								}
							}
							itemChangeStr = "<strg_code protect = '0' visible = '1'><![CDATA["+scCode+"]]></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks>" +
									"<next_plan_date protect='1' visible = '0'></next_plan_date><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'><![CDATA["+callOutcome+"]]></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
									"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><gender protect='1' visible = '0'><![CDATA[M]]></gender><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'>" +
									"</strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
									"<promoter_name visible = '0'></promoter_name><man_power visible = '0'></man_power><image_id visible = '0'></image_id><gst_no visible = '0'></gst_no>" +
									"<subclass_code visible = '0'></subclass_code><pin visible = '0'></pin><subclass_descr visible = '0'></subclass_descr>" +
									"<strg_event_info visible = '1'></strg_event_info><reg_no protect = '0' visible='1'></reg_no><type_cust protect = '1' visible = '0'><![CDATA[U]]></type_cust>"; ////Added by sadique shaikh 02-03-2020 [For Event info for customer] Start

							//commented by mrunalini sinkar to show visited with in case of unlisted customer also (start)
							/*if(gradeTypes == 'M')
							{
								itemChangeStr+="<visited_with protect = '0' visible = '1'></visited_with>";
							}
							else
							{
								itemChangeStr+="<visited_with protect = '0' visible = '0'></visited_with>";
							}*/
							//commented by mrunalini sinkar to show visited with in case of unlisted customer also (end)

							if(memberPresent!='Y')
							{
								itemChangeStr+="<member_present visible = '0'></member_present>";
							}
							else
							{
								itemChangeStr+="<member_present visible = '1'></member_present>";
							}

							if(memType=="D")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Doctor Details]]></strg_name>";
							}
							else if(memType=="C")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Chemist Details]]></strg_name>";
							}
							else if(memType=="S")
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Stockist Details]]></strg_name>";
							}
							else
							{
								itemChangeStr = itemChangeStr +"<strg_name visible = '0'><![CDATA[Other Details]]></strg_name>";
							}
							if( isFortuneActivity  == 'Y')
							{

								if( allowVisitTime  == 'Y')
								{
									itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else if( allowVisitTime  == 'N')
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B'  && diffDays > 0)
								{
									itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

								}
								else
								{
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
							}
							else
							{
								if(diffDays>0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
								{

									itemChangeStr +="<event_time_start visible = '0'><![CDATA[]]></event_time_start>" +
											"<event_time_end visible = '1'><![CDATA[]]></event_time_end><visit_time_from visible = '1'><![CDATA[]]></visit_time_from>" ;

								}
								else
								{
									itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
							}
							itemChangeStr+="</Detail1>";
						}
					}
				}
				//added by mrunalini sinkar on 16/02/2018 for auto mode(end)
				// added by rupali on 08/05-18 for single screen manager reporting [start]
				else if( fieldName === 'visited_with' )
				{
					console.log("inside if fieldValue before if is:::::::::::::"+fieldValue);
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					var gradeType = "",visitedWithDesignCode ="", sprsCodeWw = "",visitedWithCode="";
					var activityType ="",memberVisPresent="";
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("grade_type")[0] != null && detail.getElementsByTagName("grade_type")[0].childNodes[0] != null )
						{
							gradeType = detail.getElementsByTagName("grade_type")[0].childNodes[0].nodeValue;
						}
						//added by mrunalini sinkar for place required 09/09/2018 changes(start)
						if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
						{
							activityType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
							console.log("type activityType is:::"+activityType);
						}
						if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
						{
							memberVisPresent = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("visited_with_design_code")[0] != null && detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0] != null )
						{
							visitedWithDesignCode = detail.getElementsByTagName("visited_with_design_code")[0].childNodes[0].nodeValue;
						}
						console.log("visitedWithDesignCode:::::::"+visitedWithDesignCode);
						if( detail.getElementsByTagName("sprs_code__ww")[0] != null && detail.getElementsByTagName("sprs_code__ww")[0].childNodes[0] != null )
						{
							sprsCodeWw = detail.getElementsByTagName("sprs_code__ww")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("visited_with_code")[0] != null && detail.getElementsByTagName("visited_with_code")[0].childNodes[0] != null )
						{
							visitedWithCode = detail.getElementsByTagName("visited_with_code")[0].childNodes[0].nodeValue;
						}
						console.log("visitedWithCode:::::::"+visitedWithCode);
						console.log("sprsCodeWw:::::::"+sprsCodeWw);
						if( sprsCodeWw == null || sprsCodeWw.length == 0 )
						{
							sprsCodeWw = visitedWithCode;
						}
						console.log("sprsCodeWw:::::::after >>>>>>>>"+sprsCodeWw);
						//added by mrunalini sinkar for place required 09/09/2018 changes(end)
					}
					if( fieldValue != 'null' && fieldValue.trim().length > 0 && gradeType == 'M')
					{
						var selTeam = "";
						console.log("inside if fieldValue::::::::"+fieldValue);
						//if(fieldValue.indexOf("(") != -1 && fieldValue.indexOf(")") != -1)
						if( fieldValue != 'SELF' )
						{
							if(fieldValue.indexOf("(") != -1 && fieldValue.indexOf(")") != -1)
							{
								selTeam = fieldValue.substring(fieldValue.indexOf("(")+1, fieldValue.indexOf(")"));
							}
							else
							{
								selTeam = sprsCodeWw;
							}
							//selTeam = fieldValue.substring(fieldValue.indexOf("(")+1, fieldValue.indexOf(")"));

							selectedTeam = selTeam;
							console.log("selTeam inside selTeam:::::::"+selTeam);
							if(activityType == 'FW' && memberVisPresent!='Y' && eventType != 'CA')
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									if( gradeTypes != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform>";
									}
									else if( gradeTypes != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\'>";
									}
								}
								else
								{
									if( gradeTypes != 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									else if( gradeTypes == 'M' && eventType == 'MI' )
									{
										itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
									}
									//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
									else if( gradeTypes != 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else if( gradeTypes == 'M' && eventType == 'OT' )
									{
										itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName>";
									}
								}
								itemChangeStr += "<sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
										//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
										"<strg_code></strg_code><strg_name ></strg_name><address_as ></address_as>"+
										"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
							}
							else
							{
								//Added by Prasad on 19/12/19 [coaching related implementation] START
								if( gradeTypes == 'M' && eventType  == 'CA' )
								{
									/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
									if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
									{
										itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
												//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
												"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
									}
									else
									{
										itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
												//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
												"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
									}
								}
								else if( gradeTypes != 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
											//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
											"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><strg_code></strg_code><strg_name></strg_name><address_as ></address_as><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								else if( gradeTypes == 'M' && eventType == 'MI' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
											//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
											"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><strg_code></strg_code><strg_name></strg_name><address_as ></address_as><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
								else if( gradeTypes != 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
											//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
											"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><strg_code></strg_code><strg_name></strg_name><address_as ></address_as><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								else if( gradeTypes == 'M' && eventType == 'OT' )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
											//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
											"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><strg_code></strg_code><strg_name></strg_name><address_as ></address_as><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA["+selTeam+"]]></sprs_code__ww>"+
											//"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '1' visible = '1'></locality_descr>"+
											"<visited_with_team><![CDATA["+selTeam+"]]></visited_with_team><route_id><![CDATA[]]></route_id><strg_code></strg_code><strg_name></strg_name><address_as ></address_as><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								//Added by Prasad on 19/12/19 [coaching related implementation] END
							}
						}
						else if(fieldValue == 'SELF')
						{
							var empcode = getUserInfo( "empCode" );
							console.log("selTeam:::::::"+selTeam);
							//Added by Prasad on 19/12/19 [coaching related implementation] START
							selectedTeam = empcode;
							if( gradeTypes == 'M' && eventType == 'CA' )
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey,coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code></strg_code><strg_name></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code></strg_code><strg_name></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
							}
							else if( gradeTypes != 'M' && eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code></strg_code><strg_name></strg_name>"+
										"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
							}
							//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
							else if( gradeTypes != 'M' && eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code></strg_code><strg_name></strg_name>"+
										"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
							}
							else if( gradeTypes == 'M' && eventType == 'OT' )
							{
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code  ></strg_code><strg_name ></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code  ></strg_code><strg_name ></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
							}
							else if( gradeTypes == 'M' && eventType == 'MI' )
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code  ></strg_code><strg_name ></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code  ></strg_code><strg_name ></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
							}
							else
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code  ></strg_code><strg_name ></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA["+empcode+"]]></sprs_code__ww><strg_code  ></strg_code><strg_name ></strg_name>"+
											"<visited_with_team><![CDATA["+empcode+"]]></visited_with_team><route_id><![CDATA[]]></route_id><locality_descr><![CDATA[]]></locality_descr><locality_code><![CDATA[]]></locality_code></Detail1>";
								}
							}
							//Added by Prasad on 19/12/19 [coaching related implementation] END
						}
					}
					else if( fieldValue != 'null' && fieldValue.trim().length > 0 )
					{
						var exprFilter = "(value.visited_with_code || '').trim() == '" + fieldValue.trim() +"'"; //Changes by Jatin M on 21-05-2021 for worked with not set in proper format
						console.log("exprFilter  ["+exprFilter+"] fieldValue ["+fieldValue+"]");
						var jsonObj = JSON.parse( filterVisitedWithJSON( dataModelJson, exprFilter ) );
						var visitedWithValue = "";
						if( jsonObj.visited_with ) //Changes by Jatin M on 21-05-2021 for worked with not set in proper format
						{
							visitedWithValue = jsonObj.visited_with; //Changes by Jatin M on 21-05-2021 for worked with not set in proper format
							console.log("visitedWithValue  ["+visitedWithValue+"]");
							//Added by Prasad on 19/12/19 [coaching related implementation] START
							if( gradeTypes == 'M' && eventType  == 'CA' )
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
							}
							else if( gradeTypes != 'M' && eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
							//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
							else if( gradeTypes != 'M' && eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
							else  if( gradeTypes == 'M' && eventType == 'OT' )
							{
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:Receipt\'><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
							}
							else  if( gradeTypes == 'M' && eventType == 'MI' )
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'survey:PeopleTrained\'><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
							}
							else
							{
								/*Added by Pooja on 04/01/2020 to allow coaching for perticular workedWith*/
								if( visitedWithDesignCodeArr.includes(visitedWithDesignCode.trim()) )
								{
									itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'\' changeSubformName=\'\'><chg_subFormName><![CDATA[]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
								else
								{
									itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><visited_with><![CDATA["+visitedWithValue+"]]></visited_with><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
								}
							}
							//Added by Prasad on 19/12/19 [coaching related implementation] END
						}
						else
						{
							if(gradeTypes == 'M' && eventType  == 'CA' )
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' changeSubformName=\'\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
							else if( gradeTypes != 'M' && eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
							else if( gradeTypes == 'M' && eventType == 'MI' )
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
							//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
							else if( gradeTypes != 'M' && eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
							else if( gradeTypes == 'M' && eventType == 'OT' )
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:Receipt\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
							else
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'coaching\' changeSubformName=\'\'><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[]]></chg_subFormName><sprs_code__ww><![CDATA[]]></sprs_code__ww></Detail1>";
							}
						}
					}
				}
				// added by rupali on 08/05-18 for single screen manager reporting [end]
				else if ( fieldName === 'strg_name')
				{
					var time = getStartTime();
					var value = "";
					var firstString = "",finalString="", secondString = "", secString = "", thirdString = "", thiString = "",addr="";
					var Address1="",Address2="",Address3="";
					itemChangeStr = "<Detail1 domID='"+domId+"'>";

					var fieldDataJson = JSON.parse(fieldValue);


					for(var key in fieldDataJson)
					{
						value = fieldDataJson[key];
						if ( "address_components" == key )
						{
							var type = "",longName = "",pin = "";

							var obj = null;
							for ( var i = 0; i < value.length; i++)
							{
								obj = value[i];
								for ( var key in obj )
								{
									var data = obj[key];
									if ( "long_name" == key )
									{
										longName = data;
									}
									else if ( "types" == key )
									{
										type = data;
									}
								}
								if ("postal_code" == type)
								{
									pin = longName;
								}
							}
							itemChangeStr +="<pin><![CDATA["+pin+"]]></pin>";
						}
						else if ("adr_address" == key)
						{
							var finalS= value.substring(0,value.indexOf("<span class=\"locality\">"));
							var arr2 = [];
							var addressData = finalS.split(/\<span.*?\>/);
							//var addressData = finalS.split(/<\/?span.*?>/);
							for(var j=0;j < addressData.length;j++)
							{
								var addrData = addressData[j].trim();
								arr2.push(addrData);
							}
							for(var k=0;k < arr2.length;k++)
							{
								var concatString = [];
								var concatData = arr2[k].split("</span>");
								for(var m=0; m < concatData.length; m++)
								{
									var concatDataTemp = concatData[m].trim();
									concatString.push(concatDataTemp);
								}
								finalString = finalString.concat(concatString[0]);
							}
							if (finalString.length > 40)
							{
								addr = finalString.substring(0, 40);
								firstString = addr.substring(0, addr.lastIndexOf(","));
								Address1 = firstString;

								var address = finalString.substring(finalString.indexOf(firstString) + firstString.length);

								if (finalString.length > firstString.length && address.length > 40)
								{
									secondString = finalString.substring( firstString.length +1 ,( firstString.length +1 )+ 40);
									if(secondString.includes(","))
									{

										secString = secondString.substring(0, secondString.lastIndexOf(","));
										Address2 = secString;
									}
									else
									{
										secString = secondString.substring(0, secondString.lastIndexOf(" "));
										Address2=secString;
									}
									var address1 = finalString.substring(finalString.indexOf(secString) + secString.length);

									if (finalString.length > ((firstString.length) + (secString.length))&& address1.length > 40)
									{

										thirdString = finalString.substring(((finalString.indexOf(secString)) + secString.length) + 1,
												(((finalString.indexOf(secString)) + secString.length) + 1) + 40);

										if(thirdString.includes(","))
										{
											thiString = thirdString.substring(0, thirdString.lastIndexOf(","));
											Address3=thiString;
										}
										else
										{
											thiString = thirdString.substring(0, thirdString.lastIndexOf(" "));
											Address3=thiString;
										}
									}
									else
									{
										Address3=address1;
									}

								}
								else
								{
									Address2=address;
									Address3="";
								}
							}
							else
							{
								Address1=finalString;
								Address2="";
								Address3="";
							}
							itemChangeStr +="<addr1><![CDATA["+Address1+"]]></addr1><addr2><![CDATA["+Address2+"]]></addr2><addr3><![CDATA["+Address3+"]]></addr3>";
						}
						else if ("formatted_phone_number" == key)
						{
							if(value.indexOf(" ") != -1)
							{
								value = value.replace(" ", "");
							}
							if(value.indexOf("0") == 0)
							{
								value = value.substring(1);
							}
							itemChangeStr +="<mobile_no><![CDATA["+value+"]]></mobile_no>";
						}
						else if ("name" == key)
						{
							itemChangeStr +="<strg_name><![CDATA["+value+"]]></strg_name>";
						}
					}
					var currentDate = new Date();
					var diffDays = getDaysBetweenTwoDates(workDate,currentDate);
					//added by Hariom S for fortune [18/05/2021]
					if( isFortuneActivity  == 'Y')
					{

						if( allowVisitTime  == 'Y')
						{
							itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

						}
						else if( allowVisitTime  == 'N')
						{
							itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
						}
						else if( allowVisitTime  == 'B'  && diffDays > 0)
						{
							itemChangeStr +="<event_time_start  protect='0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end  protect='0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;

						}
						else
						{
							itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
						}
					}
					else
					{
						if(diffDays > 0 && (setVisitTime.trim().length == 0 || setVisitTime == 'N'))
						{
							itemChangeStr += "<event_time_start><![CDATA[]]></event_time_start><event_time_end><![CDATA[]]></event_time_end>";
						}
						else
						{
							itemChangeStr += "<event_time_start><![CDATA["+time+"]]></event_time_start><event_time_end><![CDATA["+time+"]]></event_time_end>";
						}
					}
					//added by Hariom S for fortune [18/05/2021]
					itemChangeStr +="</Detail1>";
					//alert(itemChangeStr);
				}
				else if( fieldName === 'event_time_start' )
				{
					//added by Hariom S for fortune [18/05/2021]
					if( isFortuneActivity  == 'Y')
					{

					}
					else
					{
						itemChangeStr = "<Detail1><event_time_end><![CDATA["+fieldValue+"]]></event_time_end><visit_time_from><![CDATA["+fieldValue+"]]></visit_time_from></Detail1>";
					}
				}
				//added by prachi
				else if( fieldName === 'qualification' )
				{
					console.log("fieldValue qualification "+fieldValue)
					if( fieldValue == 'null' || fieldValue.trim().length == 0)
					{
						itemChangeStr = "<Detail1><qualification_descr protect = '1' visible = '1'></qualification_descr></Detail1>";
					}
				}
				else if( fieldName === 'spl_code' )
				{
					console.log("fieldValue spl_code "+fieldValue)
					if( fieldValue == 'null' || fieldValue.trim().length == 0)
					{
						itemChangeStr = "<Detail1><speciality_descr protect = '1' visible = '1'></speciality_descr></Detail1>";
					}
				}
				else if( fieldName === 'visit_time_from' )
				{
					if( isFortuneActivity  == 'Y')
					{

					}
					else
					{
						itemChangeStr = "<Detail1><event_time_start><![CDATA["+fieldValue+"]]></event_time_start></Detail1>";
					}
					//added by Hariom S for fortune [18/05/2021]
				}
				//Added by sadique shaikh on 18-02-2020 [Attachment field unprotected if user select yes for signed consents for OT event type] Start
				else if( fieldName === 'cust_conf' )
				{
					console.log('fieldName cust_conf ['+signedConsents+']');
					var docRandomNo = Math.floor(Math.random()*1000000);
					itemChangeStr =  "<Detail1 domID='"+domId+"' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName>";
					if(signedConsents === 'Y')
					{
						itemChangeStr += "<cust_conf_proof visible ='1'><![CDATA["+docRandomNo+"]]></cust_conf_proof></Detail1>";
						console.log('cust_conf itemChangeStr ['+itemChangeStr+']');
					}
					else
					{
						itemChangeStr += "<cust_conf_proof visible ='1' protect ='1'><![CDATA[]]></cust_conf_proof></Detail1>";
						console.log('cust_conf itemChangeStr else['+itemChangeStr+']');
					}
				}
				else if( fieldName === 'plan_chg_reas' )
				{
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					for (var i = 0; i < detailElement.length; i++)
					{
						var beatChnageReasonDescr="",beatchangeReasonUdf="";
						var detail = detailElement[i];
						if( detail.getElementsByTagName("beat_change_descr")[0] != null && detail.getElementsByTagName("beat_change_descr")[0].childNodes[0] != null )
						{
							beatChnageReasonDescr = detail.getElementsByTagName("beat_change_descr")[0].childNodes[0].nodeValue;
							beatChnageReasonDescr = beatChnageReasonDescr.substring(1, beatChnageReasonDescr.length-1);

						}
						if( detail.getElementsByTagName("beat_change_udf")[0] != null && detail.getElementsByTagName("beat_change_udf")[0].childNodes[0] != null )
						{
							beatchangeReasonUdf = detail.getElementsByTagName("beat_change_udf")[0].childNodes[0].nodeValue;

						}
					}



					var betchnDesc = beatChnageReasonDescr.split(',');
					var fldDescr="";
					for(var p=0;p < betchnDesc.length;p++)
					{
						var fldvalue = betchnDesc[p].split('@')[0].trim();


						fieldValue=fieldValue.trim();

						if(fldvalue==fieldValue)
						{
							fldDescr=betchnDesc[p].split('@')[1].trim();
							break;
						}
					}
					var udfDescr="";
					if(beatchangeReasonUdf!=null && beatchangeReasonUdf.trim().length >0)
					{
						var beatChgUDF = beatchangeReasonUdf.split('#');

						for(var p=0;p < beatChgUDF.length;p++)
						{
							var beatCHgUDFNumber = beatChgUDF[p].split('@')[0].trim();

							fieldValue=fieldValue.trim();
							if(beatCHgUDFNumber==fieldValue)
							{
								udfDescr=beatChgUDF[p].split('@')[1].trim();
								break;
							}
						}
					}
					itemChangeStr = "<Detail1><plan_chg_reason_descr><![CDATA["+fldDescr+"]]></plan_chg_reason_descr><plan_chg_reason_udf visible ='1'><![CDATA["+udfDescr+"]]></plan_chg_reason_udf></Detail1>";
				}
				//Added by sadique shaikh on 18-02-2020 [Attachment field unprotected if user select yes for signed consents for OT event type] End
				else
				{
					itemChangeStr = "";
				}
			}
			//else if(objContext==4  || objContext==9 || objContext==14 ||objContext==2)
			else if(objFormName=='sampleorder')
			{
				//if(fieldName.toUpperCase()=='DESELECT' || fieldName.toUpperCase()=='SELECT')
				{

					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					//alert("detailElement.length =["+detailElement.length+"]");
					var selValue = "",item="";
					var selitemDescr="",selquantity="";
					var tollDesr="",itemSize="",selRemarkDescr="",selRemark="";
					for (var i = 0; i < detailElement.length; i++)
					{
						var quantity = "";
						var rate = "";
						var value="";
						var discount = "",itemDescr="";
						var detail = detailElement[i];
						var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
						var domIDVal = detail.getAttribute("domID");
						//alert("domIDVal =["+domIDVal+"]");
						console.log("domIDVal =["+domIDVal+"]");
						var remark = "",remarkList="";
						var focusDeviRes ="";
						if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
						}
						/*if( detail.getElementsByTagName("remarks")[0] != null && detail.getElementsByTagName("remarks")[0].childNodes[0] != null )
						{
							remark = detail.getElementsByTagName("remarks")[0].childNodes[0].nodeValue;
	                        selRemark = remark;
						}*/
						if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
						{
							itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
						}
						console.log("itemDescr =["+itemDescr+"]");
						if( detail.getElementsByTagName("landing_rate")[0] != null && detail.getElementsByTagName("landing_rate")[0].childNodes[0] != null && detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null)
						{
							rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
						}
						else if( detail.getElementsByTagName("landing_rate")[0] != null && detail.getElementsByTagName("landing_rate")[0].childNodes[0] != null )
						{
							rate = detail.getElementsByTagName("landing_rate")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("disc_perc")[0] != null && detail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
						{
							discount = detail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("disc_perc")[0] != null && detail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
						{
							discount = detail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("remark_list")[0] != null && detail.getElementsByTagName("remark_list")[0].childNodes[0] != null )
						{
							remarkList = detail.getElementsByTagName("remark_list")[0].childNodes[0].nodeValue;
						}
						//added by bhgayashri t on[21/08/21][start]
						if( detail.getElementsByTagName("focus_devi_reas")[0] != null && detail.getElementsByTagName("focus_devi_reas")[0].childNodes[0] != null )
						{
							focusDeviRes = detail.getElementsByTagName("focus_devi_reas")[0].childNodes[0].nodeValue;
							selRemark = focusDeviRes;
						}
						//added by bhgayashri t on[21/08/21][end]
						console.log("domIDVal ["+ domIDVal +"], domId ["+ domId +"]");
						if(domIDVal == domId)
						{
							if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								selquantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								selitemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("prev_two_order")[0] != null && detail.getElementsByTagName("prev_two_order")[0].childNodes[0] != null )
							{
								tollDesr = detail.getElementsByTagName("prev_two_order")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_size")[0] != null && detail.getElementsByTagName("item_size")[0].childNodes[0] != null )
							{
								itemSize = detail.getElementsByTagName("item_size")[0].childNodes[0].nodeValue;
							}
						}


						/*if( remark != 'undefined' && remark != null )
						{
							if(domIDVal == domId)
							{
								remarkList = remarkList.substring(1, remarkList.length-1);
								var remarkdescrList = remarkList.split(',');
	                            console.log("remarkdescrList ["+ remarkdescrList +"]");
								for(var j=0;j < remarkdescrList.length;j++)
								{
									var listRemark = remarkdescrList[j].split('@')[0].trim();


	                                if(listRemark==remark)
									{
										selRemark=listRemark;
										selRemarkDescr = remarkdescrList[j].split('@')[1];
										break;
									}
								}
							}
						}*/
						if( focusDeviRes != 'undefined' && focusDeviRes != null )
						{
							if(domIDVal == domId)
							{
								remarkList = remarkList.substring(1, remarkList.length-1);
								var remarkdescrList = remarkList.split(',');
								console.log("remarkdescrList ["+ remarkdescrList +"]");
								for(var j=0;j < remarkdescrList.length;j++)
								{
									var listRemark = remarkdescrList[j].split('@')[0].trim();


									if(listRemark==focusDeviRes)
									{
										selRemark=listRemark;
										selRemarkDescr = remarkdescrList[j].split('@')[1];
										break;
									}
								}
							}
						}
						console.log("selRemarkDescr 123 ["+ selRemarkDescr +"]");
						//Change by bhagyashri T for itemchange of value from quantity[start][28/02/22]
						if ( selRemarkDescr == null || "" == selRemarkDescr )
						{
							var remarksSelect = document.getElementById( "Detail"+objContext+"."+domId+".focus_devi_reas" );
							if ( remarksSelect != null )
							{
								var remarkIndex=remarksSelect.selectedIndex;
								console.log("remarksSelect inside remarkIndex ["+ remarkIndex +"]");
								if( remarkIndex != 'undefined' && remarkIndex != null )
								{
									selRemarkDescr = remarksSelect.options[remarksSelect.selectedIndex].text;
								}
							}
							console.log("selRemarkDescr ["+ selRemarkDescr +"]");
						}
						//Change by bhagyashri T for itemchange of value from quantity[END][28/02/22]
						if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' )
						{
							if(domIDVal == domId)
							{
								item = itemDescr;
								console.log("item =["+item+"]");
								selValue= parseFloat(quantity) * parseFloat(rate);
								//selValue = Math.round(selValue,2);
								//selValue = selValue.toFixed(2);
								selValue= parseFloat(quantity) * parseFloat(rate) - (discount * selValue /100);
								selValue = Number(Math.round(selValue+'e'+2)+'e-'+2);
								console.log("selValue =["+selValue+"]");
								//alert("selValue=["+selValue+"]");
							}
						}
						//console.log("quantity =["+quantity+"], rate=["+rate+"], attributeVal=["+attributeVal+"]");
						/*if(attributeVal != null && attributeVal != 'D')
						{
							if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined')
							{
								//value=parseFloat(quantity) * parseFloat(rate);
								//totalPOBValue = totalPOBValue + (parseFloat(quantity) * parseFloat(rate));
								if ( quantity > 0 && rate > 0)
								{
									totalPOBValue = totalPOBValue + (parseFloat(quantity) * parseFloat(rate) - (discount * (rate * quantity) /100));
									totalPOBValue = Number(Math.round(totalPOBValue+'e'+2)+'e-'+2);
								}
							}
						}
						if(attributeVal != null && attributeVal == 'D')
						{
							if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined')
							{
								//value=parseFloat(quantity) * parseFloat(rate);
							//	totalPOBValue = totalPOBValue + (parseFloat(quantity) * parseFloat(rate));
								if ( quantity > 0 && rate > 0)
								{
									totalPOBValue = totalPOBValue - (parseFloat(quantity) * parseFloat(rate) - (discount * (rate * quantity) /100));
									totalPOBValue = Number(Math.round(totalPOBValue+'e'+2)+'e-'+2);
								}
							}
						}*/
					}

					//If Condition added by pramod S for handle exception getTotalPOBValue() - [START] 
					if(allFormDetaildataDom != 'undefined' && allFormDetaildataDom != null && allFormDetaildataDom != "")
					{
						totalPOBValue = getTotalPOBValue(allFormDetaildataDom, objContext);
						console.log("updatetotalPOBValue =["+totalPOBValue+"]");
					}
					//If Condition added by pramod S for handle exception getTotalPOBValue() - [END]

					if(isNaN(selValue))
					{
						selValue = "";
					}
					if(isNaN(totalPOBValue))
					{
						totalPOBValue = "0";
					}
					//console.log("totalPOBValue =["+totalPOBValue+"]");
					console.log("totalPOBValue ===["+totalPOBValue+"]");
					//added by mrunalini sinkar on 16/02/2018 for auto mode(end)
					//itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'><quantity><![CDATA[]]></quantity><value><![CDATA["+selValue+"]]></value><Detail"+parentFormNo+"."+parentDomID+".sku_value><![CDATA["+totalPOBValue+"]]></Detail"+parentFormNo+"."+parentDomID+".sku_value></Detail"+objContext+"></Root>";



					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>";
					if( fieldName == 'deselect')
					{
						itemChangeStr += "<selectbox><![CDATA[false]]></selectbox><quantity><![CDATA[]]></quantity><stock_qty><![CDATA[0]]></stock_qty><value><![CDATA[]]></value>" ;
					}
					else
					{
						itemChangeStr += "<selectbox><![CDATA[true]]></selectbox><quantity><![CDATA["+selquantity+"]]></quantity><value><![CDATA["+selValue+"]]></value>" ;
					}
					itemChangeStr += "<strg_code><![CDATA["+scCode+"]]></strg_code>" +
							"<item_descr><![CDATA["+selitemDescr+"]]></item_descr>" +
							"<prev_two_order><![CDATA["+tollDesr+"]]></prev_two_order>" +
							"<item_size><![CDATA["+itemSize+"]]></item_size>" +
							"<focus_devi_reas><![CDATA["+selRemark+"]]></focus_devi_reas>" +   //Added by bhagyashri T[21/08/21]
							"<remark_descr><![CDATA["+selRemarkDescr+"]]></remark_descr>" +
							"<Detail1.1.sku_value><![CDATA["+totalPOBValue+"]]></Detail1.1.sku_value>" +
							"</Detail"+objContext+"></Root>";				
					//added by mrunalini sinkar on 16/02/2018 for auto mode(end)

					//console.log("itemChangeStr =["+itemChangeStr+"]");
					// added by rupali on 23/02/18 for edit mode of realtime report [start]
					if(updateFlagVal == 'E')
					{
						console.log("inside else updateFlagVal if is:::::"+updateFlagVal);
						itemChangeStr = itemChangeStr+"<Detail1 protectSubform=\"2,4\"><protect_subform><![CDATA[2,4]]></protect_subform></Detail1>";
					}
				}
			}
			//Added by Prasad on 15/01/18 [setting pitchSeq value in card view implementation] START
			else if( objFormName == 'brand' )
			{
				//alert("inside itemchange ata::"+objFormName);
				var brandWorkDate = "", brandSalesPers = "", brandStrgCode = "",brandDescr="" ,pitchStatus="";

				brandWorkDate = workDate;
				brandSalesPers = SalesPers;
				brandScCode = scCode;

				console.log("workDate ==> "+workDate);
				console.log("SalesPers ==> "+SalesPers);
				console.log("scCode ==> "+scCode);
				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				console.log( "detailElement.length ["+ detailElement.length +"], action - ["+ action +"]" );
				if ( action == "itemchange" )
				{
					/*for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
						var domIDVal = detail.getAttribute("domID");

						if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
						}
					}*/

					if(brandWorkDate == null || brandWorkDate.trim().length == 0)
					{
						for (var i = 0; i < detailElement.length; i++)
						{
							var detail = detailElement[i];
							var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
							var domIDVal = detail.getAttribute("domID");

							if( detail.getElementsByTagName("work_date")[0] != null && detail.getElementsByTagName("work_date")[0].childNodes[0] != null )
							{
								brandWorkDate = detail.getElementsByTagName("work_date")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
							{
								brandSalesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("sc_code")[0] != null && detail.getElementsByTagName("sc_code")[0].childNodes[0] != null )
							{
								brandScCode = detail.getElementsByTagName("sc_code")[0].childNodes[0].nodeValue;
							}

						}
					}


					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
						var domIDVal = detail.getAttribute("domID");
						if ( domIDVal == domId )
						{
							if( detail.getElementsByTagName("brand_descr")[0] != null && detail.getElementsByTagName("brand_descr")[0].childNodes[0] != null )
							{
								brandDescr = detail.getElementsByTagName("brand_descr")[0].childNodes[0].nodeValue;

							}
							if( detail.getElementsByTagName("pitch_detail_descr")[0] != null && detail.getElementsByTagName("pitch_detail_descr")[0].childNodes[0] != null )
							{
								pitchStatus = detail.getElementsByTagName("pitch_detail_descr")[0].childNodes[0].nodeValue;

							}
							if( detail.getElementsByTagName("sc_code")[0] != null && detail.getElementsByTagName("sc_code")[0].childNodes[0] != null )
							{
								brandScCode = detail.getElementsByTagName("sc_code")[0].childNodes[0].nodeValue;
								console.log("inside itemchange brand brandScCode1 "+brandScCode);
							}

						}
					}

					//added by mrunalini sinkar on for add customer code ,work date and sales pers in offline mode16-feb-2018(start)
					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" +
							"<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>" ;
					if(fieldName == 'deselect')
					{
						itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
					}
					else
					{
						itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
					}
					itemChangeStr +="<Detail"+objContext+"."+domId+".pitch_sequence><![CDATA["+ (++pitchSeq) +"]]></Detail"+objContext+"."+domId+".pitch_sequence>" +
							/*"<Detail"+objContext+"."+domId+".work_date><![CDATA["+workDate+"]]></Detail"+objContext+"."+domId+".work_date>" +
							"<Detail"+objContext+"."+domId+".sales_pers><![CDATA["+SalesPers+"]]></Detail"+objContext+"."+domId+".sales_pers>" +
							"<Detail"+objContext+"."+domId+".sc_code><![CDATA["+scCode+"]]></Detail"+objContext+"."+domId+".sc_code>" +*/
							"<Detail"+objContext+"."+domId+".work_date><![CDATA["+brandWorkDate+"]]></Detail"+objContext+"."+domId+".work_date>" +
							"<Detail"+objContext+"."+domId+".sales_pers><![CDATA["+brandSalesPers+"]]></Detail"+objContext+"."+domId+".sales_pers>" +
							"<Detail"+objContext+"."+domId+".sc_code><![CDATA["+brandScCode+"]]></Detail"+objContext+"."+domId+".sc_code>" +
							"<Detail"+objContext+"."+domId+".brand_descr><![CDATA["+brandDescr+"]]></Detail"+objContext+"."+domId+".brand_descr>" +
							"<Detail"+objContext+"."+domId+".pitch_detail_descr><![CDATA["+pitchStatus+"]]></Detail"+objContext+"."+domId+".pitch_detail_descr>" +
							"<Detail1.1.subform_meeting_status><![CDATA["+meetingStatus+"]]></Detail1.1.subform_meeting_status>" +
							"</Detail"+objContext+">" +
							"</Root>";
				}//Added by Prasad on 27/09/18 [set usage data related changes] START
				else if ( action == "usagedata" )
				{
					var usageDetailData = "";
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						var domIDVal = detail.getAttribute("domID");
						console.log( "domIDVal : ["+ domIDVal +"], domId : ["+ domIDVal +"]" );
						if ( domIDVal == domId )
						{
							if( detail.getElementsByTagName("usage_detail_data")[0] != null && detail.getElementsByTagName("usage_detail_data")[0].childNodes[0] != null )
							{
								usageDetailData = detail.getElementsByTagName("usage_detail_data")[0].childNodes[0].nodeValue;
							}
							break;
						}
					}
					console.log( "inside usageDetailData - ["+ usageDetailData +"]" );
					var usageDetailDataJson = [];
					if ( usageDetailData != "" )
					{
						usageDetailDataJson = JSON.parse( usageDetailData );
					}
					console.log( "inside usageDetailDataJson - ["+ JSON.stringify( usageDetailDataJson ) +"]" );
					var fieldDataJson = JSON.parse( fieldValue );
					var obj = null;
					for ( var i = 0; i < fieldDataJson.length; i++ )
					{
						obj = fieldDataJson[i];
						for ( var key in obj )
						{
							var data = obj[ key ];
							if ( "USAGE_DETAILS" == key )
							{
								var dataJsonArr = [];
								for ( var dataKey in data )
								{
									var dataJson = {};
									dataJson[ dataKey ] = ""+data[ dataKey ];
									dataJsonArr.push( dataJson );
									if ( dataKey == "start" )
									{
										obj[ "START_TIME" ] = data[ dataKey ];
									}
									else if ( dataKey == "end" )
									{
										obj[ "END_TIME" ] = data[ dataKey ];
									}
								}
								obj[ "USAGE_DETAIL_DATA" ] = dataJsonArr;
								delete obj[ key ];
							}
							else if( key == "DOC_NAME" )
							{
								var fileType = data.substring( data.lastIndexOf( "." ) + 1 );
								obj[ "FILE_TYPE" ] = fileType;
							}
						}
						usageDetailDataJson.push( obj );
					}

					itemChangeStr = "<Root>" +
							"<Header><editFlag>A</editFlag></Header>" +
							"<Errors></Errors>" +
							"<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>" ;
					itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
					itemChangeStr +="<Detail"+objContext+"."+domId+".usage_detail_data><![CDATA["+ JSON.stringify( usageDetailDataJson ) +"]]>" +
							"</Detail"+objContext+"."+domId+".usage_detail_data></Detail"+objContext+">" +
							"</Root>";
				}
				else if ( action == "usageDetailData" )
				{
					fieldValue = "["+ fieldValue +"]";
					console.log( "fieldValue : ["+ fieldValue +"]" );
					var brandWiseJson = {};
					var fieldDataJson = JSON.parse( fieldValue );
					var obj = null;
					var startTime = 0, endTime = 0;
					var fileType = null;
					for ( var i = 0; i < fieldDataJson.length; i++)
					{
						obj = fieldDataJson[i];
						var innerJson = {};
						startTime = 0;
						endTime = 0;
						fileType = "";
						for ( var key in obj )
						{
							var data = obj[ key ];
							//console.log( key,  data );
							if ( ( key != "BRAND_CODE" ) && ( key != "DOC_ID" ) && ( key != "DOC_NAME" ) )
							{
								var usageArr = [];
								if ( innerJson[ "USAGE_DETAIL_DATA" ] != null )
								{
									usageArr = innerJson[ "USAGE_DETAIL_DATA" ];
								}
								usageArr.push( data );
								innerJson[ "USAGE_DETAIL_DATA" ] = usageArr;

								for ( var dataKey in data )
								{
									if ( dataKey == "start" )
									{
										startTime = data[dataKey];
										innerJson[ "START_TIME" ] = +(startTime);
									}
									else if ( dataKey == "end" )
									{
										endTime = data[dataKey];
										innerJson[ "END_TIME" ] = +(endTime);
									}
								}
							}
							else if( key == "DOC_ID" )
							{
								innerJson[ key ] = data;
							}
							else if( key == "DOC_NAME" )
							{
								fileType = data.substring( data.lastIndexOf( "." ) + 1 );
								innerJson[ key ] = data;
								innerJson[ "FILE_TYPE" ] = fileType;
							}
						}
						//console.log(innerJson);
						var brandWiseArr = [];
						var usageBrandCode = obj[ "BRAND_CODE" ];
						if ( brandWiseJson[ usageBrandCode ] != null )
						{
							brandWiseArr = brandWiseJson[ usageBrandCode ];
						}
						var totalTime = (+endTime) - (+startTime);
						innerJson[ "TOTAL_TIME" ] = totalTime;
						brandWiseArr.push( innerJson );
						brandWiseJson[ usageBrandCode ] = brandWiseArr;
					}
					console.log( brandWiseJson );

					itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
						var domIDVal = detail.getAttribute("domID");
						var brandCode = "";
						domId = domIDVal;
						if( detail.getElementsByTagName("brand_code")[0] != null && detail.getElementsByTagName("brand_code")[0].childNodes[0] != null )
						{
							brandCode = detail.getElementsByTagName("brand_code")[0].childNodes[0].nodeValue;
						}
						if(brandWorkDate == null || brandWorkDate.trim().length == 0)
						{
							if( detail.getElementsByTagName("work_date")[0] != null && detail.getElementsByTagName("work_date")[0].childNodes[0] != null )
							{
								brandWorkDate = detail.getElementsByTagName("work_date")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
							{
								brandSalesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("sc_code")[0] != null && detail.getElementsByTagName("sc_code")[0].childNodes[0] != null )
							{
								brandScCode = detail.getElementsByTagName("sc_code")[0].childNodes[0].nodeValue;
							}
						}
						//alert("usage brandWorkDate::"+brandWorkDate);
						var usageFieldData = brandWiseJson[ brandCode ];
						if ( usageFieldData != null )
						{
							itemChangeStr += "<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>";
							itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
							itemChangeStr +="<Detail"+objContext+"."+domId+".pitch_sequence><![CDATA["+ (++pitchSeq) +"]]></Detail"+objContext+"."+domId+".pitch_sequence>" +
									/*"<Detail"+objContext+"."+domId+".work_date><![CDATA["+workDate+"]]></Detail"+objContext+"."+domId+".work_date>" +
									"<Detail"+objContext+"."+domId+".sales_pers><![CDATA["+SalesPers+"]]></Detail"+objContext+"."+domId+".sales_pers>" +
									"<Detail"+objContext+"."+domId+".sc_code><![CDATA["+scCode+"]]></Detail"+objContext+"."+domId+".sc_code>" +*/
									"<Detail"+objContext+"."+domId+".work_date><![CDATA["+brandWorkDate+"]]></Detail"+objContext+"."+domId+".work_date>" +
									"<Detail"+objContext+"."+domId+".sales_pers><![CDATA["+brandSalesPers+"]]></Detail"+objContext+"."+domId+".sales_pers>" +
									"<Detail"+objContext+"."+domId+".sc_code><![CDATA["+brandScCode+"]]></Detail"+objContext+"."+domId+".sc_code>" +
									"<Detail"+objContext+"."+domId+".usage_detail_data><![CDATA["+ JSON.stringify(usageFieldData) +"]]></Detail"+objContext+"."+domId+".usage_detail_data>" +
									"</Detail"+objContext+">";
						}
					}
					itemChangeStr += "</Root>";
					console.log( "itemChangeStr : ["+ itemChangeStr +"]" );
				}
				//Added by Prasad on 27/09/18 [set usage data related changes] END
				//Added by Prasad on 15/01/18 [setting pitchSeq value in card view implementation] END
			}
			//added by mrunalini sinkar on for add customer code ,work date and sales pers in offline mode16-feb-2018(start)
			else if( objFormName == 'display' )
			{
				//added by mrunalini sinkar on 30-nov-2018 for disp_type changes(start)
				if (fieldName == 'disp_type')
				{
					//var itmDispTyp="";
					var dispType="";
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						var domIDVal = detail.getAttribute("domID");
						if( detail.getElementsByTagName("itm_display_type")[0] != null && detail.getElementsByTagName("itm_display_type")[0].childNodes[0] != null && itmDispTyp == "")
						{
							itmDispTyp = detail.getElementsByTagName("itm_display_type")[0].childNodes[0].nodeValue;
							itmDispTyp = itmDispTyp.substring(1, itmDispTyp.length-1);
						}
						if( detail.getElementsByTagName("disp_type")[0] != null && detail.getElementsByTagName("disp_type")[0].childNodes[0] != null )
						{
							dispType = detail.getElementsByTagName("disp_type")[0].childNodes[0].nodeValue;
						}
					}
					if(itmDispTyp!="" && domIDVal == domId)
					{
						var list = itmDispTyp.split(',');
						itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";

						for(var j=0;j<list.length;j++)
						{
							var displayType = list[j].split('@')[0];
							var itmOption = list[j].split('@')[1];
							if(displayType.trim() == dispType)
							{
								if(itmOption == '1')
								{
									itemChangeStr +=
											"<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>";
									if(fieldName == 'deselect')
									{
										itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
									}
									else
									{
										itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
									}
									itemChangeStr +="<brand_code visible='1'></brand_code>"+
											"<quantity visible='0'></quantity>"+
											"<target_qty visible='0'></target_qty>"+
											"<brand_descr visible='1'></brand_descr>"+
											"<strg_code><![CDATA["+scCode+"]]></strg_code>"+
											"</Detail"+objContext+">" ;

								}
								else if(itmOption == '2')
								{
									itemChangeStr += "<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>";
									if(fieldName == 'deselect')
									{
										itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
									}
									else
									{
										itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
									}
									itemChangeStr +="<brand_code visible='1'></brand_code>"+
											"<quantity visible='1'></quantity>"+
											"<target_qty visible='1'></target_qty>"+
											"<brand_descr visible='1'></brand_descr>"+
											"<strg_code><![CDATA["+scCode+"]]></strg_code>"+
											"</Detail"+objContext+">" ;
								}
								else if(itmOption == '3')
								{
									itemChangeStr +=
											"<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>" ;
									if(fieldName == 'deselect')
									{
										itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
									}
									else
									{
										itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
									}
									itemChangeStr += "<brand_code visible='0'></brand_code>"+
											"<quantity visible='1'></quantity>"+
											"<target_qty visible='0'></target_qty>"+
											"<brand_descr visible='0'></brand_descr>"+
											"<strg_code><![CDATA["+scCode+"]]></strg_code>"+
											"</Detail"+objContext+">" ;
								}
							}
						}
						itemChangeStr += "</Root>";
						//alert("itemChangeStr::::::"+itemChangeStr);
					}
				}
				else if (fieldName == 'itm_default_add')
				{
					console.log("Inside itm_default_add ");
					itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
					itemChangeStr +=
							"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
									"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";
					itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
					itemChangeStr += "<dcr_id><![CDATA[]]></dcr_id>\r\n"+
							"<line_no><![CDATA["+domId+"]]></line_no>\r\n"+
							"<strg_code><![CDATA[]]></strg_code>\n"+
							"<doc_id><![CDATA[]]></doc_id>\n"+
							"<doc_id_1><![CDATA[]]></doc_id_1>\n"+
							"<display_area><![CDATA[]]></display_area>\r\n"+
							"<tran_id><![CDATA[]]></tran_id>\r\n"+
							"<disp_type><![CDATA[]]></disp_type>\r\n"+
							"<brand_code visible = '1'><![CDATA[]]></brand_code>\r\n"+
							"<brand_descr visible = '1'><![CDATA[]]></brand_descr>\r\n"+//added by nilesh for item change in auto mode
							//"<quantity visible = '0'><![CDATA[]]></quantity>\r\n"+
							"<quantity visible = '1'><![CDATA[]]></quantity>\r\n"+// Added By Nilesh change visible to 1 for display field
							"<target_qty visible = '0'><![CDATA[]]></target_qty>\r\n"+
							"</Detail"+objContext+">\r\n";
					itemChangeStr += "</Root>";
				}
				else
				{
					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail "+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>";
					if(fieldName == 'deselect')
					{
						itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
					}
					else
					{
						itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
					}
					itemChangeStr +="<strg_code><![CDATA["+scCode+"]]></strg_code></Detail"+objContext+"></Root>";
				}
				//added by mrunalini sinkar on 30-nov-2018 for disp_type changes(start)
				//alert("itemChangeStr:display order"+itemChangeStr);
			}

			//added by prachi on 03-AUG-22 [W22EBAS005]
			else if( objFormName == 'collection' )
			{

				console.log("Inside collection subform ");
				console.log("collection form field value is:"+fieldName+" fieldValue is: ["+fieldValue+"]");
			   
				if (fieldName == 'pay_mode')
				{
					itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>\r\n"+
							"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
							"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";

					if(fieldValue == 'C')
					{
						itemChangeStr += "<ref_date visible = '0'></ref_date><ref_no visible = '0'></ref_no><ref_bank visible = '0'></ref_bank><selectbox><![CDATA[true]]></selectbox>";
					}
					else
					{
						itemChangeStr += "<ref_date visible = '1'></ref_date><ref_no visible = '1'></ref_no><ref_bank visible = '1'></ref_bank><selectbox><![CDATA[true]]></selectbox>";
					}   
					itemChangeStr +="<Detail1.1.payment_mode><![CDATA["+fieldValue+"]]></Detail1.1.payment_mode>" ;

					itemChangeStr +="</Detail"+objContext+"></Root>";
				}
				else if (fieldName == 'itm_default_add')
				{
					var amount ="";
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					console.log("detailElement: "+detailElement);
					for (var i = 0; i < 1; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("bill_amt")[0] != null && detail.getElementsByTagName("bill_amt")[0].childNodes[0] != null)
						{
							amount = detail.getElementsByTagName("bill_amt")[0].childNodes[0].nodeValue;
							console.log("amount bill::"+amount);
						}
					}	
					var currentDate = localStorage.getItem( 'SYSTEM_DISP_DATE' );
					itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>\r\n";
					itemChangeStr +=
							"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
									"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
									"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
									"<line_no><![CDATA["+domId+"]]></line_no>\r\n"+
									"<strg_code><![CDATA[]]></strg_code>\n"+
									"<selectbox><![CDATA[true]]></selectbox>"+
									"<tran_id><![CDATA[]]></tran_id>\r\n"+
									"<bill_amt><![CDATA["+amount+"]]></bill_amt>\r\n"+
									"<bill_date><![CDATA["+currentDate+"]]></bill_date>\r\n"+
									"<pay_mode><![CDATA[]]></pay_mode>\r\n"+
									"<ref_date><![CDATA[]]></ref_date>\r\n"+
									"<ref_no><![CDATA[]]></ref_no>\r\n"+
									"<amount><![CDATA[]]></amount>\r\n"+
									"<ref_bank><![CDATA[]]></ref_bank>\r\n"+
									"<remarks_collect><![CDATA[]]></remarks_collect>\r\n"+
									"</Detail"+objContext+">\r\n"+
									"</Root>";
				}
				else
				{
					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail "+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>";
					if(fieldName == 'deselect')
					{
						itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
					}
					else
					{
						itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
					}
					itemChangeStr +="<strg_code><![CDATA["+scCode+"]]></strg_code></Detail"+objContext+"></Root>";
				}


			}//added by prachi on 03-AUG-22 [W22EBAS005] end

			else if( objFormName == 'team' )
			{
				//alert("inside team objFormName["+objFormName+"]");
				console.log("Inside Team subform ");
				console.log("Inside Team subform::: "+fieldName);
				/*var randomNo = Math.floor(1000000 + Math.random() * 9000000);
				nMemCode = "M"+randomNo;
	            console.log("randomNo is::["+randomNo+"] nmemCode IS ::["+nMemCode+"]");*/
				if (fieldName == 'itm_default_add')
				{
					//alert("itmdefault add fieldValue["+fieldValue+"] fieldName["+fieldName+"]");
					console.log("Inside Team Itm_default_add realtime change");
					var randomNo = Math.floor(1000000 + Math.random() * 9000000);
					nMemCode = "M"+randomNo;
					console.log("randomNo is::["+randomNo+"] nmemCode IS ::["+nMemCode+"]");
					itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
					itemChangeStr +=
							"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
									"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";
					itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
					itemChangeStr += "<dcr_id><![CDATA[]]></dcr_id>\r\n"+
							"<line_no><![CDATA["+domId+"]]></line_no>\r\n"+
							"<strg_code><![CDATA[]]></strg_code>\n"+
							"<member_type visible='0'><![CDATA[]]></member_type>\n"+
							"<member_name visible='1'><![CDATA[]]></member_name>\n"+
							"<mem_code visible='0'><![CDATA[]]></mem_code>\r\n"+
							"<sales_pers visible='0'><![CDATA["+nMemCode+"]]></sales_pers>\r\n"+
							"<tran_id><![CDATA[]]></tran_id>\r\n"+
							"<team_mobile_no visible='1'><![CDATA[]]></team_mobile_no>\r\n"+
							"<disp_descr visible= '0'><![CDATA[Customer Representative]]></disp_descr>\r\n"+
							"</Detail"+objContext+">\r\n";
					itemChangeStr += "</Root>";
				}
				else if(fieldName == 'member_type')
				{
					//alert("fieldValue["+fieldValue+"] fieldName["+fieldName+"]");
					console.log("fieldValue in team["+fieldValue+"] fieldName in team ["+fieldName+"]");
					/*var randomNo = Math.floor(1000000 + Math.random() * 9000000);
					var nMemCode = "M"+randomNo;*/
					if(fieldValue == 'C')
					{
						console.log("fieldValue in team inside customer["+fieldValue+"] fieldName in team ["+fieldName+"]");
						itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>\r\n"+
								"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
								"<member_name protect = '1'><![CDATA[]]></member_name>\r\n"+
								"<mem_code visible = '1'><![CDATA[]]></mem_code>\r\n"+
								"<team_mobile_no protect = '1'><![CDATA[]]></team_mobile_no>\r\n"+
								//"<sales_pers visible = '1'><![CDATA[]]></sales_pers>\r\n"+
								"<disp_descr visible= '0'><![CDATA[Customer Contact]]></disp_descr>\r\n"+
								"</Detail"+objContext+">\r\n"+
								"</Root>";
					}
					else if(fieldValue == 'E')
					{
						console.log("fieldValue in team inside  employee["+fieldValue+"] fieldName in team ["+fieldName+"]");
						itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>\r\n"+
								"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
								"<member_name protect = '1'><![CDATA[]]></member_name>\r\n"+
								"<mem_code visible = '1'><![CDATA[]]></mem_code>\r\n"+
								"<team_mobile_no protect = '1'><![CDATA[]]></team_mobile_no>\r\n"+
								//"<sales_pers visible = '1'><![CDATA[]]></sales_pers>\r\n"+
								"<disp_descr visible= '0'><![CDATA[Employee]]></disp_descr>\r\n"+
								"</Detail"+objContext+">\r\n"+
								"</Root>";
					}
					else if(fieldValue == 'R')
					{
						console.log("fieldValue in team inside Represenatativ["+fieldValue+"] fieldName in team ["+fieldName+"]");
						itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>\r\n"+
								"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
								"<member_name protect = '0'><![CDATA[]]></member_name>\r\n"+
								"<mem_code visible = '0'><![CDATA[]]></mem_code>\r\n"+
								//"<sales_pers visible = '0'><![CDATA["+nMemCode+"]]></sales_pers>\r\n"+
								"<team_mobile_no protect = '0'><![CDATA[]]></team_mobile_no>\r\n"+
								"<disp_descr visible= '0'><![CDATA[Customer Representative]]></disp_descr>\r\n"+
								"</Detail"+objContext+">\r\n"+
								"</Root>";
					}
					else if(fieldValue == 'O')
					{
						console.log("fieldValue in team inside OTHERS["+fieldValue+"] fieldName in team ["+fieldName+"]");
						itemChangeStr += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>\r\n"+
								"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
								"<member_name protect = '0'><![CDATA[]]></member_name>\r\n"+
								"<mem_code visible = '0'><![CDATA[]]></mem_code>\r\n"+
								//"<sales_pers visible = '0'><![CDATA["+nMemCode+"]]></sales_pers>\r\n"+
								"<team_mobile_no protect = '0'><![CDATA[]]></team_mobile_no>\r\n"+
								"<disp_descr visible= '0'><![CDATA[Others]]></disp_descr>\r\n"+
								"</Detail"+objContext+">\r\n"+
								"</Root>";
					}
				}
				else
				{
					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail "+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>";
					if(fieldName == 'deselect')
					{
						itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
					}
					else
					{
						itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
					}
					itemChangeStr +="<strg_code><![CDATA["+scCode+"]]></strg_code></Detail"+objContext+"></Root>";
				}
			}

			/*Changed by Pooja on 11/06/2020 [to resolve the same data displaying on tema feed related changes] START*/
			/*else if( objFormName == 'team' )
			{
				var salesPersName="",salesPers="",strgCode="",designCode="";
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
				itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" ;
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var domIDVal = detail.getAttribute("domID");
					var attributeVal = detail.getAttribute("selected");
					console.log("attributeVal is"+attributeVal);
					if( detail.getElementsByTagName("sales_pers_sp_name")[0] != null && detail.getElementsByTagName("sales_pers_sp_name")[0].childNodes[0] != null )
					{
						salesPersName = detail.getElementsByTagName("sales_pers_sp_name")[0].childNodes[0].nodeValue;
						console.log("salesPersName is:"+salesPersName);
					}
					if( detail.getElementsByTagName("design_code")[0] != null && detail.getElementsByTagName("design_code")[0].childNodes[0] != null )
					{
						designCode = detail.getElementsByTagName("design_code")[0].childNodes[0].nodeValue;
						console.log("design_code is:"+ designCode );
					}
					if( attributeVal == 'Y')
					{
						if( domIDVal == domId )
						{
							itemChangeStr += "<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>" ;
							if(fieldName == 'select')
							{
								itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>" ;
							}
							else
							{
								itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>";
							}
							itemChangeStr +="<strg_code><![CDATA["+scCode+"]]></strg_code>" +
							"<sales_pers><![CDATA["+SalesPers+"]]></sales_pers>" +
							"<sales_pers_sp_name><![CDATA["+salesPersName+"]]></sales_pers_sp_name>" +
							"<name><![CDATA["+salesPersName+"]]></name>" +
							"<design_code><![CDATA["+designCode+"]]></design_code>" +
							"</Detail"+objContext+">";
						}
					}
				}
				itemChangeStr += "</Root>";
			}*/
			/*Changed by Pooja on 11/06/2020 [to resolve the same data displaying on tema feed related changes] END*/
			else if( objFormName == 'survey' )
			{
				console.log("in the survey form "+fieldName);
				//Added by Pooja S [to set item change response to result] START
				if ( fieldName == 'result5' )
				{
					console.log( "dataModelJson in localItemChange : fieldValue ["+ fieldValue +"]" );
					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" +
							"<Detail"+objContext+" domID='" + domId + "' formName='"+objFormName+"'>" +
							"<result><![CDATA["+fieldValue+"]]></result>" +
							"</Detail"+objContext+">" +
							"</Root>";
				}//Added by Pooja S [to set item change response to result] END
				else if (fieldName == 'itm_default_add')
				{
					console.log("in the survey form itm_default_add ");
					var survCount = 0,surveyCode="",selectbox="";
					var resultVal="";
					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
					var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
					var resultType = "",resultFormat = "",attachOpt="",surveyTemp="",surveyDescr="",context="",contextDescr="",result="",metaData="",
							result1="",result2="",result3="",result4="",result5= "",dcrId="",surveyMandatory="",docId2="",surveyStrgCode="";
					var codeCust="",srvgroupdescr="";
					var custSurveyList=[];
					var custCodeList=[];
					console.log( "detailElement.length - ["+ detailElement.length +"]" );
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						console.log( "detail - ["+ detail +"]" );
						if( detail.getElementsByTagName("result_type")[0] != null && detail.getElementsByTagName("result_type")[0].childNodes[0] != null )
						{
							resultType = detail.getElementsByTagName("result_type")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result_format")[0] != null && detail.getElementsByTagName("result_format")[0].childNodes[0] != null )
						{
							resultFormat = detail.getElementsByTagName("result_format")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("attach_opt")[0] != null && detail.getElementsByTagName("attach_opt")[0].childNodes[0] != null )
						{
							attachOpt = detail.getElementsByTagName("attach_opt")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("survey_templ")[0] != null && detail.getElementsByTagName("survey_templ")[0].childNodes[0] != null )
						{
							surveyTemp = detail.getElementsByTagName("survey_templ")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("survey_code")[0] != null && detail.getElementsByTagName("survey_code")[0].childNodes[0] != null )
						{
							surveyCode = detail.getElementsByTagName("survey_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("survey_descr")[0] != null && detail.getElementsByTagName("survey_descr")[0].childNodes[0] != null )
						{
							surveyDescr = detail.getElementsByTagName("survey_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("context")[0] != null && detail.getElementsByTagName("context")[0].childNodes[0] != null )
						{
							context = detail.getElementsByTagName("context")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("context_descr")[0] != null && detail.getElementsByTagName("context_descr")[0].childNodes[0] != null )
						{
							contextDescr = detail.getElementsByTagName("context_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result")[0] != null && detail.getElementsByTagName("result")[0].childNodes[0] != null )
						{
							result = detail.getElementsByTagName("result")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("meta_data")[0] != null && detail.getElementsByTagName("meta_data")[0].childNodes[0] != null )
						{
							metaData = detail.getElementsByTagName("meta_data")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result1")[0] != null && detail.getElementsByTagName("result1")[0].childNodes[0] != null )
						{
							result1 = detail.getElementsByTagName("result1")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result2")[0] != null && detail.getElementsByTagName("result2")[0].childNodes[0] != null )
						{
							result2 = detail.getElementsByTagName("result2")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result3")[0] != null && detail.getElementsByTagName("result3")[0].childNodes[0] != null )
						{
							result3 = detail.getElementsByTagName("result3")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("result4")[0] != null && detail.getElementsByTagName("result4")[0].childNodes[0] != null )
						{
							result4 = detail.getElementsByTagName("result4")[0].childNodes[0].nodeValue;
							resultVal = detail.getElementsByTagName("result4")[0].getAttribute("ddlblist");
						}
						if( detail.getElementsByTagName("result5")[0] != null && detail.getElementsByTagName("result5")[0].childNodes[0] != null )
						{
							result5 = detail.getElementsByTagName("result5")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("dcr_id")[0] != null && detail.getElementsByTagName("dcr_id")[0].childNodes[0] != null )
						{
							dcrId = detail.getElementsByTagName("dcr_id")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("survey_mandatory")[0] != null && detail.getElementsByTagName("survey_mandatory")[0].childNodes[0] != null )
						{
							surveyMandatory = detail.getElementsByTagName("survey_mandatory")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("doc_id_2")[0] != null && detail.getElementsByTagName("doc_id_2")[0].childNodes[0] != null )
						{
							docId2 = detail.getElementsByTagName("doc_id_2")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							surveyStrgCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("selectbox")[0] != null && detail.getElementsByTagName("selectbox")[0].childNodes[0] != null )
						{
							selectbox = detail.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("srv_group_descr")[0] != null && detail.getElementsByTagName("srv_group_descr")[0].childNodes[0] != null )
						{
							srvgroupdescr = detail.getElementsByTagName("srv_group_descr")[0].childNodes[0].nodeValue;
						}

						if(DocsurveyTemp==surveyTemp )
						{
							itemChangeStr +=
									"<Detail"+objContext+" domID='" + domId + "' selected = 'N' formName='"+objFormName+"'>\r\n"+
											"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";
							if(fieldName == 'deselect')
							{
								itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
							}
							else
							{
								itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
							}
							itemChangeStr +="<line_no><![CDATA["+domId+"]]></line_no>\r\n"+
									"<strg_code><![CDATA[]]></strg_code>\n"+
									"<survey_code><![CDATA["+ surveyCode +"]]></survey_code>\n"+
									"<survey_descr><![CDATA["+surveyDescr+"]]></survey_descr>\n"+
									"<context><![CDATA["+ surveyCode +"]]></context>\n" +
									"<context_descr><![CDATA[]]></context_descr>"+
									"<result_type><![CDATA["+ resultType +"]]></result_type>\n"+
									"<result_format><![CDATA[]]></result_format>\n"+
									"<result><![CDATA[]]></result>\n"+
									"<meta_data><![CDATA[]]></meta_data>\n"+
									"<dcr_id><![CDATA[]]></dcr_id>\n"+
									"<attach_opt><![CDATA[]]></attach_opt>\n"+
									"<survey_mandatory><![CDATA[]]></survey_mandatory>\n"+
									"<survey_templ><![CDATA[]]></survey_templ>";
							if(resultType == 'N')
							{
								itemChangeStr +=
										"<result1 visible='1'><![CDATA[]]></result1>\n"+
												"<result2 visible='0'><![CDATA[]]></result2>\n"+
												"<result3 visible='0'><![CDATA[]]></result3>\n"+
												"<result4 visible='0'><![CDATA[]]></result4>"+
												"<result5 visible='0'><![CDATA[]]></result4>"+
												"<result5 visible='0'><![CDATA[]]></result5>";
							}
							else if(resultType == 'L' && resultFormat == 'D')
							{
								itemChangeStr +=
										"<result1 visible='0'><![CDATA[]]></result1>\n"+
												"<result2 visible='0'><![CDATA[]]></result2>\n"+
												"<result3 visible='0'><![CDATA[]]></result3>\n"+
												"<result4 visible='1' ddlblist=''><![CDATA[]]></result4>"+
												"<result5 visible='0'><![CDATA[]]></result5>";
							}
							else if(resultType == 'L' || resultType == 'D')
							{
								itemChangeStr +=
										"<result1 visible='0'><![CDATA[]]></result1>\n"+
												"<result2 visible='1'><![CDATA[]]></result2>\n"+
												"<result3 visible='0'><![CDATA[]]></result3>\n"+
												"<result4 visible='0'><![CDATA[]]></result4>"+
												"<result5 visible='0'><![CDATA[]]></result5>";
							}
							else if(resultType == 'T')
							{
								itemChangeStr +=
										"<result1 visible='0'><![CDATA[]]></result1>\n"+
												"<result2 visible='0'><![CDATA[]]></result2>\n"+
												"<result3 visible='1'><![CDATA[]]></result3>\n"+
												"<result4 visible='0'><![CDATA[]]></result4>"+
												"<result5 visible='0'><![CDATA[]]></result5>";
							}
							else if(resultType == 'A')
							{
								itemChangeStr +=
										"<result1 visible='0'><![CDATA[]]></result1>\n"+
												"<result2 visible='0'><![CDATA[]]></result2>\n"+
												"<result3 visible='0'><![CDATA[]]></result3>\n"+
												"<result4 visible='0'><![CDATA[]]></result4>\n"+
												"<result5 visible='1'><![CDATA[]]></result5>";
							}
							else
							{
								itemChangeStr +=
										"<result1 visible='0'><![CDATA[]]></result1>\n"+
												"<result2 visible='0'><![CDATA[]]></result2>\n"+
												"<result3 visible='1'><![CDATA[]]></result3>\n"+
												"<result4 visible='0'><![CDATA[]]></result4>"+
												"<result5 visible='0'><![CDATA[]]></result5>";
							}
							if(attachOpt == '1' || attachOpt == '2')
							{
								itemChangeStr +=
										"<doc_id_2 visible='1'><![CDATA[]]></doc_id_2>";
							}
							else
							{
								itemChangeStr +=
										"<doc_id_2 visible='0'><![CDATA[]]></doc_id_2>";
							}
							itemChangeStr +="<srv_group_descr visible='0'><![CDATA["+srvgroupdescr+"]]></srv_group_descr></Detail"+objContext+">";

							if (custSurveyList.indexOf(surveyCode) ==-1)
							{
								custSurveyList.push(surveyCode)
							}
						}
					}
					itemChangeStr += "</Root>";
				}
			}
			//added by mrunalini sinkar on for add customer code ,work date and sales pers in offline mode16-feb-2018(end)
			//added by mrunalini sinkar for sample management realted changes in realtime report(start)
			if( objFormName == 'sampleitem' || objFormName == 'retailersampleitem' || objFormName == 'stockistsampleitem'  )
			{
				// selected details
				var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);

				for( var cnt= 0 ; cnt < detailElement.length; cnt++ )
				{
					if ( ! window.dataMap )
					{
						window.dataMap = {};
					}
					var currDetail = detailElement[cnt];
					var currDomIDVal = currDetail.getAttribute("domID");
					var sampleAllow = currDetail.getElementsByTagName("sample_allow")[0].childNodes[0].nodeValue; //added by mrunalini sinkar sfaparam condition to remove sampel validation
					console.log( "sampleAllow cnt ["+sampleAllow+"] allFormDetaildataDom ["+allFormDetaildataDom+"]");
					if( sampleAllow.trim() === 'E' )
					{
						var currItemCode = currDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
						var maxAllowance = currDetail.getElementsByTagName("max_sample_allow")[0].childNodes[0].nodeValue;
						console.log( "588 currItemCode ["+currItemCode+"] maxAllowance ["+maxAllowance+"]");

						var currStockData= "";
						var quantity = '';
						//var oldQty;
						var flag = false;

						if( currDetail.getElementsByTagName("quantity")[0] != null && currDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity = currDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
						}
						if( currDetail.getElementsByTagName("curr_stock_qty")[0] != null && currDetail.getElementsByTagName("curr_stock_qty")[0].childNodes[0] != null )
						{
							currStockData = currDetail.getElementsByTagName("curr_stock_qty")[0].childNodes[0].nodeValue;
						}
						var detaildata = "Detail"+objContext+"[domID=\""+ domId +"\"]";
						console.log('611 prevValue :::['+prevValue+']detaildata['+detaildata+']');
						if( allFormDetaildataDom != undefined && allFormDetaildataDom != '' )
						{
							// all detaildata
							var reqDetail = allFormDetaildataDom.querySelector(detaildata);
							console.log('611 reqDetail ['+reqDetail+']');

							if( reqDetail.getElementsByTagName("curr_stock_qty")[0] != null && reqDetail.getElementsByTagName("curr_stock_qty")[0].childNodes[0] != null )
							{
								quantity = quantity -prevValue;
								currStockData = reqDetail.getElementsByTagName("curr_stock_qty")[0].childNodes[0].nodeValue;
							}
							if( action == 'itemchange' && fieldName == 'deselect')
							{
								quantity = 0;
							}
							else if( action == 'itemchange' && fieldName == 'select')
							{
								if(prevValue == '' )
								{
									quantity = quantity;
								}
								else
								{
									quantity = prevValue;
								}
							}
						}
						else
						{
							//console.log( "726 currStockData ["+currStockData+"] quantity ["+quantity+"] action ["+action+"] fieldName ["+fieldName+"] prevValue ["+prevValue+"]");
							if( parseInt(quantity) > parseInt(prevValue) )
							{
								quantity = quantity - prevValue;
							}
							if( action == 'itemchange' && fieldName == 'deselect')
							{
								//quantity = quantity;
								//quantity = 0;
								if( prevValue = '')
								{
									quantity = 0;
								}
								else
								{
									quantity = quantity;
								}
							}
							else if( action == 'itemchange' && fieldName == 'select')
							{
								if(prevValue == '' )
								{
									quantity = quantity;
								}
								else
								{
									quantity = prevValue;
								}
							}
						}
						console.log( "626 currStockData ["+currStockData+"] quantity ["+quantity+"] currDomIDVal["+currDomIDVal+"] domId ["+domId+"] fieldValue ["+fieldValue+"] prevValue ["+prevValue+"]");
						if( currDomIDVal == domId && parseInt(quantity) <= parseInt(currStockData) || fieldName == 'select' && quantity == '' )//for validation of qty enter
						{
							flag = true;
						}
						//console.log( "641 quantity ["+quantity+"] currStockData ["+currStockData+"] itemCode ["+itemCode+"] currItemCode ["+currItemCode+"]");
						if( currItemCode.trim() == itemCode.trim())
						{
							if(flag)
							{
								if( action == 'itemchange' && fieldName == 'quantity')
								{
									currStockData = parseInt(currStockData) - parseInt(quantity);//calculation of current stock from qty
									itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail"+objContext+" dbID='' domID='"+currDomIDVal+"' objContext='"+objContext+"'>";
									if(fieldName == 'deselect')
									{
										itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
									}
									else
									{
										itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
									}
									itemChangeStr +="<curr_stock_qty><![CDATA["+ currStockData  +"]]></curr_stock_qty></Detail"+objContext+"></Root>";
									//store current detail data in datamflap
									if (! dataMap['Detail_'+objFormName]) dataMap['Detail_'+objFormName] = {};
									dataMap['Detail_'+objFormName][currItemCode] = {
											'domID' : ''+ currDomIDVal,
											'item_code' : ''+currItemCode,
											'curr_stock' : ''+currStockData,
											'tagName' : 'curr_stock_qty'
									};
								}
								else if( action == 'itemchange' && fieldName == 'deselect' )
								{
									currStockData = parseInt(currStockData) + parseInt(quantity);//calculation of current stock from qty
									itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail"+objContext+" dbID='' domID='"+currDomIDVal+"' objContext='"+objContext+"'>";
									if(fieldName == 'deselect')
									{
										itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
									}
									else
									{
										itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
									}
									itemChangeStr +="<curr_stock_qty><![CDATA["+ currStockData  +"]]></curr_stock_qty></Detail"+objContext+"></Root>";
									//store current detail data in datamflap
									if (! dataMap['Detail_'+objFormName]) dataMap['Detail_'+objFormName] = {};
									dataMap['Detail_'+objFormName][currItemCode] = {
											'domID' : ''+ currDomIDVal,
											'item_code' : ''+currItemCode,
											'curr_stock' : ''+currStockData,
											'tagName' : 'curr_stock_qty'
									};
								}
							}
							else
							{
								alert("Enter quantity is greater than currenstock");
								if( prevValue === '')
								{
									quantity = '';
								}
								else
								{
									quantity = parseInt(prevValue);
								}
								itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors><Detail"+objContext+" dbID='' domID='"+currDomIDVal+"' objContext='"+objContext+"'>";
								if(fieldName == 'deselect')
								{
									itemChangeStr += "<selectbox><![CDATA[false]]></selectbox>" ;
								}
								else
								{
									itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
								}

								itemChangeStr +="<quantity><![CDATA["+ quantity  +"]]></quantity></Detail"+objContext+"></Root>";
							}
						}
					}
				}
				console.log( "realtime dataMap : ["+ dataMap +"]" );
			}
			//added by mrunalini sinkar for sample management realted changes in realtime report(end)
			//Added  by Bhagyashri T for Invoice subform[start]
			else if(objFormName=='invoice')
			{


				var selValue = "",item="",selSgstAmt ="",selCgstAmt ="",selValueTotal="";
				var selitemDescr="",selquantity="";
				var itemSize="",selRemarkDescr="",selRemark="";
				var currentStock="";
				var orgStock="";
				if ( action == "itemchange" )
				{
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					for (var i = 0; i < detailElement.length; i++)
					{
						var itemCode="",itemCode1="";
						var quantity = "";
						var rate = "";
						var value="";
						var itemDescr="";
						var taxAmount="";
						var remarks ="";
						var currentInvoiceStock ="",invoiceNoref="",maxInvoiceNo="",cashInvoiceAmnt="";
						var orgInvoiceStock ="";
						var detail = detailElement[i];
						var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
						var domIDVal = detail.getAttribute("domID");
						if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
						{
							itemCode1 = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
						}				
						if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
						{
							itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
						{
							rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
						{
							taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("remarks_inv")[0] != null && detail.getElementsByTagName("remarks_inv")[0].childNodes[0] != null )
						{
							remarks = detail.getElementsByTagName("remarks_inv")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
						{
							currentInvoiceStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
						{
							orgInvoiceStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("subform_invoice_no")[0] != null && detail.getElementsByTagName("subform_invoice_no")[0].childNodes[0] != null )
						{
							invoiceNoref = detail.getElementsByTagName("subform_invoice_no")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("max_invoice_id")[0] != null && detail.getElementsByTagName("max_invoice_id")[0].childNodes[0] != null )
						{
							maxInvoiceNo = detail.getElementsByTagName("max_invoice_id")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cash_invoice_amount")[0] != null && detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
						{
							cashInvoiceAmnt = detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
						}
						if(domIDVal == domId)
						{
							if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
							{
								itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								selquantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								selitemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_size")[0] != null && detail.getElementsByTagName("item_size")[0].childNodes[0] != null )
							{
								itemSize = detail.getElementsByTagName("item_size")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
							{
								currentStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
							{
								orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
							}

						}
						var routeRefNo="";
						if(invoiceNoref != 'undefined' && invoiceNoref != null)
						{
							if(invoiceNoref.indexOf("/")!=-1)
							{
								routeRefNo=invoiceNoref.split("/")[0];
							}
						}
						//console.log("currentInvoiceStock in invoice outside the same dom:: ["+ currentInvoiceStock +"], currentStock in invoice:: ["+ currentStock +"]");
						if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' )
						{
							if(domIDVal == domId)
							{
								item = itemDescr;
								selValue= (parseFloat(quantity) * parseFloat(rate));
								selValue = Number(Math.round(selValue+'e'+2)+'e-'+2);
								//console.log("Basic Amount inside invoice::=["+selValue+"]");
								selSgstAmt=(parseFloat(quantity) * parseFloat(rate) * (taxAmount/200));
								selSgstAmt = Number(Math.round(selSgstAmt+'e'+2)+'e-'+2);
								//console.log("SGST inside invoice::=["+selSgstAmt+"]");
								selCgstAmt = selSgstAmt;
								//console.log("CGST inside invoice::=["+selCgstAmt+"]");
								selValueTotal= (parseFloat(selValue) + parseFloat(selSgstAmt) + parseFloat(selCgstAmt));
								selValueTotal = Number(Math.round(selValueTotal+'e'+2)+'e-'+2);
								//console.log("Total Amount inside invoice::=["+selValueTotal+"]");

							}
						}

					}
					//console.log("Field name in invoice is:"+fieldName);
					//console.log("currentInvoiceStock in invoice:: ["+ currentInvoiceStock +"], currentStock in invoice:: ["+ currentStock +"]");
					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" ;
					var currentListDomId="";
					var currentListiteCode="";
					var currentListInvID="";
					var miInvoice="",maxInvoice="",invIdList="";
					var currentListbasicValue="",currentListgstValue="",currentListtotalValue="";
					var currentListinvoiceValue="",currentListrndOffValue="",currentListamtWordValue="";
					if(allFormDetaildataDom != 'undefined' && allFormDetaildataDom != null && allFormDetaildataDom != "")
					{
						totalBasicAmt = getTotalBasicAmt(allFormDetaildataDom, objContext);


						totalSGSTValue = getTotalSGSTValue(allFormDetaildataDom, objContext);



						totalCGSTValue=totalSGSTValue;
						totalGSTValue =(totalSGSTValue + totalCGSTValue);

						totalAmount = getTotalAmount(allFormDetaildataDom, objContext);

						//invoiceItem=InvoiceIDGenration(allFormDetaildataDom, objContext,invoiceNoref,maxInvoiceNo,cashInvoiceAmnt);

						console.log("invoiceItem when generate invoiceId:::::::::::["+invoiceItem+"]");

						var totalBasicAmtEl=document.getElementById("subheader_basic_value");
						if(totalBasicAmt != null && totalBasicAmtEl!=null)
						{
							totalBasicAmtEl.innerHTML="Basic:"+totalBasicAmt;
						}
						var totalGSTValueEl=document.getElementById("subheader_total_gst");
						if(totalGSTValue != null && totalGSTValueEl!=null)
						{
							totalGSTValueEl.innerHTML="GST:"+totalGSTValue;
						}
						var totalAmountEl=document.getElementById("subheader_total_value");
						if(totalAmount != null && totalAmountEl!=null)
						{
							totalAmountEl.innerHTML="Total Amount:"+totalAmount;
						}
						invoiceAmount= Number(Math.round(totalAmount));
						roundOff =(invoiceAmount-totalAmount);
						roundOff = Number(Math.round(roundOff+'e'+2)+'e-'+2);
						amountWrd= inWords(invoiceAmount);
                        /* comment by prachi start
						var listInvoiceData="",invoicedataList="",allDetailInvList="";
						if(invoiceItem.indexOf("#")!=-1)
						{
							listInvoiceData=invoiceItem.split("#");
							console.log("listInvoiceData when split primary stage:::::::::::["+listInvoiceData+"]")

							invoicedataList=listInvoiceData[0];
							miInvoice=listInvoiceData[1];
							maxInvoice=listInvoiceData[2];
							invIdList=listInvoiceData[3];
							allDetailInvList=listInvoiceData[4];

						}

						console.log("invoicedataList:::::::::::["+invoicedataList+"]");
						console.log("miInvoice:::::::::::["+miInvoice+"]");
						console.log("maxInvoice:::::::::::["+maxInvoice+"]");
						console.log("invIdList for all invoice Id:::::::::::["+invIdList+"]");
						console.log("allDetailInvList:::::::::::["+allDetailInvList+"]");

						invIdList=invIdList+",";

						var invoiceItemList=[];
						if(invoiceItem.indexOf(",")!=-1)
						{
							invoiceItemList=invoicedataList.split(",");

						}
						else
						{
							invoicedataList=invoicedataList+",";
							invoiceItemList=invoicedataList.split(",");

						}
						console.log("invoiceItemList:::::::::::["+invoiceItemList+"]");

						var allDetailInvData=[];
						if(allDetailInvList.indexOf(",")!=-1)
						{
							allDetailInvData=allDetailInvList.split(",");

						}
						else
						{
							allDetailInvList=allDetailInvList+",";
							allDetailInvData=allDetailInvList.split(",");

						}
						console.log("allDetailInvData:::::::::::["+allDetailInvData+"]")
						for(var q=0;q < invoiceItemList.length;q++)
						{

							var itemInList=invoiceItemList[q].split("@");
							console.log("listInvoiceData:::::::::::["+itemInList+"]");
							if(itemInList!=null && itemInList!="" )
							{
								var invoiceDomId=itemInList[0];
								var invoiceItem=itemInList[1];
								var invoiceID=itemInList[2];
								var detailsBasicValue="",detailsGstValue="",detaislTotalValue="";
								var detaitsInvoiceValue="",detailsRoundOff="",detailsAmtInWrd="";
								for(var r=0;r < allDetailInvData.length;r++)
								{
									var detailsIDList=allDetailInvData[r].split("@");
									console.log("detailsIDList:::::::::::["+detailsIDList+"]");
									var detailsInvId="";
									if(detailsIDList!=null && detailsIDList!="" )
									{
										detailsInvId=detailsIDList[0];

									}
									console.log("detailsIDList detailsInvId:::::::::::["+detailsInvId+"]");
									console.log("invoiceID detailsInvId:::::::::::["+invoiceID+"]");
									if(invoiceID == detailsInvId)
									{
										console.log("invoiceID detailsInvId are equal:::::::::::["+detailsIDList+"]");
										detailsBasicValue=detailsIDList[1];
										detailsGstValue=detailsIDList[2];
										detaislTotalValue=detailsIDList[3];
										detaitsInvoiceValue= Number(Math.round(detaislTotalValue));
										detailsRoundOff =(detaitsInvoiceValue-detaislTotalValue);
										detailsRoundOff = Number(Math.round(detailsRoundOff+'e'+2)+'e-'+2);
										detailsAmtInWrd= inWords(detaitsInvoiceValue);
										break;
									}
									console.log("invoiceID detailsInvId after break:::::::::::["+detailsInvId+"]");	
								}comment by prachi end for invoiceIDGeneration*/
								/*if(invoiceNoref != 'undefined' && invoiceNoref != null)
								{
									if(invoiceNoref.indexOf("/")!=-1)
									{
										var invoiceFormId=routeRefNo+"/"+invoiceID;
									}
									else
									{
									  var invoiceFormId=invoiceID;
									}
								}*/
								/* comment by prachi start for code dependent on InvoiceIDGenration
								var invoiceFormId=invoiceID;
								//var invoiceFormId=routeRefNo+"/"+invoiceID;
								console.log("invoiceFormId for all:::::::::::["+invoiceFormId+"]");

								var allDetailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
								for (var j = 0; j < allDetailElement.length; j++)
								{

									var allDetail = allDetailElement[j];
									var alldomIDVal = allDetail.getAttribute("domID");
									var allHsnNo="",allItemCode="",allCurrStock="",allOrgStock="",allItemDescr="",allquantity="",allRate="",allLineNo="",allPriceList="";
									var brokenQTY="",selectBox="",loadQuantity="";
									if( allDetail.getElementsByTagName("item_code")[0] != null && allDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
									{
										allItemCode = allDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("curr_stock")[0] != null && allDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
									{
										allCurrStock = allDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("org_stock")[0] != null && allDetail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
									{
										allOrgStock = allDetail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("item_descr")[0] != null && allDetail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
									{
										allItemDescr = allDetail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("quantity")[0] != null && allDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
									{
										allquantity = allDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("selectbox")[0] != null && allDetail.getElementsByTagName("selectbox")[0].childNodes[0] != null )
									{
										selectBox = allDetail.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
									}

									if(domId==invoiceDomId)
									{
										currentListDomId=invoiceDomId;
										currentListiteCode=invoiceItem;
										currentListInvID=invoiceFormId;
										currentListbasicValue=detailsBasicValue;
										currentListgstValue=detailsGstValue;
										currentListtotalValue=detaislTotalValue;
										currentListinvoiceValue=detaitsInvoiceValue;
										currentListrndOffValue=detailsRoundOff;
										currentListamtWordValue=detailsAmtInWrd;
									}
									if(invoiceDomId==alldomIDVal && invoiceItem==allItemCode && domId!=invoiceDomId)
									{

										itemChangeStr +="<Detail"+objContext+" dbID='' domID='"+invoiceDomId+"' objContext='"+objContext+"'>"+
												"<selectbox><![CDATA["+selectBox+"]]></selectbox>"+
												"<invoice_id><![CDATA["+invoiceFormId+"]]></invoice_id>" +
												"<item_code><![CDATA["+invoiceItem+"]]></item_code>" +
												"<item_descr><![CDATA["+allItemDescr+"]]></item_descr>" +
												"<quantity><![CDATA["+allquantity+"]]></quantity>" +
												"<org_stock><![CDATA["+allOrgStock+"]]></org_stock>" +
												"<curr_stock><![CDATA["+allCurrStock+"]]></curr_stock>" +
												"<inv_basic_value><![CDATA["+detailsBasicValue+"]]></inv_basic_value>" +
												"<inv_total_gst><![CDATA["+detailsGstValue+"]]></inv_total_gst>" +
												"<inv_total_value><![CDATA["+detaislTotalValue+"]]></inv_total_value>" +
												"<inv_invoice_value><![CDATA["+detaitsInvoiceValue+"]]></inv_invoice_value>" +
												"<inv_rndoff_value><![CDATA["+detailsRoundOff+"]]></inv_rndoff_value>" +
												"<inv_amtword_value><![CDATA["+detailsAmtInWrd+"]]></inv_amtword_value>" +
												"</Detail"+objContext+">" ;
										break;
									}
								}
							}//end of if

						}comment by prachi ended */

					}

					if(isNaN(selValue))
					{
						selValue = "";
					}
					if(isNaN(totalBasicAmt))
					{
						totalBasicAmt = "0";
					}
					if(isNaN(totalGSTValue))
					{
						totalGSTValue = "0";
					}
					if(isNaN(totalAmount))
					{
						totalAmount = "0";
					}
					if(isNaN(totalSGSTValue))
					{
						totalSGSTValue = "0";
					}
					if(isNaN(totalCGSTValue))
					{
						totalCGSTValue = "0";
					}
					if(isNaN(invoiceAmount))
					{
						invoiceAmount = "0";
					}

					if( fieldName == 'deselect')
					{
						itemChangeStr += "<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>"+
								"<selectbox><![CDATA[false]]></selectbox>"+
								"<quantity><![CDATA[]]></quantity>" +
								"<value><![CDATA[]]></value>" +
								"<curr_stock><![CDATA["+orgStock+"]]></curr_stock>" +
								"<org_stock><![CDATA["+orgStock+"]]></org_stock>" +
								"<item_descr><![CDATA["+selitemDescr+"]]></item_descr>" +
								//"<basic_value><![CDATA[Basic:"+totalBasicAmt+"]]></basic_value>" +
								//"<total_gst><![CDATA[GST:"+totalGSTValue+"]]></total_gst>" +
								//"<total_value><![CDATA["+totalAmount+"]]></total_value>" +
								"<Detail1.1.basic_value><![CDATA[Basic:"+totalBasicAmt+"]]></Detail1.1.basic_value>" +
								"<Detail1.1.total_gst><![CDATA[GST:"+totalGSTValue+"]]></Detail1.1.total_gst>" +
								"<Detail1.1.total_value><![CDATA[Total Amount:"+totalAmount+"]]></Detail1.1.total_value>" +
								"<total_amount><![CDATA["+selValueTotal+"]]></total_amount>" +
								"<total_sgst_amount><![CDATA[]]></total_sgst_amount>" +
								"<total_cgst_amount><![CDATA[]]></total_cgst_amount>" +
								"<invoice_id><![CDATA[]]></invoice_id>" +
								"<inv_basic_value><![CDATA[]]></inv_basic_value>" +
								"<inv_total_gst><![CDATA[]]></inv_total_gst>" +
								"<inv_total_value><![CDATA[]]></inv_total_value>" +
								"<inv_invoice_value><![CDATA[]]></inv_invoice_value>" +
								"<inv_rndoff_value><![CDATA[]]></inv_rndoff_value>" +
								"<inv_amtword_value><![CDATA[]]></inv_amtword_value>" +
								"<Detail1.1.net_amt><![CDATA["+totalBasicAmt+"]]></Detail1.1.net_amt>" +
								"<Detail1.1.tax_amount><![CDATA["+totalGSTValue+"]]></Detail1.1.tax_amount>" +
								"<Detail1.1.amount><![CDATA["+totalAmount+"]]></Detail1.1.amount>" +
								"<Detail1.1.invoice_amount><![CDATA["+invoiceAmount+"]]></Detail1.1.invoice_amount>" +
								"<Detail1.1.total_sgst_amt><![CDATA["+totalSGSTValue+"]]></Detail1.1.total_sgst_amt>" +
								"<Detail1.1.total_cgst_amt><![CDATA["+totalCGSTValue+"]]></Detail1.1.total_cgst_amt>" +
								"<Detail1.1.round_off><![CDATA["+roundOff+"]]></Detail1.1.round_off>" +
								/* comment by prachi code dependent on invoiceIdGen
								"<Detail1.1.minimum_invoice><![CDATA["+miInvoice+"]]></Detail1.1.minimum_invoice>" +
								"<Detail1.1.maximum_invoice><![CDATA["+maxInvoice+"]]></Detail1.1.maximum_invoice>" +
								"<Detail1.1.reference_no><![CDATA["+invIdList+"]]></Detail1.1.reference_no>" +
								*/
                                "</Detail"+objContext+">" ;

					}
					else
					{

						var orgCurrStock= orgStock - selquantity;
						//console.log("orgCurrStock stock invoice is:"+orgCurrStock);

						itemChangeStr += "<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>"+
								"<selectbox><![CDATA[true]]></selectbox>"+
								"<quantity><![CDATA["+selquantity+"]]></quantity>" +
								"<value><![CDATA["+selValue+"]]></value>" +
								"<curr_stock><![CDATA["+orgCurrStock+"]]></curr_stock>" +
								"<org_stock><![CDATA["+orgStock+"]]></org_stock>" +
								"<item_descr><![CDATA["+selitemDescr+"]]></item_descr>" +
								/* comment by prachi code dependent on invoiceIdGen
								"<invoice_id><![CDATA["+currentListInvID+"]]></invoice_id>" +
								"<inv_basic_value><![CDATA["+currentListbasicValue+"]]></inv_basic_value>" +
								"<inv_total_gst><![CDATA["+currentListgstValue+"]]></inv_total_gst>" +
								"<inv_total_value><![CDATA["+currentListtotalValue+"]]></inv_total_value>" +
								"<inv_invoice_value><![CDATA["+currentListinvoiceValue+"]]></inv_invoice_value>" +
								"<inv_rndoff_value><![CDATA["+currentListrndOffValue+"]]></inv_rndoff_value>" +
								"<inv_amtword_value><![CDATA["+currentListamtWordValue+"]]></inv_amtword_value>" +
								comment by prachi end code dependent on invoiceIdGen */
                                "<Detail1.1.basic_value><![CDATA[Basic:"+totalBasicAmt+"]]></Detail1.1.basic_value>" +
								"<Detail1.1.total_gst><![CDATA[GST:"+totalGSTValue+"]]></Detail1.1.total_gst>" +
								"<Detail1.1.total_value><![CDATA[Total Amount:"+totalAmount+"]]></Detail1.1.total_value>" +
								"<total_amount><![CDATA["+selValueTotal+"]]></total_amount>" +
								"<total_sgst_amount><![CDATA["+selSgstAmt+"]]></total_sgst_amount>" +
								"<total_cgst_amount><![CDATA["+selCgstAmt+"]]></total_cgst_amount>" +
								"<Detail1.1.net_amt><![CDATA["+totalBasicAmt+"]]></Detail1.1.net_amt>" +
								"<Detail1.1.tax_amount><![CDATA["+totalGSTValue+"]]></Detail1.1.tax_amount>" +
								"<Detail1.1.amount><![CDATA["+totalAmount+"]]></Detail1.1.amount>" +
								"<Detail1.1.invoice_amount><![CDATA["+invoiceAmount+"]]></Detail1.1.invoice_amount>" +
								"<Detail1.1.total_sgst_amt><![CDATA["+totalSGSTValue+"]]></Detail1.1.total_sgst_amt>" +
								"<Detail1.1.total_cgst_amt><![CDATA["+totalCGSTValue+"]]></Detail1.1.total_cgst_amt>" +
								"<Detail1.1.round_off><![CDATA["+roundOff+"]]></Detail1.1.round_off>" +
								"<Detail1.1.amount_in_word><![CDATA["+amountWrd+"]]></Detail1.1.amount_in_word>" +
								/* comment by prachi code dependent on invoiceIdGen
								"<Detail1.1.minimum_invoice><![CDATA["+miInvoice+"]]></Detail1.1.minimum_invoice>" +
								"<Detail1.1.maximum_invoice><![CDATA["+maxInvoice+"]]></Detail1.1.maximum_invoice>" +
								"<Detail1.1.reference_no><![CDATA["+invIdList+"]]></Detail1.1.reference_no>" +
								*/
                                "</Detail"+objContext+">" ;


					}
					itemChangeStr += "</Root>";

				}
				else if ( action == "break" )
				{
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					var itemChildDescr="",itemChildrate="",childItem="",childHsnNumber="",childPricelist="",currentStock="",orgStock="",itemCode="",parentItemDescr="",quantity="";
					var childPacakgeSize="",subItmChild="",subChildDescr="",subHSNNumber="",subChildRate="",subChildPriceList="",subPackSize="",taxAmount="",invoiceNoref="",maxInvoiceNo="",cashInvoiceAmnt="",stockBreak="";
					for (var i = 0; i < detailElement.length; i++)
					{

						var detail = detailElement[i];
						var domIDVal = detail.getAttribute("domID");

						if( detail.getElementsByTagName("itm_child_descr")[0] != null && detail.getElementsByTagName("itm_child_descr")[0].childNodes[0] != null )
						{
							itemChildDescr = detail.getElementsByTagName("itm_child_descr")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("itm_child")[0] != null && detail.getElementsByTagName("itm_child")[0].childNodes[0] != null )
						{
							childItem = detail.getElementsByTagName("itm_child")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("itm_child_rate")[0] != null && detail.getElementsByTagName("itm_child_rate")[0].childNodes[0] != null )
						{
							itemChildrate = detail.getElementsByTagName("itm_child_rate")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("child_hsn_number")[0] != null && detail.getElementsByTagName("child_hsn_number")[0].childNodes[0] != null )
						{
							childHsnNumber = detail.getElementsByTagName("child_hsn_number")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("child_price_list")[0] != null && detail.getElementsByTagName("child_price_list")[0].childNodes[0] != null )
						{
							childPricelist = detail.getElementsByTagName("child_price_list")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("pkg_size")[0] != null && detail.getElementsByTagName("pkg_size")[0].childNodes[0] != null )
						{
							pacakgeSize = detail.getElementsByTagName("pkg_size")[0].childNodes[0].nodeValue;

						}	
						if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
						{
							currentStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
						{
							orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
						{
							itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;

						}		
						if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
						{
							parentItemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
						{
							quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("child_pack_size")[0] != null && detail.getElementsByTagName("child_pack_size")[0].childNodes[0] != null )
						{
							childPacakgeSize = detail.getElementsByTagName("child_pack_size")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("sub_itm_child")[0] != null && detail.getElementsByTagName("sub_itm_child")[0].childNodes[0] != null )
						{
							subItmChild = detail.getElementsByTagName("sub_itm_child")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("sub_child_descr")[0] != null && detail.getElementsByTagName("sub_child_descr")[0].childNodes[0] != null )
						{
							subChildDescr = detail.getElementsByTagName("sub_child_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("sub_hsn_number")[0] != null && detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0] != null )
						{
							subHSNNumber = detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("sub_child_rate")[0] != null && detail.getElementsByTagName("sub_child_rate")[0].childNodes[0] != null )
						{
							subChildRate = detail.getElementsByTagName("sub_child_rate")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("sub_price_list")[0] != null && detail.getElementsByTagName("sub_price_list")[0].childNodes[0] != null )
						{
							subChildPriceList = detail.getElementsByTagName("sub_price_list")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("sub_pack_size")[0] != null && detail.getElementsByTagName("sub_pack_size")[0].childNodes[0] != null )
						{
							subPackSize = detail.getElementsByTagName("sub_pack_size")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
						{
							taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("subform_invoice_no")[0] != null && detail.getElementsByTagName("subform_invoice_no")[0].childNodes[0] != null )
						{
							invoiceNoref = detail.getElementsByTagName("subform_invoice_no")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("max_invoice_id")[0] != null && detail.getElementsByTagName("max_invoice_id")[0].childNodes[0] != null )
						{
							maxInvoiceNo = detail.getElementsByTagName("max_invoice_id")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cash_invoice_amount")[0] != null && detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
						{
							cashInvoiceAmnt = detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("stock_break")[0] != null && detail.getElementsByTagName("stock_break")[0].childNodes[0] != null )
						{
							stockBreak = detail.getElementsByTagName("stock_break")[0].childNodes[0].nodeValue;

						}

					}
					if(fieldName == 'itm_default_break')
					{

						if(childItem==null ||childItem.trim().length==0 ||currentStock=="0")
						{
							alert("You can't break this item");
							return itemChangeStr="";
						}
						if(stockBreak=="Y")
						{
							alert("Item was already break so you can't break this item again");
							return itemChangeStr="";

						}
						else
						{


							itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" ;


							var itemExistFlag=false;
							if(allFormDetaildataDom != 'undefined' && allFormDetaildataDom != null && allFormDetaildataDom != "")
							{
								var allDetailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
								for (var j = 0; j < allDetailElement.length; j++)
								{

									var allDetail = allDetailElement[j];
									var alldomIDVal = allDetail.getAttribute("domID");

									var allHsnNo="",allItemCode="",allCurrStock="",allOrgStock="",allItemDescr="",allquantity="",allRate="",allLineNo="",allPriceList="";
									var brokenQTY="",selectBox="",loadQuantity="";
									if( allDetail.getElementsByTagName("item_code")[0] != null && allDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
									{
										allItemCode = allDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("curr_stock")[0] != null && allDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
									{
										allCurrStock = allDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("org_stock")[0] != null && allDetail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
									{
										allOrgStock = allDetail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("item_descr")[0] != null && allDetail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
									{
										allItemDescr = allDetail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("quantity")[0] != null && allDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
									{
										allquantity = allDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("rate")[0] != null && allDetail.getElementsByTagName("rate")[0].childNodes[0] != null )
									{
										allRate = allDetail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("line_no")[0] != null && allDetail.getElementsByTagName("line_no")[0].childNodes[0] != null )
									{
										allLineNo = allDetail.getElementsByTagName("line_no")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("price_list")[0] != null && allDetail.getElementsByTagName("price_list")[0].childNodes[0] != null )
									{
										allPriceList = allDetail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("hsn_number")[0] != null && allDetail.getElementsByTagName("hsn_number")[0].childNodes[0] != null )
									{
										allHsnNo = allDetail.getElementsByTagName("hsn_number")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("broken_qty")[0] != null && allDetail.getElementsByTagName("broken_qty")[0].childNodes[0] != null )
									{
										brokenQTY = allDetail.getElementsByTagName("broken_qty")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("selectbox")[0] != null && allDetail.getElementsByTagName("selectbox")[0].childNodes[0] != null )
									{
										selectBox = allDetail.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
									}
									if( allDetail.getElementsByTagName("load_qty")[0] != null && allDetail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
									{
										loadQuantity = allDetail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
									}
									if(allItemCode==itemCode)
									{

										var parentStock=parseInt(currentStock)-1;
										var paraentOriginalSTock=parseInt(orgStock)-1;
										
										if(quantity== null || quantity.trim().length == 0)
										{
											quantity=0;
										}
			                    		
			                    		
										itemChangeStr += "<Detail"+objContext+" domID='" + domIDVal + "' formName='"+objFormName+"'>" +
												"<selectbox><![CDATA[true]]></selectbox>"+
												"<curr_stock><![CDATA["+stockValue+"]]></curr_stock>" +				  							
												"<item_descr><![CDATA["+parentItemDescr+"]]></item_descr>" +
												"<quantity><![CDATA["+quantity+"]]></quantity>" +
												"<curr_stock><![CDATA["+parentStock+"]]></curr_stock>" +
												"<org_stock><![CDATA["+paraentOriginalSTock+"]]></org_stock>" +
												"<stock_break><![CDATA[Y]]></stock_break>" +
												"<itm_child><![CDATA["+childItem+"]]></itm_child>"+
												"<itm_child_descr><![CDATA["+itemChildDescr+"]]></itm_child_descr>"+	
												"<child_hsn_number><![CDATA["+childHsnNumber+"]]></child_hsn_number>"+						                    				                    
												"<itm_child_rate><![CDATA["+itemChildrate+"]]></itm_child_rate>"+						                    				                    
												"<pkg_size><![CDATA["+pacakgeSize+"]]></pkg_size>"+ 	
												"</Detail"+objContext+">" ;

									}


									if(allItemCode == childItem)
									{
										itemExistFlag=true;

										var stockValue=parseInt(allCurrStock) + parseInt(pacakgeSize);
										var originalStockValue=parseInt(allOrgStock) + parseInt(pacakgeSize);
										if(brokenQTY== null || brokenQTY.trim().length == 0)
			                    		{
			                    			brokenQTY=0;
			                    		}
			                    		var brokeQuantity=parseInt(brokenQTY)+parseInt(pacakgeSize);
										selectBox="true";
										itemChangeStr += "<Detail"+objContext+" domID='" + alldomIDVal + "' formName='"+objFormName+"'>" +
												"<selectbox><![CDATA["+selectBox+"]]></selectbox>"+
												"<curr_stock><![CDATA["+stockValue+"]]></curr_stock>" +
												"<org_stock><![CDATA["+originalStockValue+"]]></org_stock>" +
												"<item_code><![CDATA["+allItemCode+"]]></item_code>"+
												"<item_descr><![CDATA["+allItemDescr+"]]></item_descr>" +
												"<rate><![CDATA["+allRate+"]]></rate>"+
												"<line_no><![CDATA["+allLineNo+"]]></line_no>"+
												"<price_list><![CDATA["+allPriceList+"]]></price_list>"+
												"<hsn_number><![CDATA["+allHsnNo+"]]></hsn_number>"+	
												"<break_item__ref><![CDATA["+itemCode+"]]></break_item__ref>"+	
												"<itm_child><![CDATA["+subItmChild+"]]></itm_child>"+
												"<itm_child_descr><![CDATA["+subChildDescr+"]]></itm_child_descr>"+	
												"<child_hsn_number><![CDATA["+subHSNNumber+"]]></child_hsn_number>"+						                    				                    
												"<itm_child_rate><![CDATA["+subChildRate+"]]></itm_child_rate>"+						                    				                    
												"<pkg_size><![CDATA["+childPacakgeSize+"]]></pkg_size>"+ 	
												"<quantity><![CDATA["+allquantity+"]]></quantity>" +
												"<sub_itm_child><![CDATA[]]></sub_itm_child>" +
												"<sub_child_descr><![CDATA[]]></sub_child_descr>" +
												"<sub_hsn_number><![CDATA[]]></sub_hsn_number>" +
												"<sub_child_rate><![CDATA[]]></sub_child_rate>" +
												"<broken_qty><![CDATA["+brokeQuantity+"]]></broken_qty>" +
												"<load_qty><![CDATA["+loadQuantity+"]]></load_qty>" +
												"<is_broken><![CDATA[Y]]></is_broken>" +
												"</Detail"+objContext+">" ;

									}
								}
							}//all form detail close




							if(itemExistFlag==false)
							{
								itemChangeStr +="<Detail"+objContext+" domID='"+domId+"' selected = 'N' formName='"+objFormName+"'>\r\n"+
										"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";
								itemChangeStr += "<selectbox><![CDATA[true]]></selectbox>";
								itemChangeStr += "<strg_code><![CDATA[]]></strg_code>"+
										"<quantity><![CDATA[]]></quantity>"+
										"<rate><![CDATA["+itemChildrate+"]]></rate>"+
										"<item_code><![CDATA["+childItem+"]]></item_code>"+
										"<item_descr><![CDATA["+itemChildDescr+"]]></item_descr>"+
										"<line_no><![CDATA["+domId+"]]></line_no>"+
										"<price_list><![CDATA["+childPricelist+"]]></price_list>"+
										"<curr_stock><![CDATA["+pacakgeSize+"]]></curr_stock>"+
										"<org_stock><![CDATA["+pacakgeSize+"]]></org_stock>" +
										"<hsn_number><![CDATA["+childHsnNumber+"]]></hsn_number>"+	
										"<break_item__ref><![CDATA["+itemCode+"]]></break_item__ref>"+	
										"<itm_child><![CDATA["+subItmChild+"]]></itm_child>"+
										"<itm_child_descr><![CDATA["+subChildDescr+"]]></itm_child_descr>"+	
										"<child_hsn_number><![CDATA["+subHSNNumber+"]]></child_hsn_number>"+						                    				                    
										"<itm_child_rate><![CDATA["+subChildRate+"]]></itm_child_rate>"+						                    				                    
										"<pkg_size><![CDATA["+childPacakgeSize+"]]></pkg_size>"+ 
										"<sub_itm_child><![CDATA[]]></sub_itm_child>" +
										"<sub_child_descr><![CDATA[]]></sub_child_descr>" +
										"<sub_hsn_number><![CDATA[]]></sub_hsn_number>" +
										"<sub_child_rate><![CDATA[]]></sub_child_rate>" +
										"<load_qty><![CDATA[0]]></load_qty>" +
										"<broken_qty><![CDATA["+pacakgeSize+"]]></broken_qty>" +
										"<tax_amt_inv><![CDATA["+taxAmount+"]]></tax_amt_inv>" +
										"<is_broken><![CDATA[Y]]></is_broken>" +
										"<subform_invoice_no><![CDATA["+invoiceNoref+"]]></subform_invoice_no>" +
										"<max_invoice_id><![CDATA["+maxInvoiceNo+"]]></max_invoice_id>" +
										"<cash_invoice_amount><![CDATA["+cashInvoiceAmnt+"]]></cash_invoice_amount>" +
										"</Detail"+objContext+">" ;
							}//item exist fals eclose

							itemChangeStr +="</Root>";


						}//else close child node exist

					}//itm_default break close


				}//action break close
				var isTBSUpdated = updateTableFormState(objContext, xmlDoc);
				//alert('28112022 isTBSUpdated:::',isTBSUpdated);
				console.log("itemChangeStr INVOICE =["+itemChangeStr+"]");
			}

			//Added by Bhagyashri T for Invoice subform[end]
		}
		console.log("itemChangeStr pk=["+itemChangeStr+"]");//prachi

		return itemChangeStr;
	}
	else if(objName ==='stocks_transfer_wiz')
	{

		console.log("inside stocktransferwiz localItemChange"+objFormName +"action::"+action + "buttonId:::"+buttonId + "fieldName:::"+fieldName);
		console.log("inside localItemChange"+objFormName);

		console.log("inside localItemChange allFormDetaildata "+allFormDetaildata);
		var currentFormData=currentFormData;
		var objcon=objContext;
		var allFormDetaildataDom = "";
		var checkitemchangeData = "";
		var itemChangeStr = "";
		var retString = "";
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			console.log("cureentform data is not null"+currentFormData);

			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}

		}
		else
		{
			console.log("null currentformdata");
		}
		if (window.DOMParser)
		{

			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");

					if(allFormDetaildata != null && allFormDetaildata.trim().length > 0)
					{
						var xmlVersionAll = allFormDetaildata.indexOf("<?xml version");
						console.log("xmlVersionAll is in localItemChange: "+xmlVersionAll)
						if(xmlVersionAll == 0)
						{

							allFormDetaildata = allFormDetaildata;
						}
						else
						{
							console.log("inside else");
							allFormDetaildata = "<Root>"+allFormDetaildata+"</Root>";

						}
						try
						{
							allFormDetaildataDom = parser.parseFromString(allFormDetaildata, "text/xml");
						}
						catch (e)
						{
							alert("XML parsing error.");
						}
					}
					else
					{
						console.log("nul currentformdata");
					}

				}

			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else 
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}

		if(xmlDoc != null )
		{
			console.log("Objformname in itemchange::"+objFormName);
			if(objFormName === 'stock')
			{
				if( fieldName === 'loc_code__fr' )
				{
					console.log("fieldValue loc_code__fr "+fieldValue)
					if( fieldValue == 'null' || fieldValue.trim().length == 0)
					{
						itemChangeStr = "<Detail1><loc_descr_fr protect = '1' visible = '1'></loc_descr_fr></Detail1>";
					}

				}
				else if( fieldName === 'loc_code__to' )
				{
					console.log("fieldValue loc_code__to "+fieldValue)
					if( fieldValue == 'null' || fieldValue.trim().length == 0)
					{
						itemChangeStr = "<Detail1><loc_descr_to protect = '1' visible = '1'></loc_descr_to></Detail1>";
					}
				}
				//var isDetailUpdate = updateTableFormState(objContext,xmlDoc);
				//console.log("isDetailUpdate::"+isDetailUpdate);
			}

			if(objFormName === 'item')
			{

				if( fieldName === 'quantity' || fieldName === 'select')
				{
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					var quantity="",qtPerart="";
					var loc_codeTo = "",loc_codeFR="",locCodeStockFR="",lotnoFr="",lotnoTo="",quant="",lotSLFr="",lotSLTo="",acctCodeCr="",cctrCodeCr="",acctCodeDr="",cctrCodeDr="";
					var itemDescr="",itemCode="", currStock="",qtyPerArt="0",lineNo="",lotList="",orgStock="";
					var qty=0,rpqty=0,noArt=0;
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						var domIDVal = detail.getAttribute("domID");

						console.log("domIDVal ["+ domIDVal +"], domId ["+ domId +"]");
						if(domIDVal == domId)
						{
							if( detail.getElementsByTagName("acct_code__cr")[0] != null && detail.getElementsByTagName("acct_code__cr")[0].childNodes[0] != null )
							{
								acctCodeCr = detail.getElementsByTagName("acct_code__cr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cctr_code__cr")[0] != null && detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0] != null )
							{
								cctrCodeCr = detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("acct_code__dr")[0] != null && detail.getElementsByTagName("acct_code__dr")[0].childNodes[0] != null )
							{
								acctCodeDr = detail.getElementsByTagName("acct_code__dr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cctr_code__dr")[0] != null && detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0] != null )
							{
								cctrCodeDr = detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
							{
								itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
							{
								currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
							{
								locCodeStockFR = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_no__fr")[0] != null && detail.getElementsByTagName("lot_no__fr")[0].childNodes[0] != null )
							{
								lotnoFr = detail.getElementsByTagName("lot_no__fr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_sl__fr")[0] != null && detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0] != null )
							{
								lotSLFr = detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
							{
								loc_codeTo = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_no__to")[0] != null && detail.getElementsByTagName("lot_no__to")[0].childNodes[0] != null )
							{
								lotnoTo = detail.getElementsByTagName("lot_no__to")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_sl__to")[0] != null && detail.getElementsByTagName("lot_sl__to")[0].childNodes[0] != null )
							{
								lotSLTo = detail.getElementsByTagName("lot_sl__to")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("qty_per_art")[0] != null && detail.getElementsByTagName("qty_per_art")[0].childNodes[0] != null )
							{
								qtPerart = detail.getElementsByTagName("qty_per_art")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("line_no")[0] != null && detail.getElementsByTagName("line_no")[0].childNodes[0] != null )
							{
								lineNo = detail.getElementsByTagName("line_no")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_data_list")[0] != null && detail.getElementsByTagName("lot_data_list")[0].childNodes[0] != null )
							{
								lotList = detail.getElementsByTagName("lot_data_list")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
							{
								orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
							}
							console.log("orgStock::"+orgStock);
							console.log("currStock::"+currStock);
							console.log("quantity:"+quantity+"qtPerart"+qtPerart);
							if( quantity != null && quantity.trim().length > 0 && qtPerart != null && qtPerart.trim().length > 0)
							{
								qty=parseInt(quantity);
								rpqty=parseInt(qtPerart)
										console.log("qty::"+qty+" rpqty:"+rpqty);
								var lc_modqty=qty % rpqty;
								console.log("lc_modqty::"+lc_modqty);
								if (lc_modqty > 0)
								{
									noArt = parseInt((qty /rpqty) + 1);
								}
								else
								{
									if (lc_modqty!="NaN")
									{
										noArt = parseInt(qty /rpqty) ;
									}  
								}
							}

							var currOrgStock="";
							if( quantity != null && quantity.trim().length > 0)
							{
								qty=parseInt(quantity);
								currOrgStock=orgStock-qty;
							}
							else
							{
								currOrgStock=orgStock;
							}

							console.log("currOrgStock::"+currOrgStock);




							console.log("noArt::"+noArt);
							itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" +
									"<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>"+
									"<selectbox><![CDATA[true]]></selectbox>"+
									"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
									"<item_code><![CDATA["+itemCode+"]]></item_code>\r\n"+
									"<curr_stock><![CDATA["+currOrgStock+"]]></curr_stock>\n"+
									"<org_stock><![CDATA["+orgStock+"]]></org_stock>\n"+
									"<quantity><![CDATA["+quantity+"]]></quantity>\r\n"+
									"<line_no><![CDATA["+domId+"]]></line_no>"+
									"<tran_id><![CDATA[]]></tran_id>\r\n"+
									"<loc_code__fr><![CDATA["+locCodeStockFR+"]]></loc_code__fr>\r\n"+
									"<loc_code__to><![CDATA["+loc_codeTo+"]]></loc_code__to>\r\n"+
									"<lot_no__fr><![CDATA["+lotnoFr+"]]></lot_no__fr>\r\n"+
									"<lot_sl__fr><![CDATA["+lotSLFr+"]]></lot_sl__fr>\r\n"+
									"<qty_per_art><![CDATA["+qtPerart+"]]></qty_per_art>\r\n"+
									"<acct_code__cr><![CDATA["+acctCodeCr+"]]></acct_code__cr>\r\n"+
									"<cctr_code__cr><![CDATA["+cctrCodeCr+"]]></cctr_code__cr>\r\n"+
									"<acct_code__dr><![CDATA["+acctCodeDr+"]]></acct_code__dr>\r\n"+
									"<cctr_code__dr><![CDATA["+cctrCodeDr+"]]></cctr_code__dr>\r\n"+
									"<lot_no__to><![CDATA["+lotnoTo+"]]></lot_no__to>\r\n"+
									"<lot_sl__to><![CDATA["+lotSLTo+"]]></lot_sl__to>\r\n"+ 
									"<no_art><![CDATA["+noArt+"]]></no_art>"+
									"<lot_data_list><![CDATA["+lotList+"]]></lot_data_list>"+
									"</Detail"+objContext+">" ;
						}	
					}
				}	
				if( fieldName == 'deselect')
				{
					console.log("deselect !!!!!!!!!!!!!!!!!!!!");
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					var quantity="",qtPerart="";
					var loc_codeTo = "",loc_codeFR="",locCodeStockFR="",lotnoFr="",lotnoTo="",quant="",lotSLFr="",lotSLTo="",acctCodeCr="",cctrCodeCr="",acctCodeDr="",cctrCodeDr="";
					var itemDescr="",itemCode="", currStock="",qtyPerArt="0",lineNo="",lotList="",orgStock="";
					var qty=0,rpqty=0,noArt=0;
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						var domIDVal = detail.getAttribute("domID");

						console.log("domIDVal ["+ domIDVal +"], domId ["+ domId +"]");
						if(domIDVal == domId)
						{
							if( detail.getElementsByTagName("acct_code__cr")[0] != null && detail.getElementsByTagName("acct_code__cr")[0].childNodes[0] != null )
							{
								acctCodeCr = detail.getElementsByTagName("acct_code__cr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cctr_code__cr")[0] != null && detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0] != null )
							{
								cctrCodeCr = detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("acct_code__dr")[0] != null && detail.getElementsByTagName("acct_code__dr")[0].childNodes[0] != null )
							{
								acctCodeDr = detail.getElementsByTagName("acct_code__dr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("cctr_code__dr")[0] != null && detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0] != null )
							{
								cctrCodeDr = detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
							{
								itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
							{
								currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
							{
								locCodeStockFR = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_no__fr")[0] != null && detail.getElementsByTagName("lot_no__fr")[0].childNodes[0] != null )
							{
								lotnoFr = detail.getElementsByTagName("lot_no__fr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_sl__fr")[0] != null && detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0] != null )
							{
								lotSLFr = detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
							{
								loc_codeTo = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_no__to")[0] != null && detail.getElementsByTagName("lot_no__to")[0].childNodes[0] != null )
							{
								lotnoTo = detail.getElementsByTagName("lot_no__to")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_sl__to")[0] != null && detail.getElementsByTagName("lot_sl__to")[0].childNodes[0] != null )
							{
								lotSLTo = detail.getElementsByTagName("lot_sl__to")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("qty_per_art")[0] != null && detail.getElementsByTagName("qty_per_art")[0].childNodes[0] != null )
							{
								qtPerart = detail.getElementsByTagName("qty_per_art")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("line_no")[0] != null && detail.getElementsByTagName("line_no")[0].childNodes[0] != null )
							{
								lineNo = detail.getElementsByTagName("line_no")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("lot_data_list")[0] != null && detail.getElementsByTagName("lot_data_list")[0].childNodes[0] != null )
							{
								lotList = detail.getElementsByTagName("lot_data_list")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
							{
								orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
							}
							console.log("orgStock::"+orgStock);
							console.log("currStock::"+currStock);
							console.log("quantity:"+quantity+"qtPerart"+qtPerart);
							if( quantity != null && quantity.trim().length > 0 && qtPerart != null && qtPerart.trim().length > 0)
							{
								qty=parseFloat(quantity);
								rpqty=parseInt(qtPerart)
										console.log("qty::"+qty+" rpqty:"+rpqty);
								var lc_modqty=qty % rpqty;
								console.log("lc_modqty::"+lc_modqty);
								if (lc_modqty > 0)
								{
									noArt = parseInt((qty /rpqty) + 1);
								}
								else
								{
									if (lc_modqty!="NaN")
									{
										noArt = parseInt(qty /rpqty) ;
									}  
								}
							}

							console.log("noArt::"+noArt);
							itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" +
									"<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>"+
									"<selectbox><![CDATA[false]]></selectbox>"+
									"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
									"<item_code><![CDATA["+itemCode+"]]></item_code>\r\n"+
									"<org_stock><![CDATA["+orgStock+"]]></org_stock>\n"+
									"<curr_stock><![CDATA["+orgStock+"]]></curr_stock>\n"+
									"<quantity><![CDATA["+""+"]]></quantity>\r\n"+
									"<line_no><![CDATA["+domId+"]]></line_no>"+
									"<tran_id><![CDATA[]]></tran_id>\r\n"+
									"<loc_code__fr><![CDATA["+locCodeStockFR+"]]></loc_code__fr>\r\n"+
									"<loc_code__to><![CDATA["+loc_codeTo+"]]></loc_code__to>\r\n"+
									"<lot_no__fr><![CDATA["+lotnoFr+"]]></lot_no__fr>\r\n"+
									"<lot_sl__fr><![CDATA["+lotSLFr+"]]></lot_sl__fr>\r\n"+
									"<qty_per_art><![CDATA["+qtPerart+"]]></qty_per_art>\r\n"+
									"<acct_code__cr><![CDATA["+acctCodeCr+"]]></acct_code__cr>\r\n"+
									"<cctr_code__cr><![CDATA["+cctrCodeCr+"]]></cctr_code__cr>\r\n"+
									"<acct_code__dr><![CDATA["+acctCodeDr+"]]></acct_code__dr>\r\n"+
									"<cctr_code__dr><![CDATA["+cctrCodeDr+"]]></cctr_code__dr>\r\n"+
									"<lot_no__to><![CDATA["+lotnoTo+"]]></lot_no__to>\r\n"+
									"<lot_sl__to><![CDATA["+lotSLTo+"]]></lot_sl__to>\r\n"+ 
									"<no_art><![CDATA["+noArt+"]]></no_art>"+
									"<lot_data_list><![CDATA["+lotList+"]]></lot_data_list>"+
									"</Detail"+objContext+">" ;
						}	
					}

				}//end deselect


			}

			console.log("Endof Xmldoc");
		}//end xmlDoc
		console.log("itemChangeStr for localItemchnage=["+itemChangeStr+"]");
		return itemChangeStr;
	}
	else if(objName ==='stocks_receive_wiz')
	{
		console.log("inside localItemChange allFormDetaildata stock receive"+allFormDetaildata);
		var currentFormData=currentFormData;
		var itemChangeStr = "";
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			console.log("cureentform data is not null"+currentFormData);

			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}

		}
		else
		{
			console.log("null currentformdata");
		}
		if (window.DOMParser)
		{

			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");

					if(allFormDetaildata != null && allFormDetaildata.trim().length > 0)
					{
						var xmlVersionAll = allFormDetaildata.indexOf("<?xml version");
						console.log("xmlVersionAll is in localItemChange: "+xmlVersionAll)
						if(xmlVersionAll == 0)
						{

							allFormDetaildata = allFormDetaildata;
						}
						else
						{
							console.log("inside else");
							allFormDetaildata = "<Root>"+allFormDetaildata+"</Root>";

						}
						try
						{
							allFormDetaildataDom = parser.parseFromString(allFormDetaildata, "text/xml");
						}
						catch (e)
						{
							alert("XML parsing error.");
						}
					}
					else
					{
						console.log("nul currentformdata");
					}

				}

			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else 
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}

		if(xmlDoc != null )
		{
			console.log("Objformname in itemchange::"+objFormName);
			if(objFormName === 'stock')
			{
				console.log("fieldvalue is ["+fieldValue+"]")

				var scanInput = fieldValue ; 
				console.log("scanInput is ["+scanInput+"]")

				var locationFrom ="", locationTo="",item="", itemDescr="",quantity="",invoiceFormNo="";
				var splitScannerData = "";


				if(scanInput.indexOf("~")!=-1)
				{
					splitScannerData=scanInput.split("~");

					locationFrom=splitScannerData[0];
					locationTo=splitScannerData[1];
					item=splitScannerData[2];
					quantity=splitScannerData[3];
					itemDescr=splitScannerData[4];
					invoiceFormNo=splitScannerData[5];

				}
				console.log("location from:::::::::::["+locationFrom+"]");
				console.log("location to::::::::["+locationTo+"]");
				console.log("item:::::::::::["+item+"]");
				console.log("item description::::::::::["+itemDescr+"]");
				console.log("quantity:::::::["+quantity+"]");
				console.log("invoiceFormNo is:::::::["+invoiceFormNo+"]");

				itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>" +
						"<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>"+
						"<scan_input><![CDATA[]]></scan_input>\r\n"+
						"<loc_code__fr><![CDATA["+locationFrom+"]]></loc_code__fr>\r\n"+
						"<loc_code__to><![CDATA["+locationTo+"]]></loc_code__to>\r\n"+
						"<item_code><![CDATA["+item+"]]></item_code>\r\n"+ 
						"<item_descr><![CDATA["+itemDescr+"]]></item_descr>"+
						"<quantity><![CDATA["+quantity+"]]></quantity>"+
						"<load_qty><![CDATA[]]></load_qty>"+
						"<invoice_form_no><![CDATA["+invoiceFormNo+"]]></invoice_form_no>"+
						"</Detail"+objContext+">" ;

			}

		}
		console.log("itemChangeStr for localItemchnage=["+itemChangeStr+"]");
		return itemChangeStr;
	}
}
var buttonLabel = '';
function localPreActionPerformed(buttonId, allFormResponseData)
{

	console.log("Inside localPreActionPerformed function having obj name is::["+allFormResponseData+"]");
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{

		teamFlg = true;
		orderFlg = true;
		brandFlg = true;
		displayFlg = true;
		surveyFlg = true;
		coachingFlg = true;
		invoiceFlg = true;
		collectionFlg = true;
		updateFlg == true;
		callOutCmGlobal ="";
	    addModeCallOutCm ="";
		editInvoiceFlg =true;
		editCollectFlg =true;
		billAmountGlobal = 0;

		console.log('inside localPreActionPerformed function in js file **************************'+buttonId);
		var action = buttonId;
		var allFormResponseData = allFormResponseData;

		console.log(action);

		const formatAMPM = (date) => {
			let hours = date.getHours();
			let minutes = date.getMinutes();
			let ampm = hours >= 12 ? 'pm' : 'am';
			hours = hours % 12;
			hours = hours ? hours : 12;
			minutes = minutes.toString().padStart(2, '0');
			let strTime = hours + ':' + minutes + ' ' + ampm;
			return strTime;
		}


		var PrintDate=localStorage.getItem( 'SYSTEM_DISP_DATE' );
		var printTime=formatAMPM(new Date());
		var printedOn=PrintDate+" / "+printTime;
		console.log("new printedOn["+printedOn+"]");
		

		// var isPrExist='N';
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(allFormResponseData != null && allFormResponseData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(allFormResponseData,"text/xml");
					console.log("xmlDoc =["+xmlDoc+"]");

				}

			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		if(xmlDoc != null)
		{

			var detailElement = xmlDoc.getElementsByTagName("Detail1");
			var referencenno="",invoiceNoref="";
			var referecneListArray=[];

			for (var i = 0; i < detailElement.length; i++)
			{
				var detail = detailElement[i];
				if( detail.getElementsByTagName("reference_no")[0] != null && detail.getElementsByTagName("reference_no")[0].childNodes[0] != null )
				{
					referencenno = detail.getElementsByTagName("reference_no")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("invoice_no")[0] != null && detail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
				{
					invoiceNoref = detail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
				}

			}
						console.log("Invoice reference no at before:;"+invoiceNoref);
			/*if(invoiceref!=null && invoiceref!="")
			{
				var invoicerefarry=invoiceref.split("/");
				invoiceref=invoicerefarry[0];
			}			
			console.log("Invoice reference no at first:;"+invoiceref);*/
			var invoiceref="";
			if(invoiceNoref.indexOf("/")!=-1)
			{
				invoiceref=invoiceNoref.split("/")[0];
			}
			console.log("Invoice reference no at invoiceref:;"+invoiceref);			
			if(referencenno!=null && referencenno!="")
			{
				referecneListArray=referencenno.split(",");
			}	


			if(action == 'C')
			{
				var isConfirm = buildError('','Do you want to confirm the report ?','W');
				return isConfirm;
			}
			else if(action == 'D')
			{
				var isDelete = buildError('','Do you want to delete the report ?','W');
				return isDelete;
			}
			else if(action == 'E')
			{
				var isEdit = buildError('','Do you want to Edit the report ?','W');
				return isEdit;
			}
			else if(action === 'P')
			{
				buttonLabel = 'Cust Copy';
				//document.getElementById("printed-on-time").innerHTML=printedOn;

				for(var q=0;q < referecneListArray.length;q++)
				{

					var invoiceID=referecneListArray[q];
					var wholeInvoice="";
					console.log("Invoice refernce id::"+invoiceref);
					if(invoiceref!=null && invoiceref!="")
					{
						wholeInvoice=invoiceref+"/"+invoiceID;
					}
					else
					{
						wholeInvoice=invoiceID;
					}
					//var wholeInvoice=invoiceref+"/"+invoiceID;
					var printID="print_label_"+wholeInvoice;
					var custCopyID="cust_copy_text_"+wholeInvoice;
					var suppCopyID="sup_copy_text_"+wholeInvoice;

					var printIdavilable = document.getElementById(printID);
					var custCopyIDavilable = document.getElementById(custCopyID);
					var suppCopyIDavilable = document.getElementById(suppCopyID);

					var printLabelavilable = document.getElementById("print-label");
					var custCopyTxtavilable = document.getElementById("cust_copy_text");
					var suppCopyTxtavilable = document.getElementById("sup_copy_text");

					var printeDateTime ="printed_on_"+wholeInvoice;
					var printDateTimeTxt = document.getElementById("printed-on");

					var printDate=document.getElementById(printeDateTime);
					
					if(printDateTimeTxt)
					{
						document.getElementById("printed-on").innerHTML=printedOn;
					}
					if(printDate)
					{
						document.getElementById(printeDateTime).innerHTML=printedOn;
					}
					if(printIdavilable)
					{
						document.getElementById(printID).style.display ='block';
					}
					if(custCopyIDavilable)
					{
						document.getElementById(custCopyID).style.display ='block';
					}
					if(suppCopyIDavilable)
					{
						document.getElementById(suppCopyID).style.display ='none';
					}
					if(printLabelavilable)
					{
						document.getElementById("print-label").style.display ='block';
					}
					if(custCopyTxtavilable)
					{
						document.getElementById("cust_copy_text").style.display ='block';
					}
					if(suppCopyTxtavilable)
					{
						document.getElementById("sup_copy_text").style.display ='none';
					}

				}
			}
			else if(action === 'O')
			{
				buttonLabel = 'Sup Copy';
				//document.getElementById("printed-on-time").innerHTML=printedOn;
				for(var q=0;q < referecneListArray.length;q++)
				{

					var invoiceID=referecneListArray[q];
					var wholeInvoice="";
					if(invoiceref!=null && invoiceref!="")
					{
						wholeInvoice=invoiceref+"/"+invoiceID;
					}
					else
					{
						wholeInvoice=invoiceID;
					}

					//var wholeInvoice=invoiceref+"/"+invoiceID;
					var printID="print_label_"+wholeInvoice;
					var custCopyID="cust_copy_text_"+wholeInvoice;
					var suppCopyID="sup_copy_text_"+wholeInvoice;

					var printIdavilable = document.getElementById(printID);
					var custCopyIDavilable = document.getElementById(custCopyID);
					var suppCopyIDavilable = document.getElementById(suppCopyID);

					var printLabelavilable = document.getElementById("print-label");
					var custCopyTxtavilable = document.getElementById("cust_copy_text");
					var suppCopyTxtavilable = document.getElementById("sup_copy_text");

					var printeDateTime ="printed_on_"+wholeInvoice;
					var printDateTimeTxt = document.getElementById("printed-on");

					var printDate=document.getElementById(printeDateTime);
					
					if(printDateTimeTxt)
					{
						document.getElementById("printed-on").innerHTML=printedOn;
					}
					if(printDate)
					{
						document.getElementById(printeDateTime).innerHTML=printedOn;
					}
					if(printIdavilable)
					{
						document.getElementById(printID).style.display ='block';
					}
					if(custCopyIDavilable)
					{
						document.getElementById(custCopyID).style.display ='none';
					}
					if(suppCopyIDavilable)
					{
						document.getElementById(suppCopyID).style.display ='block';
					}
					if(printLabelavilable)
					{
						document.getElementById("print-label").style.display ='block';

					}
					if(custCopyTxtavilable)
					{
						document.getElementById("cust_copy_text").style.display ='none';

					}
					if(suppCopyTxtavilable)
					{
						document.getElementById("sup_copy_text").style.display ='block';
					}

				}


			}
			else
			{

				for(var q=0;q < referecneListArray.length;q++)
				{

					var invoiceID=referecneListArray[q];
					console.log("Inside else");
					var wholeInvoice="";
					if(invoiceref!=null && invoiceref!="")
					{
						wholeInvoice=invoiceref+"/"+invoiceID;
					}
					else
					{
						wholeInvoice=invoiceID;
					}
					//var wholeInvoice=invoiceref+"/"+invoiceID;
					var printID="print_label_"+wholeInvoice;
					var custCopyID="cust_copy_text_"+wholeInvoice;
					var suppCopyID="sup_copy_text_"+wholeInvoice;

					var printIdavilable = document.getElementById(printID);
					var custCopyIDavilable = document.getElementById(custCopyID);
					var suppCopyIDavilable = document.getElementById(suppCopyID);

					var printLabelavilable = document.getElementById("print-label");
					var custCopyTxtavilable = document.getElementById("cust_copy_text");
					var suppCopyTxtavilable = document.getElementById("sup_copy_text");

					if(printIdavilable)
					{
						document.getElementById(printID).style.display ='none';
					}
					if(custCopyIDavilable)
					{
						document.getElementById(custCopyID).style.display ='none';
					}
					if(suppCopyIDavilable)
					{
						document.getElementById(suppCopyID).style.display ='none';
					}
					if(printLabelavilable)
					{
						document.getElementById("print-label").style.display ='none';

					}
					if(custCopyTxtavilable)
					{
						document.getElementById("cust_copy_text").style.display ='none';

					}
					if(suppCopyTxtavilable)
					{
						document.getElementById("sup_copy_text").style.display ='none';
					}

				}

			}

		}

		if (action == 'P')
		{
			let recvdBy = '<received_by><![CDATA[Customer Copy]]></received_by>';
			updatePrintLog(xmlDoc, allFormResponseData, 'CUST_COPY_LOG.json', recvdBy);

		}

		if (action == 'O')
		{
			let recvdBy = '<received_by><![CDATA[Supplier Copy]]></received_by>';
			updatePrintLog(xmlDoc, allFormResponseData, 'SUP_COPY_LOG.json', recvdBy);
		}

		return "true";


	}
	else
	{

	}

}

function updatePrintLog(xmlDoc, allFormResponseData, dataModelFileName, recvdBy) 
{
	var userId = localStorage.getItem('userName');
	console.log("user id: ",userId);
	var onSuccess = function(result)
	{
		console.log('result on success of data model :::', result);
		var dmList = localStorage.getItem('PRINT_DM_LIST');
		if(dmList != null && dmList.indexOf(dataModelFileName) == -1)
		{
			dmList = dmList + ',' + dataModelFileName;
		}
		else
		{
			dmList = dataModelFileName;
		}
		localStorage.setItem('PRINT_DM_LIST',dmList);
		var detailElement = xmlDoc.getElementsByTagName("Detail1");
		for (var i = 0; i < detailElement.length; i++)
		{
			var detail = detailElement[i];
			if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
			{
				strgCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
				console.log('strgcode is:',strgCode);
			}
			if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
			{
				eventDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
				console.log('eventDate is:',eventDate);
			}
		}
		
		const dataModelJSONObj = JSON.parse(result);
		console.log("dataModelJSONObj:: ",dataModelJSONObj);

		var dataModelJSONArray = dataModelJSONObj.DETAILS
		
		for(var i = 0; i < dataModelJSONArray.length; i++)
		{
			const jsonObj = dataModelJSONArray[i];
			
			var customerID = jsonObj.Customer_Id != undefined ? jsonObj.Customer_Id : '';
			
			if(customerID == strgCode)
			{
				let onPrintFailure = function(printErr)
				{
					console.log('Failure in getPrintData printErr:::', printErr);
				}

				let onPrintSuccess = function(printSuccess)
				{
					console.log('Success in getPrintData printSuccess:::', printSuccess);	
					if(jsonObj.Is_Printed == 'Y' && jsonObj.Event_Date == eventDate)
					{
						console.log("Inside if condition when printed second time");
						// var addDuplicateWaterMark = document.getElementById('water-mark-icon');
						// addDuplicateWaterMark.setAttribute('style','display:block;');
					}
					else
					{
						console.log("Inside if condition to update datamodel");
						jsonObj.Is_Printed = "Y";
						jsonObj.Event_Date = eventDate;
						var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/'+dataModelFileName; 	
						var updatedDataModel = JSON.stringify(dataModelJSONObj);
						backUpAndWriteFile(filePath, updatedDataModel);//This will update the datamodel's data
						// var addDuplicateWaterMark = document.getElementById('water-mark-icon');
						// addDuplicateWaterMark.setAttribute('style','display:none;');
					}
					
				}
				let printedTag = '<is_printed><![CDATA['+ (jsonObj.Is_Printed == 'Y' ? 'true' : 'false') +']]></is_printed>';
				let splitArr = allFormResponseData.split('</Detail1>');
				splitArr[1] = '</Detail1>'+splitArr[1];
				allFormResponseData = splitArr[0] + printedTag + recvdBy + splitArr[1];
				let formattedXML = allFormResponseData.replaceAll('"',"'");
				window.plugins.printDocument.getPrintData(onPrintSuccess, onPrintFailure, formattedXML);
			}
		}	
	}
	
	var onFail = function(error)
	{
	console.log('error :::', error);
	}

	var getDataModelData = readFile('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/'+dataModelFileName,onSuccess,onFail);

}

//This method will be called on summary form load
function onPageLoad(buttonPnlId, allFormResponseString)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		
		teamFlg = true;
		orderFlg = true;
		brandFlg = true;
		displayFlg = true;
		surveyFlg = true;
		coachingFlg = true;
		invoiceFlg = true;
		collectionFlg = true;
		updateFlg == true;
		callOutCmGlobal ="";
	    addModeCallOutCm ="";
		editInvoiceFlg =true;
		editCollectFlg =true;
		billAmountGlobal = 0;
		try
		{
			console.log('inside checkSummaryActions onPageLoad function in js file **************************'+buttonPnlId);
			var action = buttonPnlId;
			var allFormResponseString = allFormResponseString;
			console.log("Inside checkSummaryAction JS ["+action+"]");
			console.log("Inside checkSummaryAction JS allFormResponseString ["+allFormResponseString+"]");
			if( action == null || action == 'undefined' || action.trim() == '' )
			{
				alert("Action Title in Js is Null");
			}
			else
			{

				if (window.DOMParser)
				{
					parser=new DOMParser();
					try
					{
						if(allFormResponseString != null && allFormResponseString.trim().length > 0)
						{
							xmlDoc = parser.parseFromString(allFormResponseString,"text/xml");
						}

					}
					catch(ex)
					{
						alert("Exception occurs while parsing xml data");
					}
				}
				else // Internet Explorer
				{
					xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
					xmlDoc.async=false;
					xmlDoc.loadXML(txt);
				}
				if(xmlDoc != null)
				{
					var isPrExist="";
					var detailElement = xmlDoc.getElementsByTagName("Detail1");
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("is_pr_exist")[0] != null && detail.getElementsByTagName("is_pr_exist")[0].childNodes[0] != null )
						{
							isPrExist = detail.getElementsByTagName("is_pr_exist")[0].childNodes[0].nodeValue;
							console.log("isPrExist =["+isPrExist+"]");

						}
					}

					if( isPrExist != 'undefined' && isPrExist != null && isPrExist != 'null' && isPrExist != "" )
					{

						var currentElem = document.getElementById('summary_Prescription Report');
						console.log("currentElem =["+currentElem+"]");

						if(isPrExist == 'N')
						{
							currentElem.src = _getHostURL() + '/ibase/webitm/images/Summary/summary_Prescription Report_Red.png';
						}
						else
						{
							currentElem.src = _getHostURL() + '/ibase/webitm/images/Summary/summary_Prescription Report_Green.png';

						}
					}
				}
			}

		}
		catch (e)
		{
			console.log("Exception in onPageLoad Js [" +e+"]");
		}


		return "true";
	}
	else
	{

	}

}

function disableBtn(actionTitle)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var id = actionTitle;

		if(document.getElementById(id) != null)
		{
			alert("ID is not Null");
			document.getElementById(id).disabled = true;
		}
		else
		{
			alert("ID is Null");
		}
	}
	else
	{

	}
}

function enableBtn(actionTitle) 
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var id = actionTitle;
		document.getElementById(id).disabled = false;
	}
	else
	{

	}

}

function visibleBtn(actionTitle) 
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var id = actionTitle;
		document.getElementById(id).style.visibility='visible';
	}
	else
	{

	}
	
}

function inVisibleBtn(actionTitle)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var id = actionTitle;
		document.getElementById(id).style.visibility='hidden';
	}
	else
	{

	}
}
function buildError(message,description,type)
{
	var msgStr = "";

	msgStr = "<Errors>"
			+ "<error id=\"PRJNOT\" type=\"W\" column_name=\"\">"
			+ "<message><![CDATA["+message+"]]></message>"
			+ "<description><![CDATA["+description+"]]></description>"
			+ "<type><![CDATA[]]></type>"
			+ "<option><![CDATA[]]></option>"
			+ "<time><![CDATA[]]></time>"
			+ "<alarm><![CDATA[]]></alarm>"
			+ "<source><![CDATA[]]></source>"
			+ "<trace><![CDATA[]]></trace>"
			+ "<redirect><![CDATA[]]></redirect>"
			+ "</error>"
			+ "</Errors>";

	return msgStr;
}
//Added by Pankaj R on 25-Sept-17 to hide the field or column which does not have any value in that field on itemchange
function localPostItemChange( objContext, action, objName, currentFormData, fieldName, domId, objFormName, fieldValue , parentFormNo , parentFormDomId ,nextBtnID, prevBtnID, finishBtnID, addBtnID)
{
	globalObjName = objName;
	console.log("Inside localPostItemChange function having obj name is::["+objName+"]");
	if( objName ==='strg_meet_dcr_realtime_wiz')
	{
		//alert("inside post itemchange:"+currentFormData);
		console.log("Inside localPostItemChange function having obj name is strg_meet_dcr_realtime_wiz");
		console.log("inside post itemchange:"+currentFormData);
		var currentFormData=currentFormData;
		var objcon=objContext;
		var checkitemchangeData = "";
		var itemChangeStr = "";
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			console.log("currentform data is not null in localPostItemChange");

			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata localPostItemChange");
		}
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
					console.log("localPostItemChange xmlDoc =["+currentFormData+"]");
				}
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data localPostItemChange");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		//var totalPOBValue = 0;
		if(xmlDoc != null )
		{
			if(objContext == 1)
			{
				if( fieldName === 'event_type')
				{
					var activityType="";
					var eventType="";
					var activityDescr="";
					var placeRequired="";
					var activityPlace=""; //added by Bhagyashri T for actvity place[28/JUL/21]


					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
						{
							activityType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
							console.log("activity type is:"+activityType);
						}
						if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
						{
							eventType = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
							console.log("eventType type is:"+eventType);
						}
						if( detail.getElementsByTagName("activity_descr")[0] != null && detail.getElementsByTagName("activity_descr")[0].childNodes[0] != null )
						{
							activityDescr = detail.getElementsByTagName("activity_descr")[0].childNodes[0].nodeValue;
							console.log("activityDescr type is:"+activityDescr);
						}
						//added by mrunalini sinkar on 09-sep-2018 for place required changes (start)
						if( detail.getElementsByTagName("place_required")[0] != null && detail.getElementsByTagName("place_required")[0].childNodes[0] != null )
						{
							placeRequired = detail.getElementsByTagName("place_required")[0].childNodes[0].nodeValue;
							console.log("placeRequired type is:"+placeRequired);
						}
						//added by mrunalini sinkar on 09-sep-2018 for place required changes (end)
						//added by Bhagyashri T for actvity place[28/JUL/21] (start)
						if( detail.getElementsByTagName("activity_place")[0] != null && detail.getElementsByTagName("activity_place")[0].childNodes[0] != null )
						{
							activityPlace = detail.getElementsByTagName("activity_place")[0].childNodes[0].nodeValue;
							console.log("activityPlace type isPI:"+activityPlace);
						}
						//added by Bhagyashri T for actvity place[28/JUL/21] (end)

					}
					// added by mrunalini sinkar for offline 16-feb-2018 (start)
					//if( activityType == 'NFW' ||  activityType == 'LEAVE') //Added & commented by mrunalini sinkar for NFW activity type not found(13-02-2019)
					//Added by Prasad on 19/12/19 [coaching related implementation]
					//if( activityType != 'FW')
					if( activityType != 'FW' || eventType  == 'CA' )
					{
						//commented by mrunalini Sinkar on 11-june-2018(start)
						/*itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,display,team,coaching,survey\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'></cust_type>" +
						"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr><event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'></meet_summ><stockist_code protect = '1' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" +
						"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
						"</Detail1>";*/
						//commented by mrunalini Sinkar on 11-june-2018(end)
						//added  by mrunalini Sinkar to set ---NA-- in case leave on 11-june-2018(start)
						///added by mrunalini sinkar to visible on localitycode in case of nfw 26-june-2018(START)
						// Changes by mrunalini sinkar on 09-sep-2018 for place required changes (start)
						/*if(activityType == 'NFW' )
						{
						itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,display,team,coaching,survey\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'></cust_type>" +
						"<locality_code protect = '0' visible = '0'></locality_code><locality_descr protect = '0' visible = '1'></locality_descr><event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_code protect = '1' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" +
						"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
						"</Detail1>";
						}*/
						if(placeRequired == 'Y' )
						{
							//Added by Prasad on 19/12/19 [coaching related implementation] START
							if( eventType  == 'CA' )
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'></cust_type>" +
										"<locality_code protect = '0' visible = '0'></locality_code><locality_descr protect = '0' visible = '1'></locality_descr>" +
										//"<event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end>" +
										"<visited_with protect = '0' visible = '1'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_code protect = '1' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>";
								//added by Hariom S for fortune [18/05/2021]
								if( isFortuneActivity  == 'Y')
								{
									if( allowVisitTime  == 'Y')
									{

										itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'N')
									{									
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B')
									{
										itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else
									{
										itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}															
								}
								//added by Hariom S for fortune [18/05/2021]
								itemChangeStr +="</Detail1>";
							}
							else
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' visibleSubform ='YES'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'></cust_type>" +
										"<locality_code protect = '0' visible = '0'></locality_code><locality_descr protect = '0' visible = '1'></locality_descr>" +
										//"<event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end>" +
										"<visited_with protect = '0' visible = '1'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_code protect = '1' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>";
								//added by Hariom S for fortune [18/05/2021]
								if( isFortuneActivity  == 'Y')
								{
									if( allowVisitTime  == 'Y')
									{

										itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'N')
									{

										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B')
									{
										itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else
									{
										itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}															
								}
								//added by Hariom S for fortune [18/05/2021]
								itemChangeStr +="</Detail1>";
							}
							//Added by Prasad on 19/12/19 [coaching related implementation] END
						}
						// Changes by mrunalini sinkar on 09-sep-2018 for place required changes (end)
						else
						{
							//Added by Prasad on 19/12/19 [coaching related implementation] START
							if( eventType  == 'CA' )
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,survey\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'></cust_type>" +
										"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr>" +
										//"<event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end>" +
										"<visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_code protect = '1' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><address_as protect = '1' visible = '0'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
										"</Detail1>";
							}
							else
							{
								itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching,survey\' visibleSubform ='YES'><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'></cust_type>" +
										"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr>" +
										//"<event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end>" +
										"<visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ><stockist_code protect = '1' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" +
										"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><age protect = '1' visible = '0'></age><qualification protect = '1' visible = '0'></qualification><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" ;
								//added by Hariom S for fortune [18/05/2021]
								if( isFortuneActivity  == 'Y')
								{
									if( allowVisitTime  == 'Y')
									{

										itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'N')
									{

										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B')
									{
										itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else
									{
										itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}															
								}
								//added by Hariom S for fortune [18/05/2021]
								itemChangeStr +="</Detail1>";
							}
							//Added by Prasad on 19/12/19 [coaching related implementation] END
						}
						//added by mrunalini sinkar to visible on localitycode in case of nfw 26-june-2018(end)
					}
					else
					{
						itemChangeStr = "<Detail1 domID='1' protectSubform=\'\'><activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr><event_type protect = '0'><![CDATA["+eventType+"]]></event_type><activity_type><![CDATA["+activityType+"]]></activity_type><strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '1' visible = '1'></address_as>" +
								"<place_required protect = '0' visible = '0'><![CDATA["+placeRequired+"]]></place_required><gender protect='0' visible = '0'><![CDATA[M]]></gender><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust><locality_code protect = '0' visible = '1'></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
								"<addr3 protect = '0' visible = '0'></addr3><age protect = '0' visible = '0'></age><qualification protect = '0' visible = '0'></qualification><spl_code protect = '0' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><remarks protect = '0' visible = '1'></remarks><strg_class_code protect = '0' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><visited_with protect = '0' visible = '1'></visited_with>" +
								"<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code><locality_descr protect = '1' visible = '1'></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr>" +
								//"<event_time_start visible = '1'></event_time_start><event_time_end visible = '1'></event_time_end>" +
								"<copy_plan protect='1' visible = '1'><![CDATA[N]]></copy_plan><oth_participant protect = '0' visible = '1'></oth_participant>"
								if( isFortuneActivity  == 'Y')
								{
									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'N')
									{							
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B')
									{
										itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else
									{
										itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}															
								}

						itemChangeStr +="</Detail1>";
					}
				}
				else if( fieldName === 'default_data')
				{
					var activityType="";
					var eventType="";
					var activityDescr="";
					var subformProtect="";
					var placeRequired="";
					var customrType="", addressAs = "",gender = "",addr1 = "",addr2 = "",addr3 = "";
					var emailAddr="", mobileNo = "",strgClassCode = "",classCodeDescr = "",splCode = "",specialityDescr = "";
					var promoterName="", manPower = "",imageId = "",gstNo = "",subclassCode = "",pin = "",subclassDescr = "",ismemberPresent="";
					var time = getStartTime();
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					var isFortuneActivity="";
					var allowVisitTime="";
					var age="",qualification="";
					var activityPlace="";  //added by Bhagyashri T on[27/Jul/21]
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						// added by rupali on 23/02/18 for edit mode of realtime report [start]
						updateFlagVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
						console.log("updateFlagVal is"+updateFlagVal);
						// added by rupali on 23/02/18 for edit mode of realtime report [end]
						if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
						{
							activityType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
							console.log("activity type is:"+activityType);
						}
						if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
						{
							eventType = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
							console.log("eventType type is:"+eventType);
						}
						if( detail.getElementsByTagName("activity_descr")[0] != null && detail.getElementsByTagName("activity_descr")[0].childNodes[0] != null )
						{
							activityDescr = detail.getElementsByTagName("activity_descr")[0].childNodes[0].nodeValue;
							console.log("activityDescr type is:"+activityDescr);
						}
						// added by rupali on 23/02/18 for edit mode of realtime report [start]
						if( detail.getElementsByTagName("call_outcome")[0] != null && detail.getElementsByTagName("call_outcome")[0].childNodes[0] != null )
						{
							callOutcome = detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
							console.log("callOutcome is::::::::::::"+callOutcome);
						}
						// added by rupali on 23/02/18 for edit mode of realtime report [end]
						// added by Mrunalini for edit mode of realtime report [end]
						if( detail.getElementsByTagName("subform_protect")[0] != null && detail.getElementsByTagName("subform_protect")[0].childNodes[0] != null )
						{
							subformProtect = detail.getElementsByTagName("subform_protect")[0].childNodes[0].nodeValue;
							console.log("subformProtect is:"+subformProtect);
						}
						// added by Mrunalini for edit mode of realtime report [end]
						//added by mrunalini sinkar on 09-sep-2018 for place required changes (start)
						if( detail.getElementsByTagName("place_required")[0] != null && detail.getElementsByTagName("place_required")[0].childNodes[0] != null )
						{
							placeRequired = detail.getElementsByTagName("place_required")[0].childNodes[0].nodeValue;
							console.log("placeRequired type is:"+placeRequired);
						}
						//added by mrunalini sinkar on 09-sep-2018 for place required changes (end)
						if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
						{
							customrType = detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
							console.log("customrType is:"+customrType);
						}
						if( detail.getElementsByTagName("address_as")[0] != null && detail.getElementsByTagName("address_as")[0].childNodes[0] != null )
						{
							addressAs = detail.getElementsByTagName("address_as")[0].childNodes[0].nodeValue;
							console.log("addressAs is:"+addressAs);
						}
						if( detail.getElementsByTagName("gender")[0] != null && detail.getElementsByTagName("gender")[0].childNodes[0] != null )
						{
							gender = detail.getElementsByTagName("gender")[0].childNodes[0].nodeValue;
							console.log("gender is:"+gender);
						}
						if( detail.getElementsByTagName("addr1")[0] != null && detail.getElementsByTagName("addr1")[0].childNodes[0] != null )
						{
							addr1 = detail.getElementsByTagName("addr1")[0].childNodes[0].nodeValue;
							console.log("addr1 is:"+addr1);
						}
						if( detail.getElementsByTagName("addr2")[0] != null && detail.getElementsByTagName("addr2")[0].childNodes[0] != null )
						{
							addr2 = detail.getElementsByTagName("addr2")[0].childNodes[0].nodeValue;
							console.log("addr2 is:"+addr2);
						}
						if( detail.getElementsByTagName("addr3")[0] != null && detail.getElementsByTagName("addr3")[0].childNodes[0] != null )
						{
							addr3 = detail.getElementsByTagName("addr3")[0].childNodes[0].nodeValue;
							console.log("addr3 is:"+addr3);
						}
						if( detail.getElementsByTagName("age")[0] != null && detail.getElementsByTagName("age")[0].childNodes[0] != null )
						{
							age = detail.getElementsByTagName("age")[0].childNodes[0].nodeValue;
							console.log("age is:"+age);
						}
						if( detail.getElementsByTagName("qualification")[0] != null && detail.getElementsByTagName("qualification")[0].childNodes[0] != null )
						{
							qualification = detail.getElementsByTagName("qualification")[0].childNodes[0].nodeValue;
							console.log("qualification is:"+qualification);
						}
						if( detail.getElementsByTagName("email_addr")[0] != null && detail.getElementsByTagName("email_addr")[0].childNodes[0] != null )
						{
							emailAddr = detail.getElementsByTagName("email_addr")[0].childNodes[0].nodeValue;
							console.log("emailAddr is:"+emailAddr);
						}
						if( detail.getElementsByTagName("mobile_no")[0] != null && detail.getElementsByTagName("mobile_no")[0].childNodes[0] != null )
						{
							mobileNo = detail.getElementsByTagName("mobile_no")[0].childNodes[0].nodeValue;
							console.log("mobileNo is:"+mobileNo);
						}
						if( detail.getElementsByTagName("strg_class_code")[0] != null && detail.getElementsByTagName("strg_class_code")[0].childNodes[0] != null )
						{
							strgClassCode = detail.getElementsByTagName("strg_class_code")[0].childNodes[0].nodeValue;
							console.log("strgClassCode is:"+strgClassCode);
						}
						if( detail.getElementsByTagName("class_code_descr")[0] != null && detail.getElementsByTagName("class_code_descr")[0].childNodes[0] != null )
						{
							classCodeDescr = detail.getElementsByTagName("class_code_descr")[0].childNodes[0].nodeValue;
							console.log("classCodeDescr is:"+classCodeDescr);
						}
						if( detail.getElementsByTagName("spl_code")[0] != null && detail.getElementsByTagName("spl_code")[0].childNodes[0] != null )
						{
							splCode = detail.getElementsByTagName("spl_code")[0].childNodes[0].nodeValue;
							console.log("splCode is:"+splCode);
						}
						if( detail.getElementsByTagName("speciality_descr")[0] != null && detail.getElementsByTagName("speciality_descr")[0].childNodes[0] != null )
						{
							specialityDescr = detail.getElementsByTagName("speciality_descr")[0].childNodes[0].nodeValue;
							console.log("specialityDescr is:"+specialityDescr);
						}
						if( detail.getElementsByTagName("promoter_name")[0] != null && detail.getElementsByTagName("promoter_name")[0].childNodes[0] != null )
						{
							promoterName = detail.getElementsByTagName("promoter_name")[0].childNodes[0].nodeValue;
							console.log("promoterName is:"+promoterName);
						}
						if( detail.getElementsByTagName("man_power")[0] != null && detail.getElementsByTagName("man_power")[0].childNodes[0] != null )
						{
							manPower = detail.getElementsByTagName("man_power")[0].childNodes[0].nodeValue;
							console.log("manPower is:"+manPower);
						}
						if( detail.getElementsByTagName("image_id")[0] != null && detail.getElementsByTagName("image_id")[0].childNodes[0] != null )
						{
							imageId = detail.getElementsByTagName("image_id")[0].childNodes[0].nodeValue;
							console.log("imageId is:"+imageId);
						}
						if( detail.getElementsByTagName("gst_no")[0] != null && detail.getElementsByTagName("gst_no")[0].childNodes[0] != null )
						{
							gstNo = detail.getElementsByTagName("gst_no")[0].childNodes[0].nodeValue;
							console.log("gstNo is:"+gstNo);
						}
						if( detail.getElementsByTagName("subclass_code")[0] != null && detail.getElementsByTagName("subclass_code")[0].childNodes[0] != null )
						{
							subclassCode = detail.getElementsByTagName("subclass_code")[0].childNodes[0].nodeValue;
							console.log("subclassCode is:"+subclassCode);
						}
						if( detail.getElementsByTagName("pin")[0] != null && detail.getElementsByTagName("pin")[0].childNodes[0] != null )
						{
							pin = detail.getElementsByTagName("pin")[0].childNodes[0].nodeValue;
							console.log("pin is:"+pin);
						}
						if( detail.getElementsByTagName("subclass_descr")[0] != null && detail.getElementsByTagName("subclass_descr")[0].childNodes[0] != null )
						{
							subclassDescr = detail.getElementsByTagName("subclass_descr")[0].childNodes[0].nodeValue;
							console.log("subclassDescr is:"+subclassDescr);
						}
						if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
						{
							ismemberPresent = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
							console.log("ismemberPresent is:"+ismemberPresent);
						}
						//added by Hariom S for fortune [18/05/2021]
						if( detail.getElementsByTagName("allow_chg_visittime")[0] != null && detail.getElementsByTagName("allow_chg_visittime")[0].childNodes[0] != null )
						{
							allowVisitTime = detail.getElementsByTagName("allow_chg_visittime")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("is_fortune_activity")[0] != null && detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0] != null )
						{
							isFortuneActivity = detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0].nodeValue;
						}	
						//added by Hariom S for fortune [18/05/2021]		
						//added by bhagyashri T on [27/Jul/21]] for activity Place changes (start)
						if( detail.getElementsByTagName("activity_place")[0] != null && detail.getElementsByTagName("activity_place")[0].childNodes[0] != null )
						{
							activityPlace = detail.getElementsByTagName("activity_place")[0].childNodes[0].nodeValue;
							console.log("activityPlace type is as:"+activityPlace);
						}
						//added by bhagyashri T on [27/Jul/21]] for activity Place changes (end)	
					}
					// added by mrunalini sinkar for offline 16-feb-2018 (start)
					// commented by rupali on 23/02/18 for edit mode of realtime report [start]
					/*if( activityType == 'NFW' ||  activityType == 'LEAVE')
					{

						itemChangeStr = "<Detail1 domID='1' protectSubform=\'brand,sampleorder,display,team,coaching\'><protect_subform><![CDATA[brand,sampleorder,display,team,coaching]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'></cust_type>" +
						"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr><event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'></meet_summ><stockist_code protect = '1' visible = '0'></stockist_code><stockist_name protect = '1' visible = '0'></stockist_name>" +
						"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
						"</Detail1>";
					}
					else
					{
						itemChangeStr = "<Detail1 domID='1' protectSubform=\'\'><activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr><event_type protect = '0'><![CDATA["+eventType+"]]></event_type><activity_type><![CDATA["+activityType+"]]></activity_type><strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '0' visible = '0'></address_as>" +
						"<gender protect = '0' visible = '0'></gender><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><locality_code protect = '0' visible = '1'></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
						"<addr3 protect = '0' visible = '0'></addr3><spl_code protect = '0' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><remarks protect = '0' visible = '1'></remarks><strg_class_code protect = '0' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><visited_with protect = '0' visible = '1'></visited_with>" +
						"<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code><locality_descr protect = '1' visible = '1'></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr><event_time_start visible = '1'></event_time_start><event_time_end visible = '1'></event_time_end><copy_plan protect='1' visible = '1'><![CDATA[N]]></copy_plan><oth_participant protect = '0' visible = '1'></oth_participant>" +
						"</Detail1>";
					}*/
					// commented by rupali on 23/02/18 for edit mode of realtime report [end]
					// added by rupali on 23/02/18 for edit mode of realtime report [start]
					//Added & commented by mrunalini sinkar for NFW activity type not found(13-02-2019)
					//if( activityType == 'NFW' ||  activityType == 'LEAVE' && updateFlagVal != 'E') // added condition of updateFlagVal by rupali on 23/02/18 for edit mode of realtime report
					//Added by Prasad on 19/12/19 [coaching related implementation]
					//if( activityType !='FW' && updateFlagVal != 'E')
					if( (activityType !='FW' && updateFlagVal != 'E') || eventType == 'CA' )
					{
						//commented by mrunalini Sinkar on 11-june-2018(start)
						/*itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,display,team,coaching,survey\"><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type>" +
								"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr><event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'></<meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
								"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
								"</Detail1>";*/
						//commented by mrunalini Sinkar on 11-june-2018(end)
						//added  by mrunalini Sinkar to set ---NA-- in case leave on 11-june-2018(start)
						//added by mrunalini sinkar to visible on localitycode in case of nfw 26-june-2018(START)
						// Changes by mrunalini sinkar on 09-sep-2018 for place required changes (start)

						/*if(activityType == 'NFW')
						{
						itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,display,team,coaching,survey\"><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type>" +
								"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '0' visible = '1'></locality_descr><event_time_start visible = '0'></event_time_start><event_time_end visible = '0'></event_time_end><visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></<meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
								"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
								"</Detail1>";
						}*/
						if(placeRequired == 'Y')
						{
							//Added by Prasad on 19/12/19 [coaching related implementation] START
							if( eventType  == 'CA' )
							{
								itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,invoice,display,team,survey\"><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><strg_code protect = '1' visible = '0'><![CDATA[NA]]></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
										"<locality_code protect = '0' visible = '1'></locality_code>" ;
								//added by Hariom S for fortune [18/05/2021]
								if( isFortuneActivity  == 'Y')
								{
									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'N')
									{									
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B')
									{
										itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else
									{
										itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}															
								}
								else
								{
									itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start><event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end>";
								}
								//added by Hariom S for fortune [18/05/2021]
								itemChangeStr +="<visited_with protect = '0' visible = '1'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></<meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
										//"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
										"<address_as visible = '0'><![CDATA["+addressAs+"]]></address_as><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><age visible = '0'><![CDATA["+age+"]]></age><qualification visible = '0'><![CDATA["+qualification+"]]></qualification><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'><![CDATA["+mobileNo+"]]></mobile_no>" +
										"<strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>" +
										"<promoter_name visible = '0'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '0'><![CDATA["+manPower+"]]></man_power><image_id visible = '0'><![CDATA["+imageId+"]]></image_id><gst_no visible = '0'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '0'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '0'><![CDATA["+pin+"]]></pin><subclass_descr visible = '0'><![CDATA["+subclassDescr+"]]></subclass_descr>" +
										"<resign_emp><![CDATA[N]]></resign_emp></Detail1>";
							}
							else
							{
								itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,invoice,display,team,coaching,survey\"><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
										"<locality_code protect = '0' visible = '1'></locality_code><locality_descr protect = '0' visible = '1'></locality_descr>";

								if( isFortuneActivity  == 'Y')
								{
									if( allowVisitTime  == 'Y')
									{
										itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'N')
									{									
										itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else if( allowVisitTime  == 'B')
									{
										itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}
									else
									{
										itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
												"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
												"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
									}


								}
								else
								{
									itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start><event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end>";
								}
								itemChangeStr +="<visited_with protect = '0' visible = '1'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></<meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
										//"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
										"<address_as visible = '0'><![CDATA["+addressAs+"]]></address_as><age visible = '0'><![CDATA["+age+"]]></age><qualification visible = '0'><![CDATA["+qualification+"]]></qualification><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'><![CDATA["+mobileNo+"]]></mobile_no>" +
										"<strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>" +
										"<promoter_name visible = '0'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '0'><![CDATA["+manPower+"]]></man_power><image_id visible = '0'><![CDATA["+imageId+"]]></image_id><gst_no visible = '0'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '0'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '0'><![CDATA["+pin+"]]></pin><subclass_descr visible = '0'><![CDATA["+subclassDescr+"]]></subclass_descr>" +
										"<resign_emp><![CDATA[N]]></resign_emp></Detail1>";
							}
							//Added by Prasad on 19/12/19 [coaching related implementation] END
						}
						// Changes by mrunalini sinkar on 09-sep-2018 for place required changes (end)
						else
						{
							itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,invoice,display,team,coaching,survey\"><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><strg_code protect = '1' visible = '0'></strg_code><strg_name protect = '1' visible = '0'></strg_name><remarks protect = '1' visible = '0'></remarks><cust_type protect = '1' visible = '0'><![CDATA[LISTED]]></cust_type><type_cust><![CDATA[L]]></type_cust>" +
									"<locality_code protect = '1' visible = '0'></locality_code><locality_descr protect = '1' visible = '0'></locality_descr>";
							//added by Hariom S for fortune [18/05/2021]
							if( isFortuneActivity  == 'Y')
							{
								if( allowVisitTime  == 'Y')
								{
									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'N')
								{									
									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B')
								{
									itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else
								{
									itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}


							}
							else
							{

								itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start><event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end>";
							}
							//added by Hariom S for fortune [18/05/2021]
							itemChangeStr +="<visited_with protect = '1' visible = '0'></visited_with><copy_plan protect='1' visible = '0'></copy_plan><oth_participant protect = '1' visible = '0'></oth_participant><call_outcome protect = '1' visible = '0'></call_outcome><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></<meet_summ><stockist_name protect = '1' visible = '0'></stockist_name><stockist_code protect = '1' visible = '0'></stockist_code>" +
									//"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><address_as protect = '1' visible = '0'></address_as><gender protect = '1' visible = '0'></gender><mobile_no protect = '1' visible = '0'></mobile_no><email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr>" +
									//"<address_as visible = '0'></address_as><gender visible = '0'></gender><addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><email_addr visible = '0'></email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0'></strg_class_code><spl_code visible = '0'></spl_code>" +
									"<address_as visible = '0'><![CDATA["+addressAs+"]]></address_as><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><age visible = '0'><![CDATA["+age+"]]></age><qualification visible = '0'><![CDATA["+qualification+"]]></qualification><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'><![CDATA["+mobileNo+"]]></mobile_no><strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>"+
									"<resign_emp><![CDATA[N]]></resign_emp></Detail1>";
						}
						//added by mrunalini sinkar to visible on localitycode in case of nfw 26-june-2018(end)

						//added  by mrunalini Sinkar to set ---NA-- in case leave on 11-june-2018(end)
					}
					/*else if(activityType == 'FW' && updateFlagVal != 'E') // added condition of updateFlagVal by rupali on 23/02/18 for edit mode of realtime report
					{
						itemChangeStr = "<Detail1 protectSubform=\"\"><activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr><event_type protect = '0'><![CDATA["+eventType+"]]></event_type><activity_type><![CDATA["+activityType+"]]></activity_type><strg_code protect = '0' visible = '1'></strg_code><strg_name protect = '1' visible = '1'></strg_name><address_as protect = '0' visible = '0'></address_as>" +
								"<gender protect = '0' visible = '0'></gender><cust_type protect = '0' visible = '1'><![CDATA[LISTED]]></cust_type><locality_code protect = '0' visible = '1'></locality_code><call_outcome protect = '0' visible = '1'></call_outcome><meet_summ protect = '0' visible = '1'></meet_summ><addr1 protect = '0' visible = '0'></addr1><addr2 protect = '0' visible = '0'></addr2>" +
								"<addr3 protect = '0' visible = '0'></addr3><spl_code protect = '0' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><remarks protect = '0' visible = '1'></remarks><strg_class_code protect = '0' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr><visited_with protect = '0' visible = '1'></visited_with>" +
								"<stockist_name protect = '1' visible = '1'></stockist_name><stockist_code protect = '0' visible = '1'></stockist_code><locality_descr protect = '1' visible = '1'></locality_descr><mobile_no protect = '0' visible = '0'></mobile_no><email_addr protect = '0' visible = '0'></email_addr><event_time_start visible = '1'></event_time_start><event_time_end visible = '1'></event_time_end><copy_plan protect='1' visible = '1'><![CDATA[N]]></copy_plan><oth_participant protect = '0' visible = '1'></oth_participant>" +
								"</Detail1>";
					}*/
					else if(callOutcome === '0' || callOutcome === '9' )
					{
						//commented by mrunalini Sinkar on 11-june-2018(start)
						console.log("inside call outcome condition");
						//itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,display,team,coaching,survey\"><protect_subform><![CDATA[brand,sampleorder,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1'></meet_summ></Detail1>";
						//commented by mrunalini Sinkar on 11-june-2018(end)
						//added  by mrunalini Sinkar to set ---NA-- in case leave on 11-june-2018(start)
						itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,invoice,display,team,coaching,survey\"><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1' visble='0'><![CDATA[---NA---]]></meet_summ>" +
								//"<address_as visible = '0'></address_as><gender visible = '0'></gender><addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><email_addr visible = '0'></email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0'></strg_class_code><spl_code visible = '0'></spl_code>" +
								"<address_as protect='1' visible = '1'><![CDATA["+addressAs+"]]></address_as><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><age visible = '0'><![CDATA["+age+"]]></age><qualification visible = '0'><![CDATA["+qualification+"]]></qualification><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'><![CDATA["+mobileNo+"]]></mobile_no>" +
								"<strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>"+
								"<promoter_name visible = '0'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '0'><![CDATA["+manPower+"]]></man_power><image_id visible = '0'><![CDATA["+imageId+"]]></image_id><gst_no visible = '1'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '0'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '0'><![CDATA["+pin+"]]></pin><subclass_descr visible = '0'><![CDATA["+subclassDescr+"]]></subclass_descr>"+
								"<resign_emp><![CDATA[N]]></resign_emp>";
						if( isFortuneActivity  == 'Y')
						{
							//alert("isFortuneActivity 00000::y"+isFortuneActivity);
							if( allowVisitTime  == 'Y')
							{
								//alert("allowVisitTime ::9999999999: Y"+allowVisitTime);

								itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'N')
							{

								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'B')
							{
								itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else
							{
								itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}


						}
						itemChangeStr +="</Detail1>";
						console.log("after itemchange:"+itemChangeStr);
					}
					else if(updateFlagVal == 'E')
					{
						console.log("inside else is:::::"+callOutcome);
						if(callOutcome === '0' || callOutcome === '9')
						{
							itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>" +
									//"<address_as visible = '0'></address_as><gender visible = '0'></gender><addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><email_addr visible = '0'></email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0'></strg_class_code><spl_code visible = '0'></spl_code>" +
									"<address_as protect='1' visible = '1'><![CDATA["+addressAs+"]]></address_as><age visible = '0'><![CDATA["+age+"]]></age><qualification visible = '0'><![CDATA["+qualification+"]]></qualification><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'><![CDATA["+mobileNo+"]]></mobile_no>" +
									"<strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>"+
									"<promoter_name visible = '0'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '0'><![CDATA["+manPower+"]]></man_power><image_id visible = '0'><![CDATA["+imageId+"]]></image_id><gst_no visible = '1'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '0'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '0'><![CDATA["+pin+"]]></pin><subclass_descr visible = '0'><![CDATA["+subclassDescr+"]]></subclass_descr>"+
									"<resign_emp><![CDATA[N]]></resign_emp>";
							if( isFortuneActivity  == 'Y')
							{
								if( allowVisitTime  == 'Y')
								{

									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'N')
								{

									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B')
								{
									itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else
								{
									itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}


							}
							itemChangeStr +="</Detail1>";
						}
						else
						{

							itemChangeStr = "<Detail1 protectSubform=\""+subformProtect+"\"><protect_subform><![CDATA["+subformProtect+"]]></protect_subform><meet_summ protect = '0' visible = '1'></meet_summ>" +
									//"<address_as visible = '0'></address_as><gender visible = '0'></gender><addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><email_addr visible = '0'></email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0'></strg_class_code><spl_code visible = '0'></spl_code>" +
									"<address_as protect='1' visible = '1'><![CDATA["+addressAs+"]]></address_as><age visible = '0'><![CDATA["+age+"]]></age><qualification visible = '0'><![CDATA["+qualification+"]]></qualification><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'><![CDATA["+mobileNo+"]]></mobile_no>" +
									"<strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>"+
									"<promoter_name visible = '0'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '0'><![CDATA["+manPower+"]]></man_power><image_id visible = '0'><![CDATA["+imageId+"]]></image_id><gst_no visible = '0'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '0'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '0'><![CDATA["+pin+"]]></pin><subclass_descr visible = '0'><![CDATA["+subclassDescr+"]]></subclass_descr>"+
									"<resign_emp><![CDATA[N]]></resign_emp>" ;
							if( isFortuneActivity  == 'Y')
							{
								if( allowVisitTime  == 'Y')
								{

									itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'N')
								{

									itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else if( allowVisitTime  == 'B')
								{
									itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
								else
								{
									itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
											"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
											"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
								}
							}
							itemChangeStr +="</Detail1>";
						}

					}
					else
					{
						itemChangeStr = //"<Detail1><address_as visible = '0'></address_as><gender visible = '0'></gender><addr1 visible = '0'></addr1><addr2 visible = '0'></addr2><addr3 visible = '0'></addr3><email_addr visible = '0'></email_addr><mobile_no visible = '0'></mobile_no><strg_class_code visible = '0'></strg_class_code><spl_code visible = '0'></spl_code>" +
								"<Detail1><address_as protect='1' visible = '1'><![CDATA["+addressAs+"]]></address_as><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'><![CDATA["+mobileNo+"]]></mobile_no>" +
								"<strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>"+
								"<promoter_name visible = '0'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '0'><![CDATA["+manPower+"]]></man_power><image_id visible = '0'><![CDATA["+imageId+"]]></image_id><gst_no visible = '1'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '0'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '0'><![CDATA["+pin+"]]></pin><subclass_descr visible = '0'><![CDATA["+subclassDescr+"]]></subclass_descr>"+
								"<resign_emp><![CDATA[N]]></resign_emp><call_outcome><![CDATA[6]]></call_outcome>";
						if( isFortuneActivity  == 'Y')
						{
							if( allowVisitTime  == 'Y')
							{

								itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'N')
							{

								itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else if( allowVisitTime  == 'B')
							{
								itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
							else
							{
								itemChangeStr +="<event_time_start protect = '1'><![CDATA["+time+"]]></event_time_start>" +
										"<event_time_end protect = '1'><![CDATA["+time+"]]></event_time_end>"+
										"<visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
							}
						}
						else
						{
							itemChangeStr +="<event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start><event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from>" ;
						}
						itemChangeStr +="</Detail1>";
					}
					if ( customrType != '' && customrType != 'LISTED')
					{
						console.log("customerType not listed:::::::::");
						if(ismemberPresent!='Y')
						{
							itemChangeStr = //"<Detail1><address_as visible = '1'></address_as><gender visible = '1'></gender><addr1 visible = '1'></addr1><addr2 visible = '1'></addr2><addr3 visible = '1'></addr3><email_addr visible = '1'></email_addr><mobile_no visible = '1'></mobile_no><strg_class_code visible = '1'></strg_class_code><spl_code visible = '1></spl_code>" +
									"<Detail1><address_as protect='1' visible = '1'><![CDATA["+addressAs+"]]></address_as><gender visible = '1'><![CDATA["+gender+"]]></gender><addr1 visible = '1'><![CDATA["+addr1+"]]></addr1><addr2 visible = '1'><![CDATA["+addr2+"]]></addr2><addr3 visible = '1'><![CDATA["+addr3+"]]></addr3><email_addr visible = '1'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '1'>" +
									"<![CDATA["+mobileNo+"]]></mobile_no><strg_class_code visible = '1'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '1'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '1'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '1'><![CDATA["+specialityDescr+"]]></speciality_descr>"+
									"<promoter_name visible = '1'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '1'><![CDATA["+manPower+"]]></man_power><image_id visible = '1'><![CDATA["+imageId+"]]></image_id><gst_no visible = '1'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '1'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '1'><![CDATA["+pin+"]]></pin><subclass_descr visible = '1'><![CDATA["+subclassDescr+"]]></subclass_descr>"+
									"<resign_emp><![CDATA[N]]></resign_emp><event_time_start visible = '0'><![CDATA["+time+"]]></event_time_start><event_time_end visible = '0'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from></Detail1>";
						}
						else
						{

							itemChangeStr = //"<Detail1><address_as visible = '1'></address_as><gender visible = '1'></gender><addr1 visible = '1'></addr1><addr2 visible = '1'></addr2><addr3 visible = '1'></addr3><email_addr visible = '1'></email_addr><mobile_no visible = '1'></mobile_no><strg_class_code visible = '1'></strg_class_code><spl_code visible = '1></spl_code>" +
									"<Detail1><address_as protect='1' visible = '1'><![CDATA["+addressAs+"]]></address_as><gender visible = '0'><![CDATA["+gender+"]]></gender><addr1 visible = '0'><![CDATA["+addr1+"]]></addr1><addr2 visible = '0'><![CDATA["+addr2+"]]></addr2><addr3 visible = '0'><![CDATA["+addr3+"]]></addr3><email_addr visible = '0'><![CDATA["+emailAddr+"]]></email_addr><mobile_no visible = '0'>" +
									"<![CDATA["+mobileNo+"]]></mobile_no><strg_class_code visible = '0'><![CDATA["+strgClassCode+"]]></strg_class_code><spl_code visible = '0'><![CDATA["+splCode+"]]></spl_code><class_code_descr visible = '0'><![CDATA["+classCodeDescr+"]]></class_code_descr><speciality_descr visible = '0'><![CDATA["+specialityDescr+"]]></speciality_descr>"+
									"<promoter_name visible = '0'><![CDATA["+promoterName+"]]></promoter_name><man_power visible = '0'><![CDATA["+manPower+"]]></man_power><image_id visible = '0'><![CDATA["+imageId+"]]></image_id><gst_no visible = '0'><![CDATA["+gstNo+"]]></gst_no><subclass_code visible = '0'><![CDATA["+subclassCode+"]]></subclass_code><pin visible = '0'><![CDATA["+pin+"]]></pin><subclass_descr visible = '0'><![CDATA["+subclassDescr+"]]></subclass_descr>"+
									"<resign_emp><![CDATA[N]]></resign_emp><event_time_start visible = '1' protect='1'><![CDATA["+time+"]]></event_time_start><event_time_end visible = '1' protect='1'><![CDATA["+time+"]]></event_time_end><visit_time_from visible = '0'><![CDATA["+time+"]]></visit_time_from></Detail1>";
						}
					}
					// added by rupali on 23/02/18 for edit mode of realtime report [end]
				}
				else if( fieldName === 'default_data_edit' )
				{
					isAutoEdit = true;
					updateFlg = false;
					//alert("inside default_data_edit:::::::: "+itemChangeStr);
					var detailElement = xmlDoc.getElementsByTagName("Detail1");
					for (var i = 0; i < detailElement.length; i++)
					{
						var eventDate = "", eventType = "", actDescr = "", custCode = "", custName = "";
						var locCode = "", locDescr = "", subProtect = "", custType = "", callOutcm = "", imgId = "",route="",isMemberPresent="",activityTempl="";
						var activityPlace = ""; //added by Bhagyashri T on[28/JUL/21]
						var detail = detailElement[i];
						if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
						{
							eventDate = detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
						{
							eventType = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("activity_descr")[0] != null && detail.getElementsByTagName("activity_descr")[0].childNodes[0] != null )
						{
							actDescr = detail.getElementsByTagName("activity_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							custCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("strg_name")[0] != null && detail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
						{
							custName = detail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("locality_code")[0] != null && detail.getElementsByTagName("locality_code")[0].childNodes[0] != null )
						{
							locCode = detail.getElementsByTagName("locality_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("locality_descr")[0] != null && detail.getElementsByTagName("locality_descr")[0].childNodes[0] != null )
						{
							locDescr = detail.getElementsByTagName("locality_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cust_type")[0] != null && detail.getElementsByTagName("cust_type")[0].childNodes[0] != null )
						{
							custType = detail.getElementsByTagName("cust_type")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("subform_protect")[0] != null && detail.getElementsByTagName("subform_protect")[0].childNodes[0] != null )
						{
							subProtect = detail.getElementsByTagName("subform_protect")[0].childNodes[0].nodeValue;
							//alert("subProtect::::"+subProtect);
						}
						if( detail.getElementsByTagName("call_outcome")[0] != null && detail.getElementsByTagName("call_outcome")[0].childNodes[0] != null )
						{
							callOutcm = detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
							addModeCallOutCm = callOutcm;
						}
						if( detail.getElementsByTagName("image_id")[0] != null && detail.getElementsByTagName("image_id")[0].childNodes[0] != null )
						{
							imgId = detail.getElementsByTagName("image_id")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("survey_templ")[0] != null && detail.getElementsByTagName("survey_templ")[0].childNodes[0] != null )
						{
							DocsurveyTemp = detail.getElementsByTagName("survey_templ")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("route_id")[0] != null && detail.getElementsByTagName("route_id")[0].childNodes[0] != null )
						{
							route = detail.getElementsByTagName("route_id")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
						{
							isMemberPresent = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
						}

						//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm Start
						if( detail.getElementsByTagName("activity_templ")[0] != null && detail.getElementsByTagName("activity_templ")[0].childNodes[0] != null )
						{
							activityTempl = detail.getElementsByTagName("activity_templ")[0].childNodes[0].nodeValue;
						}
						//Added by Bhagyashri T on[28/Jul/21] for actvity place[start]
						if( detail.getElementsByTagName("activity_place")[0] != null && detail.getElementsByTagName("activity_place")[0].childNodes[0] != null )
						{
							activityPlace = detail.getElementsByTagName("activity_place")[0].childNodes[0].nodeValue;
							console.log("activity place default edit:"+activityPlace);
						}
						//Added by Bhagyashri T on[28/Jul/21] for actvity place[end]
						if(eventType == 'MI' || eventType == 'OT' )
						{
							DocsurveyTemp = activityTempl;
						}
						//Added by Pooja S on [10-FEB-2020] MI Activity related changes for suborm End
					}
					
					if(callOutcm === '0' || callOutcm === '9')
					{
						itemChangeStr = "<Detail1 protectSubform=\"brand,sampleorder,invoice,display,team,coaching,survey\"><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching,survey]]></protect_subform><meet_summ protect = '1' visible = '0'><![CDATA[---NA---]]></meet_summ>";
					}
					else
					{
						itemChangeStr = "<Detail1 protectSubform=\""+subProtect+"\"><protect_subform><![CDATA["+subProtect+"]]></protect_subform>";
					}
					if(custType == 'LISTED')
					{
						itemChangeStr += "<strg_name protect = '1'><![CDATA["+custName+"]]></strg_name>" +
								"<image_id visible = '0'><![CDATA["+imgId+"]]></image_id>";
					}
					if(isMemberPresent=='Y')
					{
						itemChangeStr += "<image_id visible = '0'><![CDATA["+imgId+"]]></image_id><oth_participant visible = '0'></oth_participant>";
					}

					itemChangeStr +=
							//"<Detail"+ objContext +" domID='1' protectSubform=\""+subProtect+"\"><protect_subform><![CDATA["+subProtect+"]]></protect_subform>" +
							"<attribute pkNames='' status='N' updateFlag='A' selected='N' />" +
							"<event_date protect = '1'><![CDATA["+eventDate+"]]></event_date>" +
							"<event_type protect = '1'><![CDATA["+eventType+"]]></event_type>" +
							"<activity_descr protect = '1'><![CDATA["+actDescr+"]]></activity_descr>" +
							"<strg_code protect = '1'><![CDATA["+custCode+"]]></strg_code>" +
							"<survey_templ><![CDATA["+DocsurveyTemp+"]]></survey_templ>" +
							"<route_id protect = '1'><![CDATA["+route+"]]></route_id>" +
							"<activity_place protect = '1'><![CDATA["+activityPlace+"]]></activity_place>" +  //Added by Bhagyashri T[27/07/21]
							"<locality_code protect = '1'><![CDATA["+locCode+"]]></locality_code>" +
							"<locality_descr protect = '1'><![CDATA["+locDescr+"]]></locality_descr>" +
							"<cust_type protect = '1'><![CDATA["+custType+"]]></cust_type>" +
							"<call_outcome protect = '0'><![CDATA["+callOutcm+"]]></call_outcome>" +
							"</Detail"+ objContext +">";
					//alert("itemChangeStr::::::::"+itemChangeStr);
				}
				else if ( fieldName === 'cust_type')
				{
					console.log("cust type inside");
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							scCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
							console.log("scCode type is:"+scCode);
						}
					}
				}
				//Added by Sagar B. to perform pre_save IC[23-Jan-20]START
				else if( fieldName === 'pre_save')
				{
					var custType = "", eventDate = "";
					var time = getStartTime();
					var currentDate = new Date();
					var detailElement = xmlDoc.getElementsByTagName("Detail1");
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("event_date")[0] != null && detail.getElementsByTagName("event_date")[0].childNodes[0] != null )
						{
							eventDate=detail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
						}
					}
					var diffDays = getDaysBetweenTwoDates(eventDate,currentDate);
					if( diffDays == 0 )
					{
						itemChangeStr = "<Detail1><event_time_end><![CDATA["+time+"]]></event_time_end></Detail1>";
					}
				}
				//Added by Sagar B. to perform pre_save IC[23-Jan-20]END
				if ( fieldName === 'strg_code')
				{
					var elemByTag = xmlDoc.getElementsByTagName('Detail1');
					var elemByItm = elemByTag.item(0);
					var noOfChild = elemByItm.childNodes.length
							var i = 0;
					for(i = 0; i < noOfChild; i++)
					{
						var childElem = elemByItm.childNodes[i];
						if(childElem.nodeType === Node.ELEMENT_NODE)
						{
							if(! childElem.textContent)
							{
								if(childElem.getAttribute('id'))
								{
									var id = childElem.getAttribute('id').substr(20);
									var elemTohide = document.getElementById(id);
									if(elemTohide && (id === 'stockist_name' || id === 'remarks'))
									{
										elemTohide.style.display = '';
									}
									else if(elemTohide)
									{
										elemTohide.style.display = 'none';
									}
								}
								else
								{
									var id = childElem.nodeName;
									var elemTohide = document.getElementById(id);
									if(elemTohide && (id === 'stockist_name' || id === 'remarks'))
									{
										elemTohide.style.display = '';
									}
									else if(elemTohide)
									{
										elemTohide.style.display = 'none';
									}
								}
							}
							// Added by Amol Sant to implement anchor tag functionality for mobile no and email id in real time reporting mobile [START]
							else
							{
								if(childElem)
								{
									if(childElem.getAttribute('id'))
									{
										var id = childElem.getAttribute('id').substr(20);
										var elemTohide = document.getElementById(id);
										var newElem = document.getElementById(id);

										if(id === "mobile_no" || id ==="email_addr")
										{
											var anchorValue = childElem.textContent;
											var parent = elemTohide.parentNode;
											var anchor = document.createElement('a');
											var parentElem = document.createElement('div');
											var newAnchor = document.createElement('a');
											var newParent = document.createElement('div');
											try
											{
												var input = elemTohide.getElementsByTagName('input')[0];
												var anchorTag = elemTohide.getElementsByTagName('a')[0];

												if (input)
												{
													if(id ==="mobile_no")
													{
														anchor.innerHTML = anchorValue;
														anchor.href = "tel:" + anchorValue;
													}
													if(id ==="email_addr")
													{
														anchor.innerHTML = anchorValue;
														anchor.href = "mailto:" + anchorValue;
													}
													parentElem.className = input.className;
													parentElem.setAttribute('fieldid', input.getAttribute('fieldid') || '');
													parentElem.id = input.id;

													parentElem.appendChild(anchor);
													elemTohide.insertBefore(parentElem, input);
													input.remove();
												}
												else if(anchorTag)
												{
													var firstChild = elemTohide.childNodes[0];
													if(id ==="mobile_no")
													{
														newAnchor.innerHTML = anchorValue;
														newAnchor.href = "tel:" + anchorValue;
													}
													if(id ==="email_addr")
													{
														newAnchor.innerHTML = anchorValue;
														newAnchor.href = "mailto:" + anchorValue;
													}
													newParent.className = firstChild.className;
													newParent.setAttribute('fieldid', firstChild.getAttribute('fieldid') || '');
													newParent.id = firstChild.id;
													newParent.appendChild(newAnchor);
													elemTohide.insertBefore(newParent, firstChild);
													firstChild.remove();
												}

											}
											catch(e)
											{
												console.log("EXCEPTION IN STRG_MEET_DCR_REALTIME_WIZ.JS if :: ANCHOR :"+e);
											}
										}

									}
								}
							}
						}
					}

				}

				else
				{
					try
					{
						var elemByTag = xmlDoc.getElementsByTagName('Detail1');
						var elemByItm = elemByTag.item(0);
						var noOfChild = elemByItm.childNodes.length
								var i =0;
						for(i=0; i<noOfChild; i++)
						{
							var childElem = elemByItm.childNodes[i];
							if(childElem)
							{

								if(childElem.getAttribute('id'))
								{
									var id = childElem.getAttribute('id').substr(20);
									var elemTohide = document.getElementById(id);

									if(id === "mobile_no" || id ==="email_addr")
									{
										var textBox = document.createElement('input');
										var input = elemTohide.getElementsByTagName('input')[0];
										var panel = elemTohide.getElementsByTagName('div')[0];
										if( !input )
										{
											textBox.className = panel.className;
											textBox.setAttribute('fieldid', panel.getAttribute('fieldid') || '');
											textBox.setAttribute('required',"");
											textBox.id = panel.id;
											elemTohide.insertBefore(textBox, panel);
											panel.remove();
										}
									}

								}
							}
						}
					}
					catch(e)
					{
						console.log("EXCEPTION IN STRG_MEET_DCR_REALTIME_WIZ.JS :: ANCHOR :"+e);
					}
				}
				// Added by Amol Sant to implement anchor tag functionality for mobile no and email id in real time reporting mobile [END]
			}
			//alert("itemChangeStr is"+itemChangeStr);
			return itemChangeStr;
		}
	}
	else if( objName ==='stocks_transfer_wiz')
	{

		//alert("inside post itemchange:"+currentFormData);
		console.log("inside post itemchange:"+currentFormData);
		var currentFormData=currentFormData;
		var objcon=objContext;
		var checkitemchangeData = "";
		var itemChangeStr = "";
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			console.log("currentform data is not null in localPostItemChange");

			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata localPostItemChange");
		}
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
					console.log("localPostItemChange xmlDoc =["+currentFormData+"]");
				}
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data localPostItemChange");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		if(xmlDoc != null )
		{
			if(objContext == 1)
			{
				if( fieldName === 'default_data_edit' )
				{
					isAutoEdit = true;
					//alert("inside default_data_edit::::::::"+itemChangeStr);
					var detailElement = xmlDoc.getElementsByTagName("Detail1");
					var siteCode="",itemSer="",chgDate="",chgTerm="",formMandatory="",chgUser="",confirm="",loccodeto="",loctodescr="",refser="",trandate="",locCodeTo="",locCodeToDescr="",empCodeAprv="";
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						console.log("detail column::"+detail)
						if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
						{
							locCodeFR = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
							console.log("locCodeFR in "+locCodeFR);
						}

						if( detail.getElementsByTagName("loc_descr_fr")[0] != null && detail.getElementsByTagName("loc_descr_fr")[0].childNodes[0] != null )
						{
							locDescrFR = detail.getElementsByTagName("loc_descr_fr")[0].childNodes[0].nodeValue;
							console.log("locDescrFR in "+locDescrFR);
						}
						if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
						{
							loccodeto = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
							console.log("loccodeto in "+loccodeto);
						}

						if( detail.getElementsByTagName("loc_descr_to")[0] != null && detail.getElementsByTagName("loc_descr_to")[0].childNodes[0] != null )
						{
							loctodescr = detail.getElementsByTagName("loc_descr_to")[0].childNodes[0].nodeValue;
							console.log("loctodescr in "+loctodescr);
						}
						if( detail.getElementsByTagName("site_code")[0] != null && detail.getElementsByTagName("site_code")[0].childNodes[0] != null )
						{
							siteCode = detail.getElementsByTagName("site_code")[0].childNodes[0].nodeValue;
							console.log("siteCode in "+siteCode);
						}
						if( detail.getElementsByTagName("item_ser")[0] != null && detail.getElementsByTagName("item_ser")[0].childNodes[0] != null )
						{
							itemSer = detail.getElementsByTagName("item_ser")[0].childNodes[0].nodeValue;
							console.log("itemSer in "+itemSer);
						}
						if( detail.getElementsByTagName("ref_ser__for")[0] != null && detail.getElementsByTagName("ref_ser__for")[0].childNodes[0] != null )
						{
							refser = detail.getElementsByTagName("ref_ser__for")[0].childNodes[0].nodeValue;
							console.log("refser in "+refser);
						}
						if( detail.getElementsByTagName("tran_date")[0] != null && detail.getElementsByTagName("tran_date")[0].childNodes[0] != null )
						{
							trandate = detail.getElementsByTagName("tran_date")[0].childNodes[0].nodeValue;
							console.log("trandate in "+trandate);
						}
						if( detail.getElementsByTagName("chg_date")[0] != null && detail.getElementsByTagName("chg_date")[0].childNodes[0] != null )
						{
							chgDate = detail.getElementsByTagName("chg_date")[0].childNodes[0].nodeValue;
							console.log("chgDate in "+chgDate);
						}
						if( detail.getElementsByTagName("chg_term")[0] != null && detail.getElementsByTagName("chg_term")[0].childNodes[0] != null )
						{
							chgTerm = detail.getElementsByTagName("chg_term")[0].childNodes[0].nodeValue;
							console.log("chgTerm in "+chgTerm);
						}
						if( detail.getElementsByTagName("chg_user")[0] != null && detail.getElementsByTagName("chg_user")[0].childNodes[0] != null )
						{
							chgUser = detail.getElementsByTagName("chg_user")[0].childNodes[0].nodeValue;
							console.log("chgUser in "+chgUser);
						}

						if( detail.getElementsByTagName("emp_code__aprv")[0] != null && detail.getElementsByTagName("emp_code__aprv")[0].childNodes[0] != null )
						{
							empCodeAprv = detail.getElementsByTagName("emp_code__aprv")[0].childNodes[0].nodeValue;
							console.log("emp_code__aprv in "+empCodeAprv);
						}


						console.log("locCodeFR"+locCodeFR);
					}

					itemChangeStr +="<Detail"+objContext+" domID = '1' selected = 'N'>"+
							"<loc_code__fr protect='1'><![CDATA["+locCodeFR+"]]></loc_code__fr>\r\n"+
							"<loc_descr_fr><![CDATA["+locDescrFR+"]]></loc_descr_fr>\n";

					itemChangeStr +="<loc_code__to protect='1'><![CDATA["+loccodeto+"]]></loc_code__to>\r\n"+
							"<loc_descr_to><![CDATA["+loctodescr+"]]></loc_descr_to>\r\n"+
							"<site_code><![CDATA["+siteCode+"]]></site_code>"+
							"<tran_id><![CDATA[]]></tran_id>"+
							"<tran_date><![CDATA["+trandate+"]]></tran_date>"+
							"<item_ser><![CDATA["+itemSer+"]]></item_ser>"+
							"<chg_date><![CDATA["+chgDate+"]]></chg_date>"+
							"<chg_term><![CDATA["+chgTerm+"]]></chg_term>"+
							"<chg_user><![CDATA["+chgUser+"]]></chg_user>"+
							"<confirmed><![CDATA[N]]></confirmed>"+
							"<emp_code__aprv><![CDATA["+empCodeAprv+"]]></emp_code__aprv>"+
							"<ref_ser__for><![CDATA["+refser+"]]></ref_ser__for>"+
							"</Detail"+objContext+">\r\n";

				}

			}
			//alert("itemChangeStr posave is"+itemChangeStr);
			return itemChangeStr;
		}	

	}

}
//Added by Pankaj R on 25-Sept-17 to hide the field or column which does not have any value in that field on itemchange

//added by mrunalini sinkar for offline validation ON 16-FEB-2018(start)
function callDefaultData(currentFormData, objContext, action, objName)
{
	salesTypeGlobal = "I";
	globalObjName = objName;
	console.log("Inside callDefaultData function having obj name is::["+objName+"]");
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		console.log("Inside callDefaultData function having obj name is strg_meet_dcr_realtime_wiz");
		teamFlg = true;
		orderFlg = true;
		brandFlg = true;
		displayFlg = true;
		surveyFlg = true;
		coachingFlg = true;
		invoiceFlg = true;
		collectionFlg = true;
		updateFlg = true;
		callOutCmGlobal ="";
	    addModeCallOutCm ="";
		editInvoiceFlg =true;
		editCollectFlg =true;
		billAmountGlobal = 0;


		custFlag=false;
		var pitchDetailArray=[];


		var locReq = "";
		var itemChangeStr="";
		var action=action;
		var activityTemplate =""
				//added by mrunalini sinkar for first for data model on 07-02-2019(start)
				var currentFormData=currentFormData;
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata localPostItemChange");
		}
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
				}
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data localPostItemChange");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		if(xmlDoc != null )
		{

			try
			{
				if( action=='defaultData' && objContext=='1' )
				{
					var cusClassInputs="";
					//alert("inside callDefaultData::::::::");
					//Added by sadique shaikh 02-03-2020 [For Event info for customer] Start
					var subProtect = "",strgEventInfo="";
					var gradeType = "",holidayDate="",pendDcr="";
					var locCode = "", locDescr = "", custClassInput = "", stockistName = "", stockistCode = "",allDelay="",futureDate="",routeId="",stationType="",stationdescr="",routeType="",invoiceNoD="",custTypeListDef="";
					var localityOrder = "",designCode="",isBangla="",branAval="";
					var hostUrl = "",orderFormNo="",teamFormNo="",viewTo="", invoiceFormNo="", collectionFormNo="";
					var applyStpVal = "", joinDate = "", allowDarRep = "", futureDateAct = "",memberPresnt="",stanCodeHQ="",headQuarter="",loadNo="",vehicleNo="";
					var realparmValue="";
					var formMandatory = "", setVisitTime = "",listDesignCodes="";
					var parentActCode = '',activityTempl= '';
					var displayTimeField="",pitchDetailList="",meetingStatusData="",unlstScCodeData="",cntPersData="",cntPersDataCd="";
					var qualList="",strgCodeList="";//added by prachi on 25-May-2022 [ W22AGOC002 ]
					var pricelist="";
					var totCgst="";
					var totSgst="";
					var isFortuneActivity="";
					var allowVisitTime="";
					var custTypeDetail="",custTypeData="";
					var beatChnageReasonDescr="";
					var beatchangeReasonUdf="";

					// Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [START]
					var itemSer="";
					var planBeats="",planRoute="";
					var evenDate = localStorage.getItem( 'SYSTEM_DISP_DATE' );
					var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
					prefixes = ['1st', '2nd', '3rd', '4th', '5th'];
					let splitDate = evenDate.split('/');
					var parseEvenDate = splitDate[1]+'/'+splitDate[0]+'/'+splitDate[2];
					var d = new Date(parseEvenDate);
					var dayName = days[d.getDay()];
					var weekAndDay = '';
					if(d.getDate() % 7 == 0)
					{
						weekAndDay = prefixes[Math.floor((d.getDate() / 7) - 1)] + ' ' + days[d.getDay()];
					}
					else
					{
						weekAndDay = prefixes[Math.floor(d.getDate() / 7)] + ' ' + days[d.getDay()];
					}

					// Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [END]
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					console.log("detailElement is:"+detailElement);
					var activityPlace="";   //Added by Bhagyashri T [27/Jul/21]
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						if( detail.getElementsByTagName("activity_type")[0] != null && detail.getElementsByTagName("activity_type")[0].childNodes[0] != null )
						{
							activityType = detail.getElementsByTagName("activity_type")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
						{
							eventType = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
							//Added by Amey W. [OT activity related implementation] on 18/02/2020
							selectedActivity = eventType;
							console.log( "Amy callDefalutData() selectedActivity ["+ selectedActivity +"]" );
						}
						if( detail.getElementsByTagName("activity_descr")[0] != null && detail.getElementsByTagName("activity_descr")[0].childNodes[0] != null )
						{
							activityDescr = detail.getElementsByTagName("activity_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("place_required")[0] != null && detail.getElementsByTagName("place_required")[0].childNodes[0] != null )
						{
							placeRequired = detail.getElementsByTagName("place_required")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("subform_protect")[0] != null && detail.getElementsByTagName("subform_protect")[0].childNodes[0] != null )
						{
							subProtect = detail.getElementsByTagName("subform_protect")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("grade_type")[0] != null && detail.getElementsByTagName("grade_type")[0].childNodes[0] != null )
						{
							gradeType = detail.getElementsByTagName("grade_type")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("allwd_delay_prd")[0] != null && detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0] != null )
						{
							allDelay = detail.getElementsByTagName("allwd_delay_prd")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("holiday_dates")[0] != null && detail.getElementsByTagName("holiday_dates")[0].childNodes[0] != null )
						{
							holidayDate = detail.getElementsByTagName("holiday_dates")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("pending_dcr")[0] != null && detail.getElementsByTagName("pending_dcr")[0].childNodes[0] != null )
						{
							pendDcr = detail.getElementsByTagName("pending_dcr")[0].childNodes[0].nodeValue;
						}
						/*if( detail.getElementsByTagName("holi_length")[0] != null && detail.getElementsByTagName("holi_length")[0].childNodes[0] != null )
							{
								holidayLength = detail.getElementsByTagName("holi_length")[0].childNodes[0].nodeValue;
							}*/
						if( detail.getElementsByTagName("locality_order")[0] != null && detail.getElementsByTagName("locality_order")[0].childNodes[0] != null )
						{
							localityOrder = detail.getElementsByTagName("locality_order")[0].childNodes[0].nodeValue;

						}
						// added by mrunalini sinakr to allow future event for particulat event_type on 03-april-2019(start)
						if( detail.getElementsByTagName("future_date")[0] != null && detail.getElementsByTagName("future_date")[0].childNodes[0] != null )
						{
							futureDate = detail.getElementsByTagName("future_date")[0].childNodes[0].nodeValue;

						}
						// added by mrunalini sinakr to allow future event for particulat event_type on 03-april-2019(end)
						if( detail.getElementsByTagName("host_url")[0] != null && detail.getElementsByTagName("host_url")[0].childNodes[0] != null )
						{
							hostUrl = detail.getElementsByTagName("host_url")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("order_form_no")[0] != null && detail.getElementsByTagName("order_form_no")[0].childNodes[0] != null )
						{
							orderFormNo = detail.getElementsByTagName("order_form_no")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("team_form_no")[0] != null && detail.getElementsByTagName("team_form_no")[0].childNodes[0] != null )
						{
							teamFormNo = detail.getElementsByTagName("team_form_no")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("invoice_form_no")[0] != null && detail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
						{
							invoiceFormNo = detail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("collection_form_no")[0] != null && detail.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
						{
							collectionFormNo = detail.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cust_type_list")[0] != null && detail.getElementsByTagName("cust_type_list")[0].childNodes[0] != null )
						{
							custTypeListDef = detail.getElementsByTagName("cust_type_list")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("emp_design")[0] != null && detail.getElementsByTagName("emp_design")[0].childNodes[0] != null )
						{
							designCode = detail.getElementsByTagName("emp_design")[0].childNodes[0].nodeValue;
							teamDesignCode=designCode;

						}
						//Added by mrunalini sinkar for banglasdesh user validation(start)
						if( detail.getElementsByTagName("is_bangla")[0] != null && detail.getElementsByTagName("is_bangla")[0].childNodes[0] != null )
						{
							isBangla = detail.getElementsByTagName("is_bangla")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("bradn_aval")[0] != null && detail.getElementsByTagName("bradn_aval")[0].childNodes[0] != null )
						{
							branAval = detail.getElementsByTagName("bradn_aval")[0].childNodes[0].nodeValue;

						}
						//Added by mrunalini sinkar for banglasdesh user validation(end)
						if( detail.getElementsByTagName("apply_stp_val")[0] != null && detail.getElementsByTagName("apply_stp_val")[0].childNodes[0] != null )
						{
							applyStpVal = detail.getElementsByTagName("apply_stp_val")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("emp_join_date")[0] != null && detail.getElementsByTagName("emp_join_date")[0].childNodes[0] != null )
						{
							joinDate = detail.getElementsByTagName("emp_join_date")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("allow_dar_rep")[0] != null && detail.getElementsByTagName("allow_dar_rep")[0].childNodes[0] != null )
						{
							allowDarRep = detail.getElementsByTagName("allow_dar_rep")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("future_date_act")[0] != null && detail.getElementsByTagName("future_date_act")[0].childNodes[0] != null )
						{
							futureDateAct = detail.getElementsByTagName("future_date_act")[0].childNodes[0].nodeValue;
						}
						//added by mrunalini sinkar for member present in unlisted customer (start)
						if( detail.getElementsByTagName("is_member_present")[0] != null && detail.getElementsByTagName("is_member_present")[0].childNodes[0] != null )
						{
							memberPresnt = detail.getElementsByTagName("is_member_present")[0].childNodes[0].nodeValue;
						}
						//added by mrunalini sinkar for member present in unlisted customer (end)
						//added by shraddha M for stockist[03-09-19:start]
						if( detail.getElementsByTagName("allow_stockist_dar")[0] != null && detail.getElementsByTagName("allow_stockist_dar")[0].childNodes[0] != null )
						{
							realparmValue = detail.getElementsByTagName("allow_stockist_dar")[0].childNodes[0].nodeValue;
						}
						//added by shraddha M for stockist[03-09-19:end]
						//Added by mrunalini sinkar to showing headquarter on summary(start)
						if( detail.getElementsByTagName("stan_code__hq")[0] != null && detail.getElementsByTagName("stan_code__hq")[0].childNodes[0] != null )
						{
							stanCodeHQ = detail.getElementsByTagName("stan_code__hq")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("headquarter")[0] != null && detail.getElementsByTagName("headquarter")[0].childNodes[0] != null )
						{
							headQuarter = detail.getElementsByTagName("headquarter")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("view_to")[0] != null && detail.getElementsByTagName("view_to")[0].childNodes[0] != null )
						{
							viewTo = detail.getElementsByTagName("view_to")[0].childNodes[0].nodeValue;
						}
						//Added by mrunalini sinkar to showing headquarter on summary(end)
						var totAllwCallList = 0, listCnt = 0;
						if( detail.getElementsByTagName("tot_allow_call_list")[0] != null && detail.getElementsByTagName("tot_allow_call_list")[0].childNodes[0] != null )
						{
							totAllwCallList = detail.getElementsByTagName("tot_allow_call_list")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("tot_call_list")[0] != null && detail.getElementsByTagName("tot_call_list")[0].childNodes[0] != null )
						{
							listCnt = detail.getElementsByTagName("tot_call_list")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("grade_code")[0] != null && detail.getElementsByTagName("grade_code")[0].childNodes[0] != null )
						{
							gradeCode = detail.getElementsByTagName("grade_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("form_mandatory")[0] != null && detail.getElementsByTagName("form_mandatory")[0].childNodes[0] != null )
						{
							formMandatory = detail.getElementsByTagName("form_mandatory")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("set_visit_time")[0] != null && detail.getElementsByTagName("set_visit_time")[0].childNodes[0] != null )
						{
							setVisitTime = detail.getElementsByTagName("set_visit_time")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("parent_act_code")[0] != null && detail.getElementsByTagName("parent_act_code")[0].childNodes[0] != null )
						{
							parentActCode = detail.getElementsByTagName("parent_act_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("activity_templ")[0] != null && detail.getElementsByTagName("activity_templ")[0].childNodes[0] != null )
						{
							activityTempl = detail.getElementsByTagName("activity_templ")[0].childNodes[0].nodeValue;
						}
						//Added by mrunalini sinkar for remove sequntial DAR validation in case of RSM & CA activity(start)
						if( detail.getElementsByTagName("list_design_code")[0] != null && detail.getElementsByTagName("list_design_code")[0].childNodes[0] != null )
						{
							listDesignCodes = detail.getElementsByTagName("list_design_code")[0].childNodes[0].nodeValue;
						}
						//Added by sadique shaikh 02-03-2020 [For Event info for customer] Start
						if( detail.getElementsByTagName("strg_event_info")[0] != null && detail.getElementsByTagName("list_design_code")[0].childNodes[0] != null )
						{
							strgEventInfo = detail.getElementsByTagName("strg_event_info")[0].childNodes[0].nodeValue;
						}
						//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] START
						if( detail.getElementsByTagName("loc_req")[0] != null && detail.getElementsByTagName("loc_req")[0].childNodes[0] != null )
						{
							locReq = detail.getElementsByTagName("loc_req")[0].childNodes[0].nodeValue;
						}
						//Added by Pooja on 14-AUGUST-2020 [Coaching related detail form implementation] start
						if( detail.getElementsByTagName("coaching_design_code")[0] != null && detail.getElementsByTagName("coaching_design_code")[0].childNodes[0] != null )
						{
							visitedWithDesignCodeArr = detail.getElementsByTagName("coaching_design_code")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("pitch_detail_data")[0] != null && detail.getElementsByTagName("pitch_detail_data")[0].childNodes[0] != null )
						{
							pitchDetailList = detail.getElementsByTagName("pitch_detail_data")[0].childNodes[0].nodeValue;
						}

						//added by prachi on 25-May-2022 [ W22AGOC002 ] start
						if( detail.getElementsByTagName("qualification_list")[0] != null && detail.getElementsByTagName("qualification_list")[0].childNodes[0] != null )
						{
							qualList = detail.getElementsByTagName("qualification_list")[0].childNodes[0].nodeValue;
						}
						
						//end 

                         if( detail.getElementsByTagName("strg_code_list")[0] != null && detail.getElementsByTagName("strg_code_list")[0].childNodes[0] != null )
					     {
						    strgCodeList = detail.getElementsByTagName("strg_code_list")[0].childNodes[0].nodeValue;
						 }
                         
						//added by prachi on 02-AUGUST-2022 [ W22EBAS002 ] start
						if( detail.getElementsByTagName("price_list")[0] != null && detail.getElementsByTagName("price_list")[0].childNodes[0] != null )
						{
							pricelist = detail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
						}
						//end
						//added by Bhagyashri on 12-AUGUST-2022 [ W22EBAS004 ] start
						if( detail.getElementsByTagName("total_cgst")[0] != null && detail.getElementsByTagName("total_cgst")[0].childNodes[0] != null )
						{
							totCgst = detail.getElementsByTagName("total_cgst")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("total_sgst")[0] != null && detail.getElementsByTagName("total_sgst")[0].childNodes[0] != null )
						{
							totSgst = detail.getElementsByTagName("total_sgst")[0].childNodes[0].nodeValue;
						}
						//end
						if( detail.getElementsByTagName("meeting_status_data")[0] != null && detail.getElementsByTagName("meeting_status_data")[0].childNodes[0] != null )
						{
							meetingStatusData = detail.getElementsByTagName("meeting_status_data")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("unlst_sccode_data")[0] != null && detail.getElementsByTagName("unlst_sccode_data")[0].childNodes[0] != null )
						{
							unlstScCodeData = detail.getElementsByTagName("unlst_sccode_data")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cnt_pers_data")[0] != null && detail.getElementsByTagName("cnt_pers_data")[0].childNodes[0] != null )
						{
							cntPersData = detail.getElementsByTagName("cnt_pers_data")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cnt_pers_code")[0] != null && detail.getElementsByTagName("cnt_pers_code")[0].childNodes[0] != null )
						{
							cntPersDataCd = detail.getElementsByTagName("cnt_pers_code")[0].childNodes[0].nodeValue;
						}
						//Added by Pooja on 14-AUGUST-2020 [Coaching related detail form implementation]  End
						//Added by sadique 20-06-2020 [to validate from LOC_REQ value from fieldactivity table] END
						//Added by sadique shaikh 02-03-2020 [For Event info for customer] End
						//Added by mrunalini sinkar for remove sequntial DAR validation in case of RSM & CA activity(end)
						//alert("totAllwCallList::"+totAllwCallList+" listCnt::"+listCnt);
						//added by shraddha M for event_time end hide changess[17/07/2020]
						if( detail.getElementsByTagName("display_time_fld")[0] != null && detail.getElementsByTagName("display_time_fld")[0].childNodes[0] != null )
						{
							displayTimeField = detail.getElementsByTagName("display_time_fld")[0].childNodes[0].nodeValue;
						}
						//added by shraddha M for event_time end hide changess end[17/07/2020]
						//added by Hariom S for fortune [18/05/2021]
						if( detail.getElementsByTagName("allow_chg_visittime")[0] != null && detail.getElementsByTagName("allow_chg_visittime")[0].childNodes[0] != null )
						{
							allowVisitTime = detail.getElementsByTagName("allow_chg_visittime")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("is_fortune_activity")[0] != null && detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0] != null )
						{
							isFortuneActivity = detail.getElementsByTagName("is_fortune_activity")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cust_type_detail")[0] != null && detail.getElementsByTagName("cust_type_detail")[0].childNodes[0] != null )
						{
							custTypeDetail = detail.getElementsByTagName("cust_type_detail")[0].childNodes[0].nodeValue;

						}
						if( detail.getElementsByTagName("cust_type_data")[0] != null && detail.getElementsByTagName("cust_type_data")[0].childNodes[0] != null )
						{
							custTypeData = detail.getElementsByTagName("cust_type_data")[0].childNodes[0].nodeValue;

						}
						//added by Hariom S for fortune [18/05/2021]
						//Added by Pankaj R on 09-JUL-21 to set default data [START]
						if( detail.getElementsByTagName("route_data")[0] != null && detail.getElementsByTagName("route_data")[0].childNodes[0] != null )
						{
							routeData = detail.getElementsByTagName("route_data")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("customer_data")[0] != null && detail.getElementsByTagName("customer_data")[0].childNodes[0] != null )
						{
							customerData = detail.getElementsByTagName("customer_data")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("visited_customer")[0] != null && detail.getElementsByTagName("visited_customer")[0].childNodes[0] != null )
						{
							visitedCust = detail.getElementsByTagName("visited_customer")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("activity_place")[0] != null && detail.getElementsByTagName("activity_place")[0].childNodes[0] != null )
						{
							activityPlace = detail.getElementsByTagName("activity_place")[0].childNodes[0].nodeValue;
							console.log("activity_place is:"+activityPlace);
						}
						if( detail.getElementsByTagName("beat_change_descr")[0] != null && detail.getElementsByTagName("beat_change_descr")[0].childNodes[0] != null )
						{
							beatChnageReasonDescr = detail.getElementsByTagName("beat_change_descr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("beat_change_udf")[0] != null && detail.getElementsByTagName("beat_change_udf")[0].childNodes[0] != null )
						{
							beatchangeReasonUdf = detail.getElementsByTagName("beat_change_udf")[0].childNodes[0].nodeValue;
						}
						//Added by Pankaj R on 09-JUL-21 to show default data [END]
						if( detail.getElementsByTagName("load_no")[0] != null && detail.getElementsByTagName("load_no")[0].childNodes[0] != null )
						{
							loadNo = detail.getElementsByTagName("load_no")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("vehicle_no")[0] != null && detail.getElementsByTagName("vehicle_no")[0].childNodes[0] != null )
						{
							vehicleNo = detail.getElementsByTagName("vehicle_no")[0].childNodes[0].nodeValue;
						}

					}
					//added by mrunalini sinkar for first for data model on 07-02-2019(end)
					var empCode1 = localStorage.getItem( 'EMP_CODE' );
					empCode1 = getUserInfo( "empCode" );
					if(empCode1)
					{
						empCode1 = empCode1.trim();
					}

					console.log("isFortuneActivity sadique ["+ isFortuneActivity +"]");
					console.log("allowVisitTime sadique ["+ allowVisitTime +"]");
					//alert("isFortuneActivity :::"+isFortuneActivity);
					//alert("allowVisitTime :::"+allowVisitTime);
					// Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [START]
					if(! Array.isArray(routeData))
					{
						routeData = JSON.parse(routeData);
					}
					if(! Array.isArray(customerData))
					{
						customerData = JSON.parse(customerData);
						console.log('customerData Cust:'+customerData);
					}
					if(! Array.isArray(visitedCust))
					{
						visitedCust = JSON.parse(visitedCust);
						//console.log('Visited Cust New:'+visitedCust[0]);
					}
					var selectedEmpId = "";
					if(Array.isArray(routeData))
					{
						const resSuper = routeData.filter(word => {
							return (selectedEmpId) ? (Object.keys(word)[0].includes(selectedEmpId)) : (Object.keys(word)[0].includes(empCode1))
						});
						console.log('resSuper :: ',resSuper);

						const result = resSuper.filter(word => {return Object.values(word)[0].PLAN_DAYS.includes(weekAndDay)});
						//console.log('result :: ',Object.values(result[0])[0]);
						for (const res of result) 
						{
							console.log('res ::: ',res);
							routeId = Object.values(res)[0].ROUTE_ID;
							console.log('routeId  :'+routeId);

							let resVal = '';
							visitedCust.forEach(e => {
								console.log('Object.keys(e)[0] : ',Object.keys(e)[0],Object.keys(e)[0] == parseInt(routeId));
								if(Object.keys(e)[0] == parseInt(routeId)){
									resVal = Object.values(e)[0];
									console.log('resval ::: ',resVal);
								}
							});

							let resValArr = resVal.split(",");
							console.log('resValArr :: ',resValArr);
							let localStorageCust = localStorage.getItem(evenDate+'_'+routeId+'_StrgCode');
							console.log('localStorageCust :: ',localStorageCust);
							let localStorageCustArr = localStorageCust ? localStorageCust.split(",") : [];
							console.log('localStorageCustArr :: ',localStorageCustArr);

							const allVisitedNames = new Set([
							                                 ...resValArr,
							                                 ...localStorageCustArr
							                                 ]);
							allVisitedNames.delete("");
							const allVisitedNamesArr = [...allVisitedNames];
							console.log('allVisitedNamesArr :: ',allVisitedNamesArr);

							const plannedV = customerData.find(element => element.hasOwnProperty(routeId));
							console.log('plannedV : ',plannedV);
							let plannedVArr = Object.values(plannedV)[0].split(",");
							console.log('plannedVArr : ',plannedVArr);

							let allVisited = false;
							if(plannedVArr.every(item => allVisitedNamesArr.includes(item)) && allVisitedNamesArr.every(item => plannedVArr.includes(item)))
							{
								allVisited = true;
							}
							console.log('All Visited..',allVisited);

							if(!allVisited) 
							{
								locCode = Object.values(res)[0].LOCALITY_CODE;
								locDescr = Object.values(res)[0].DESCR;
								stockistCode = Object.values(res)[0].STOCKIST_CODE;
								stockistName = Object.values(res)[0].STOCKIST_NAME;
								itemSer = Object.values(res)[0].ITEM_SER;
								stationdescr = Object.values(res)[0].STATION_DESCR;
								routeType = Object.values(res)[0].ROUTE_TYPE;
								invoiceNoD = Object.values(res)[0].INVOICE_NO;
								break;
							}
							else{
								routeId = "";
							}
						}
						for (const res of result) 
						{

							var route = Object.values(res)[0].ROUTE_ID;

							let resVal = '';
							visitedCust.forEach(e => {
								console.log('Object.keys(e)[0] : ',Object.keys(e)[0],Object.keys(e)[0] == parseInt(route));
								if(Object.keys(e)[0] == parseInt(route)){
									resVal = Object.values(e)[0];
									console.log('resval ::: ',resVal);
								}
							});

							let resValArr = resVal.split(",");
							console.log('resValArr :: ',resValArr);
							let localStorageCust = localStorage.getItem(evenDate+'_'+route+'_StrgCode');
							console.log('localStorageCust :: ',localStorageCust);
							let localStorageCustArr = localStorageCust ? localStorageCust.split(",") : [];
							console.log('localStorageCustArr :: ',localStorageCustArr);

							const allVisitedNames = new Set([
							                                 ...resValArr,
							                                 ...localStorageCustArr
							                                 ]);
							allVisitedNames.delete("");
							const allVisitedNamesArr = [...allVisitedNames];
							console.log('allVisitedNamesArr :: ',allVisitedNamesArr);

							const plannedV = customerData.find(element => element.hasOwnProperty(route));
							console.log('plannedV : ',plannedV);
							let plannedVArr = Object.values(plannedV)[0].split(",");
							console.log('plannedVArr : ',plannedVArr);

							let allVisited = false;
							if(plannedVArr.every(item => allVisitedNamesArr.includes(item)) && allVisitedNamesArr.every(item => plannedVArr.includes(item)))
							{
								allVisited = true;
							}
							console.log('All Visited..',allVisited);


							var beatDescr = Object.values(res)[0].DESCR;
							if(planBeats==null ||planBeats.trim().length==0)
							{
								planBeats=beatDescr;
							}
							else
							{
								planBeats=planBeats+", "+beatDescr;

							}

							if(planRoute==null ||planRoute.trim().length==0)
							{
								planRoute=route;
							}
							else
							{
								planRoute=planRoute+","+route;

							}
						}
					}
					if(itemSer !=null && itemSer.trim().length > 0)
					{
						custClassInput = itemSer;
					}
					// Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [END]
					//added by mrunalini sinkar to set default activity if no activity present in the dom
					//Added by Bhagyashri T on[28/Jul/21] for actvity place[start]
					if(activityPlace != 'R')
					{
						localStorage.setItem('_defActType', activityType);
						localStorage.setItem('_defActCode', eventType);
						localStorage.setItem('_defActDescr', activityDescr);
						localStorage.setItem('_defActPlaceReq', placeRequired);
						localStorage.setItem('_defParentActCode', parentActCode);
						localStorage.setItem('_defActivityTempl', activityTempl);
						localStorage.setItem('_defLocReq', locReq);
						localStorage.setItem('_defActivityPlace', activityPlace); //Added by Bhagyashri T on[28/Jul/21] for actvity place
					}
					//Added by Bhagyashri T on[28/Jul/21] for actvity place[end]
					//added by mrunalini sinkar to set default activity if no activity present in the dom
					var evenDate = localStorage.getItem( 'SYSTEM_DISP_DATE' );
					var empCode = localStorage.getItem( 'EMP_CODE' );
					empCode = getUserInfo( "empCode" );
					var empName = getUserInfo( "empName" );
					var currentGeoPOS = localStorage.getItem( 'CURRENT_GEO_POS' );
					var currentGeoPOSName = localStorage.getItem( 'CURRENT_GEO_POS_NAME' );
					var geoPosAccuracy = localStorage.getItem('GEOPOS_ACCURACY' );
					//added by mrunalini sinkar on 18-sep-2018 for chg_date changes(start)
					var currentTime = new Date();
					var time = getStartTime();
					var date=currentTime.getDate();
					var year = currentTime.getFullYear();
					var month=currentTime.getMonth();
					month=month+1;
					var chgDate = date +"/"+month+"/"+year;
					var visitedWith= localStorage.getItem(empCode.trim()+'_GET_VISITED_WITH'); // added by nilesh gunjal
					var othParticipant = localStorage.getItem(evenDate+'_OthParticipant');
					var activity = localStorage.getItem(evenDate+'_ActivityType');
					//Added By Mrunalini Sinkar (start)
					var eventCode = localStorage.getItem(evenDate+'_ActivityCode');
					var eventDescr = localStorage.getItem(evenDate+'_ActivityDescr');
					var actPlaceReq = localStorage.getItem(evenDate+'_ActivityPlaceReq');
					var parentActCodeStorage = localStorage.getItem(evenDate+'_ParentActivityCode');
					var activityTemplStorage = localStorage.getItem(evenDate+'_ActivityTemplate');
					//Added by Sadique on 27/06/2020 [loc_req related implementation]
					var locReqStorage = localStorage.getItem(evenDate+'_LocReq');
					//Added By Mrunalini Sinkar (end)
					//Added by Bhagyashri T[27/Jul/21][start]
					var activityplc = localStorage.getItem(evenDate+'_ActivityActPlace');
					//Added by Bhagyashri T[27/Jul/21][End]
					var locDetails = localStorage.getItem(evenDate+'_LocalityDetails');
					if(!routeId)
					{
						if(locDetails != null && locDetails.trim().length != 0)
						{
							var locDetailList = locDetails.split('|');

							locCode = locDetailList[0];
							locDescr = locDetailList[1];
							custClassInput = locDetailList[2];
							stockistCode = locDetailList[3];
							stockistName = locDetailList[4];
							routeId = locDetailList[5]; // added by mrunalini sinka to set routeId on 26-04-2019
							stationType = locDetailList[6] // added by mrunalini sinka to set routeId on 26-04-2019
									stationdescr = locDetailList[7];//added by mrunalini sinakr on 20-05-2019 for showing staion_descr on summary page
							routeType = locDetailList[8]; // added by mrunalini sinkar for route type on 24-05-2019
							invoiceNoD = locDetailList[9]; 
						}
					}

					// added by rupali on 07/03/19 to set order of visit on summary screen [start]
					var maxOrderVisit = 0;
					maxOrderVisit = localStorage.getItem(evenDate+'_OrderOfVisit');
					maxOrderVisit++;
					var localtyCode = localStorage.getItem(evenDate+'_LocalityCode');
					var locDetail = "";
					var flag = false;

					//alert("localtyCode callDefaultData:::"+localtyCode);
					if(localtyCode != null && localtyCode.trim().length != 0)
					{
						var locList = localtyCode.split(',');
						for(var i=0; i<locList.length; i++)
						{
							var locCodeNew = locList[i].split('@')[0];
							var locOrder = locList[i].split('@')[1];
							if(locCodeNew.trim() == locCode)
							{
								maxOrderVisit = locOrder;
							}
						}
					}
					else if(localityOrder != null && localityOrder.trim().length != 0)
					{
						localStorage.setItem(evenDate+'_LocalityCode', localityOrder);
						var locOrderOld = localityOrder.substring(localityOrder.lastIndexOf("@")+1,localityOrder.length);
						localStorage.setItem(evenDate+'_OrderOfVisit', locOrderOld);
					}
					// added by rupali on 07/03/19 to set order of visit on summary screen [end]

					//alert("activity::"+activity);
					//added by mrunalini sinkar on 18-sep-2018 for chg_date changes(end)
					//alert("empCode["+empCode+"]");
					//Added by Prasad on 19/12/19 [coaching related implementation] START
					selectedActivity = eventCode;
					console.log( "gradeType ["+ gradeType +"]eventCode["+eventCode );
					if( gradeType == 'M' )
					{
						if ( eventCode  == 'CA' )
						{
							itemChangeStr = "<Detail"+ objContext +" domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,survey\'  ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,survey]]></protect_subform><attribute pkNames='' status='N' updateFlag='A' selected='N' />" ;
						}
						else if( eventCode == 'OT' )
						{
							itemChangeStr = "<Detail"+ objContext +" domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><attribute pkNames='' status='N' updateFlag='A' selected='N' />" ;
						}
						if( eventCode == 'MI' )
						{
							itemChangeStr = "<Detail"+ objContext +" domID='1' protectSubform=\'coaching\' changeSubformName=\'survey:PeopleTrained\' ><protect_subform><![CDATA[coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
						}
						else
						{
							itemChangeStr = "<Detail"+ objContext +" domID='1' ><attribute pkNames='' status='N' updateFlag='A' selected='N' />" ;
						}
					}
					else
					{
						if( eventCode == 'MI' )
						{
							itemChangeStr = "<Detail"+ objContext +" domID='1' protectSubform=\'sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:PeopleTrained\'><protect_subform><![CDATA[sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:PeopleTrained]]></chg_subFormName>";
						}
						else if( eventCode == 'OT' )
						{
							itemChangeStr = "<Detail"+ objContext +" domID='1' protectSubform=\'brand,sampleorder,invoice,display,team,coaching\' changeSubformName=\'survey:Receipt\' ><protect_subform><![CDATA[brand,sampleorder,invoice,display,team,coaching]]></protect_subform><chg_subFormName><![CDATA[survey:Receipt]]></chg_subFormName><attribute pkNames='' status='N' updateFlag='A' selected='N' />" ;
						}
						else
						{
							itemChangeStr = "<Detail"+ objContext +" domID='1' protectSubform=\'coaching\'  ><protect_subform><![CDATA[coaching]]></protect_subform><attribute pkNames='' status='N' updateFlag='A' selected='N' />" ;
						}
					}
					//Added by Prasad on 19/12/19 [coaching related implementation] END
					//"<event_date protect = '1'><![CDATA["+evenDate+"]]></event_date>" +
					//"<activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr>" +//added by mrunalini sinkar for first for data model on 07-02-2019
					//"<event_type><![CDATA["+eventType+"]]></event_type>" +//added by mrunalini sinkar for first for data model on 07-02-2019
					//"<activity_type><![CDATA["+activityType+"]]></activity_type>" +//added by mrunalini sinkar for first for data model on 07-02-2019
					itemChangeStr += "<gender><![CDATA[M]]></gender>" +
							"<wf_status><![CDATA[P]]></wf_status>" +
							"<cust_type ><![CDATA[LISTED]]></cust_type>" +
							"<chg_date protect='1'><![CDATA["+evenDate+"]]></chg_date>" +
							"<chg_user protect='1'><![CDATA["+empCode+"]]></chg_user>" +
							"<confirmed><![CDATA[N]]></confirmed>" +
							"<sales_pers_sp_name protect = '1'><![CDATA["+empName+"]]></sales_pers_sp_name>"+
							"<sales_pers protect = '1'><![CDATA["+empCode+"]]></sales_pers>"+
							"<type_cust><![CDATA[L]]></type_cust>";//Added by bhagyashri t for contact_pers
					//added by Hariom S for fortune [18/05/2021]
					if( isFortuneActivity  == 'Y')
					{
						//alert("isFortuneActivity 00000::y"+isFortuneActivity);
						if( allowVisitTime  == 'Y')
						{
							//alert("allowVisitTime ::9999999999: Y"+allowVisitTime);

							itemChangeStr +="<event_time_start protect='0'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='0'><![CDATA["+time+"]]></event_time_end>"+
									"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
						}
						else if( allowVisitTime  == 'N')
						{
							//alert("allowVisitTime ::9999999999: N"+allowVisitTime);

							itemChangeStr +="<event_time_start protect='1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='1'><![CDATA["+time+"]]></event_time_end>"+
									"<visit_time_from protect ='1'><![CDATA["+time+"]]></visit_time_from>" ;
						}
						else if( allowVisitTime  == 'B')
						{
							//alert("allowVisitTime ::9999999999: B"+allowVisitTime);
							itemChangeStr +="<event_time_start protect='0' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect='0' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
									"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
						}
						else
						{
							//alert("allowVisitTime ::9999999999: else"+allowVisitTime);
							itemChangeStr +="<event_time_start protect = '1' visible = '1'><![CDATA["+time+"]]></event_time_start>" +
									"<event_time_end protect = '1' visible = '1'><![CDATA["+time+"]]></event_time_end>"+
									"<visit_time_from protect = '1'><![CDATA["+time+"]]></visit_time_from>" ;
						}


					}
					//added by Hariom S for fortune [18/05/2021]
					else
					{
						//alert("isFortuneActivity 00000::N"+isFortuneActivity);


						itemChangeStr +="<event_time_start visible = '1'><![CDATA["+time+"]]></event_time_start>" +
								"<event_time_end visible = '1'><![CDATA["+time+"]]></event_time_end>" +
								"<visit_time_from><![CDATA["+time+"]]></visit_time_from>" ;
					}

					itemChangeStr +="<copy_plan><![CDATA[N]]></copy_plan>" +
							"<visited_with_team><![CDATA["+empCode+"]]></visited_with_team>" + // added by rupali on 08/05-18 for single screen manager reporting
							"<add_geopos><![CDATA["+currentGeoPOS+"]]></add_geopos>" +
							"<chg_geopos><![CDATA["+currentGeoPOS+"]]></chg_geopos>" +
							"<geo_pos_name><![CDATA["+currentGeoPOSName+"]]></geo_pos_name>" +
							"<geopos_accuracy><![CDATA["+geoPosAccuracy+"]]></geopos_accuracy>" +
							//"<place_required><![CDATA["+placeRequired+"]]></place_required>" + //added by mrunalini sinkar for first for data model on 07-02-2019
							"<chg_date><![CDATA["+chgDate+"]]></chg_date>"+ //added by mrunalini sinkar on 18-sep-2018 for change date
							"<is_auto><![CDATA[Y]]></is_auto>"+ //added by mrunalini sinkar on 18-sep-2018 for change date
							"<entry_mode><![CDATA[A]]></entry_mode>"+ //added by kailash on 01-oct-2018 for entry_mode.
							"<visited_with><![CDATA["+visitedWith+"]]></visited_with>"+// added by nilesh gunjal
							"<subform_protect><![CDATA["+subProtect+"]]></subform_protect>"+
							"<oth_participant><![CDATA["+othParticipant+"]]></oth_participant>" +
							"<grade_type><![CDATA["+gradeType+"]]></grade_type>" +
							"<locality_code><![CDATA["+locCode+"]]></locality_code>" +
							"<locality_descr><![CDATA["+locDescr+"]]></locality_descr>" +
							"<route_id><![CDATA["+routeId+"]]></route_id>" +// added by mrunalini sinka to set routeId on 26-04-2019
							"<station_type><![CDATA["+stationType+"]]></station_type>" +
							"<cust_class_input><![CDATA["+custClassInput+"]]></cust_class_input>" +
							"<stockist_name><![CDATA["+stockistName+"]]></stockist_name>"+
							"<holiday_dates><![CDATA["+holidayDate+"]]></holiday_dates>"+ // added by mruanlini sinkar for holidays
							"<pending_dcr><![CDATA["+pendDcr+"]]></pending_dcr>"+
							"<allwd_delay_prd><![CDATA["+allDelay+"]]></allwd_delay_prd>" +
							"<order_of_visit><![CDATA["+maxOrderVisit+"]]></order_of_visit>"+
							"<station_descr><![CDATA["+stationdescr+"]]></station_descr>"+//added by mrunalini sinakr on 20-05-2019 for showing staion_descr on summary page
							"<future_date><![CDATA["+futureDate+"]]></future_date>"+ // aded by mrunalini sinkar
							"<cust_type_list><![CDATA["+custTypeListDef+"]]></cust_type_list>"+
							"<route_type><![CDATA["+routeType+"]]></route_type>" +
							"<invoice_no><![CDATA["+invoiceNoD+"]]></invoice_no>" +
							"<order_form_no><![CDATA["+orderFormNo+"]]></order_form_no>" +
							"<team_form_no><![CDATA["+teamFormNo+"]]></team_form_no>" +
							"<invoice_form_no><![CDATA["+invoiceFormNo+"]]></invoice_form_no>" +
							"<collection_form_no><![CDATA["+collectionFormNo+"]]></collection_form_no>" +
							"<host_url><![CDATA["+hostUrl+"]]></host_url>" +
							"<is_bangla><![CDATA["+isBangla+"]]></is_bangla>" + //Added by mrunalini sinkar for banglasdesh user validation
							"<bradn_aval><![CDATA["+branAval+"]]></bradn_aval>" + //Added by mrunalini sinkar for banglasdesh user validation
							"<apply_stp_val><![CDATA["+applyStpVal+"]]></apply_stp_val>" +
							"<emp_join_date><![CDATA["+joinDate+"]]></emp_join_date>" +
							"<allow_dar_rep><![CDATA["+allowDarRep+"]]></allow_dar_rep>" +
							"<emp_design><![CDATA["+designCode+"]]></emp_design>"+
							"<list_design_code><![CDATA["+listDesignCodes+"]]></list_design_code>"+
							"<is_member_present><![CDATA["+memberPresnt+"]]></is_member_present>" +
							"<member_present visible = '1' ><![CDATA[0]]></member_present>"+
							"<pitch_detail_data><![CDATA["+ pitchDetailList +"]]></pitch_detail_data>"+

							//added by prachi on 25-May-2022 [ W22AGOC002 ]
							"<qualification_list><![CDATA["+ qualList +"]]></qualification_list>"+
							"<strg_code_list><![CDATA["+ strgCodeList +"]]></strg_code_list>"+
							"<price_list><![CDATA["+ pricelist +"]]></price_list>"+//added by prachi on 02-august-22 [W22EBAS002]
							"<total_cgst><![CDATA["+ totCgst +"]]></total_cgst>"+//added by Bhagyashri on 12-august-22 [W22EBAS004]
							"<total_sgst><![CDATA["+ totSgst +"]]></total_sgst>"+//added by Bhagyashri on 12-august-22 [W22EBAS004]
							"<meeting_status_data><![CDATA["+ meetingStatusData +"]]></meeting_status_data>"+
							"<unlst_sccode_data><![CDATA["+ unlstScCodeData +"]]></unlst_sccode_data>"+  //Added by Bhagyashri T for Fortune EUIN no[15/02/2022]
							"<cnt_pers_data><![CDATA["+ cntPersData +"]]></cnt_pers_data>"+   //Added by Bhagyashri T for Fortune EUIN no[15/02/2022]
							"<cnt_pers_code><![CDATA["+ cntPersDataCd +"]]></cnt_pers_code>"+
							"<cust_type_detail><![CDATA["+custTypeDetail+"]]></cust_type_detail>"+ //added by shweta m
							"<cust_type_data><![CDATA["+custTypeData+"]]></cust_type_data>"+   //added by shweta m
							"<strg_event_info visible = '0' ><![CDATA["+strgEventInfo+"]]></strg_event_info>"; ////Added by sadique shaikh 02-03-2020 [For Event info for customer]
					if( eventCode  == 'CA')
					{
						itemChangeStr +="<strg_code><![CDATA[NA]]></strg_code><future_date_act visible = '0'  ><![CDATA["+futureDateAct+"]]></future_date_act>" +
								"<stockist_code visible = '0'><![CDATA["+stockistCode+"]]></stockist_code>" +
								"<next_plan_date visible = '0' ><![CDATA[]]></next_plan_date><oth_participant protect = '1' visible = '0'></oth_participant>" +
								"<addr1 protect = '1' visible = '0'></addr1><addr2 protect = '1' visible = '0'></addr2><addr3 protect = '1' visible = '0'></addr3><age protect = '1' visible = '0'></age>" +
								"<address_as protect = '1' visible = '1'></address_as><gender protect='1' visible = '0'><![CDATA[M]]></gender><mobile_no protect = '1' visible = '0'></mobile_no>" +
								"<email_addr protect = '1' visible = '0'></email_addr><strg_class_code protect = '1' visible = '0'></strg_class_code><class_code_descr protect = '1' visible = '0'></class_code_descr>" +
								"<spl_code protect = '1' visible = '0'></spl_code><speciality_descr protect = '1' visible = '0'></speciality_descr><strg_type protect = '1' visible = '0'></strg_type>" +
								"<visited_with_design_code protect = '1' visible = '0'></visited_with_design_code><reg_no visible = '0'></reg_no><meeting_status visible = '0'></meeting_status><last_meet_summ visible = '0'></last_meet_summ>" +
								"<last_meet_date visible = '0'></last_meet_date><contact_pers visible = '0'></contact_pers><contact_pers_name visible = '0'></contact_pers_name><member_present visible = '0'><![CDATA[]]></member_present>" +
								"<pob_item visible = '0'><![CDATA[]]></pob_item><sku_value visible = '0'><![CDATA[]]></sku_value><qualification visible = '0'></qualification><promoter_name visible = '0'><![CDATA[]]></promoter_name>" +
								"<man_power visible = '0'><![CDATA[]]></man_power><image_id visible = '0'><![CDATA[]]></image_id><gst_no visible = '0'><![CDATA[]]></gst_no><subclass_code visible = '0'><![CDATA[]]></subclass_code>" +
								"<pin visible = '0'><![CDATA[]]></pin><beat_plan visible = '0'><![CDATA[]]></beat_plan><subclass_descr visible = '0'><![CDATA[]]></subclass_descr>";
					}
					else
					{
						itemChangeStr +="<future_date_act><![CDATA["+futureDateAct+"]]></future_date_act>";
					}
					if(displayTimeField == 'Y')
					{

					}
					else
					{

					}


					itemChangeStr +="<headquarter><![CDATA["+headQuarter+"]]></headquarter>" +   //Added by mrunalini sinkar to showing headquarter on summary
							"<stan_code__hq><![CDATA["+stanCodeHQ+"]]></stan_code__hq>" +
							"<load_no><![CDATA["+loadNo+"]]></load_no>" +
							"<vehicle_no><![CDATA["+vehicleNo+"]]></vehicle_no>" +
							"<view_to><![CDATA["+viewTo+"]]></view_to>" +   //Added by mrunalini sinkar to showing headquarter on summary
							"<allow_stockist_dar><![CDATA["+realparmValue+"]]></allow_stockist_dar>" +
							"<grade><![CDATA["+gradeType+"]]></grade>" +//added by mrunalini sinkar for member present in unlisted customer
							"<tot_allow_call_list><![CDATA["+totAllwCallList+"]]></tot_allow_call_list>" +
							"<tot_call_list><![CDATA["+listCnt+"]]></tot_call_list>"+
							"<grade_code><![CDATA["+ gradeCode +"]]></grade_code>"+
							"<form_mandatory><![CDATA["+ formMandatory +"]]></form_mandatory>"+
							"<set_visit_time><![CDATA["+ setVisitTime +"]]></set_visit_time>"+
							"<display_time_fld><![CDATA["+ displayTimeField +"]]></display_time_fld>"+ //added by shraddha M[17/07/2020]
							//Added by Pooja on 14-AUGUST-2020 [Coaching related detail form implementation]
							"<coaching_design_code><![CDATA["+ visitedWithDesignCodeArr +"]]></coaching_design_code>"+
							"<resign_emp><![CDATA[N]]></resign_emp>";

					console.log("eventCode sadique ["+ eventCode +"]");
					if(eventCode == 'OT')
					{
						itemChangeStr += "<cust_conf visible = '1'><![CDATA[]]></cust_conf>" +
								"<cust_conf_proof visible = '1'><![CDATA[]]></cust_conf_proof>" +
								"<pob_item  visible = '1'><![CDATA[]]></pob_item>"+
								"<stockist_name visible = '0'><![CDATA["+stockistName+"]]></stockist_name>";
					}
					else
					{
						itemChangeStr += "<cust_conf visible = '0'><![CDATA[]]></cust_conf>" +
								"<cust_conf_proof visible = '0'></cust_conf_proof>" +
								"<pob_item  visible = '0'><![CDATA[]]></pob_item>" +
								"<stockist_name visible = '1'><![CDATA["+stockistName+"]]></stockist_name>";
					}
					//Added by sadique shaikh on 18-02-2020 [For Event Type  OT connect ] Start
					//"</Detail"+ objContext +">";
					console.log("activity ["+ activity +"]");
					if((activity != null && activity.trim().length != 0) || ( parentActCodeStorage !=null && parentActCodeStorage.trim().length != 0 ))
					{
						itemChangeStr += "<event_type ><![CDATA["+eventCode+"]]></event_type><activity_descr protect = '1'><![CDATA["+eventDescr+"]]></activity_descr>" +
								"<activity_type><![CDATA["+activity+"]]></activity_type><place_required><![CDATA["+actPlaceReq+"]]></place_required><parent_act_code><![CDATA["+parentActCodeStorage+"]]></parent_act_code><activity_templ><![CDATA["+activityTemplStorage+"]]></activity_templ><activity_place><![CDATA["+activityplc+"]]></activity_place>" ; //Added by Bhagyashri T on[28/Jul/21] for actvity place
					}
					else
					{
						itemChangeStr += "<event_type ><![CDATA["+eventType+"]]></event_type><activity_descr protect = '1'><![CDATA["+activityDescr+"]]></activity_descr>" +
								"<activity_type><![CDATA["+activityType+"]]></activity_type><place_required><![CDATA["+placeRequired+"]]></place_required><parent_act_code><![CDATA["+parentActCode+"]]></parent_act_code><activity_place><![CDATA["+activityPlace+"]]></activity_place>" ; //Added by Bhagyashri T on[28/Jul/21] for actvity place
					}
					//Added by Sadique on 27/06/2020 [loc_req related implementation] START
					console.log("locReqStorage ["+ locReqStorage +"]");
					if((activity != null && activity.trim().length != 0) || ( locReqStorage !=null && locReqStorage.trim().length > 0 ))
					{
						itemChangeStr += "<loc_req><![CDATA["+ locReqStorage +"]]></loc_req>";
					}
					else
					{
						itemChangeStr += "<loc_req><![CDATA["+ locReq +"]]></loc_req>";
					}
					//Added by Sadique on 27/06/2020 [loc_req related implementation] END

					// addded by mrunalini sinkar for all_delay_prd on 28-feb-2018(start)
					if(allDelay >0)
					{
						itemChangeStr += "<event_date protect = '0'><![CDATA["+evenDate+"]]></event_date>";
					}
					else
					{
						itemChangeStr += "<event_date protect = '1'><![CDATA["+evenDate+"]]></event_date>";
					}
					// addded by mrunalini sinkar for all_delay_prd on 28-feb-2018(end)
					//alert("isFortuneActivity callDefaultData:::"+isFortuneActivity);
					//alert("allowVisitTime callDefaultData:::"+allowVisitTime);
					itemChangeStr +="<allow_chg_visittime><![CDATA["+ allowVisitTime +"]]></allow_chg_visittime>"+
							"<is_fortune_activity><![CDATA["+ isFortuneActivity +"]]></is_fortune_activity>"+
							"<item_ser><![CDATA["+ itemSer +"]]></item_ser>"+
							"<plan_days><![CDATA["+ weekAndDay +"]]></plan_days>"+ // Added by Pankaj R on 15-JUL-21 to set the route bydefault if it is defined in sprs_route [START]
							"<event_week_day><![CDATA["+ weekAndDay +"]]></event_week_day>"+
							"<route_plan><![CDATA["+ planRoute +"]]></route_plan>"+
							"<plan_chg_reas visible = '0'><![CDATA[1]]></plan_chg_reas>"+
							"<beat_change_descr><![CDATA["+beatChnageReasonDescr+"]]></beat_change_descr>"+
							"<beat_change_udf><![CDATA["+beatchangeReasonUdf+"]]></beat_change_udf>"+
							"<sku_value><![CDATA[]]></sku_value>"+
							"<net_amt><![CDATA[0]]></net_amt>"+
							"<tax_amount><![CDATA[0]]></tax_amount>"+
							"<amount><![CDATA[0]]></amount>"+
							"<basic_value><![CDATA[Basic:0]]></basic_value>" +
							"<total_gst><![CDATA[GST:0]]></total_gst>" +
							"<total_value><![CDATA[Total Amount:0]]></total_value>" +
							"<plan_chg_reason_descr><![CDATA[]]></plan_chg_reason_descr>"+
							"<plan_chg_reason_udf visible = '0'><![CDATA[]]></plan_chg_reason_udf>"+
							"<age visible='0'><![CDATA[]]></age>"+
							"<qualification visible='0'><![CDATA[]]></qualification>"+
							"<beat_plan><![CDATA["+ planBeats +"]]></beat_plan>" +
							"<sales_type><![CDATA[I]]></sales_type>" ;

					itemChangeStr += "</Detail"+ objContext +">";
				}
				console.log('itemChangeStr calldefault data ['+itemChangeStr+']');
			}
			catch(e)
			{
				console.log("catch ["+e);
			}
		}


		//console.log("itemChangeStr ["+ itemChangeStr +"]");
		//alert("itemChangeStr::"+itemChangeStr);
		return itemChangeStr;
	}
	else if(objName ==='stocks_transfer_wiz')
	{

		console.log("inside call default data:"+currentFormData+" objContext:"+objContext+" action:"+action);
		var itemChangeStr="";
		var currentFormData=currentFormData;
		var xmlVersion = currentFormData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			if(xmlVersion == 0)
			{
				currentFormData = currentFormData;
			}
			else
			{
				currentFormData = "<Root>"+currentFormData+"</Root>";
			}
		}
		else
		{
			console.log("null currentformdata localPostItemChange");
		}
		console.log("before window parser:"+window.DOMParser);
		if (window.DOMParser)
		{
			console.log("inside window parser");
			parser=new DOMParser();
			console.log("parser defined");
			try
			{
				if(currentFormData != null && currentFormData.trim().length > 0)
				{
					console.log("inside try defined");
					xmlDoc = parser.parseFromString(currentFormData,"text/xml");
				}
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data localPostItemChange");
			}
		}
		else // Internet Explorer
		{
			console.log("else window parser");
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
			console.log("else end window parser");
		}
		if(xmlDoc != null )
		{

			try
			{
				if( action=='defaultData' && objContext=='1' )
				{
					var detailElement = xmlDoc.getElementsByTagName("Detail"+objContext);
					console.log("detailElement is:"+detailElement);
					var locCodeFR="",locDescrFR="";
					var siteCode="",itemSer="",chgDate="",chgTerm="",hoUser="",stockloclist="",locCodeTolist="",chgUser="",confirm="",refser="",trandate="",locCodeTo="",locCodeToDescr="",empCodeAprv="",invoiceFormNo="";
					for (var i = 0; i < detailElement.length; i++)
					{
						var detail = detailElement[i];
						console.log("detail column::"+detail)
						if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
						{
							locCodeFR = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
							console.log("locCodeFR in "+locCodeFR);
						}

						if( detail.getElementsByTagName("loc_descr_fr")[0] != null && detail.getElementsByTagName("loc_descr_fr")[0].childNodes[0] != null )
						{
							locDescrFR = detail.getElementsByTagName("loc_descr_fr")[0].childNodes[0].nodeValue;
							console.log("locDescrFR in "+locDescrFR);
						}
						if( detail.getElementsByTagName("site_code")[0] != null && detail.getElementsByTagName("site_code")[0].childNodes[0] != null )
						{
							siteCode = detail.getElementsByTagName("site_code")[0].childNodes[0].nodeValue;
							console.log("siteCode in "+siteCode);
						}
						if( detail.getElementsByTagName("item_ser")[0] != null && detail.getElementsByTagName("item_ser")[0].childNodes[0] != null )
						{
							itemSer = detail.getElementsByTagName("item_ser")[0].childNodes[0].nodeValue;
							console.log("itemSer in "+itemSer);
						}
						if( detail.getElementsByTagName("ref_ser__for")[0] != null && detail.getElementsByTagName("ref_ser__for")[0].childNodes[0] != null )
						{
							refser = detail.getElementsByTagName("ref_ser__for")[0].childNodes[0].nodeValue;
							console.log("refser in "+refser);
						}
						if( detail.getElementsByTagName("tran_date")[0] != null && detail.getElementsByTagName("tran_date")[0].childNodes[0] != null )
						{
							trandate = detail.getElementsByTagName("tran_date")[0].childNodes[0].nodeValue;
							console.log("trandate in "+trandate);
						}
						if( detail.getElementsByTagName("chg_date")[0] != null && detail.getElementsByTagName("chg_date")[0].childNodes[0] != null )
						{
							chgDate = detail.getElementsByTagName("chg_date")[0].childNodes[0].nodeValue;
							console.log("chgDate in "+chgDate);
						}
						if( detail.getElementsByTagName("chg_term")[0] != null && detail.getElementsByTagName("chg_term")[0].childNodes[0] != null )
						{
							chgTerm = detail.getElementsByTagName("chg_term")[0].childNodes[0].nodeValue;
							console.log("chgTerm in "+chgTerm);
						}
						if( detail.getElementsByTagName("chg_user")[0] != null && detail.getElementsByTagName("chg_user")[0].childNodes[0] != null )
						{
							chgUser = detail.getElementsByTagName("chg_user")[0].childNodes[0].nodeValue;
							console.log("chgUser in "+chgUser);
						}

						if( detail.getElementsByTagName("emp_code__aprv")[0] != null && detail.getElementsByTagName("emp_code__aprv")[0].childNodes[0] != null )
						{
							empCodeAprv = detail.getElementsByTagName("emp_code__aprv")[0].childNodes[0].nodeValue;
							console.log("emp_code__aprv in "+empCodeAprv);
						}
						if( detail.getElementsByTagName("loc_code_list")[0] != null && detail.getElementsByTagName("loc_code_list")[0].childNodes[0] != null )
						{
							stockloclist = detail.getElementsByTagName("loc_code_list")[0].childNodes[0].nodeValue;
							console.log("loc_code_list in "+stockloclist);
						}
						if( detail.getElementsByTagName("loc_code_to_list")[0] != null && detail.getElementsByTagName("loc_code_to_list")[0].childNodes[0] != null )
						{
							locCodeTolist = detail.getElementsByTagName("loc_code_to_list")[0].childNodes[0].nodeValue;
							console.log("loc_code_to_list in "+locCodeTolist);
						}
						if( detail.getElementsByTagName("invoice_form_no")[0] != null && detail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
						{
							invoiceFormNo = detail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
							console.log("invoice_form_no in stock"+invoiceFormNo);
						}
						if( detail.getElementsByTagName("is_houser")[0] != null && detail.getElementsByTagName("is_houser")[0].childNodes[0] != null )
						{
							hoUser = detail.getElementsByTagName("is_houser")[0].childNodes[0].nodeValue;
							console.log("is_houser in stock"+hoUser);
						}


						console.log("locCodeFR"+locCodeFR);
					}

					itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
					itemChangeStr +=
							"<Detail"+objContext+" domID = '1' selected = 'N'>\r\n"+
									"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";
					if((locCodeFR==null && locCodeFR.trim().length==0) || hoUser=='Y')
					{
						itemChangeStr +="<loc_code__fr><![CDATA[]]></loc_code__fr>\r\n"+
								"<loc_descr_fr><![CDATA[]]></loc_descr_fr>\n";
					}
					else
					{
						itemChangeStr += "<loc_code__fr protect='1'><![CDATA["+locCodeFR+"]]></loc_code__fr>\r\n"+
								"<loc_descr_fr><![CDATA["+locDescrFR+"]]></loc_descr_fr>\n";
					}

					//itemChangeStr +="<loc_code__to><![CDATA[]]></loc_code__to>\r\n"+
					//"<loc_descr_to><![CDATA[]]></loc_descr_to>\r\n"+
					itemChangeStr +="<site_code><![CDATA["+siteCode+"]]></site_code>"+
							"<tran_id><![CDATA[]]></tran_id>"+
							"<tran_date><![CDATA["+trandate+"]]></tran_date>"+
							"<item_ser><![CDATA["+itemSer+"]]></item_ser>"+
							"<chg_date><![CDATA["+chgDate+"]]></chg_date>"+
							"<chg_term><![CDATA["+chgTerm+"]]></chg_term>"+
							"<chg_user><![CDATA["+chgUser+"]]></chg_user>"+
							"<confirmed><![CDATA[N]]></confirmed>"+
							"<emp_code__aprv><![CDATA["+empCodeAprv+"]]></emp_code__aprv>"+
							"<loc_code_list><![CDATA["+stockloclist+"]]></loc_code_list>"+
							"<loc_code_to_list><![CDATA["+locCodeTolist+"]]></loc_code_to_list>"+
							"<ref_ser__for><![CDATA["+refser+"]]></ref_ser__for>"+
							"<tran_type><![CDATA[I]]></tran_type>"+
							"<reas_code><![CDATA[R05]]></reas_code>"+
							"<invoice_form_no><![CDATA["+invoiceFormNo+"]]></invoice_form_no>"+
							"</Detail"+objContext+">\r\n"+
							"</Root>";
				}
			}
			catch(e)
			{
				console.log("catch ["+e);
			}
		}  
		console.log("return from calldefaultdata::"+itemChangeStr);
		return itemChangeStr;  
	}
	else if(objName ==='stocks_receive_wiz')
	{
		var itemChangeStr="";
		console.log("Inside callDefaultData function in stock receive action["+action+"]");
		try
		{
			console.log("Inside callDefaultData function in stock receive objContext["+objContext+"]");
			if( action=='defaultData' && objContext=='1' )
			{
				itemChangeStr = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
				itemChangeStr +=
						"<Detail"+objContext+" domID = '1' selected = 'N'>\r\n"+
								"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
								"<scan_input><![CDATA[]]></scan_input>\r\n"+
								"<loc_code__fr><![CDATA[]]></loc_code__fr>\r\n"+
								"<loc_code__to><![CDATA[]]></loc_code__to>\r\n"+
								"<item_code><![CDATA[]]></item_code>\r\n"+ 
								"<item_descr><![CDATA[]]></item_descr>"+
								"<quantity><![CDATA[]]></quantity>"+
								"<invoice_form_no><![CDATA[]]></invoice_form_no>"+
								"</Detail"+objContext+">\r\n"+
								"</Root>";
			}
		}
		catch(e)
		{
			console.log("catch ["+e);
		}
		console.log("return from calldefaultdata in stock receive from real time::"+itemChangeStr);
		return itemChangeStr;
	} 
}
//added by mrunalini sinkar on 16/02/2018 for auto mode(start)
function getStartTime()
{
	var strTime="";
	try
	{
		var date=new Date();
		var hours = date.getHours();
		var minutes = date.getMinutes();
		var ampm = hours >= 12 ? 'PM' : 'AM';
		hours = hours % 12;
		hours = hours ? hours : 12;
		minutes = minutes < 10 ? '0'+minutes : minutes;
		strTime = hours + ':' + minutes + ' ' + ampm;

	}
	catch(e)
	{
		console.log("catch ["+e);
	}
	return strTime;
}
function getMonth(month)
{
	var monthNumber="";
	try
	{
		if(month=="Jan")
		{
			monthNumber="1";
		}
		else if(month=="Feb")
		{
			monthNumber="2";
		}
		else if(month=="Mar")
		{
			monthNumber="3";
		}
		else if(month=="Apr")
		{
			monthNumber="4";
		}
		else if(month=="May")
		{
			monthNumber="5";
		}
		else if(month=="Jun")
		{
			monthNumber="6";
		}
		else if(month=="Jul")
		{
			monthNumber="7";
		}
		else if(month=="Aug")
		{
			monthNumber="8";
		}
		else if(month=="Sep")
		{
			monthNumber="9";
		}
		else if(month=="Oct")
		{
			monthNumber="10";
		}
		else if(month=="Nov")
		{
			monthNumber="11";
		}
		else if(month=="Dec")
		{
			monthNumber="12";
		}
	}
	catch(e)
	{
		console.log("catch ["+e);
	}
	return monthNumber;
}
//added by mrunalini sinkar for offline validation ON 16-FEB-2018(end)

//added by Sandeep S. for sync on 7-march-18(start)
function getDetailData( objContext, objName, formDetailData, objFormName, parentFormNo, parentFormData )
{
	globalObjName = objName;
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		var dummyXml = "<Root></Root>";
		var dummyXmlDoc = null;
		var parentFormDom = null;
		var xmlVersion = formDetailData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if( formDetailData != null && formDetailData.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( formDetailData.indexOf("<Root>") == -1 )
				{
					formDetailData = "<Root>"+formDetailData+"</Root>";
				}
			}
		}
		else
		{
			console.log("null formDetailData");
		}

		//Added by Prasad on 19/12/19 [coaching related implementation] START
		if( parentFormData != null && parentFormData.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( parentFormData.indexOf("<Root>") == -1 )
				{
					parentFormData = "<Root>"+parentFormData+"</Root>";
				}
			}
		}
		else
		{
			console.log("null parentFormData");
		}
		//Added by Prasad on 19/12/19 [coaching related implementation] END

		if ( window.DOMParser )
		{
			parser = new DOMParser();
			try
			{
				if( formDetailData != null && formDetailData.trim().length > 0 )
				{
					xmlDoc = parser.parseFromString( formDetailData, "text/xml" );
				}
				if( parentFormData != null && parentFormData.trim().length > 0 )
				{
					parentFormDom = parser.parseFromString( parentFormData, "text/xml" );
				}
				dummyXmlDoc = parser.parseFromString( dummyXml, "text/xml" );
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async = false;
			xmlDoc.loadXML( formDetailData );

			dummyXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			dummyXmlDoc.async = false;
			dummyXmlDoc.loadXML( dummyXml );
		}

		if( xmlDoc != null )
		{
			if( objFormName == 'brand1' )
			{
				if ( xmlDoc.evaluate )
				{
					var filteredNodes = xmlDoc.evaluate( "//Detail"+ objContext +"[normalize-space(brand_code)='C0022']", xmlDoc, null, XPathResult.ANY_TYPE, null );
					//console.log('This document contains ' + nodes + ' paragraph elements');
					var filterNode = filteredNodes.iterateNext();
					while ( filterNode )
					{
						var copiedNode = dummyXmlDoc.importNode( filterNode, true );
						dummyXmlDoc.documentElement.appendChild( copiedNode );

						filterNode = filteredNodes.iterateNext();
					}
					dummyXmlDoc.normalize();
					var filteredXml = new XMLSerializer().serializeToString( dummyXmlDoc );
					return filteredXml;
				}
			}
			else if( objFormName == 'brand' )
			{
				var brandWorkDate = "", brandSalesPers = "", brandStrgCode = "",brandcallOutcome="";

				brandWorkDate = workDate;
				brandSalesPers = SalesPers;
				brandScCode = scCode;

				if(brandWorkDate == null || brandWorkDate.trim().length == 0)
				{
					var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("event_date")[0] != null && parentDetail.getElementsByTagName("event_date")[0].childNodes[0] != null )
						{
							brandWorkDate = parentDetail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("sales_pers")[0] != null && parentDetail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
						{
							brandSalesPers = parentDetail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("strg_code")[0] != null && parentDetail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							brandScCode = parentDetail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						}
					}
				}

				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					brandcallOutcome = parentDetail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue;
				}
				//alert("brandWorkDate::"+brandWorkDate);
				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				console.log("workDate ==> "+workDate);
				console.log("SalesPers ==> "+SalesPers);
				console.log("scCode ==> "+scCode);
				console.log("brandcallOutcome ==> "+brandcallOutcome);



				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
					var domIDVal = detail.getAttribute("domID");
					//if( workDate != null )
					if( brandWorkDate != null )
					{
						//detail.getElementsByTagName("work_date")[0].childNodes[0].nodeValue = workDate;
						detail.getElementsByTagName("work_date")[0].childNodes[0].nodeValue = brandWorkDate;
					}
					//if( SalesPers != null )
					if( brandSalesPers != null )
					{
						//detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue = SalesPers;
						detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue = brandSalesPers;
					}
					//if( scCode != null )
					if( brandScCode != null )
					{
						//detail.getElementsByTagName("sc_code")[0].childNodes[0].nodeValue = scCode;
						detail.getElementsByTagName("sc_code")[0].childNodes[0].nodeValue = brandScCode;
					}
					if(brandcallOutcome!=null)
					{
						detail.getElementsByTagName("call_outcome")[0].childNodes[0].nodeValue = brandcallOutcome;

					}
					//return filteredXml;
				}
				xmlDoc.normalize();
				formDetailData = new XMLSerializer().serializeToString( xmlDoc );
			}
			else if( objFormName == 'display' )
			{
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";

				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var dispStrgCode="",dispArea="",brandCode="",brandDescr="",targetQty="";
				var dispCount = 0;
				for (var i = 0; i < detailElement.length; i++)
				{

					var detail = detailElement[i];
					var domId = detail.getAttribute("domID");

					if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
					{
						dispStrgCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("display_area")[0] != null && detail.getElementsByTagName("display_area")[0].childNodes[0] != null )
					{
						dispArea = detail.getElementsByTagName("display_area")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("brand_code")[0] != null && detail.getElementsByTagName("brand_code")[0].childNodes[0] != null )
					{
						brandCode = detail.getElementsByTagName("brand_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("brand_descr")[0] != null && detail.getElementsByTagName("brand_descr")[0].childNodes[0] != null )
					{
						brandDescr = detail.getElementsByTagName("brand_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("target_qty")[0] != null && detail.getElementsByTagName("target_qty")[0].childNodes[0] != null )
					{
						targetQty = detail.getElementsByTagName("target_qty")[0].childNodes[0].nodeValue;
					}

					if(dispStrgCode == scCode)
					{
						dispCount++;
						formDetailData +=
								"<Detail"+objContext+" domID='" + dispCount + "' selected = 'N'>\r\n"+
										"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
										"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
										"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
										"<strg_code><![CDATA["+dispStrgCode+"]]></strg_code>\n"+
										"<doc_id><![CDATA[]]></doc_id>\n"+
										"<doc_id_1><![CDATA[]]></doc_id_1>\n"+
										"<display_area><![CDATA["+dispArea+"]]></display_area>\r\n"+
										"<tran_id><![CDATA[]]></tran_id>\r\n"+
										"<disp_type><![CDATA[]]></disp_type>\r\n"+
										"<brand_code visible = '0'><![CDATA["+brandCode+"]]></brand_code>\r\n"+
										"<quantity visible = '1'><![CDATA[]]></quantity>\r\n"+
										"<brand_descr visible = '1'><![CDATA["+brandDescr+"]]></brand_descr>"+
										"<target_qty visible = '1'><![CDATA["+targetQty+"]]></target_qty>"+
										"</Detail"+objContext+">";

						/*detail.getElementsByTagName("line_no")[0].childNodes[0].nodeValue = domId;
						detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue = dispStrgCode;
						detail.getElementsByTagName("display_area")[0].childNodes[0].nodeValue = dispArea;
						detail.getElementsByTagName("brand_code")[0].childNodes[0].nodeValue = brandCode;
						detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue = brandCode;
						detail.getElementsByTagName("brand_descr")[0].childNodes[0].nodeValue = brandDescr;
						detail.getElementsByTagName("target_qty")[0].childNodes[0].nodeValue = targetQty;
						xmlDoc.normalize();
						formDetailData = new XMLSerializer().serializeToString( xmlDoc );
						alert("formDetailData:::::["+formDetailData+"]");*/

					}
				}
				if(dispCount == 0)
				{
					formDetailData +=
							"<Detail"+objContext+" domID = '1' selected = 'N'>\r\n"+
									"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
									"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
									"<line_no><![CDATA[1]]></line_no>\r\n"+
									"<strg_code><![CDATA["+scCode+"]]></strg_code>\n"+
									"<doc_id><![CDATA[]]></doc_id>\n"+
									"<doc_id_1><![CDATA[]]></doc_id_1>\n"+
									"<display_area><![CDATA[]]></display_area>\r\n"+
									"<tran_id><![CDATA[]]></tran_id>\r\n"+
									"<disp_type><![CDATA[]]></disp_type>\r\n"+
									"<brand_code visible = '1'><![CDATA[]]></brand_code>\r\n"+
									"<quantity visible = '1'><![CDATA[]]></quantity>\r\n"+
									"<brand_descr visible = '1'><![CDATA[]]></brand_descr>"+
									"<target_qty visible = '0'><![CDATA["+targetQty+"]]></target_qty>"+
									"</Detail"+objContext+">";
				}
				formDetailData += "</Root>";
				//alert("formDetailData:::::"+formDetailData);

			}
			//added by prachi on 04-aug [W22EBAS005] getDefaultData
			else if( objFormName == 'collection' )
			{
				if((callOutCmGlobal != '0' && callOutCmGlobal != '9') && invoiceFlg== true && updateFlg == true) 
				{
					alert("Invoice form is mandatory ! Please select the Invoice form first");
					return formDetailData="<Root><Header><editFlag>A</editFlag></Header><Errors></Errors></Root>";
				}
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				var amount = "",MaxCashSalesAmt= "",custName="" ;
				var amountRoundOff = 0;
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("amount")[0] != null && parentDetail.getElementsByTagName("amount")[0].childNodes[0] != null )
					{
						amount = parentDetail.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("strg_name")[0] != null && parentDetail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
					{
						custName = parentDetail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
						custName=custName.trim();
					}

				}
				
				amountRoundOff = Math.round(amount);
				
				for (var i = 0; i < detailElement.length; i++)
				{

					var detail = detailElement[i];
					if( detail.getElementsByTagName("max_amount")[0] != null && detail.getElementsByTagName("max_amount")[0].childNodes[0] != null )
					{
						MaxCashSalesAmt=detail.getElementsByTagName("max_amount")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("strg_name")[0] != null && detail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
					{
						custName = detail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
						custName=custName.trim();
					}
				}

				var currentDate = localStorage.getItem( 'SYSTEM_DISP_DATE' );
				if (salesTypeGlobal == 'C')
				{
					formDetailData +=
						"<Detail"+objContext+" domID = '1' selected = 'N'>\r\n"+
								"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
								"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
								"<line_no><![CDATA[1]]></line_no>\r\n"+
								"<strg_code><![CDATA[]]></strg_code>\n"+
								"<tran_id><![CDATA[]]></tran_id>\r\n"+
								"<selectbox><![CDATA[true]]></selectbox>"+
								"<bill_amt protect='1'><![CDATA["+amount+"]]></bill_amt>\r\n"+
								"<bill_date protect='1'><![CDATA["+currentDate+"]]></bill_date>\r\n"+
								"<pay_mode protect='1'><![CDATA[C]]></pay_mode>\r\n"+
								"<ref_no visible = '0'><![CDATA[]]></ref_no>\r\n"+
								"<ref_date visible = '0'><![CDATA[]]></ref_date>\r\n"+
								"<amount><![CDATA["+amountRoundOff+"]]></amount>\r\n"+
								"<ref_bank visible = '0'><![CDATA[]]></ref_bank>\r\n"+
								"<max_amount><![CDATA["+MaxCashSalesAmt+"]]></max_amount>\r\n"+				
								"<remarks_collect><![CDATA[]]></remarks_collect>\r\n"+
								"<cust_name><![CDATA["+custName+"]]></cust_name>\r\n"+
								"</Detail"+objContext+">\r\n"+
								"</Root>";
				}
				else
				{
				
				formDetailData +=
						"<Detail"+objContext+" domID = '1' selected = 'N'>\r\n"+
								"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
								"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
								"<line_no><![CDATA[1]]></line_no>\r\n"+
								"<strg_code><![CDATA[]]></strg_code>\n"+
								"<tran_id><![CDATA[]]></tran_id>\r\n"+
								"<selectbox><![CDATA[true]]></selectbox>"+
								"<bill_amt protect='1'><![CDATA["+amount+"]]></bill_amt>\r\n"+
								"<bill_date protect='1'><![CDATA["+currentDate+"]]></bill_date>\r\n"+
								"<pay_mode protect='0'><![CDATA[Q]]></pay_mode>\r\n"+
								"<ref_no visible = '1'><![CDATA[]]></ref_no>\r\n"+
								"<ref_date visible = '1'><![CDATA["+currentDate+"]]></ref_date>\r\n"+
								"<amount><![CDATA["+amountRoundOff+"]]></amount>\r\n"+
								"<ref_bank visible = '1'><![CDATA[]]></ref_bank>\r\n"+
								"<max_amount><![CDATA["+MaxCashSalesAmt+"]]></max_amount>\r\n"+				
								"<remarks_collect><![CDATA[]]></remarks_collect>\r\n"+
								"</Detail"+objContext+">\r\n"+
								"</Root>";
				}
			}
			//Added by Prasad on 19/12/19 [to display selected workwith in team form] START
			else if( objFormName == 'team' )
			{
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var teamCode="",empName="",teamHierarchy="",empDesign="",designation="",empNameDesign="",empDesignCode="",salesPers="",visitedWithCode="",vistedWith="",vistedWithTeam="",visitedWithDesignCode="",mobileNo="";
				var dispCount = 0;
				//var memcodeData ="";
				var strgCodeprnt ="";
				var strgCdsub ="";
				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("visited_with")[0] != null && parentDetail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
					{
						vistedWith = parentDetail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("visited_with_code")[0] != null && parentDetail.getElementsByTagName("visited_with_code")[0].childNodes[0] != null )
					{
						visitedWithCode = parentDetail.getElementsByTagName("visited_with_code")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("visited_with_design_code")[0] != null && parentDetail.getElementsByTagName("visited_with_design_code")[0].childNodes[0] != null )
					{
						visitedWithDesignCode = parentDetail.getElementsByTagName("visited_with_design_code")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("strg_code")[0] != null && parentDetail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
					{
						strgCodeprnt = parentDetail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						strgCodeprnt =strgCodeprnt.trim();
					}
				}
				console.log('Inside subform teamof js strgCodeprnt1 ::'+strgCodeprnt);
				if( visitedWithCode != "" )
				{
					console.log('Inside subform teamof js when visited with not blank');
					console.log('Inside subform teamof js visitedWithCode ::'+visitedWithCode);
					var mobNo="",teamHierarchys="";
					for (var j = 0; j < detailElement.length; j++)
					{
						var detail = detailElement[j];
						var attributeVal = detail.getAttribute("selected");
						var teamCodesp="";
						if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
						{
							teamCodesp = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
						}
						console.log('Inside subform teamof js teamCodesp ::'+teamCodesp);
						if(visitedWithCode.trim() == teamCodesp.trim() )
						{
							if( detail.getElementsByTagName("team_mobile_no")[0] != null && detail.getElementsByTagName("team_mobile_no")[0].childNodes[0] != null )
							{
								mobNo = detail.getElementsByTagName("team_mobile_no")[0].childNodes[0].nodeValue;
							}
							if( detail.getElementsByTagName("team_hierarchy_list")[0] != null && detail.getElementsByTagName("team_hierarchy_list")[0].childNodes[0] != null )
							{
								teamHierarchys = detail.getElementsByTagName("team_hierarchy_list")[0].childNodes[0].nodeValue;
								teamHierarchys =teamHierarchys.trim();
							}

						}
						console.log('Inside subform teamof js mobNo ::'+mobNo);
					}
					dispCount++;
					formDetailData +=
							"<Detail"+objContext+" domID='" + dispCount + "' selected = 'Y'>\r\n"+
									"<attribute selected='Y' updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
									"<selectbox><![CDATA[true]]></selectbox>" +
									"<sales_pers><![CDATA["+ visitedWithCode +"]]></sales_pers>\r\n"+
									"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
									"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
									"<strg_code><![CDATA[]]></strg_code>\r\n"+
									"<name><![CDATA["+vistedWith+"]]></name>\r\n"+
									"<member_name visible='0'><![CDATA["+vistedWith+"]]></member_name>\r\n"+
									"<mem_code visible='0'><![CDATA["+ visitedWithCode +"]]></mem_code>\r\n"+
									"<member_type visible='0'><![CDATA[]]></member_type>\r\n"+
									"<team_mobile_no visible='0'><![CDATA["+mobNo+"]]></team_mobile_no>\r\n"+
									"<sales_pers_sp_name ><![CDATA["+vistedWith+"]]></sales_pers_sp_name>\r\n"+
									"<design_code><![CDATA["+ visitedWithDesignCode +"]]></design_code>\r\n"+
									"<disp_descr><![CDATA["+visitedWithDesignCode+"]]></disp_descr>\r\n"+
									"<employee_designation><![CDATA[]]></employee_designation>\r\n"+
									"<visited_with_display><![CDATA["+vistedWith+"]]></visited_with_display>\r\n"+
									"<team_hierarchy_list><![CDATA["+teamHierarchys+"]]></team_hierarchy_list>\r\n"+
									"</Detail"+objContext+">";
				}

				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var attributeVal = detail.getAttribute("selected");
					if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
					{
						teamCode = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("name")[0] != null && detail.getElementsByTagName("name")[0].childNodes[0] != null )
					{
						empName = detail.getElementsByTagName("name")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("design_code")[0] != null && detail.getElementsByTagName("design_code")[0].childNodes[0] != null )
					{
						empDesign = detail.getElementsByTagName("design_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("employee_designation")[0] != null && detail.getElementsByTagName("employee_designation")[0].childNodes[0] != null )
					{
						designation = detail.getElementsByTagName("employee_designation")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("visited_with_display")[0] != null && detail.getElementsByTagName("visited_with_display")[0].childNodes[0] != null )
					{
						empNameDesign = detail.getElementsByTagName("visited_with_display")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("team_mobile_no")[0] != null && detail.getElementsByTagName("team_mobile_no")[0].childNodes[0] != null )
					{
						mobileNo = detail.getElementsByTagName("team_mobile_no")[0].childNodes[0].nodeValue;
					}
					/*if( detail.getElementsByTagName("mem_code_data")[0] != null && detail.getElementsByTagName("mem_code_data")[0].childNodes[0] != null )
					{
	                	memcodeData = detail.getElementsByTagName("mem_code_data")[0].childNodes[0].nodeValue;
						console.log("indetailsdata mem_code_data :::"+memcodeData) ;
					}*/
					if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
					{
						strgCdsub = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						strgCdsub =strgCdsub.trim();
					}
					if( detail.getElementsByTagName("team_hierarchy_list")[0] != null && detail.getElementsByTagName("team_hierarchy_list")[0].childNodes[0] != null )
					{
						teamHierarchy = detail.getElementsByTagName("team_hierarchy_list")[0].childNodes[0].nodeValue;
						teamHierarchy =teamHierarchy.trim();
					}
					console.log("getDetailData strg_code subform ==> "+strgCdsub);
					if(strgCdsub == null || strgCdsub.trim().length ==0)
					{
						console.log("getDetailData empNameDesign ==> "+empNameDesign);
						console.log("getDetailData mobileNo ==> "+mobileNo);
						console.log("getDetailData visitedWithCode ==>["+ visitedWithCode +"] teamCode ["+ teamCode +"], empName ["+ empName +"]");
						empName = empName.substring( 0, empName.indexOf( "(" ) );
						console.log('Inside subform teamof js strgCodeprnt2 in subform ::'+strgCodeprnt);
						if( visitedWithCode.trim() != teamCode.trim() )
						{
							console.log('Inside subform teamof js when visited with not equal to team code');
							dispCount++;
							formDetailData +=
									"<Detail"+objContext+" domID='" + dispCount + "' selected = '"+attributeVal+"'>\r\n"+
											"<attribute selected='"+attributeVal+"' updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";

							if( attributeVal == 'Y')
							{
								formDetailData += "<selectbox><![CDATA[true]]></selectbox>";
							}
							formDetailData +=
									"<sales_pers><![CDATA["+teamCode+"]]></sales_pers>\r\n"+
											"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
											"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
											"<strg_code><![CDATA[]]></strg_code>\r\n"+
											"<name><![CDATA["+empName+"]]></name>\r\n"+
											"<member_name visible='0'><![CDATA["+empName+"]]></member_name>\r\n"+
											"<mem_code visible='0'><![CDATA["+teamCode+"]]></mem_code>\r\n"+
											"<member_type visible='0'><![CDATA[]]></member_type>\r\n"+
											"<team_mobile_no visible='0'><![CDATA["+mobileNo+"]]></team_mobile_no>\r\n"+
											"<sales_pers_sp_name ><![CDATA["+empName+"]]></sales_pers_sp_name>\r\n"+
											"<design_code><![CDATA["+empDesign+"]]></design_code>\r\n"+
											"<disp_descr><![CDATA["+empDesign+"]]></disp_descr>\r\n"+
											"<employee_designation><![CDATA["+designation+"]]></employee_designation>\r\n"+
											"<visited_with_display><![CDATA["+empNameDesign+"]]></visited_with_display>\r\n"+
											"<team_hierarchy_list><![CDATA["+teamHierarchy+"]]></team_hierarchy_list>\r\n"+
											//"<mem_code_data><![CDATA["+memcodeData+"]]></mem_code_data>\r\n"+                       
											"</Detail"+objContext+">";
						}
					}
					else if(strgCodeprnt ==strgCdsub)
					{
						console.log("getDetailData in else strg_code parent ==> "+strgCodeprnt);
						console.log("getDetailData in else  strg_code subform ==> "+strgCdsub);
						console.log("getDetailData in else dispCount ==> "+dispCount);
						dispCount++;
						console.log("getDetailData in else strg_code subform dispCount ==> "+dispCount);
						formDetailData +=
								"<Detail"+objContext+" domID='" + dispCount + "' selected = '"+attributeVal+"'>\r\n"+
										"<attribute selected='"+attributeVal+"' updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n";

						if( attributeVal == 'Y')
						{
							formDetailData += "<selectbox><![CDATA[true]]></selectbox>";
						}
						formDetailData +=
								"<sales_pers><![CDATA["+teamCode+"]]></sales_pers>\r\n"+
										"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
										"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
										"<strg_code><![CDATA["+strgCdsub+"]]></strg_code>\r\n"+
										"<name><![CDATA["+empName+"]]></name>\r\n"+
										"<member_name visible='0'><![CDATA["+empName+"]]></member_name>\r\n"+
										"<mem_code visible='0'><![CDATA["+teamCode+"]]></mem_code>\r\n"+
										"<member_type visible='0'><![CDATA[R]]></member_type>\r\n"+
										"<team_mobile_no visible='0'><![CDATA["+mobileNo+"]]></team_mobile_no>\r\n"+
										"<sales_pers_sp_name ><![CDATA["+empName+"]]></sales_pers_sp_name>\r\n"+
										"<design_code><![CDATA["+empDesign+"]]></design_code>\r\n"+
										"<disp_descr><![CDATA[Customer Represantative]]></disp_descr>\r\n"+
										"<employee_designation><![CDATA["+designation+"]]></employee_designation>\r\n"+
										"<visited_with_display><![CDATA["+empNameDesign+"]]></visited_with_display>\r\n"+
										"<team_hierarchy_list><![CDATA["+teamHierarchy+"]]></team_hierarchy_list>\r\n"+
										//"<mem_code_data><![CDATA["+memcodeData+"]]></mem_code_data>\r\n"+                       
										"</Detail"+objContext+">";
					}
				}
				formDetailData += "</Root>";
				console.log('formDetailData team  realtime',formDetailData);
			}
			//Added by Prasad on 19/12/19 [to display selected workwith in team form] END
			else if( objFormName == 'survey' )
			{
				var survCount = 0,surveyCode="",selectbox="";
				var resultVal="";
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var resultType = "",resultFormat = "",attachOpt="",surveyTemp="",surveyDescr="",context="",contextDescr="",result="",metaData="",
						result1="",result2="",result3="",result4="",result5= "",dcrId="",surveyMandatory="",docId2="",surveyStrgCode="", srvgroupdescr = "";
				var codeCust="",activityTempl="",activityCode="";
				var custSurveyList=[];
				var custCodeList=[];
				var maxRange ="", minRange ="";
				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				console.log("parentDetailElement.length ["+ parentDetailElement.length +"]");
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("activity_templ")[0] != null && parentDetail.getElementsByTagName("activity_templ")[0].childNodes[0] != null )
					{
						activityTempl = parentDetail.getElementsByTagName("activity_templ")[0].childNodes[0].nodeValue;
					}
					console.log("activityTempl ["+ activityTempl +"]");
					if( parentDetail.getElementsByTagName("event_type")[0] != null && parentDetail.getElementsByTagName("event_type")[0].childNodes[0] != null )
					{
						activityCode = parentDetail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
					}
					console.log("activityCode ["+ activityCode +"]");
				}
				console.log("detailElement.length ["+ detailElement.length +"]");
				for (var j = 0; j < detailElement.length; j++)
				{
					var details = detailElement[j];
					if( details.getElementsByTagName("strg_code")[0] != null && details.getElementsByTagName("strg_code")[0].childNodes[0] != null )
					{
						codeCust = details.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
					}

					if (custCodeList.indexOf(codeCust) ==-1)
					{
						custCodeList.push(codeCust)
					}
				}
				console.log("detailElement.length 8218 ["+ detailElement.length +"]");
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					console.log("detail 8222 ["+ detail +"]");
					if( detail.getElementsByTagName("result_type")[0] != null && detail.getElementsByTagName("result_type")[0].childNodes[0] != null )
					{
						resultType = detail.getElementsByTagName("result_type")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("result_format")[0] != null && detail.getElementsByTagName("result_format")[0].childNodes[0] != null )
					{
						resultFormat = detail.getElementsByTagName("result_format")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("attach_opt")[0] != null && detail.getElementsByTagName("attach_opt")[0].childNodes[0] != null )
					{
						attachOpt = detail.getElementsByTagName("attach_opt")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("survey_templ")[0] != null && detail.getElementsByTagName("survey_templ")[0].childNodes[0] != null )
					{
						surveyTemp = detail.getElementsByTagName("survey_templ")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("survey_code")[0] != null && detail.getElementsByTagName("survey_code")[0].childNodes[0] != null )
					{
						surveyCode = detail.getElementsByTagName("survey_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("survey_descr")[0] != null && detail.getElementsByTagName("survey_descr")[0].childNodes[0] != null )
					{
						surveyDescr = detail.getElementsByTagName("survey_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("context")[0] != null && detail.getElementsByTagName("context")[0].childNodes[0] != null )
					{
						context = detail.getElementsByTagName("context")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("context_descr")[0] != null && detail.getElementsByTagName("context_descr")[0].childNodes[0] != null )
					{
						contextDescr = detail.getElementsByTagName("context_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result")[0] != null && detail.getElementsByTagName("result")[0].childNodes[0] != null )
					{
						result = detail.getElementsByTagName("result")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("meta_data")[0] != null && detail.getElementsByTagName("meta_data")[0].childNodes[0] != null )
					{
						metaData = detail.getElementsByTagName("meta_data")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("result1")[0] != null && detail.getElementsByTagName("result1")[0].childNodes[0] != null )
					{
						result1 = detail.getElementsByTagName("result1")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result2")[0] != null && detail.getElementsByTagName("result2")[0].childNodes[0] != null )
					{
						result2 = detail.getElementsByTagName("result2")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result3")[0] != null && detail.getElementsByTagName("result3")[0].childNodes[0] != null )
					{
						result3 = detail.getElementsByTagName("result3")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result4")[0] != null && detail.getElementsByTagName("result4")[0].childNodes[0] != null )
					{
						result4 = detail.getElementsByTagName("result4")[0].childNodes[0].nodeValue;
						resultVal = detail.getElementsByTagName("result4")[0].getAttribute("ddlblist");
					}
					if( detail.getElementsByTagName("result5")[0] != null && detail.getElementsByTagName("result5")[0].childNodes[0] != null )
					{
						result5 = detail.getElementsByTagName("result5")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("dcr_id")[0] != null && detail.getElementsByTagName("dcr_id")[0].childNodes[0] != null )
					{
						dcrId = detail.getElementsByTagName("dcr_id")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("survey_mandatory")[0] != null && detail.getElementsByTagName("survey_mandatory")[0].childNodes[0] != null )
					{
						surveyMandatory = detail.getElementsByTagName("survey_mandatory")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("doc_id_2")[0] != null && detail.getElementsByTagName("doc_id_2")[0].childNodes[0] != null )
					{
						docId2 = detail.getElementsByTagName("doc_id_2")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
					{
						surveyStrgCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("selectbox")[0] != null && detail.getElementsByTagName("selectbox")[0].childNodes[0] != null )
					{
						selectbox = detail.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
					}
					//Added by sadique shaikh 25-02-2020[for survey group short description]
					if( detail.getElementsByTagName("srv_group_descr")[0] != null && detail.getElementsByTagName("srv_group_descr")[0].childNodes[0] != null )
					{
						srvgroupdescr = detail.getElementsByTagName("srv_group_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result_range_max")[0] != null && detail.getElementsByTagName("result_range_max")[0].childNodes[0] != null )
					{
						maxRange = detail.getElementsByTagName("result_range_max")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result_range_min")[0] != null && detail.getElementsByTagName("result_range_min")[0].childNodes[0] != null )
					{
						minRange = detail.getElementsByTagName("result_range_min")[0].childNodes[0].nodeValue;
					}
					console.log("result5 ["+ result5 +"] result ["+ result +"] resultType ["+ resultType +"]");
					console.log("surveyTemp ["+ surveyTemp +"] activityTempl ["+ activityTempl +"] DocsurveyTemp ["+DocsurveyTemp +"]");
					console.log("minRange:::"+minRange);
					console.log("MaxRange:::"+maxRange);
					if(DocsurveyTemp==surveyTemp && surveyStrgCode == scCode)
					{
						var attributeVal = detail.getAttribute("selected");

						survCount++;
						formDetailData +=
								"<Detail"+objContext+" domID='" + survCount + "' selected = '"+attributeVal+"'>\r\n"+
										"<attribute selected='"+attributeVal+"' updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
										"<line_no><![CDATA["+survCount+"]]></line_no>\r\n"+
										"<strg_code><![CDATA["+surveyStrgCode+"]]></strg_code>\n"+
										"<survey_code><![CDATA["+surveyCode+"]]></survey_code>\n"+
										"<survey_descr><![CDATA["+surveyDescr+"]]></survey_descr>\n"+
										"<context><![CDATA["+context+"]]></context>\n" +
										"<context_descr><![CDATA["+contextDescr+"]]></context_descr>"+
										"<result_type><![CDATA["+resultType+"]]></result_type>\n"+
										"<result_format><![CDATA["+resultFormat+"]]></result_format>\n"+
										"<result><![CDATA["+result+"]]></result>\n"+
										"<meta_data><![CDATA["+metaData+"]]></meta_data>\n"+
										"<dcr_id><![CDATA["+dcrId+"]]></dcr_id>\n"+
										"<attach_opt><![CDATA["+attachOpt+"]]></attach_opt>\n"+
										"<survey_mandatory><![CDATA["+surveyMandatory+"]]></survey_mandatory>\n"+
										"<selectbox><![CDATA[true]]></selectbox>"+
										"<result_range_max><![CDATA["+maxRange+"]]></result_range_max>"+
										"<result_range_min><![CDATA["+minRange+"]]></result_range_min>"+
										"<survey_templ><![CDATA["+surveyTemp+"]]></survey_templ>";
						if(resultType == 'N')
						{
							formDetailData +=
									"<result1 visible='1'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'L' && resultFormat == 'D')
						{

							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='1' ddlblist='"+resultVal+"'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";

						}
						else if(resultType == 'L' || resultType == 'D')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='1'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'T')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'A')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='1'><![CDATA["+result5+"]]></result5>";
						}
						else
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						if(attachOpt == '1' || attachOpt == '2')
						{
							formDetailData += "<doc_id_2 visible='1'><![CDATA["+docId2+"]]></doc_id_2>";
						}
						else
						{
							formDetailData += "<doc_id_2 visible='0'><![CDATA["+docId2+"]]></doc_id_2>";
						}
						formDetailData +="<srv_group_descr visible='0'><![CDATA["+srvgroupdescr+"]]></srv_group_descr>";
						formDetailData +="</Detail"+objContext+">";

						if (custSurveyList.indexOf(surveyCode) ==-1)
						{
							custSurveyList.push(surveyCode)
						}
					}
					else if(DocsurveyTemp==surveyTemp && (surveyStrgCode==null || surveyStrgCode.trim().length==0) && custCodeList.indexOf(scCode) ==-1)
					{
						var attributeVal = detail.getAttribute("selected");

						survCount++;
						formDetailData +=
								"<Detail"+objContext+" domID='" + survCount + "' selected = '"+attributeVal+"'>\r\n"+
										"<attribute selected='"+attributeVal+"' updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
										"<line_no><![CDATA["+survCount+"]]></line_no>\r\n"+
										"<strg_code><![CDATA["+surveyStrgCode+"]]></strg_code>\n"+
										"<survey_code><![CDATA["+surveyCode+"]]></survey_code>\n"+
										"<survey_descr><![CDATA["+surveyDescr+"]]></survey_descr>\n"+
										"<context><![CDATA["+context+"]]></context>\n" +
										"<context_descr><![CDATA["+contextDescr+"]]></context_descr>"+
										"<result_type><![CDATA["+resultType+"]]></result_type>\n"+
										"<result_format><![CDATA["+resultFormat+"]]></result_format>\n"+
										"<result><![CDATA["+result+"]]></result>\n"+
										"<meta_data><![CDATA["+metaData+"]]></meta_data>\n"+
										"<dcr_id><![CDATA["+dcrId+"]]></dcr_id>\n"+
										"<attach_opt><![CDATA["+attachOpt+"]]></attach_opt>\n"+
										"<survey_mandatory><![CDATA["+surveyMandatory+"]]></survey_mandatory>\n"+
										"<result_range_max><![CDATA["+maxRange+"]]></result_range_max>"+
										"<result_range_min><![CDATA["+minRange+"]]></result_range_min>"+
										"<survey_templ><![CDATA["+surveyTemp+"]]></survey_templ>";
						if(attributeVal=='Y')
						{
							formDetailData +="<selectbox><![CDATA[true]]></selectbox>";
						}
						else
						{
							formDetailData +="<selectbox><![CDATA[false]]></selectbox>";
						}
						if(resultType == 'N')
						{
							formDetailData +=
									"<result1 visible='1'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'L' && resultFormat == 'D')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='1' ddlblist='"+resultVal+"'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";

						}
						else if(resultType == 'L' || resultType == 'D')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='1'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'T')
						{

							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'A')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='1'><![CDATA["+result5+"]]></result5>";
						}
						else
						{

							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						if(attachOpt == '1' || attachOpt == '2')
						{
							formDetailData += "<doc_id_2 visible='1'><![CDATA["+docId2+"]]></doc_id_2>";
						}
						else
						{
							formDetailData += "<doc_id_2 visible='0'><![CDATA["+docId2+"]]></doc_id_2>";
						}
						formDetailData +="<srv_group_descr visible='0'><![CDATA["+srvgroupdescr+"]]></srv_group_descr>";
						formDetailData +="</Detail"+objContext+">";
					}
					else if(DocsurveyTemp==surveyTemp  && custCodeList.indexOf(scCode) !=-1 && custSurveyList.indexOf(surveyCode) == -1 && (surveyStrgCode==null || surveyStrgCode.trim().length==0))
					{
						var attributeVal = detail.getAttribute("selected");

						survCount++;
						formDetailData +=
								"<Detail"+objContext+" domID='" + survCount + "' selected = '"+attributeVal+"'>\r\n"+
										"<attribute selected='"+attributeVal+"' updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
										"<line_no><![CDATA["+survCount+"]]></line_no>\r\n"+
										"<strg_code><![CDATA["+surveyStrgCode+"]]></strg_code>\n"+
										"<survey_code><![CDATA["+surveyCode+"]]></survey_code>\n"+
										"<survey_descr><![CDATA["+surveyDescr+"]]></survey_descr>\n"+
										"<context><![CDATA["+context+"]]></context>\n" +
										"<context_descr><![CDATA["+contextDescr+"]]></context_descr>"+
										"<result_type><![CDATA["+resultType+"]]></result_type>\n"+
										"<result_format><![CDATA["+resultFormat+"]]></result_format>\n"+
										"<result><![CDATA["+result+"]]></result>\n"+
										"<meta_data><![CDATA["+metaData+"]]></meta_data>\n"+
										"<dcr_id><![CDATA["+dcrId+"]]></dcr_id>\n"+
										"<attach_opt><![CDATA["+attachOpt+"]]></attach_opt>\n"+
										"<survey_mandatory><![CDATA["+surveyMandatory+"]]></survey_mandatory>\n"+
										"<result_range_max><![CDATA["+maxRange+"]]></result_range_max>"+
										"<result_range_min><![CDATA["+minRange+"]]></result_range_min>"+
										"<survey_templ><![CDATA["+surveyTemp+"]]></survey_templ>";
						if(attributeVal=='Y')
						{
							formDetailData +="<selectbox><![CDATA[true]]></selectbox>";

						}
						else
						{
							formDetailData +="<selectbox><![CDATA[false]]></selectbox>";
						}
						if(resultType == 'N')
						{
							formDetailData +=
									"<result1 visible='1'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'L' && resultFormat == 'D')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='1' ddlblist='"+resultVal+"'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";

						}
						else if(resultType == 'L' || resultType == 'D')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='1'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'T')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						else if(resultType == 'A')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='1'><![CDATA["+result5+"]]></result5>";
						}
						else
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>"+
											"<result5 visible='0'><![CDATA[]]></result5>";
						}
						if(attachOpt == '1' || attachOpt == '2')
						{
							formDetailData += "<doc_id_2 visible='1'><![CDATA["+docId2+"]]></doc_id_2>";
						}
						else
						{
							formDetailData += "<doc_id_2 visible='0'><![CDATA["+docId2+"]]></doc_id_2>";
						}
						formDetailData +="<srv_group_descr visible='0'><![CDATA["+srvgroupdescr+"]]></srv_group_descr>";
						formDetailData +="</Detail"+objContext+">";
					}
				}
				formDetailData += "</Root>";
				console.log("formDetailData ["+ formDetailData +"]");
			}
			//Added by Prasad on 19/12/19 [coaching detail form related implementation] START
			else if( objFormName == 'coaching' )
			{
				var survCount = 0,surveyCode="",selectbox="";
				var resultVal="";
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var resultType = "",resultFormat = "",attachOpt="",coachingTemp="",surveyDescr="",context="",contextDescr="",result="",metaData="",coachingFieldValue ="",count="",
						result1="",result2="",result3="",result4="",result5="",dcrId="",surveyMandatory="",docId1="",surveyStrgCode="",orgUnit="",paramValue="",activityCode="",shDescr="",gradeCode="",empDesign="",sprsCodeWw="";
				var isValueMatched = false;
				var coachingParamValue = "";
				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				console.log("getDetailData parentDetailElement ==> "+parentDetailElement);
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("event_type")[0] != null && parentDetail.getElementsByTagName("event_type")[0].childNodes[0] != null )
					{
						activityCode = parentDetail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData activityCode ==> "+activityCode);
					if( parentDetail.getElementsByTagName("sh_descr")[0] != null && parentDetail.getElementsByTagName("sh_descr")[0].childNodes[0] != null )
					{
						shDescr = parentDetail.getElementsByTagName("sh_descr")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData shDescr ==> "+shDescr);

					if( parentDetail.getElementsByTagName("emp_design")[0] != null && parentDetail.getElementsByTagName("emp_design")[0].childNodes[0] != null )
					{
						empDesign = parentDetail.getElementsByTagName("emp_design")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData empDesign ==> "+empDesign);
					if( parentDetail.getElementsByTagName("grade_code")[0] != null && parentDetail.getElementsByTagName("grade_code")[0].childNodes[0] != null )
					{
						gradeCode = parentDetail.getElementsByTagName("grade_code")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData gradeCode ==> "+gradeCode);

					if( parentDetail.getElementsByTagName("sprs_code__ww")[0] != null && parentDetail.getElementsByTagName("sprs_code__ww")[0].childNodes[0] != null )
					{
						sprsCodeWw = parentDetail.getElementsByTagName("sprs_code__ww")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData sprsCodeWw ==> "+sprsCodeWw);
					if( parentDetail.getElementsByTagName("visited_with")[0] != null && parentDetail.getElementsByTagName("visited_with")[0].childNodes[0] != null )
					{
						vistedWith = parentDetail.getElementsByTagName("visited_with")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData vistedWith ==> "+vistedWith);
				}
				if(gradeCode!= null && gradeCode.length > 0 )
				{
					coachingFieldValue = gradeCode;
				}
				else if(empDesign!= null && empDesign.length > 0 )
				{
					coachingFieldValue = empDesign;
				}
				if( activityCode!= null && activityCode.length > 0)
				{
					coachingFieldValue = coachingFieldValue+"_"+activityCode;
				}
				if( shDescr!= null && shDescr.length > 0)
				{
					coachingFieldValue = coachingFieldValue+"_"+shDescr;
				}
				console.log('coachingFieldValue',coachingFieldValue );
				count = coachingFieldValue.split("_").length - 1;
				console.log('coachingFieldValue count',count );

				var coachingElement = xmlDoc.getElementsByTagName( "COACHING_DET" );
				if( coachingElement.length == 0 )
				{
					coachingParamValue = 'NA';
				}
				for( var j = 0; j < coachingElement.length; j++)
				{
					var coachingDetail = coachingElement[j];
					if( coachingDetail.getElementsByTagName("ORG_UNIT")[0] != null && coachingDetail.getElementsByTagName("ORG_UNIT")[0].childNodes[0] != null )
					{
						orgUnit = coachingDetail.getElementsByTagName("ORG_UNIT")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData orgUnit ==> "+orgUnit);
					if( coachingDetail.getElementsByTagName("PARM_VALUE")[0] != null && coachingDetail.getElementsByTagName("PARM_VALUE")[0].childNodes[0] != null )
					{
						paramValue = coachingDetail.getElementsByTagName("PARM_VALUE")[0].childNodes[0].nodeValue;
					}
					console.log("getDetailData paramValue ==> "+paramValue);
					if( coachingFieldValue == orgUnit )
					{
						isValueMatched=true;
						coachingParamValue= paramValue;
						break;
					}
					if( j == coachingElement.length-1 && isValueMatched == false && coachingFieldValue.indexOf('_') != -1)
					{
						j = 0;
						coachingFieldValue= coachingFieldValue.substring(0, coachingFieldValue.lastIndexOf("_"));
					}
				}
				console.log("coachingFieldValue ==> "+coachingFieldValue);
				//coachingFieldValue = "AT00000002";

				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					if( detail.getElementsByTagName("result_type")[0] != null && detail.getElementsByTagName("result_type")[0].childNodes[0] != null )
					{
						resultType = detail.getElementsByTagName("result_type")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result_format")[0] != null && detail.getElementsByTagName("result_format")[0].childNodes[0] != null )
					{
						resultFormat = detail.getElementsByTagName("result_format")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("attach_opt")[0] != null && detail.getElementsByTagName("attach_opt")[0].childNodes[0] != null )
					{
						attachOpt = detail.getElementsByTagName("attach_opt")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("coaching_templ")[0] != null && detail.getElementsByTagName("coaching_templ")[0].childNodes[0] != null )
					{
						coachingTemp = detail.getElementsByTagName("coaching_templ")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("survey_code")[0] != null && detail.getElementsByTagName("survey_code")[0].childNodes[0] != null )
					{
						surveyCode = detail.getElementsByTagName("survey_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("survey_descr")[0] != null && detail.getElementsByTagName("survey_descr")[0].childNodes[0] != null )
					{
						surveyDescr = detail.getElementsByTagName("survey_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("context")[0] != null && detail.getElementsByTagName("context")[0].childNodes[0] != null )
					{
						context = detail.getElementsByTagName("context")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("context_descr")[0] != null && detail.getElementsByTagName("context_descr")[0].childNodes[0] != null )
					{
						contextDescr = detail.getElementsByTagName("context_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result")[0] != null && detail.getElementsByTagName("result")[0].childNodes[0] != null )
					{
						result = detail.getElementsByTagName("result")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("meta_data")[0] != null && detail.getElementsByTagName("meta_data")[0].childNodes[0] != null )
					{
						metaData = detail.getElementsByTagName("meta_data")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result1")[0] != null && detail.getElementsByTagName("result1")[0].childNodes[0] != null )
					{
						result1 = detail.getElementsByTagName("result1")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result2")[0] != null && detail.getElementsByTagName("result2")[0].childNodes[0] != null )
					{
						result2 = detail.getElementsByTagName("result2")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result3")[0] != null && detail.getElementsByTagName("result3")[0].childNodes[0] != null )
					{
						result3 = detail.getElementsByTagName("result3")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("result4")[0] != null && detail.getElementsByTagName("result4")[0].childNodes[0] != null )
					{
						result4 = detail.getElementsByTagName("result4")[0].childNodes[0].nodeValue;
						resultVal = detail.getElementsByTagName("result4")[0].getAttribute("ddlblist");
					}
					if( detail.getElementsByTagName("result5")[0] != null && detail.getElementsByTagName("result5")[0].childNodes[0] != null )
					{
						result5 = detail.getElementsByTagName("result5")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("dcr_id")[0] != null && detail.getElementsByTagName("dcr_id")[0].childNodes[0] != null )
					{
						dcrId = detail.getElementsByTagName("dcr_id")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("survey_mandatory")[0] != null && detail.getElementsByTagName("survey_mandatory")[0].childNodes[0] != null )
					{
						surveyMandatory = detail.getElementsByTagName("survey_mandatory")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("doc_id_1")[0] != null && detail.getElementsByTagName("doc_id_1")[0].childNodes[0] != null )
					{
						docId1 = detail.getElementsByTagName("doc_id_1")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
					{
						surveyStrgCode = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("selectbox")[0] != null && detail.getElementsByTagName("selectbox")[0].childNodes[0] != null )
					{
						selectbox = detail.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
					}
					console.log("coachingTemp ==> "+coachingTemp);
					console.log("coachingParamValue ==> "+coachingParamValue);


					console.log("resultType ==> "+resultType);
					console.log("resultFormat ==> "+resultFormat);

					if(	coachingParamValue == coachingTemp || coachingParamValue == 'NA')
					{
						var attributeVal = detail.getAttribute("selected");
						console.log("attributeVal ==> "+attributeVal);

						survCount++;
						formDetailData +=
								"<Detail"+objContext+" domID='" + survCount + "' selected = '"+attributeVal+"'>\r\n"+
										"<attribute selected='"+attributeVal+"' updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
										"<line_no><![CDATA["+survCount+"]]></line_no>\r\n"+
										"<strg_code><![CDATA["+surveyStrgCode+"]]></strg_code>\n"+
										"<survey_code><![CDATA["+surveyCode+"]]></survey_code>\n"+
										"<survey_descr><![CDATA["+surveyDescr+"]]></survey_descr>\n"+
										"<context><![CDATA["+context+"]]></context>\n" +
										"<context_descr><![CDATA["+contextDescr+"]]></context_descr>"+
										"<result_type><![CDATA["+resultType+"]]></result_type>\n"+
										"<result_format><![CDATA["+resultFormat+"]]></result_format>\n"+
										"<result><![CDATA["+result+"]]></result>\n"+
										"<meta_data><![CDATA["+metaData+"]]></meta_data>\n"+
										"<dcr_id><![CDATA["+dcrId+"]]></dcr_id>\n"+
										"<attach_opt><![CDATA["+attachOpt+"]]></attach_opt>\n"+
										"<survey_mandatory><![CDATA["+surveyMandatory+"]]></survey_mandatory>\n"+
										"<sprs_code__ww><![CDATA["+sprsCodeWw+"]]></sprs_code__ww>\n"+
										"<coaching_templ><![CDATA["+coachingParamValue+"]]></coaching_templ>";
						console.log("formDetailData ==> "+formDetailData);
						if(attributeVal=='Y')
						{
							formDetailData +="<selectbox><![CDATA[true]]></selectbox>";
						}
						else
						{
							formDetailData +="<selectbox><![CDATA[false]]></selectbox>";
						}
						console.log("formDetailData 11111 ==> "+formDetailData);
						console.log("resultType ==> 222 "+resultType);
						console.log("resultFormat ==> 222 "+resultFormat);
						if(resultType == 'N')
						{
							formDetailData +=
									"<result1 visible='1'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='0'><![CDATA["+result5+"]]></result5>";
						}
						else if(resultType == 'L' && resultFormat == 'D')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='1' ddlblist='"+resultVal+"'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='0'><![CDATA["+result5+"]]></result5>";
						}
						else if(resultType == 'L' || resultType == 'D')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='1'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='0'><![CDATA["+result5+"]]></result5>";
						}
						else if(resultType == 'T')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='0'><![CDATA["+result5+"]]></result5>";
						}
						else if(resultType == 'A')
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='0'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='1'><![CDATA["+result5+"]]></result5>";
						}
						else
						{
							formDetailData +=
									"<result1 visible='0'><![CDATA["+result1+"]]></result1>\n"+
											"<result2 visible='0'><![CDATA["+result2+"]]></result2>\n"+
											"<result3 visible='1'><![CDATA["+result3+"]]></result3>\n"+
											"<result4 visible='0'><![CDATA["+result4+"]]></result4>\n"+
											"<result5 visible='0'><![CDATA["+result5+"]]></result5>";
						}
						console.log("formDetailData 222222222 ==> "+formDetailData);
						if(attachOpt == '1' || attachOpt == '2')
						{
							formDetailData += "<doc_id_1 visible='1'><![CDATA["+docId1+"]]></doc_id_1>";
						}
						else
						{
							formDetailData += "<doc_id_1 visible='0'><![CDATA["+docId1+"]]></doc_id_1>";
						}
						formDetailData +="</Detail"+objContext+">";
						console.log("formDetailData ==>finall  "+formDetailData);
					}
				}
				formDetailData += "</Root>";
			}
			else if( objFormName == 'sampleorder' )
			{
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";

				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var toolDescr="",itemDescr="",landingRate="",rate="",itemCode="",orderSalesPers="",productCode="",isFocusItemList="",discountRate="",discountDisc="";
				var productDescr="",itemSize="",itemAttribDescr="",orderQTy="",stockInfo="",remarkDescr="",isProductEcoList="",isItemEcoList="",isFocusProductList="";
				var dispCount = 0;
				var priceListPrnt ="";
				var discountPriceListPrnt ="";
				var priceListSub ="";
				var discountPriceListSub ="";
				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				console.log("Inside get invoice subform of Get detail Data before Parent Form");
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					console.log("Inside get invoice after parent");
					if( parentDetail.getElementsByTagName("price_list")[0] != null && parentDetail.getElementsByTagName("price_list")[0].childNodes[0] != null )
					{
						priceListPrnt = parentDetail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
						priceListPrnt=priceListPrnt.trim();
					}
					if( parentDetail.getElementsByTagName("price_list__disc")[0] != null && parentDetail.getElementsByTagName("price_list__disc")[0].childNodes[0] != null )
					{
						discountPriceListPrnt = parentDetail.getElementsByTagName("price_list__disc")[0].childNodes[0].nodeValue;
						discountPriceListPrnt=discountPriceListPrnt.trim();
					}
				}
				console.log("Inside get invoice subform of Get detail Data priceListPrnt in sampleorder::"+priceListPrnt);
				console.log("Inside get invoice subform of Get detail Data discountPriceListPrnt in sampleorder::"+discountPriceListPrnt);

				for (var i = 0; i < detailElement.length; i++)
				{

					var detail = detailElement[i];
					var domId = detail.getAttribute("domID");

					if( detail.getElementsByTagName("prev_two_order")[0] != null && detail.getElementsByTagName("prev_two_order")[0].childNodes[0] != null )
					{
						toolDescr = detail.getElementsByTagName("prev_two_order")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
					{
						itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("landing_rate")[0] != null && detail.getElementsByTagName("landing_rate")[0].childNodes[0] != null )
					{
						landingRate = detail.getElementsByTagName("landing_rate")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
					{
						rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
					{
						itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
					{
						orderSalesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("product_code")[0] != null && detail.getElementsByTagName("product_code")[0].childNodes[0] != null )
					{
						productCode = detail.getElementsByTagName("product_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("product_descr")[0] != null && detail.getElementsByTagName("product_descr")[0].childNodes[0] != null )
					{
						productDescr = detail.getElementsByTagName("product_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("item_size")[0] != null && detail.getElementsByTagName("item_size")[0].childNodes[0] != null )
					{
						itemSize = detail.getElementsByTagName("item_size")[0].childNodes[0].nodeValue;
					}				
					if( detail.getElementsByTagName("item_attrib_descr")[0] != null && detail.getElementsByTagName("item_attrib_descr")[0].childNodes[0] != null )
					{
						itemAttribDescr = detail.getElementsByTagName("item_attrib_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("order_qty")[0] != null && detail.getElementsByTagName("order_qty")[0].childNodes[0] != null )
					{
						orderQTy = detail.getElementsByTagName("order_qty")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_stock_info")[0] != null && detail.getElementsByTagName("is_stock_info")[0].childNodes[0] != null )
					{
						stockInfo = detail.getElementsByTagName("is_stock_info")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("remark_list")[0] != null && detail.getElementsByTagName("remark_list")[0].childNodes[0] != null )
					{
						remarkDescr = detail.getElementsByTagName("remark_list")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_product_eco")[0] != null && detail.getElementsByTagName("is_product_eco")[0].childNodes[0] != null )
					{
						isProductEcoList = detail.getElementsByTagName("is_product_eco")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_item_eco")[0] != null && detail.getElementsByTagName("is_item_eco")[0].childNodes[0] != null )
					{
						isItemEcoList = detail.getElementsByTagName("is_item_eco")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_focus_product")[0] != null && detail.getElementsByTagName("is_focus_product")[0].childNodes[0] != null )
					{
						isFocusProductList = detail.getElementsByTagName("is_focus_product")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_focus_item")[0] != null && detail.getElementsByTagName("is_focus_item")[0].childNodes[0] != null )
					{
						isFocusItemList = detail.getElementsByTagName("is_focus_item")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("price_list")[0] != null && detail.getElementsByTagName("price_list")[0].childNodes[0] != null )
					{
						priceListSub = detail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
						priceListSub=priceListSub.trim();
					}
					if( detail.getElementsByTagName("price_list__disc")[0] != null && detail.getElementsByTagName("price_list__disc")[0].childNodes[0] != null )
					{
						discountPriceListSub = detail.getElementsByTagName("price_list__disc")[0].childNodes[0].nodeValue;
						discountPriceListSub=discountPriceListSub.trim();
					}
					if( detail.getElementsByTagName("disc_rate")[0] != null && detail.getElementsByTagName("disc_rate")[0].childNodes[0] != null )
					{
						discountRate = detail.getElementsByTagName("disc_rate")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("discount_disc")[0] != null && detail.getElementsByTagName("discount_disc")[0].childNodes[0] != null )
					{
						discountDisc = detail.getElementsByTagName("discount_disc")[0].childNodes[0].nodeValue;
					}
					
					console.log("getDetailData priceListSub Invoice SampleOrder ==> "+priceListSub);
					console.log("getDetailData priceListPrnt Invoice SampleOrder==> "+priceListPrnt);

					console.log("getDetailData discountPriceListPrnt Invoice SampleOrder ==> "+discountPriceListPrnt);
					console.log("getDetailData discountPriceListSub Invoice SampleOrder==> "+discountPriceListSub);
					console.log("getDetailData discountRate Invoice SampleOrder==> "+discountRate);
					console.log("getDetailData discountDisc ==> "+discountDisc);

					var prevOrderDate="";
					if(toolDescr!=null && toolDescr.trim().length > 0 )
					{
						toolDescr = toolDescr.substring(1, toolDescr.length-1);


						var toolDescrList = toolDescr.split(',');
						for(var j=0;j < toolDescrList.length;j++)
						{
							var scCodeOrder = toolDescrList[j].split('@')[0].trim();

							if(scCodeOrder==scCode)
							{
								prevOrderDate = toolDescrList[j].split('@')[1];

								break;
							}

						}
					}
					var isProductEco="",productLastVisit="";
					if(isProductEcoList!=null && isProductEcoList.trim().length > 0 )
					{
						isProductEcoList = isProductEcoList.substring(1, isProductEcoList.length-1);


						var nonEcoProList = isProductEcoList.split(',');
						for(var j=0;j < nonEcoProList.length;j++)
						{
							var scCodeOrder = nonEcoProList[j].split('@')[0].trim();

							if(scCodeOrder==scCode)
							{
								isProductEco="N";
								productLastVisit = nonEcoProList[j].split('@')[1];
								break;
							}

						}
					}

					var isItemEco="",itemLastVisit="",minQuantity="";
					if(isItemEcoList!=null && isItemEcoList.trim().length > 0 )
					{
						isItemEcoList = isItemEcoList.substring(1, isItemEcoList.length-1);


						var nonEcoItemList = isItemEcoList.split(',');
						for(var j=0;j < nonEcoItemList.length;j++)
						{
							var scCodeOrder = nonEcoItemList[j].split('@')[0].trim();

							if(scCodeOrder==scCode)
							{
								isItemEco="N";
								itemLastVisit = nonEcoItemList[j].split('@')[1];
								minQuantity=nonEcoItemList[j].split('@')[2];
								break;
							}

						}
					}

					var productFocus="";
					if(isFocusProductList!=null && isFocusProductList.trim().length > 0 )
					{
						isFocusProductList = isFocusProductList.substring(1, isFocusProductList.length-1);
						var productCustomerList = isFocusProductList.split(',');
						for(var j=0;j < productCustomerList.length;j++)
						{
							var customerFocusCustomer = productCustomerList[j].trim();

							if(customerFocusCustomer==scCode)
							{
								productFocus = "Y";
								break;
							}

						}
					}

					var itemFocus="";
					if(isFocusItemList!=null && isFocusItemList.trim().length > 0 )
					{
						isFocusItemList = isFocusItemList.substring(1, isFocusItemList.length-1);
						var itemCustomerList = isFocusItemList.split(',');
						for(var j=0;j < itemCustomerList.length;j++)
						{
							var customerFocusItem = itemCustomerList[j].split('@')[0].trim();
							if(customerFocusItem==scCode)
							{
								itemFocus = "Y";
								minQuantity=itemCustomerList[j].split('@')[1];
								break;
							}

						}
					}					
					if(minQuantity==null ||  minQuantity.trim().length==0)
					{
						minQuantity="0";
					}

					if(discountPriceListSub == discountPriceListPrnt)
					{
						if(discountRate > 0  && priceListSub == priceListPrnt)
						{
							dispCount++;
							console.log("Inside same price_list_disc of Sample Order");

							formDetailData += "<Detail"+objContext+" domID='" + dispCount + "' selected = 'N'>\r\n"+
							"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
							"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
							"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
							"<strg_code><![CDATA["+scCode+"]]></strg_code>\n"+
							"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
							"<tran_id><![CDATA[]]></tran_id>\r\n"+
							"<quantity><![CDATA[]]></quantity>\r\n"+
							"<disc_perc><![CDATA["+discountDisc+"]]></disc_perc>\r\n"+
							"<lot_no><![CDATA[]]></lot_no>\r\n"+
							"<stock_qty><![CDATA[0]]></stock_qty>\r\n"+
							"<expiry_date><![CDATA[]]></expiry_date>\r\n"+
							"<value><![CDATA[]]></value>\r\n"+
							"<stock_value><![CDATA[]]></stock_value>\r\n"+
							"<landing_rate><![CDATA["+discountRate+"]]></landing_rate>\r\n"+
							"<rate><![CDATA["+discountRate+"]]></rate>\r\n"+
							"<item_code><![CDATA["+itemCode+"]]></item_code>"+
							"<prev_two_order><![CDATA["+prevOrderDate+"]]></prev_two_order>"+
							"<tooltip_descr><![CDATA["+itemDescr+"]]></tooltip_descr>"+
							"<sales_pers><![CDATA["+orderSalesPers+"]]></sales_pers>"+
							"<stockist_code><![CDATA[]]></stockist_code>\r\n"+
							"<stock_info><![CDATA[]]></stock_info>\r\n"+
							"<promo_code><![CDATA[]]></promo_code>\r\n"+
							"<description><![CDATA[]]></description>\r\n"+
							"<product_code><![CDATA["+productCode+"]]></product_code>\r\n"+
							"<product_descr><![CDATA["+productDescr+"]]></product_descr>\r\n"+
							"<item_size><![CDATA["+itemSize+"]]></item_size>"+
							"<item_attrib_descr><![CDATA["+itemAttribDescr+"]]></item_attrib_descr>"+
							"<order_qty><![CDATA["+orderQTy+"]]></order_qty>"+
							"<is_stock_info><![CDATA["+stockInfo+"]]></is_stock_info>"+
							"<remark_list><![CDATA["+remarkDescr+"]]></remark_list>"+
							"<is_product_eco><![CDATA["+isProductEco+"]]></is_product_eco>"+
							"<is_item_eco><![CDATA["+isItemEco+"]]></is_item_eco>"+
							"<item_last_visit><![CDATA["+itemLastVisit+"]]></item_last_visit>"+
							"<min_quantity><![CDATA["+minQuantity+"]]></min_quantity>"+
							"<product_last_visit><![CDATA["+productLastVisit+"]]></product_last_visit>"+
							"<is_focus_product><![CDATA["+productFocus+"]]></is_focus_product>"+
							"<is_focus_item><![CDATA["+itemFocus+"]]></is_focus_item>"+
							"<price_list><![CDATA["+priceListSub+"]]></price_list>"+
							"</Detail"+objContext+">";
						}
						else
						{
							if(priceListSub == priceListPrnt)
							{
								dispCount++;
								console.log("Inside same price_list of Sample Order");

								formDetailData += "<Detail"+objContext+" domID='" + dispCount + "' selected = 'N'>\r\n"+
								"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
								"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
								"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
								"<strg_code><![CDATA["+scCode+"]]></strg_code>\n"+
								"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
								"<tran_id><![CDATA[]]></tran_id>\r\n"+
								"<quantity><![CDATA[]]></quantity>\r\n"+
								"<disc_perc><![CDATA[]]></disc_perc>\r\n"+
								"<lot_no><![CDATA[]]></lot_no>\r\n"+
								"<stock_qty><![CDATA[0]]></stock_qty>\r\n"+
								"<expiry_date><![CDATA[]]></expiry_date>\r\n"+
								"<value><![CDATA[]]></value>\r\n"+
								"<stock_value><![CDATA[]]></stock_value>\r\n"+
								"<landing_rate><![CDATA["+landingRate+"]]></landing_rate>\r\n"+
								"<rate><![CDATA["+rate+"]]></rate>\r\n"+
								"<item_code><![CDATA["+itemCode+"]]></item_code>"+
								"<prev_two_order><![CDATA["+prevOrderDate+"]]></prev_two_order>"+
								"<tooltip_descr><![CDATA["+itemDescr+"]]></tooltip_descr>"+
								"<sales_pers><![CDATA["+orderSalesPers+"]]></sales_pers>"+
								"<stockist_code><![CDATA[]]></stockist_code>\r\n"+
								"<stock_info><![CDATA[]]></stock_info>\r\n"+
								"<promo_code><![CDATA[]]></promo_code>\r\n"+
								"<description><![CDATA[]]></description>\r\n"+
								"<product_code><![CDATA["+productCode+"]]></product_code>\r\n"+
								"<product_descr><![CDATA["+productDescr+"]]></product_descr>\r\n"+
								"<item_size><![CDATA["+itemSize+"]]></item_size>"+
								"<item_attrib_descr><![CDATA["+itemAttribDescr+"]]></item_attrib_descr>"+
								"<order_qty><![CDATA["+orderQTy+"]]></order_qty>"+
								"<is_stock_info><![CDATA["+stockInfo+"]]></is_stock_info>"+
								"<remark_list><![CDATA["+remarkDescr+"]]></remark_list>"+
								"<is_product_eco><![CDATA["+isProductEco+"]]></is_product_eco>"+
								"<is_item_eco><![CDATA["+isItemEco+"]]></is_item_eco>"+
								"<item_last_visit><![CDATA["+itemLastVisit+"]]></item_last_visit>"+
								"<min_quantity><![CDATA["+minQuantity+"]]></min_quantity>"+
								"<product_last_visit><![CDATA["+productLastVisit+"]]></product_last_visit>"+
								"<is_focus_product><![CDATA["+productFocus+"]]></is_focus_product>"+
								"<is_focus_item><![CDATA["+itemFocus+"]]></is_focus_item>"+
								"<price_list><![CDATA["+priceListSub+"]]></price_list>"+
								"</Detail"+objContext+">";
							}
						}
					}
					else
					{
						//dispCount++;
						if(priceListSub == priceListPrnt)
						{
							dispCount++;
							console.log("Inside same price_list of Sample Order");

							formDetailData += "<Detail"+objContext+" domID='" + dispCount + "' selected = 'N'>\r\n"+
							"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
							"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
							"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
							"<strg_code><![CDATA["+scCode+"]]></strg_code>\n"+
							"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
							"<tran_id><![CDATA[]]></tran_id>\r\n"+
							"<quantity><![CDATA[]]></quantity>\r\n"+
							"<disc_perc><![CDATA[]]></disc_perc>\r\n"+
							"<lot_no><![CDATA[]]></lot_no>\r\n"+
							"<stock_qty><![CDATA[0]]></stock_qty>\r\n"+
							"<expiry_date><![CDATA[]]></expiry_date>\r\n"+
							"<value><![CDATA[]]></value>\r\n"+
							"<stock_value><![CDATA[]]></stock_value>\r\n"+
							"<landing_rate><![CDATA["+landingRate+"]]></landing_rate>\r\n"+
							"<rate><![CDATA["+rate+"]]></rate>\r\n"+
							"<item_code><![CDATA["+itemCode+"]]></item_code>"+
							"<prev_two_order><![CDATA["+prevOrderDate+"]]></prev_two_order>"+
							"<tooltip_descr><![CDATA["+itemDescr+"]]></tooltip_descr>"+
							"<sales_pers><![CDATA["+orderSalesPers+"]]></sales_pers>"+
							"<stockist_code><![CDATA[]]></stockist_code>\r\n"+
							"<stock_info><![CDATA[]]></stock_info>\r\n"+
							"<promo_code><![CDATA[]]></promo_code>\r\n"+
							"<description><![CDATA[]]></description>\r\n"+
							"<product_code><![CDATA["+productCode+"]]></product_code>\r\n"+
							"<product_descr><![CDATA["+productDescr+"]]></product_descr>\r\n"+
							"<item_size><![CDATA["+itemSize+"]]></item_size>"+
							"<item_attrib_descr><![CDATA["+itemAttribDescr+"]]></item_attrib_descr>"+
							"<order_qty><![CDATA["+orderQTy+"]]></order_qty>"+
							"<is_stock_info><![CDATA["+stockInfo+"]]></is_stock_info>"+
							"<remark_list><![CDATA["+remarkDescr+"]]></remark_list>"+
							"<is_product_eco><![CDATA["+isProductEco+"]]></is_product_eco>"+
							"<is_item_eco><![CDATA["+isItemEco+"]]></is_item_eco>"+
							"<item_last_visit><![CDATA["+itemLastVisit+"]]></item_last_visit>"+
							"<min_quantity><![CDATA["+minQuantity+"]]></min_quantity>"+
							"<product_last_visit><![CDATA["+productLastVisit+"]]></product_last_visit>"+
							"<is_focus_product><![CDATA["+productFocus+"]]></is_focus_product>"+
							"<is_focus_item><![CDATA["+itemFocus+"]]></is_focus_item>"+
							"<price_list><![CDATA["+priceListSub+"]]></price_list>"+
							"</Detail"+objContext+">";
						}
					}


				}
				formDetailData += "</Root>";


			}
			//Added by Prasad on 19/12/19 [coaching detail form related implementation] END
			//Added by bhagyashri T For Invoice subform[start]
			else if( objFormName == 'invoice' )
			{
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";

				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var itemDescr="",HsnNum="", rate="",itemCode="",orderSalesPers="",productCode="";
				var productDescr="",itemSize="",itemAttribDescr="",orderQTy="",stockInfo="",taxAmount ="",netAmount="",remarks="",currStock="",orgStock="";
				var dispCount = 0;
				var priceListPrnt ="",subItmChild="",subChildDescr="",subChildPriceList="",subChildRate="",subHSNNumber="",subPackSize="",collectionFormNo="",childPricelist="",custName="";
				var priceListSub ="",childItem="",pkgSize="",childItemDescr="",childItemRate="",childHsnNumber="",childPacakgeSize="",loadQuantity="",maxInvoiceNo="",cashInvoiceAmnt="";
				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				var invoicerefNo="";
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("price_list")[0] != null && parentDetail.getElementsByTagName("price_list")[0].childNodes[0] != null )
					{
						priceListPrnt = parentDetail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
						priceListPrnt=priceListPrnt.trim();
					}
					if( parentDetail.getElementsByTagName("invoice_no")[0] != null && parentDetail.getElementsByTagName("invoice_no")[0].childNodes[0] != null )
					{
						invoicerefNo = parentDetail.getElementsByTagName("invoice_no")[0].childNodes[0].nodeValue;
						invoicerefNo=invoicerefNo.trim();
					}
					if( parentDetail.getElementsByTagName("strg_name")[0] != null && parentDetail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
					{
						custName = parentDetail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
						custName=custName.trim();
					}
				}
				for (var i = 0; i < detailElement.length; i++)
				{
					var detail = detailElement[i];
					var domId = detail.getAttribute("domID");
					if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
					{
						itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("hsn_number")[0] != null && detail.getElementsByTagName("hsn_number")[0].childNodes[0] != null )
					{
						HsnNum = detail.getElementsByTagName("hsn_number")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
					{
						rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
					{
						itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
					{
						orderSalesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("product_code")[0] != null && detail.getElementsByTagName("product_code")[0].childNodes[0] != null )
					{
						productCode = detail.getElementsByTagName("product_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("product_descr")[0] != null && detail.getElementsByTagName("product_descr")[0].childNodes[0] != null )
					{
						productDescr = detail.getElementsByTagName("product_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("item_size")[0] != null && detail.getElementsByTagName("item_size")[0].childNodes[0] != null )
					{
						itemSize = detail.getElementsByTagName("item_size")[0].childNodes[0].nodeValue;
					}				
					if( detail.getElementsByTagName("item_attrib_descr")[0] != null && detail.getElementsByTagName("item_attrib_descr")[0].childNodes[0] != null )
					{
						itemAttribDescr = detail.getElementsByTagName("item_attrib_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("order_qty")[0] != null && detail.getElementsByTagName("order_qty")[0].childNodes[0] != null )
					{
						orderQTy = detail.getElementsByTagName("order_qty")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("is_stock_info")[0] != null && detail.getElementsByTagName("is_stock_info")[0].childNodes[0] != null )
					{
						stockInfo = detail.getElementsByTagName("is_stock_info")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
					{
						taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("net_amt")[0] != null && detail.getElementsByTagName("net_amt")[0].childNodes[0] != null )
					{
						netAmount = detail.getElementsByTagName("net_amt")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("reamrks_inv")[0] != null && detail.getElementsByTagName("reamrks_inv")[0].childNodes[0] != null )
					{
						remarks = detail.getElementsByTagName("reamrks_inv")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
					{
						currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
					{
						orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("price_list")[0] != null && detail.getElementsByTagName("price_list")[0].childNodes[0] != null )
					{
						priceListSub = detail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
						priceListSub=priceListSub.trim();
					}
					if( detail.getElementsByTagName("itm_child")[0] != null && detail.getElementsByTagName("itm_child")[0].childNodes[0] != null )
					{
						childItem = detail.getElementsByTagName("itm_child")[0].childNodes[0].nodeValue;
					}

					if( detail.getElementsByTagName("pkg_size")[0] != null && detail.getElementsByTagName("pkg_size")[0].childNodes[0] != null )
					{
						pkgSize = detail.getElementsByTagName("pkg_size")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("itm_child_descr")[0] != null && detail.getElementsByTagName("itm_child_descr")[0].childNodes[0] != null )
					{
						childItemDescr = detail.getElementsByTagName("itm_child_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("itm_child_rate")[0] != null && detail.getElementsByTagName("itm_child_rate")[0].childNodes[0] != null )
					{
						childItemRate = detail.getElementsByTagName("itm_child_rate")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("child_hsn_number")[0] != null && detail.getElementsByTagName("child_hsn_number")[0].childNodes[0] != null )
					{
						childHsnNumber = detail.getElementsByTagName("child_hsn_number")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("child_pack_size")[0] != null && detail.getElementsByTagName("child_pack_size")[0].childNodes[0] != null )
					{
						childPacakgeSize = detail.getElementsByTagName("child_pack_size")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sub_itm_child")[0] != null && detail.getElementsByTagName("sub_itm_child")[0].childNodes[0] != null )
					{
						subItmChild = detail.getElementsByTagName("sub_itm_child")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sub_child_descr")[0] != null && detail.getElementsByTagName("sub_child_descr")[0].childNodes[0] != null )
					{
						subChildDescr = detail.getElementsByTagName("sub_child_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sub_hsn_number")[0] != null && detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0] != null )
					{
						subHSNNumber = detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sub_child_rate")[0] != null && detail.getElementsByTagName("sub_child_rate")[0].childNodes[0] != null )
					{
						subChildRate = detail.getElementsByTagName("sub_child_rate")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sub_price_list")[0] != null && detail.getElementsByTagName("sub_price_list")[0].childNodes[0] != null )
					{
						subChildPriceList = detail.getElementsByTagName("sub_price_list")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("sub_pack_size")[0] != null && detail.getElementsByTagName("sub_pack_size")[0].childNodes[0] != null )
					{
						subPackSize = detail.getElementsByTagName("sub_pack_size")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("load_qty")[0] != null && detail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
					{
						loadQuantity = detail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("max_invoice_id")[0] != null && detail.getElementsByTagName("max_invoice_id")[0].childNodes[0] != null )
					{
						maxInvoiceNo = detail.getElementsByTagName("max_invoice_id")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("cash_invoice_amount")[0] != null && detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
					{
						cashInvoiceAmnt = detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("collection_form_no")[0] != null && detail.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
					{
						collectionFormNo = detail.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("child_price_list")[0] != null && detail.getElementsByTagName("child_price_list")[0].childNodes[0] != null )
					{
						childPricelist = detail.getElementsByTagName("child_price_list")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("strg_name")[0] != null && detail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
					{
						custName = detail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
						custName=custName.trim();
					}


					if(priceListSub == priceListPrnt && currStock >0)
					{
						dispCount++;
						formDetailData += "<Detail"+objContext+" domID='" + dispCount + "' selected = 'N'>\r\n"+
								"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
								"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
								"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
								"<strg_code><![CDATA["+scCode+"]]></strg_code>\n"+
								"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
								"<hsn_number><![CDATA["+HsnNum+"]]></hsn_number>\r\n"+
								"<tran_id><![CDATA[]]></tran_id>\r\n"+
								"<quantity><![CDATA[]]></quantity>\r\n"+
								"<disc_perc><![CDATA[]]></disc_perc>\r\n"+
								"<lot_no><![CDATA[]]></lot_no>\r\n"+
								"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\r\n"+
								"<org_stock><![CDATA["+orgStock+"]]></org_stock>\r\n"+
								"<tax_amt_inv><![CDATA["+taxAmount+"]]></tax_amt_inv>\r\n"+
								"<value><![CDATA[]]></value>\r\n"+
								"<rate><![CDATA["+rate+"]]></rate>\r\n"+
								"<item_code><![CDATA["+itemCode+"]]></item_code>"+
								"<sales_pers><![CDATA["+orderSalesPers+"]]></sales_pers>"+
								"<price_list><![CDATA["+priceListSub+"]]></price_list>"+
								"<description><![CDATA[]]></description>\r\n"+
								"<item_attrib_descr><![CDATA["+itemAttribDescr+"]]></item_attrib_descr>"+
								"<order_qty><![CDATA["+orderQTy+"]]></order_qty>"+
								"<is_stock_info><![CDATA["+stockInfo+"]]></is_stock_info>"+
								"<itm_child><![CDATA["+childItem+"]]></itm_child>"+
								"<pkg_size><![CDATA["+pkgSize+"]]></pkg_size>"+
								"<itm_child_descr><![CDATA["+childItemDescr+"]]></itm_child_descr>"+
								"<itm_child_rate><![CDATA["+childItemRate+"]]></itm_child_rate>"+
								"<child_hsn_number><![CDATA["+childHsnNumber+"]]></child_hsn_number>"+
								"<child_pack_size><![CDATA["+childPacakgeSize+"]]></child_pack_size>"+
								"<child_price_list><![CDATA["+childPricelist+"]]></child_price_list>"+
								"<sub_itm_child><![CDATA["+subItmChild+"]]></sub_itm_child>"+					
								"<sub_child_descr><![CDATA["+subChildDescr+"]]></sub_child_descr>"+					
								"<sub_hsn_number><![CDATA["+subHSNNumber+"]]></sub_hsn_number>"+
								"<sub_child_rate><![CDATA["+subChildRate+"]]></sub_child_rate>"+					
								"<sub_price_list><![CDATA["+subChildPriceList+"]]></sub_price_list>"+					
								"<sub_pack_size><![CDATA["+subPackSize+"]]></sub_pack_size>"+					
								"<is_broken><![CDATA[N]]></is_broken>"+
								"<load_qty><![CDATA["+loadQuantity+"]]></load_qty>"+	
								"<subform_invoice_no><![CDATA["+invoicerefNo+"]]></subform_invoice_no>"+	
								"<max_invoice_id><![CDATA["+maxInvoiceNo+"]]></max_invoice_id>"+				
								"<cash_invoice_amount><![CDATA["+cashInvoiceAmnt+"]]></cash_invoice_amount>"+	
								"<collection_form_no><![CDATA["+collectionFormNo+"]]></collection_form_no>"+
								"<cust_name><![CDATA["+custName+"]]></cust_name>"+
								"</Detail"+objContext+">";
					}
				}
				formDetailData += "</Root>";


			}
			//Added by bhagyashri T for invoice subform[end]
		}
		return formDetailData;
	}
	else if(objName ==='stocks_transfer_wiz')
	{

		var dummyXml = "<Root></Root>";
		var dummyXmlDoc = null;
		var parentFormDom = null;
		var LotDataArray=[];
		console.log("cureentform data is not null"+ formDetailData);
		console.log("objFormName"+ objFormName);
		var xmlVersion = formDetailData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if( formDetailData != null && formDetailData.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( formDetailData.indexOf("<Root>") == -1 )
				{
					formDetailData = "<Root>"+formDetailData+"</Root>";
				}
			}
		}
		else
		{
			console.log("null formDetailData");
		}

		//Added by Prasad on 19/12/19 [coaching related implementation] START
		console.log("parentFormData data is not null"+ parentFormData);
		if( parentFormData != null && parentFormData.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( parentFormData.indexOf("<Root>") == -1 )
				{
					parentFormData = "<Root>"+parentFormData+"</Root>";
				}
			}
		}
		else
		{
			console.log("null parentFormData");
		}
		//Added by Prasad on 19/12/19 [coaching related implementation] END

		if ( window.DOMParser )
		{
			parser = new DOMParser();
			try
			{
				if( formDetailData != null && formDetailData.trim().length > 0 )
				{
					xmlDoc = parser.parseFromString( formDetailData, "text/xml" );
				}
				if( parentFormData != null && parentFormData.trim().length > 0 )
				{
					parentFormDom = parser.parseFromString( parentFormData, "text/xml" );
				}
				dummyXmlDoc = parser.parseFromString( dummyXml, "text/xml" );
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async = false;
			xmlDoc.loadXML( formDetailData );

			dummyXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			dummyXmlDoc.async = false;
			dummyXmlDoc.loadXML( dummyXml );
		}
		if( xmlDoc != null )
		{
			if( objFormName == 'item' )
			{
				formDetailData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
				var detailElement = xmlDoc.getElementsByTagName( "Detail"+objContext );
				var itemDescr="",itemCode="", currStock="",qtyPerArt="0",orgStock="",loadQuantity="";
				var itemCount = 0;
				var lotList = "";
				var lc_noart = 0;

				var parentDetailElement = parentFormDom.getElementsByTagName( "Detail1" );
				var loc_codeTo = "",loc_codeFR="",locCodeStockFR="",lotnoFr="",quant="",lotSLFr="",acctCodeCr="",cctrCodeCr="",acctCodeDr="",cctrCodeDr="";
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("loc_code__to")[0] != null && parentDetail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
					{
						loc_codeTo = parentDetail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("loc_code__fr")[0] != null && parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
					{
						loc_codeFR = parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					}
				}
				for (var i = 0; i < detailElement.length; i++)
				{
					console.log("Inside get item subform of Detail elemt");
					var detail = detailElement[i];
					var domId = detail.getAttribute("domID");
					console.log("detailElement.length in item["+ detailElement.length +"]");

					if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
					{
						itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
					{
						itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
					{
						currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
					{
						locCodeStockFR = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("lot_no__fr")[0] != null && detail.getElementsByTagName("lot_no__fr")[0].childNodes[0] != null )
					{
						lotnoFr = detail.getElementsByTagName("lot_no__fr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("lot_sl__fr")[0] != null && detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0] != null )
					{
						lotSLFr = detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
					{
						quant = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
					{
						orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
					}
					if( detail.getElementsByTagName("load_qty")[0] != null && detail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
					{
						loadQuantity = detail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
					}


					console.log("locCode getDetailData loc_codeTo:"+loc_codeTo+" loc_codeFR:"+loc_codeFR+" locCodeStockFR:"+locCodeStockFR);

					if(locCodeStockFR==loc_codeFR)
					{
						itemCount++;

						if( detail.getElementsByTagName("acct_code__cr")[0] != null && detail.getElementsByTagName("acct_code__cr")[0].childNodes[0] != null )
						{
							acctCodeCr = detail.getElementsByTagName("acct_code__cr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cctr_code__cr")[0] != null && detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0] != null )
						{
							cctrCodeCr = detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("acct_code__dr")[0] != null && detail.getElementsByTagName("acct_code__dr")[0].childNodes[0] != null )
						{
							acctCodeDr = detail.getElementsByTagName("acct_code__dr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("cctr_code__dr")[0] != null && detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0] != null )
						{
							cctrCodeDr = detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0].nodeValue;
						}
						if( detail.getElementsByTagName("qty_per_art")[0] != null && detail.getElementsByTagName("qty_per_art")[0].childNodes[0] != null )
						{
							qtyPerArt = detail.getElementsByTagName("qty_per_art")[0].childNodes[0].nodeValue;
						}

						formDetailData +=
								"<Detail"+objContext+" domID = '"+itemCount+"' selected = 'N'>\r\n"+
										"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
										"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
										"<item_code><![CDATA["+itemCode+"]]></item_code>\r\n"+
										"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\n"+
										"<org_stock><![CDATA["+orgStock+"]]></org_stock>\n"+
										"<quantity><![CDATA[]]></quantity>\r\n"+
										"<line_no><![CDATA["+itemCount+"]]></line_no>"+
										"<tran_id><![CDATA[]]></tran_id>\r\n"+
										"<loc_code__fr><![CDATA["+loc_codeFR+"]]></loc_code__fr>\r\n"+
										"<loc_code__to><![CDATA["+loc_codeTo+"]]></loc_code__to>\r\n"+
										"<lot_no__fr><![CDATA["+lotnoFr+"]]></lot_no__fr>\r\n"+
										"<lot_sl__fr><![CDATA["+lotSLFr+"]]></lot_sl__fr>\r\n"+
										"<lot_no__to><![CDATA["+lotnoFr+"]]></lot_no__to>\r\n"+
										"<lot_sl__to><![CDATA["+lotSLFr+"]]></lot_sl__to>\r\n"+
										"<no_art><![CDATA[]]></no_art>\r\n"+
										"<load_qty><![CDATA["+loadQuantity+"]]></load_qty>"+
										"<qty_per_art><![CDATA["+qtyPerArt+"]]></qty_per_art>\r\n"+
										"<acct_code__cr><![CDATA["+acctCodeCr+"]]></acct_code__cr>\r\n"+
										"<cctr_code__cr><![CDATA["+cctrCodeCr+"]]></cctr_code__cr>\r\n"+
										"<acct_code__dr><![CDATA["+acctCodeDr+"]]></acct_code__dr>\r\n"+
										"<cctr_code__dr><![CDATA["+cctrCodeDr+"]]></cctr_code__dr>\r\n";

						formDetailData +="</Detail"+objContext+">\r\n";
					}

				}	
				formDetailData += "</Root>";	         
			}
		}
		console.log("stocksgetDetailData formDetailData ==> "+formDetailData);
		return formDetailData;
	}

}
//added by Sandeep S. for sync on 7-march-18(end)

//added by vishal pathare on 24.1.18 for[ for validation to add batch]Start.
function validateCustomWidgetCnt( jsonData )
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		try
		{
			var isValid = true;
			var customWidgetCnt = 0;
			var customWidgetInfo = JSON.parse( jsonData );
			var customWidgetCnt = Object.keys(customWidgetInfo).length;
			customWidgetCnt -= 4;
			if( customWidgetCnt >= 5 )
			{
				isValid = false;
				alert( "Maximum five stocks are allowed" );
				return isValid;
			}
		}
		catch(e)
		{
			console.log("catch ["+e);
		}
		return isValid;
	}
	else
	{

	}
	
}
//added by vishal pathare on 24.1.18 for[ for validation to add batch]End.
//Added by mrunalini sinkar on 05-06-2018 [for blow the summary page on one click] (Start)
function expandAllDetails(id)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var detailElement = document.getElementsByTagName("details");
		for (var i = 0; i < detailElement.length; i++)
		{
			var detail = detailElement[i];

			console.log("detail.open"+detail.open);
			if(detail.open == false)
			{
				detail.open="true";
				document.getElementById(id).value="-";
			}
			else
			{
				detail.removeAttribute("open");
				document.getElementById(id).value="+";
			}
		}
	}
	else
	{

	}

}
//Added by mrunalini sinkar on 05-06-2018 [for blow the summary page on one click] (end)
//added by rupali on 11/09/18 for applying validation for distance limit variance [start]
function getDistanceFromLatLonInMtr(lat1,lon1,lat2,lon2)
{

	console.log("inside getDistanceFromLatLonInMtr lat1:::["+lat1+"] lon1:::["+lon1+"] lat2:::["+lat2+"] lon2:::["+lon2+"]");
	var R = 6371; // Radius of the earth in km
	var dLat = deg2rad(lat2-lat1);  // deg2rad below
	var dLon = deg2rad(lon2-lon1);
	var a =
			Math.sin(dLat/2) * Math.sin(dLat/2) +
			Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
			Math.sin(dLon/2) * Math.sin(dLon/2);
	var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
	var d = R * c; // Distance in km
	console.log("In getAddress()...distanceinKm:::"+d);
	return d*1000;
}
function deg2rad(deg)
{
	return deg * (Math.PI/180)
}
//added by rupali on 11098/18 for applying validation for distance limit variance [end]
//Added by Prasad on 27/09/18 [download and filter presenataion detail data] START
function filterBrandJSON( jsonToFilter, exprToFilter, callback )
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var filterJsonObj = {};
		var filterJson = [];
		var presDetailJson = JSON.parse(jsonToFilter);
		console.log( "scCode : ["+ scCode +"], splCode : ["+ splCode +"], strgClassCode : ["+ strgClassCode +"]" );
		for ( var key in presDetailJson )
		{
			var brandJson = presDetailJson[key];
			if ( brandJson != null )
			{
				var presPurpose = brandJson[ "PRES_PURPOSE" ];
				var presAudience = brandJson[ "PRES_AUDIENCE" ];
				console.log( "presPurpose : ["+ presPurpose +"], presAudience : ["+ presAudience +"]" );
				console.log( "filterJsonObj : ["+ filterJsonObj +"]" );
				var presAudienceArr = presAudience.split( "," );
				var presDetailArr = [];
				if ( filterJsonObj[ presPurpose ] != null )
				{
					presDetailArr = filterJsonObj[ presPurpose ];
				}
				console.log( "presDetailArr : ["+ presDetailArr +"]" );
				if ( presPurpose == "2" && presAudienceArr.indexOf( scCode ) != -1 )
				{
					console.log( "presAudienceArr.indexOf scCode" );
					presDetailArr.push( brandJson );
				}
				else if ( presPurpose == "3" && presAudienceArr.indexOf( strgClassCode ) != -1 )
				{
					console.log( "presAudienceArr.indexOf strgClassCode" );
					presDetailArr.push( brandJson );
				}
				else if ( presPurpose == "4" && presAudienceArr.indexOf( splCode ) != -1 )
				{
					console.log( "presAudienceArr.indexOf splCode" );
					presDetailArr.push( brandJson );
				}
				else if ( presPurpose == "1" )
				{
					presDetailArr.push( brandJson );
				}
				filterJsonObj[ presPurpose ] = presDetailArr;
			}
		}
		//console.log( "filterJsonObj : ["+ JSON.stringify( filterJsonObj ) +"]" );
		filterJson = filterJsonObj[ "2" ];
		if ( filterJson == null || filterJson.length == 0 )
		{
			filterJson = filterJsonObj[ "3" ];
			if ( filterJson == null || filterJson.length == 0 )
			{
				filterJson = filterJsonObj[ "4" ];
				if ( filterJson == null || filterJson.length == 0 )
				{
					filterJson = filterJsonObj[ "1" ];
				}
			}
		}
		//console.log( "filterJson : ["+ JSON.stringify( filterJson ) +"]" );
		if ( filterJson != null && filterJson.length > 0 )
		{
			var selDocs = [];
			var presDetail = filterJson[0].PRES_DETAIL;
			var presFlow = presDetail[ "PRES_FLOW" ];
			var brandJsonArr = presFlow[ "BRANDS" ];
			for( var brandKey in brandJsonArr )
			{
				var brandJson = brandJsonArr[brandKey];
				var docJsonArr = brandJson[ "DOCS" ];
				for( var docKey in docJsonArr )
				{
					var docJson = docJsonArr[docKey];
					var docDetail = {
							DOC_ID : docJson.DOC_ID,
							FILE_NAME : docJson.DOC_NAME,
							DOC_TYPE: docJson.DOC_TYPE_ATTACH.trim()
					}
					console.log('docDetail ::',docDetail);
					selDocs.push(docDetail);
				}
				//brandJson[ "DOCS" ] = updateDocArr(docJsonArr);
			}

			downloadInBatch( selDocs, function(){

				for( var brandKey in brandJsonArr )
				{
					var brandJson = brandJsonArr[brandKey];
					var docJsonArr = brandJson[ "DOCS" ];
					brandJson[ "DOCS" ] = updateDocArr(docJsonArr);
				}
				var filterJsonStr = JSON.stringify( filterJson );
				console.log('filterJson : ' + filterJsonStr);
				callback( filterJsonStr );
			});
		}
	}
	else
	{

	}

}
function updateDocArr( docJsonArr )
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var newDocArray = [];
		for( var docKey in docJsonArr )
		{
			var docJson = docJsonArr[docKey];
			var fileType = docJson[ "FILE_TYPE_ATTACH" ];
			if ( "zip" == fileType )
			{
				var pageInfo = docJson[ "PAGE_INFO" ];
				var pageInfoArr = pageInfo.split( "," );
				for ( var ctr = 0; ctr < pageInfoArr.length; ctr++ )
				{
					var pageInfoDet = pageInfoArr[ctr];
					var docJsonTemp = JSON.parse(JSON.stringify(docJson));
					docJsonTemp[ "PAGE_INFO" ] = pageInfoDet;
					newDocArray.push( docJsonTemp );
				}
			}
			else
			{
				newDocArray.push( docJson );
			}
		}
		return newDocArray;
	}
	else
	{

	}

}
//Added by Prasad on 27/09/18 [download and filter presenataion detail data] END

//Added by Mrunalini Sinkar On 03-10-2018 for allw_delay_prd(start)
function getDaysBetweenTwoDates(reportDate,currentDate)
{
	console.log("getDaysBetweenTwoDates"+reportDate);
	var frReportDate = getFormatDate(reportDate);
	currentDate.setHours(0);
	currentDate.setMinutes(0);
	currentDate.setSeconds(0);
	var timeDiff = currentDate.getTime() - frReportDate.getTime();
	var diffDays = timeDiff / (1000 * 3600 * 24);
	var differentDay = Math.round(diffDays);
	console.log("differentDay "+differentDay);
	return 	differentDay;
}
function getFormatDate(reportDate)
{
	var month="";
	var year="";
	var eventDate="";
	var date="";
	if(reportDate.indexOf("-") != -1)
	{
		eventDate=reportDate.split("-");
		date = eventDate[0];
		month = eventDate[1];
		year = eventDate[2];
	}
	else if(reportDate.indexOf("/") != -1)
	{
		eventDate=reportDate.split("/");
		date = eventDate[0];
		month = eventDate[1];
		year = eventDate[2];
	}
	var newDate = month+"/"+date+"/"+year;
	var formatString = new Date(newDate);
	return 	formatString;
}
//Added by Mrunalini Sinkar On 03-10-2018 for allw_delay_prd(end)
function filterVisitedWithJSON(jsonToFilter,expressionToFilter)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var finalJsonObj = {};
		try
		{
			var filterJson = [];
			var jsonString = JSON.parse(jsonToFilter);
			jsonString.DETAILS.filter(function(value)
					{
				if (eval(expressionToFilter)) {
					filterJson.push(value);
				}
					});
			if( filterJson[0] )
			{
				finalJsonObj = filterJson[0];
			}
			console.log("return finalJsonObj::"+JSON.stringify(finalJsonObj));
			return JSON.stringify(finalJsonObj);
		}
		catch(e)
		{
			console.log("catch filterVisitedWithJSON["+e);
		}
		return JSON.stringify(finalJsonObj);
	}
	else
	{

	}

}

// Added By Prajyot on 13/02/19 to Update Todays Dashboard Data while no network - Starts
function syncTodaysDashboard(xmlData, editFlag)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var username = localStorage.getItem('userName');
		var jsonData = localStorage.getItem('TodaysServlet_'+ username);
		syncTodaysData(xmlData, jsonData, username, editFlag );
	}
	else
	{
		console.log("inside else syncTodaysDash");
	}

}
function syncTodaysData(xmlData, jsonData, username, editFlag)
{
	var detailJson = {};
	try
	{
		var parser = new DOMParser();
		var taxDom = parser.parseFromString(xmlData,"text/xml");
		var dataFields = ['event_date', 'locality_descr', 'cust_type', 'strg_code', 'event_time_start', 'strg_type', 'strg_name'];

		var detailNode = taxDom.getElementsByTagName( "Detail1" );
		if(detailNode != null)
		{
			var colNodeList = detailNode.item(0).childNodes;
			var colCount = colNodeList.length;
			for(fieldCtr = 0; fieldCtr < colCount; fieldCtr++)
			{
				var chDetNode = colNodeList.item(fieldCtr);
				if( chDetNode && chDetNode.firstChild && dataFields.includes(chDetNode.nodeName) )
				{
					//console.log(chDetNode.nodeName, chDetNode.firstChild.nodeValue);
					detailJson[chDetNode.nodeName] = chDetNode.firstChild.nodeValue;
				}
			}
		}
	}
	catch(e)
	{
		console.log( 'Execption in syncTodaysData', e);
	}

	var todaysData = JSON.parse(jsonData);
	try
	{
		console.log("Inside syncTodaysData todaysData before::");
		var todaysNewData = updateData(detailJson, todaysData, editFlag);
		console.log("Inside syncTodaysData todaysData after::");
		localStorage.setItem('TodaysServlet_'+username, JSON.stringify(todaysNewData));
		//Added by Bhagyashri T for Update datamodel on delete and OK [12-Dec-2022][start]
		if(editFlag == 'D')
		{
			console.log("Outside todaysNewData in syncTodaysData before fileDownload inside update flag D");
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/strg_meet_dcr_realtime_wiz_invoice.xml','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/strg_meet_dcr_realtime_wiz_invoice.xml');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/stocks_transfer_wiz_item.xml','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/stocks_transfer_wiz_item.xml');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/VAN_STOCK.json','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/VAN_STOCK.json');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/DAILY_SALES.json','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/DAILY_SALES.json');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/DAILY_SALES_RETAILER.json','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/DAILY_SALES_RETAILER.json');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/DAILY_SALES_PAYMENT.json','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/DAILY_SALES_PAYMENT.json');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/DAILY_SALES_CARD.json','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/DAILY_SALES_CARD.json');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/DAILY_SALES_SUBCARD.json','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/DAILY_SALES_SUBCARD.json');
			fileDownload('file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/INVOICE_DM.json','file:///data/user/0/ibase.android.Proteus/base/scopeData/'+username+'/backup/INVOICE_DM.json');
		}
		//Added by Bhagyashri T for Update datamodel on delete and OK [12-Dec-2022][End]

	}
	catch(e)
	{
		console.log('Something went wrong while updateData ...', e);
	}
}
function updateData(detailObj, todaysObj, editFlag)
{
	console.log("detailObj.strg_code in updateData::::"+detailObj.strg_code);
	var counterObj = {
			'Listed' : 0,
			'Unlisted' : 0,
			'Distributer' : 0,
			'Doctor' : 0,
			'Retailer' : 0
	};

	var todaysNewObj = {};
	console.log("Inside update data editFlag::::"+editFlag);
	if(editFlag == 'D')
	{
		// added by rupali on 20/02/19 to remove customer from localstorage on delete [start]
		try
		{
			console.log("Inside update data editFlag inside try detailObj.strg_code::::"+detailObj.strg_code);
			if(detailObj.strg_code == null || detailObj.strg_code.trim().length == 0)
			{
				console.log("Inside update data editFlag inside"+detailObj.strg_code);
				localStorage.removeItem(detailObj.event_date +'_ActivityType');
				//Added by mrunalini Sinkar (Start)
				localStorage.removeItem(detailObj.event_date +'_ActivityCode');
				localStorage.removeItem(detailObj.event_date +'_ActivityDescr');
				localStorage.removeItem(detailObj.event_date +'_ActivityPlaceReq');
				localStorage.removeItem(detailObj.event_date +'_ParentActivityCode');
				localStorage.removeItem(detailObj.event_date +'_LocReq');
				//Added by mrunalini Sinkar (End)
			}
			var customerList = localStorage.getItem(detailObj.event_date +'_StrgCode');
			console.log("Inside update data customerList"+customerList);
			if(customerList != null && customerList.trim().length != 0)
			{
				var custList = customerList.split(',');
				console.log("Inside update data custList"+custList);
				for(var i=0; i<custList.length; i++)
				{
					var customerCode = custList[i];
					console.log("Inside update data customerCode"+customerCode);
					console.log("Inside update data detailObj.strg_code"+detailObj.strg_code);
					if(customerCode == detailObj.strg_code)
					{
						if(i == 0)
						{
							customerList = customerList.replace(customerCode, '');
							console.log("Inside update data inside if"+customerList);
						}
						else
						{
							customerList = customerList.replace(","+customerCode, '');
							console.log("Inside update data customerList inside else"+customerList);
						}
						if(customerList != null && customerList.trim().length != 0)
						{
							localStorage.setItem(detailObj.event_date +'_StrgCode', customerList);
						}
						else
						{
							localStorage.removeItem(detailObj.event_date +'_StrgCode');
							localStorage.removeItem(detailObj.event_date +'_ActivityType');
							localStorage.removeItem(detailObj.event_date +'_OthParticipant');
							localStorage.removeItem(detailObj.event_date +'_LocalityDetails');
							//Added by mrunalini Sinkar (Start)
							localStorage.removeItem(detailObj.event_date +'_ActivityCode');
							localStorage.removeItem(detailObj.event_date +'_ActivityDescr');
							localStorage.removeItem(detailObj.event_date +'_ActivityPlaceReq');
							localStorage.removeItem(detailObj.event_date +'_ParentActivityCode');
							localStorage.removeItem(detailObj.event_date +'_LocReq');
							//Added by mrunalini Sinkar (End)
						}
					}
				}
			}
		}
		catch(e)
		{
			console.log('Something went wrong while removing localstorage data...', e);
		}
		// added by rupali on 20/02/19 to remove customer from localstorage on delete [end]

		//todaysNewObj['CALL_DETAILS'] = todaysObj.CALL_DETAILS.filter((callDetail)=> {
		todaysNewObj['CALL_DETAILS'] = todaysObj.CALL_DETAILS.filter(function(callDetail) {
			if( callDetail.EVENT_DATE == detailObj.event_date )
			{
				console.log( callDetail);
				//callDetail.PLACES = callDetail.PLACES.filter((placeDetail)=> {
				callDetail.PLACES = callDetail.PLACES.filter(function(placeDetail) {
					if( placeDetail.LOCALITY == detailObj.locality_descr )
					{
						//placeDetail.CUSTOMERS = placeDetail.CUSTOMERS.filter((custDetail)=> {
						placeDetail.CUSTOMERS = placeDetail.CUSTOMERS.filter(function(custDetail) {
							if( custDetail.CUST_CODE == detailObj.strg_code )
							{
								console.log( 'custDetail', custDetail);
							}
							else
							{
								return custDetail;
							}
						});
					}
					if( placeDetail.CUSTOMERS.length > 0 )
					{
						return placeDetail;
					}
				});
			}
			if( callDetail.PLACES.length > 0 )
			{
				return callDetail;
			}
		});
	}
	else
	{
		var callDet = getCallDetail(detailObj);
		//In Case No Call Details
		if( todaysObj && todaysObj.CALL_DETAILS.length == 0 )
		{
			var callDetails = [];
			callDetails.push(callDet);
			todaysNewObj['CALL_DETAILS'] = callDetails;
		}
		else
		{
			var customer = getCustomer(detailObj);
			var place = getPlace(detailObj);
			var isCallExist = false;
			//todaysNewObj['CALL_DETAILS'] = todaysObj.CALL_DETAILS.map((callDetail)=> {
			todaysNewObj['CALL_DETAILS'] = todaysObj.CALL_DETAILS.map(function(callDetail) {
				//console.log( callDetail);
				if( callDetail.PLACES && callDetail.EVENT_DATE == detailObj.event_date )
				{
					isCallExist = true;

					var isPlaceExist = false;
					//callDetail.PLACES = callDetail.PLACES.map((placeDetail)=> {
					callDetail.PLACES = callDetail.PLACES.map(function(placeDetail) {
						if( placeDetail.CUSTOMERS
								&& placeDetail.EVENT_DATE == detailObj.event_date
								&& placeDetail.LOCALITY == detailObj.locality_descr)
						{
							isPlaceExist = true;
							var isCustExist = false;
							//console.log( placeDetail);
							//placeDetail.CUSTOMERS = placeDetail.CUSTOMERS.map((custDetail)=> {
							placeDetail.CUSTOMERS = placeDetail.CUSTOMERS.map(function(custDetail) {
								if(custDetail.CUST_CODE == detailObj.strg_code )
								{
									isCustExist = true;
									return customer;
								}
								else
								{
									return custDetail;
								}
							});//End of placeDetail.CUSTOMERS

							//In Case No Customer Details
							if( !isCustExist )
							{
								placeDetail.CUSTOMERS.push(customer);
							}
							return placeDetail;
						}
						else
						{
							return placeDetail;
						}

					});//End of callDetail.PLACES

					//In Case No Place Details
					if( !isPlaceExist )
					{
						callDetail.PLACES.push(place);
					}
					return callDetail;
				}
				else
				{
					return callDetail;
				}
			}); //End of CALL_DETAILS

			if( !isCallExist )
			{
				todaysNewObj['CALL_DETAILS'].push(callDet);
			}
		}
	}

	//Update Counts after Insert/Update/Delete operation
	//todaysNewObj.CALL_DETAILS.map((callDetail)=> {
	todaysNewObj.CALL_DETAILS.map(function(callDetail) {
		//console.log( callDetail);
		//callDetail.PLACES = callDetail.PLACES.map((placeDetail)=> {
		callDetail.PLACES = callDetail.PLACES.map(function(placeDetail) {
			//placeDetail.CUSTOMERS = placeDetail.CUSTOMERS.map((custDetail)=> {
			placeDetail.CUSTOMERS = placeDetail.CUSTOMERS.map(function(custDetail) {
				//console.log( 'custDetail', custDetail);
				if( custDetail.LISTED == 'Y' )
				{
					counterObj.Listed ++;
				}
				else
				{
					counterObj.Unlisted ++;
				}

				switch(custDetail.CUST_TYPE)
				{
				case 'C': counterObj.Retailer ++; break;
				case 'D': counterObj.Doctor ++; break;
				case 'S': counterObj.Distributer ++; break;
				}
				return custDetail;
			});
			return placeDetail;
		});
		return callDetail;
	});

	console.log(customer, counterObj);
	//todaysNewObj['TODAYS_SUMMARY'] = todaysObj.TODAYS_SUMMARY.map((todaysummDetail)=> {
	todaysNewObj['TODAYS_SUMMARY'] = todaysObj.TODAYS_SUMMARY.map(function(todaysummDetail) {
		//console.log( todaysummDetail);
		todaysummDetail.OPTION_VALUE = counterObj[todaysummDetail.OPTION_NAME];
		return todaysummDetail;
	});

	//todaysNewObj['VISIT_SUMMARY'] = todaysObj.VISIT_SUMMARY.map((visitsummDetail)=> {
	todaysNewObj['VISIT_SUMMARY'] = todaysObj.VISIT_SUMMARY.map(function(visitsummDetail) {
		//console.log( visitsummDetail);
		visitsummDetail.OPTION_VALUE = counterObj[visitsummDetail.OPTION_NAME];
		return visitsummDetail;
	});

	//console.log(todaysNewObj);
	return todaysNewObj;
}
function getCallDetail(detailObj)
{
	var callDet = {};
    if( detailObj )
    {
		var place = getPlace(detailObj);
		var places = [];
		places.push(place);
		callDet = {
          "EVENT_DATE": detailObj.event_date,
          "PLACES": places
        };
    }
    return callDet;
}
function getPlace(detailObj)
{
	var place = {};
    if( detailObj )
    {
		var customer = getCustomer(detailObj);
		var customers = [];
		customers.push(customer);
        place = {
          "LOCALITY": detailObj.locality_descr,
          "EVENT_DATE": detailObj.event_date,
          "CUSTOMERS": customers,
          "EVENT_TIME": detailObj.event_time_start
        };
    }
    return place;
}
function getCustomer(detailObj)
{
    var customer = {};
    var strgtypedescr = '';
    if( detailObj )
    {
        switch(detailObj.strg_type)
        {
            case 'C': strgtypedescr = 'RETAILER'; break;
	        case 'D': strgtypedescr = 'DOCTOR'; break;
	        case 'S': strgtypedescr = 'DISTRIBUTER'; break;
        }
        customer = {
          "LISTED": detailObj.cust_type == 'LISTED' ? "Y" : "N",
          "STATUS": "UNPLANNED",
          "CUST_TYPE_DESCR": strgtypedescr,
          "CUST_CODE": detailObj.strg_code,
          "EVENT_TIME": detailObj.event_time_start,
          "CUST_TYPE": detailObj.strg_type,
          "CUST_NAME": detailObj.strg_name
        };
    }
    return customer;
}
//Added By Prajyot on 13/02/19 to Update Todays Dashboard Data while no network - Ends
function getDiffDaysBwtDates(reportDate,currentDate)
{
	try
	{
		var frReportDate = getFormatDate(reportDate);
		var toReportDate = getFormatDate(currentDate);

		var timeDiff = frReportDate.getTime() - toReportDate.getTime();
		var diffDays = timeDiff / (1000 * 3600 * 24);
		var differentDay = Math.round(diffDays);
		return 	differentDay;
	}
	catch(e1)
	{
		console.log(e1);
	}

}
//added by sagar B. for route_id changes
function localICFilterExprData( objName, formNo, fieldName )
{
	globalObjName = objName;
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		try
		{
			var filterExprValForIC = "";
			if( fieldName === 'locality_code' )
			{
				//filterExprValForIC = "locality_code == :locality_code: && visited_with_team == :visited_with_team: && route_id == :route_id:"
				filterExprValForIC = "locality_code == :locality_code: && visited_with_team == :visited_with_team:";
			}
			else if( fieldName === 'strg_code' )
			{
				filterExprValForIC = "strg_code == :strg_code: && visited_with_team == :visited_with_team:";
			}
			return filterExprValForIC;
		}
		catch(e1)
		{
			console.log(e1);
			return "";
		}
	}
	else
	{

	}
	
}
function isSubformMandatory(salesPersData)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var isMandatory=false;
		try
		{
			var surveyMan=[];
			surveyMan.push("ESL:C:LISTED");
			surveyMan.push("FR:C:LISTED");
			surveyMan.push("SFR:C:LISTED");
			surveyMan.push("KW:C:LISTED");
			surveyMan.push("KMT:C:LISTED");
			surveyMan.push("KFR:C:LISTED");
			surveyMan.push("KH:C:LISTED");
			surveyMan.push("ESL:W:LISTED");
			surveyMan.push("FR:W:LISTED");
			surveyMan.push("SFR:W:LISTED");
			surveyMan.push("KW:W:LISTED");
			surveyMan.push("KMT:W:LISTED");
			surveyMan.push("KFR:W:LISTED");
			surveyMan.push("KH:W:LISTED");
			if(surveyMan.indexOf(salesPersData)!= -1)
			{
				isMandatory=true;
			}

			return isMandatory;

		}
		catch(e1)
		{
			console.log(e1);
		}
	}
	else
	{

	}
}
function isTeamSubformMandatory(salesPersData)
{
	var isMandatory=false;
	try
	{
		var surveyMan=[];
		surveyMan.push("ESL:C");
		surveyMan.push("FR:C");
		surveyMan.push("SFR:C");
		surveyMan.push("KW:C");
		surveyMan.push("KMT:C");
		surveyMan.push("KFR:C");
		surveyMan.push("KH:C");
		surveyMan.push("ESL:W");
		surveyMan.push("FR:W");
		surveyMan.push("SFR:W");
		surveyMan.push("KW:W");
		surveyMan.push("KMT:W");
		surveyMan.push("KFR:W");
		surveyMan.push("KH:W");

		if(surveyMan.indexOf(salesPersData)!= -1)
		{
			isMandatory=true;
		}

		return isMandatory;

	}
	catch(e1)
	{
		console.log(e1);
	}

}
function showDetailsOrder(id,upImage,downImage)
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var value =  document.getElementById(id).src;
		var headerId="order."+id+".heading";
		var detailId="order."+id+".details";

		if(value == upImage)
		{
			document.getElementById(headerId).style.display = "none";
			document.getElementById(detailId).style.display = "none";
			document.getElementById(id).src = downImage;
		}
		else if(value == downImage)
		{
			document.getElementById(headerId).style.display = "";
			document.getElementById(detailId).style.display = "";
			document.getElementById(id).src = upImage;
		}
	}
	else
	{

	}
	
}
//Added by Sagar B to set brand_code and brand_descr on vision sense callback[18-Sep-19]START
function localICforAttachment( objContext, fieldName, domId, objFormName, fieldValue, noOfAttachments )
{
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		try
		{
			console.log("Inside localICforAttachment objContext["+objContext+"] fieldName["+fieldName+"] domId["+domId+"] objFormName["+objFormName+"] fieldValue["+fieldValue+"] noOfAttachments ["+noOfAttachments+"]");
			var returnXmlString = "";
			if( objFormName == 'display' && fieldValue != null )
			{
				var fieldValueJsonArr = JSON.parse( fieldValue );
				if( fieldValueJsonArr[0] )
				{
					var fieldValueJson = fieldValueJsonArr[0];
					var brand_code = fieldValueJson['ENTITY_CODE'];
					var brand_descr = fieldValueJson['PHOTO_DESCR'];
					returnXmlString += "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
					returnXmlString += "<Detail"+objContext+" dbID='' domID='"+domId+"' objContext='"+objContext+"'>"+
							"<brand_code>"+brand_code+"</brand_code>"+
							"<brand_descr>"+brand_descr+"</brand_descr>"+
							"</Detail"+objContext+">";
				}
			}
			//Added by Amey W. [OT activity related implementation] on 18/02/2020OfAttchments
			else if( objFormName == 'doctor' )
			{
				if( noOfAttachments != null )
				{
					if( noOfAttachments.length == 0 || noOfAttachments == 'undefined' )
					{
						console.log("Attchments NOT PRESENT");
						attachmentFlag = false;
					}
					else
					{
						console.log("Attchments PRESENT");
						attachmentFlag = true;
					}
				}
				else
				{
					attachmentFlag = false;;
				}
			}
			else if( objFormName == 'survey' && noOfAttachments != null )
			{
				try
				{
					var attachmentKey  = objFormName+'_'+domId;
					attachmentJson[ attachmentKey ] = noOfAttachments;
				}
				catch(ex)
				{
					console.log("amy noOfAttchments objFormName == 'survey' && noOfAttachments != null catch"+ex);
				}
			}
			console.log("Inside localICforAttachment returnXmlString["+returnXmlString+"]");
			return returnXmlString;
		}
		catch(e1)
		{
			console.log(e1);
			return "";
		}
	}
	else
	{

	}
}
//Added by Sagar B to set brand_code and brand_descr on vision sense callback[18-Sep-19]END

//Added by Prasad on 19/12/19 [coaching detail form related implementation] START
function getMultiLayoutMetadata_strg_meet_dcr_realtime_wiz_coaching_result5()
{
	var submissionJsonData = {};
	var jsonfieldDataJson = {};

	/*jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.height = "";
	jsonfieldDataJson.visible = "0";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[general]";
	jsonfieldDataJson.name = "activity_type";
	jsonfieldDataJson.displayLabel = "Activity";
	jsonfieldDataJson.textCase = "any";
	jsonfieldDataJson.initial = "A";

	submissionJsonData[ "activity_type" ] = jsonfieldDataJson;

	jsonfieldDataJson = {};*/

	jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.visible = "1";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.initial = "";
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[general]";
	jsonfieldDataJson.name = "task_descr";
	jsonfieldDataJson.displayLabel = "";
	jsonfieldDataJson.textCase = "any";
	jsonfieldDataJson.height = "31";

	submissionJsonData[ "task_descr" ] = jsonfieldDataJson;

	/*jsonfieldDataJson = {};

	jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.height = "";
	jsonfieldDataJson.visible = "0";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[general]";
	jsonfieldDataJson.name = "scope_type";
	jsonfieldDataJson.displayLabel = "Assign To";
	jsonfieldDataJson.textCase = "any";
	jsonfieldDataJson.initial = "P";

	submissionJsonData[ "scope_type" ] = jsonfieldDataJson;*/

	jsonfieldDataJson = {};

	jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.height = "";
	jsonfieldDataJson.visible = "0";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.initial = ""+selectedTeam;
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[general]";
	jsonfieldDataJson.name = "assigned_to";
	jsonfieldDataJson.displayLabel = "";
	jsonfieldDataJson.textCase = "any";

	submissionJsonData[ "assigned_to" ] = jsonfieldDataJson;

	console.log( "actionFieldData ["+ JSON.stringify(submissionJsonData) +"]" );
	return JSON.stringify(submissionJsonData);
}
//Added by Prasad on 19/12/19 [coaching detail form related implementation] END

//Added by Prasad on 24/12/19 [to display selected detail count] START
function getSubformCount( objName, formName, formNo,currentFormData,parentFormData )
{
	globalObjName = objName;
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		globalObjName = objName;

		if(parentFormData != null && parentFormData.trim().length > 0)
		{
			xmlDoc = parser.parseFromString(parentFormData,"text/xml");
		}
		var detailElement = xmlDoc.getElementsByTagName("Detail1");
		for (var i = 0; i < detailElement.length; i++)
		{
			var detail = detailElement[i];
			if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
			{
				eventType=detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
			}
		}
		var meterPurchasedVal = 0;
		currentFormData = "<Root>"+currentFormData+"</Root>";
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			xmlDoc = parser.parseFromString(currentFormData,"text/xml");
		}
		var detailElement = xmlDoc.getElementsByTagName("Detail"+formNo);
		for (var i = 0; i < detailElement.length; i++)
		{
			var meterPurchased = "";
			var value = 0;
			var updateFlag = "";
			var detail = detailElement[i];
			if( detail.getElementsByTagName("attribute")[0] != null)
			{
				updateFlag = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag")
			}
			if( detail.getElementsByTagName("result")[0] != null && detail.getElementsByTagName("result")[0].childNodes[0] != null && updateFlag != 'D' )
			{
				meterPurchased=detail.getElementsByTagName("result")[0].childNodes[0].nodeValue;
				if( meterPurchased != null && meterPurchased.length > 1 && isJson(meterPurchased))
				{
					var obj = JSON.parse(meterPurchased);
					value = Number(obj.meter_purchased);
				}
			}
			meterPurchasedVal = meterPurchasedVal + value;
		}
		if( formName === "coaching" )
		{
			return 1;
		}
		else if( eventType ==='OT' && formName === "survey" )
		{
			attchments = meterPurchasedVal;
			return meterPurchasedVal;
		}
		else
		{
			return 0;
		}
	}
	else
	{

	}
}
//Added by Prasad on 24/12/19 [to display selected detail count] END

//Added by Pankaj R to get filter xml data [START]
function getFilterXmlData( argsXml, dataModelXml, fieldName, detailXml )
{
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		console.log("argsXml["+ argsXml +"], detailXml["+ detailXml +"], dataModelXml[" + dataModelXml + "], fieldName ["+ fieldName +"]");

		var detailXmlDom = null;
		var dataModelXmlDom = null;
		var argXmlDom = null;
		var emptyXmlStr = "<Root></Root>";
		var xmlDomDummy = null;
		console.log("cureentform data is not null"+ detailXml);
		var xmlVersion = detailXml.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		if( detailXml != null && detailXml.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( detailXml.indexOf("<Root>") == -1 )
				{
					detailXml = "<Root>"+detailXml+"</Root>";
				}
			}
		}
		else
		{
			console.log("null formDetailData");
		}

		//Added by Prasad on 19/12/19 [coaching related implementation] START
		console.log("parentFormData data is not null"+ argsXml);
		if( argsXml != null && argsXml.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( argsXml.indexOf("<Root>") == -1 )get
				{
					argsXml = "<Root>"+argsXml+"</Root>";
				}
			}
		}
		else
		{
			console.log("null parentFormData");
		}
		//Added by Prasad on 19/12/19 [coaching related implementation] END

		console.log("parentFormData data is not null"+ dataModelXml);
		if( dataModelXml != null && dataModelXml.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( dataModelXml.indexOf("<Root>") == -1 )
				{
					dataModelXml = "<Root>"+dataModelXml+"</Root>";
				}
			}
		}
		else
		{
			console.log("null dataModelXml");
		}

		if ( window.DOMParser )
		{
			parser = new DOMParser();
			try
			{
				if( detailXml != null && detailXml.trim().length > 0 )
				{
					detailXmlDom = parser.parseFromString( detailXml, "text/xml" );
				}
				if( argsXml != null && argsXml.trim().length > 0 )
				{
					argXmlDom = parser.parseFromString( argsXml, "text/xml" );
				}
				if( dataModelXml != null && dataModelXml.trim().length > 0 )
				{
					dataModelXmlDom = parser.parseFromString( dataModelXml, "text/xml" );
				}
				xmlDomDummy = parser.parseFromString(emptyXmlStr, 'text/xml');
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		var parentDetailElement = argXmlDom.getElementsByTagName( "Root" );
		console.log("getDetailData parentDetailElement ==> "+parentDetailElement);
		var eventType = "", sprsCode = "", strgCode = "";
		for( var k= 0;k < parentDetailElement.length; k++)
		{
			var parentDetail = parentDetailElement[k];
			if( parentDetail.getElementsByTagName("event_type")[0] != null && parentDetail.getElementsByTagName("event_type")[0].childNodes[0] != null )
			{
				eventType = parentDetail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
			}
			console.log( "getDetailData eventType : ["+ eventType +"]" );

			if( parentDetail.getElementsByTagName("sales_pers")[0] != null && parentDetail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
			{
				sprsCode = parentDetail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
			}
			console.log( "getDetailData sprsCode : ["+ sprsCode +"]" );
			if( parentDetail.getElementsByTagName("strg_code")[0] != null && parentDetail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
			{
				strgCode = parentDetail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
			}
			console.log( "getDetailData strgCode : ["+ strgCode +"]" );
		}

		var empCode = getUserInfo( "empCode" );
		console.log( "getDetailData empCode : ["+ empCode +"]" );
		try
		{
			var isSelfCoachingDataFound = false;
			var path = "//Root/Detail1[event_type = '" + eventType + "' and strg_code = '" + strgCode + "' and sprs_code__ww = '"+ empCode.trim() +"']";
			if (dataModelXmlDom.evaluate)
			{
				var nodes = dataModelXmlDom.evaluate(path, dataModelXmlDom, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
				if (nodes != null && nodes.snapshotLength > 0)
				{
					isSelfCoachingDataFound = true;
					for (var i = 0; i < nodes.snapshotLength; i++)
					{
						xmlDomDummy.getElementsByTagName("Root").item(0).appendChild(nodes.snapshotItem(i));
					}
				}
			}
			//console.log( "selfCoaching : ["+ (new XMLSerializer().serializeToString(xmlDomDummy)) +"]" );

			if ( ! isSelfCoachingDataFound )
			{
				path = "//Root/Detail1[event_type = 'CA' and strg_code = 'NA' and sprs_code__ww = '"+ empCode.trim() +"']";
				if (dataModelXmlDom.evaluate)
				{
					var nodes = dataModelXmlDom.evaluate(path, dataModelXmlDom, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
					if (nodes != null && nodes.snapshotLength > 0)
					{
						for (var i = 0; i < nodes.snapshotLength; i++)
						{
							xmlDomDummy.getElementsByTagName("Root").item(0).appendChild(nodes.snapshotItem(i));
						}
					}
				}
				//console.log( "isSelfCoachingDataFound :: selfCoaching : ["+ (new XMLSerializer().serializeToString(xmlDomDummy)) +"]" );
			}

			path = "//Root/Detail2[event_type = '" + eventType + "' and strg_code = '" + strgCode + "' and sprs_code__ww = '" + sprsCode + "']";
			if (dataModelXmlDom.evaluate)
			{
				var nodes = dataModelXmlDom.evaluate(path, dataModelXmlDom, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
				if (nodes != null && nodes.snapshotLength > 0)
				{
					for (var i = 0; i < nodes.snapshotLength; i++)
					{
						xmlDomDummy.getElementsByTagName("Root").item(0).appendChild(nodes.snapshotItem(i));
					}
				}
			}
			//console.log( "reportingCoaching : ["+ (new XMLSerializer().serializeToString(xmlDomDummy)) +"]" );
		}
		catch(e)
		{
			console.log('filterData js : '+e);
		}
		return new XMLSerializer().serializeToString(xmlDomDummy);
	}
	else
	{

	}

}
// Addede by Pankaj R to get filter xml data [END]

function validateEndTime(startTimeStr, endTimeStr)
{
	var startTime = 0;
	var lastTime =0;
	var retFlag = true;
	try
	{
		startTime =  convertToMinute(startTimeStr.substring(0,5));
		lastTime = convertToMinute(endTimeStr.substring(0,5));
		console.log("startTime["+startTime+"]lastTime["+lastTime+"");
		if (startTime > 0 && lastTime > 0)
		{
			if (startTimeStr.substring(6,8) == "PM")
			{
				if (startTime < 720)
				{
				  startTime = startTime + 720;
				}
			}
			if (endTimeStr.substring(6,8) == "PM")
			{
				if (lastTime < 720)
				{
				  lastTime = lastTime + 720;
				}
			}
			if (startTime > lastTime )
			{
				retFlag = false;
			}
		}
	}
	catch(e)
	{
		console.log('validateEndTime js : '+e);
	}
	return retFlag;
}

function convertToMinute(timeStr)
{
	var p1 = "";
	var p2 = "";
	var p3 = "";
	var convertedMin = -1;
	try
	{
		if (timeStr != null && timeStr.trim().length == 5)
		{
			timeStr = timeStr.trim();
			p1 = timeStr.substring(0 , 2);
			p2 = timeStr.substring(2 , 3);
			p3 = timeStr.substring(3 , 5);
			var ip1 = parseInt(p1);
			var ip3 = parseInt(p3);
			convertedMin = (ip1*60) + ip3;
		}
	}
	catch(e)
	{
		console.log('convertToMinute js : '+e);
	}
	return convertedMin;
}

function getMultiLayoutMetadata_strg_meet_dcr_realtime_wiz_survey_result5()
{
	var submissionJsonData = {};
	var jsonfieldDataJson = {};

	console.log( " selectedActivity ["+ selectedActivity +"]" );
	if( selectedActivity == 'MI' )
	{
		jsonfieldDataJson.x = "";
		jsonfieldDataJson.y = "";
		jsonfieldDataJson.width = "";
		jsonfieldDataJson.visible = "1";
		jsonfieldDataJson.EditStyle = "";
		jsonfieldDataJson.limit = "";
		jsonfieldDataJson.required = "";
		jsonfieldDataJson.caseDet = "";
		jsonfieldDataJson.mask = "";
		jsonfieldDataJson.initial = "";
		jsonfieldDataJson.popHelp = "";

		jsonfieldDataJson.alignment = "0";
		jsonfieldDataJson.type = "text";
		jsonfieldDataJson.tabsequence = "0";
		jsonfieldDataJson.format = "[general]";
		jsonfieldDataJson.name = "attendee_name";
		jsonfieldDataJson.displayLabel = "Attendee Name";
		jsonfieldDataJson.textCase = "any";
		jsonfieldDataJson.height = "";

		submissionJsonData[ "attendee_name" ] = jsonfieldDataJson;

		jsonfieldDataJson = {};

		jsonfieldDataJson.x = "";
		jsonfieldDataJson.y = "";
		jsonfieldDataJson.width = "";
		jsonfieldDataJson.height = "";
		jsonfieldDataJson.visible = "1";
		jsonfieldDataJson.EditStyle = "";
		jsonfieldDataJson.limit = "10";
		jsonfieldDataJson.required = "";
		jsonfieldDataJson.caseDet = "";
		jsonfieldDataJson.mask = "";
		jsonfieldDataJson.popHelp = "";

		jsonfieldDataJson.alignment = "1";
		jsonfieldDataJson.type = "number";
		jsonfieldDataJson.tabsequence = "0";
		jsonfieldDataJson.format = "[number]";
		jsonfieldDataJson.name = "attendee_mobile_no";
		jsonfieldDataJson.displayLabel = "Mobile No";
		jsonfieldDataJson.textCase = "any";
		jsonfieldDataJson.initial = "";

		submissionJsonData[ "mobile_no" ] = jsonfieldDataJson;

		jsonfieldDataJson = {};

		jsonfieldDataJson.x = "";
		jsonfieldDataJson.y = "";
		jsonfieldDataJson.width = "";
		jsonfieldDataJson.height = "";
		jsonfieldDataJson.visible = "1";
		jsonfieldDataJson.EditStyle = "";
		jsonfieldDataJson.limit = "";
		jsonfieldDataJson.required = "";
		jsonfieldDataJson.caseDet = "";
		jsonfieldDataJson.mask = "";
		jsonfieldDataJson.initial = "";
		jsonfieldDataJson.popHelp = "";

		jsonfieldDataJson.alignment = "0";
		jsonfieldDataJson.type = "text";
		jsonfieldDataJson.tabsequence = "0";
		jsonfieldDataJson.format = "[general]";
		jsonfieldDataJson.name = "remarks";
		jsonfieldDataJson.displayLabel = "Remarks";
		jsonfieldDataJson.textCase = "any";

		submissionJsonData[ "remarks" ] = jsonfieldDataJson;
	}
	else if( selectedActivity == 'OT' )
	{
		jsonfieldDataJson = {};

		jsonfieldDataJson.x = "";
		jsonfieldDataJson.y = "";
		jsonfieldDataJson.width = "";
		jsonfieldDataJson.visible = "1";
		jsonfieldDataJson.EditStyle = "";
		jsonfieldDataJson.limit = "";
		jsonfieldDataJson.required = "";
		jsonfieldDataJson.caseDet = "";
		jsonfieldDataJson.mask = "";
		jsonfieldDataJson.initial = "";
		jsonfieldDataJson.popHelp = "";

		jsonfieldDataJson.alignment = "0";
		jsonfieldDataJson.type = "text";
		jsonfieldDataJson.tabsequence = "0";
		jsonfieldDataJson.format = "[general]";
		jsonfieldDataJson.name = "meter_name";
		jsonfieldDataJson.displayLabel = "Meter Name";
		jsonfieldDataJson.textCase = "any";
		jsonfieldDataJson.height = "";

		submissionJsonData[ "meter_name" ] = jsonfieldDataJson;

		jsonfieldDataJson = {};

		jsonfieldDataJson.x = "";
		jsonfieldDataJson.y = "";
		jsonfieldDataJson.width = "";
		jsonfieldDataJson.height = "";
		jsonfieldDataJson.visible = "1";
		jsonfieldDataJson.EditStyle = "";
		jsonfieldDataJson.limit = "10";
		jsonfieldDataJson.required = "";
		jsonfieldDataJson.caseDet = "";
		jsonfieldDataJson.mask = "";
		jsonfieldDataJson.popHelp = "";

		jsonfieldDataJson.alignment = "1";
		jsonfieldDataJson.type = "number";
		jsonfieldDataJson.tabsequence = "0";
		jsonfieldDataJson.format = "[general]";
		jsonfieldDataJson.name = "meter_purchased";
		jsonfieldDataJson.displayLabel = "Meter Purchased";
		jsonfieldDataJson.textCase = "any";
		jsonfieldDataJson.initial = "";

		submissionJsonData[ "meter_purchased" ] = jsonfieldDataJson;

		jsonfieldDataJson = {};

		jsonfieldDataJson.x = "";
		jsonfieldDataJson.y = "";
		jsonfieldDataJson.width = "";
		jsonfieldDataJson.visible = "0";
		jsonfieldDataJson.EditStyle = "";
		jsonfieldDataJson.limit = "";
		jsonfieldDataJson.required = "";
		jsonfieldDataJson.caseDet = "";
		jsonfieldDataJson.mask = "";
		jsonfieldDataJson.initial = "";
		jsonfieldDataJson.popHelp = "";

		jsonfieldDataJson.alignment = "0";
		jsonfieldDataJson.type = "text";
		jsonfieldDataJson.tabsequence = "0";
		jsonfieldDataJson.format = "[general]";
		jsonfieldDataJson.name = "meter";
		jsonfieldDataJson.displayLabel = "Meter";
		jsonfieldDataJson.textCase = "any";
		jsonfieldDataJson.height = "";

		submissionJsonData[ "meter" ] = jsonfieldDataJson;

		/*jsonfieldDataJson = {};

		jsonfieldDataJson.x = "";
		jsonfieldDataJson.y = "";
		jsonfieldDataJson.width = "";
		jsonfieldDataJson.height = "";
		jsonfieldDataJson.visible = "1";
		jsonfieldDataJson.EditStyle = "";
		jsonfieldDataJson.limit = "";
		jsonfieldDataJson.required = "";
		jsonfieldDataJson.caseDet = "";
		jsonfieldDataJson.mask = "";
		jsonfieldDataJson.initial = "";
		jsonfieldDataJson.popHelp = "";

		jsonfieldDataJson.alignment = "0";
		jsonfieldDataJson.tabsequence = "0";
		jsonfieldDataJson.format = "[camera]";
		jsonfieldDataJson.name = "receipt_attchments";
		jsonfieldDataJson.displayLabel = "Receipt's Attachments";
		jsonfieldDataJson.textCase = "any";

		submissionJsonData[ "receipt_attchments" ] = jsonfieldDataJson;*/
	}
	console.log( "actionFieldData ["+ submissionJsonData +"]" );
	return JSON.stringify(submissionJsonData);
}

//function getMultiLayoutMetadata_strg_meet_dcr_realtime_wiz()
//{
//var submissionJsonData = {};
//var jsonfieldDataJson = {};
//
///*jsonfieldDataJson.x = "";
//jsonfieldDataJson.y = "";
//jsonfieldDataJson.width = "";
//jsonfieldDataJson.height = "";
//jsonfieldDataJson.visible = "0";
//jsonfieldDataJson.EditStyle = "";
//jsonfieldDataJson.limit = "";
//jsonfieldDataJson.required = "";
//jsonfieldDataJson.caseDet = "";
//jsonfieldDataJson.mask = "";
//jsonfieldDataJson.popHelp = "";
//
//jsonfieldDataJson.alignment = "0";
//jsonfieldDataJson.tabsequence = "0";
//jsonfieldDataJson.format = "[general]";
//jsonfieldDataJson.name = "activity_type";
//jsonfieldDataJson.displayLabel = "Activity";
//jsonfieldDataJson.textCase = "any";
//jsonfieldDataJson.initial = "A";
//
//submissionJsonData[ "activity_type" ] = jsonfieldDataJson;
//
//jsonfieldDataJson = {};*/
//
//jsonfieldDataJson.x = "";
//jsonfieldDataJson.y = "";
//jsonfieldDataJson.width = "";
//jsonfieldDataJson.visible = "1";
//jsonfieldDataJson.EditStyle = "";
//jsonfieldDataJson.limit = "";
//jsonfieldDataJson.required = "";
//jsonfieldDataJson.caseDet = "";
//jsonfieldDataJson.mask = "";
//jsonfieldDataJson.initial = "";
//jsonfieldDataJson.popHelp = "";
//
//jsonfieldDataJson.alignment = "0";
//jsonfieldDataJson.tabsequence = "0";
//jsonfieldDataJson.format = "[general]";
//jsonfieldDataJson.name = "task_descr";
//jsonfieldDataJson.displayLabel = "";
//jsonfieldDataJson.textCase = "any";
//jsonfieldDataJson.height = "31";
//
//submissionJsonData[ "task_descr" ] = jsonfieldDataJson;
//
///*jsonfieldDataJson = {};
//
//jsonfieldDataJson.x = "";
//jsonfieldDataJson.y = "";
//jsonfieldDataJson.width = "";
//jsonfieldDataJson.height = "";
//jsonfieldDataJson.visible = "0";
//jsonfieldDataJson.EditStyle = "";
//jsonfieldDataJson.limit = "";
//jsonfieldDataJson.required = "";
//jsonfieldDataJson.caseDet = "";
//jsonfieldDataJson.mask = "";
//jsonfieldDataJson.popHelp = "";
//
//jsonfieldDataJson.alignment = "0";
//jsonfieldDataJson.tabsequence = "0";
//jsonfieldDataJson.format = "[general]";
//jsonfieldDataJson.name = "scope_type";
//jsonfieldDataJson.displayLabel = "Assign To";
//jsonfieldDataJson.textCase = "any";
//jsonfieldDataJson.initial = "P";
//
//submissionJsonData[ "scope_type" ] = jsonfieldDataJson;*/
//
//jsonfieldDataJson = {};
//
//jsonfieldDataJson.x = "";
//jsonfieldDataJson.y = "";
//jsonfieldDataJson.width = "";
//jsonfieldDataJson.height = "";
//jsonfieldDataJson.visible = "0";
//jsonfieldDataJson.EditStyle = "";
//jsonfieldDataJson.limit = "";
//jsonfieldDataJson.required = "";
//jsonfieldDataJson.caseDet = "";
//jsonfieldDataJson.mask = "";
//jsonfieldDataJson.initial = ""+selectedTeam;
//jsonfieldDataJson.popHelp = "";
//
//jsonfieldDataJson.alignment = "0";
//jsonfieldDataJson.tabsequence = "0";
//jsonfieldDataJson.format = "[general]";
//jsonfieldDataJson.name = "assigned_to";
//jsonfieldDataJson.displayLabel = "";
//jsonfieldDataJson.textCase = "any";
//
//submissionJsonData[ "assigned_to" ] = jsonfieldDataJson;
//
//console.log( "actionFieldData ["+ submissionJsonData +"]" );
//return JSON.stringify(submissionJsonData);
//}
// Addede by Pankaj R to get filter xml data [END]
function updateSubformNames( objName, formName, formNo, currentFormData )
{
	globalObjName = objName;
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		var eventType ="";
		console.log('updateSubformNames called',objName,formName,formNo,currentFormData);
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			xmlDoc = parser.parseFromString(currentFormData,"text/xml");
		}
		var detailElement = xmlDoc.getElementsByTagName("Detail1");
		console.log("detailElement.length =["+detailElement.length+"]");
		for (var i = 0; i < detailElement.length; i++)
		{
			var detail = detailElement[i];
			if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
			{
				eventType=detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
			}
			console.log("eventType =["+eventType+"]");
		}
		if( eventType ==='MI' && formName == "Survey" )
		{
			return "PeopleTrained";
		}
		//Added by Amey W. [ On change of Activity as OT, Survey subform name change to Receipt ] on 14-FEB-2020
		else if( eventType ==='OT' && formName == "Survey" )
		{
			console.log("eventType === OT");
			return "Receipt";
		}
		else
		{
			return formName;
		}
	}
	else
	{
		return formName;
	}
}

function showSubFormAddBtn( parentFormNo, parentFormData, currentFormNo, currentFormData )
{
	if(globalObjName === 'strg_meet_dcr_realtime_wiz')
	{
		var parentFormDataXml = parentFormData;
		parser = new DOMParser();
		try
		{
			if(parentFormDataXml != null && parentFormDataXml.trim().length > 0)
			{
				xmlDoc = parser.parseFromString(parentFormDataXml,"text/xml");
			}
		}
		catch(ex)
		{
			alert("Exception occurs while parsing xml data");
		}
		console.log('xmlDoc showAdd '+xmlDoc);
		try
		{
			if(xmlDoc!=null)
			{
				var detailElement = xmlDoc.getElementsByTagName("Detail"+parentFormNo);
				var detail = detailElement[i];
				var eventType = detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
				//W22EBAS005 added by prachi on 05-aug-2022
				if(currentFormNo.trim() == "team" || currentFormNo.trim() == "display" || currentFormNo.trim() == "collection")
				{
					return true;
				}
				else
				{
					if(eventType.trim() == 'MI' || eventType.trim() == 'OT')
					{
						return true;
					}
					else
					{
						return false;
					}
				}
				
			}

		}
		catch(ex)
		{
			alert("Exception in detail Element");
		}
	}
	else
	{
		
	}
}
//Added by sadique shaikh 02-03-2020 [For Event info for customer] Start
function getMultiLayoutMetadata_strg_meet_dcr_realtime_wiz_doctor_strg_event_info()
{
	var submissionJsonData = {};
	var jsonfieldDataJson = {};

	jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.visible = "0";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.initial = "BD";
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[general]";
	jsonfieldDataJson.name = "event_1";
	jsonfieldDataJson.displayLabel = "Event 1";
	jsonfieldDataJson.textCase = "any";
	jsonfieldDataJson.height = "";

	submissionJsonData[ "event_1" ] = jsonfieldDataJson;

	jsonfieldDataJson = {};

	jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.visible = "1";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.initial = "";
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[shortdate] [time]";
	jsonfieldDataJson.name = "event_dt1";
	jsonfieldDataJson.displayLabel = "Birth Date";
	jsonfieldDataJson.textCase = "any";
	jsonfieldDataJson.height = "";

	submissionJsonData[ "event_dt1" ] = jsonfieldDataJson;

	jsonfieldDataJson = {};

	jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.visible = "0";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.initial = "MAD";
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[general]";
	jsonfieldDataJson.name = "event_2";
	jsonfieldDataJson.displayLabel = "Event 2";
	jsonfieldDataJson.textCase = "any";
	jsonfieldDataJson.height = "";

	submissionJsonData[ "event_2" ] = jsonfieldDataJson;

	jsonfieldDataJson = {};

	jsonfieldDataJson.x = "";
	jsonfieldDataJson.y = "";
	jsonfieldDataJson.width = "";
	jsonfieldDataJson.visible = "1";
	jsonfieldDataJson.EditStyle = "";
	jsonfieldDataJson.limit = "";
	jsonfieldDataJson.required = "";
	jsonfieldDataJson.caseDet = "";
	jsonfieldDataJson.mask = "";
	jsonfieldDataJson.initial = "";
	jsonfieldDataJson.popHelp = "";

	jsonfieldDataJson.alignment = "0";
	jsonfieldDataJson.tabsequence = "0";
	jsonfieldDataJson.format = "[shortdate] [time]";
	jsonfieldDataJson.name = "event_dt2";
	jsonfieldDataJson.displayLabel = "Anniversary date";
	jsonfieldDataJson.textCase = "any";
	jsonfieldDataJson.height = "";

	submissionJsonData[ "event_dt2" ] = jsonfieldDataJson;

	console.log( "actionFieldData ["+ submissionJsonData +"]" );
	return JSON.stringify(submissionJsonData);
}
function isJson(str)
{
    try
    {
        JSON.parse(str);
    }
    catch (e)
    {
        return false;
    }
    return true;
}
//Added by sadique shaikh 02-03-2020 [For Event info for customer] End

function expandDetails(collapsibleID , iconID, collapse, expand)
{
    console.log("Value");
    var display = document.getElementById(collapsibleID).style.display;
    var iconchg = document.getElementById(iconID).src;
    if (display === "")
    {
        document.getElementById(collapsibleID).style.display = 'none';
        document.getElementById(iconID).src = expand;
    }
    if(display === "none")
    {
        document.getElementById(collapsibleID).style.display = "";
        document.getElementById(iconID).src = collapse;
    }
}
//Changes by Jatin M to expand/collapse details in feed view of summary page- end

//Changes by Jatin M to toggle between table and feed view- start
function focusView(iconLabel, view_alt_image, view_image)
{
    if(iconLabel === 'focusOnTable')
    {
        document.getElementById('section-n1').style.display = 'none';
        document.getElementById('section-n2').style.display = 'block';
        document.getElementById('tablebg').style.background = '#0273d0';
        document.getElementById('tableicon').src = view_alt_image;
        document.getElementById('feedbg').style.background = '#e6f4ff';
        document.getElementById('feedicon').src = view_image;
    }
    if(iconLabel === 'focusOnFeed')
    {
        document.getElementById('section-n1').style.display = 'block';
        document.getElementById('section-n2').style.display = 'none';
        document.getElementById('feedbg').style.background = '#0273d0';
        document.getElementById('feedicon').src = view_alt_image;
        document.getElementById('tablebg').style.background = '#e6f4ff';
        document.getElementById('tableicon').src = view_image;
    }
} 
//Changes by Jatin M to toggle between table and feed view- end

function setFeedBackground( objName, formName, formNo, currentFormData, parentFormData )
{
	globalObjName = objName;
	if(objName === 'strg_meet_dcr_realtime_wiz')
	{
		console.log('setFeedBackground called',objName,formName,formNo);
		console.log('setFeedBackground called currentFormData ',currentFormData,parentFormData);

		if(parentFormData != null && parentFormData.trim().length > 0)
		{
			xmlDoc = parser.parseFromString(parentFormData,"text/xml");

			var detailElement = xmlDoc.getElementsByTagName("Detail1");
			console.log("detailElement.length =["+detailElement.length+"]");
			for (var i = 0; i < detailElement.length; i++)
			{
				var detail = detailElement[i];
				if( detail.getElementsByTagName("event_type")[0] != null && detail.getElementsByTagName("event_type")[0].childNodes[0] != null )
				{
					eventType=detail.getElementsByTagName("event_type")[0].childNodes[0].nodeValue;
				}
				console.log("eventType =["+eventType+"]");
			}
		}
		var isFocusSKU = false;
		//currentFormData = "<Root>"+currentFormData+"</Root>";
		if(currentFormData != null && currentFormData.trim().length > 0)
		{
			xmlDoc = parser.parseFromString(currentFormData,"text/xml");
		}
		var detailElement = xmlDoc.getElementsByTagName("Detail"+formNo);
		console.log("detailElement.length =["+detailElement.length+"] formNo ["+ formNo +"]");
		for (var i = 0; i < detailElement.length; i++)
		{
			var detail = detailElement[i];
			if( detail.getElementsByTagName("is_focus_item")[0] != null && detail.getElementsByTagName("is_focus_item")[0].childNodes[0] != null )
			{
				var isFocusItem = detail.getElementsByTagName("is_focus_item")[0].childNodes[0].nodeValue;
				console.log("isFocusItem =["+ isFocusItem +"]");
				if ( "Y" == isFocusItem )
				{
					isFocusSKU = true;
				}
			}
			console.log("isFocusSKU 123 =["+ isFocusSKU +"]");
		}
		return isFocusSKU;
	}
	else
	{

	}
	
}

function getNonEchoBgColor( nonEchoInput )
{
    console.log("getNonEchoBgColor :: nonEchoInput : ["+ nonEchoInput +"]");
    if ( "CUST" == nonEchoInput || "PROD" == nonEchoInput || "ITEM" == nonEchoInput )
    {
        return "background-color: "+ getNonEchoBgColorCode( nonEchoInput ) +";";
    }
    else
    {
        return "display: none;";
    }
}

function getNonEchoBgColorCode( nonEchoInput )
{
    if ( "CUST" == nonEchoInput )
    {
        return "#f4e9ff";
    }
    else if ( "PROD" == nonEchoInput || "ITEM" == nonEchoInput )
    {
        return "#e5fbfb";
    }
    else
    {
        return "";
    }
}

function getLastVisitBgColor( lastVisitInput )
{
    console.log("getLastVisitBgColor :: lastVisitInput : ["+ lastVisitInput +"]");
    if ( lastVisitInput > 65 || lastVisitInput == -1 )
    {
        return "background-color: #ffe0e0;";
    }
    else if ( lastVisitInput <= 65 )
    {
        return "background-color: #ffebd0;";
    }
    else
    {
        return "display: none;";
    }
}

function getFocusSKUHtml( isFocusSKU )
{
    console.log("getFocusSKUHtml :: isFocusSKU : ["+ isFocusSKU +"]");
    if ( "Y" == isFocusSKU )
    {
        //alert("getFocusSKUHtml :: isFocusSKU : ["+ isFocusSKU +"]");
        return "<img style='width: 12px; height: 12px;' src='images/Star_rating.svg'>";
    }
    else
    {
        return "";
    }
}

function showRemarksDetails( fieldValue )
{
    console.log("showRemarksDetails :: fieldValue : ["+ fieldValue +"]");
    if ( fieldValue == null || "" == fieldValue )
    {
        return "";
    }
    else
    {
        return ("<br/><span style='color: #666'>Remarks : " + fieldValue + "</span>");
    }
}

function getPrevTwoOrderDet( prevTwoOrderDet )
{
	console.log( "getPrevTwoOrderDet : prevTwoOrderDet ["+ prevTwoOrderDet +"]" );
	var prevTwoOrderDetHtml = "<div style='float: right; font-size: 12px;text-align: right;width: 50%;'>";
    var prevTwoOrderDetArr = prevTwoOrderDet.split( "#" );
    for (var order in prevTwoOrderDetArr) 
    {
        console.log( "["+ order +"] : ["+ prevTwoOrderDetArr[order] +"]" );
        var prevOrder = prevTwoOrderDetArr[order];
        var prevDate = prevOrder.substring( 0, prevOrder.indexOf( " " ) );
        var prevOrderValue = prevOrder.substring( prevOrder.indexOf( " " ) + 1 );
        console.log( "["+ prevDate +"] : ["+ prevOrderValue +"]" );
        
        prevTwoOrderDetHtml += ("<span style='color: #666'>"+ prevDate +"</span>&nbsp;<b>"+ prevOrderValue +"</b>&nbsp;&nbsp;&nbsp;");
    }
    prevTwoOrderDetHtml += "</div> </div>";
    console.log( "getPrevTwoOrderDet : prevTwoOrderDetHtml ["+ prevTwoOrderDetHtml +"]" );
    
    return prevTwoOrderDetHtml;
}

function getNonEcoDetHtml( nonEcoInput )
{
    var nonEcoDetHtmlStr = "";
    console.log("getNonEcoDetHtml :: nonEcoInput : ["+ nonEcoInput +"]");
    if ( nonEcoInput != null && nonEcoInput.length > 0 )
    {
        nonEcoDetHtmlStr = '<div style="display: flex; flex-direction: row; height: auto; flex-wrap: wrap; margin: 4px 0 0 0;">';
        var nonEcoType = nonEcoInput.substring( 0, nonEcoInput.indexOf("-") );
        console.log( "nonEcoType : ["+ nonEcoType +"]" );
        var imageName = "Brand_icon.svg";
        if ( nonEcoType == "CUST" )
        {
            imageName = "Team_icon.svg";
        }
        console.log( "imageName : ["+ imageName +"]" );
        var colrCode = getNonEchoBgColorCode( nonEcoType );
        nonEcoDetHtmlStr += '<div style="'+ getNonEchoBgColor( nonEcoType ) +' border-radius: 20px; padding: 0px 8px; line-height: 20px; margin: 3px 6px 3px 0px; background-image: linear-gradient(135deg, '+ colrCode +' 56%, red 56%, '+ colrCode +' 57%); height: 20px;">';
         nonEcoDetHtmlStr += '<img style="width: 10px; height: 10px; top: 2px; position: relative; margin: 0 4px 0 0;" src="images/'+ imageName +'">';
        nonEcoDetHtmlStr += '<span style="font-size: 10px;">ECO</span>';
        nonEcoDetHtmlStr += '</div>';

        var nonEcoValue = nonEcoInput.substring( nonEcoInput.indexOf("-") + 1 );
        console.log( "nonEcoValue : ["+ nonEcoValue +"]" );
        var nonEcoValues = nonEcoValue.split( "," );
        console.log( "nonEcoValues : ["+ nonEcoValues +"]" );
        for (var nonEcoCtr in nonEcoValues) 
        {
            console.log( "["+ nonEcoCtr +"] : ["+ nonEcoValues[nonEcoCtr] +"]" );
            var nonEcoDet = nonEcoValues[nonEcoCtr];
            var nonEcoDetDescr = "";
            var nonEcoDetDays = "";
            if( nonEcoDet.indexOf("_SEP_") != -1 )
            {
                nonEcoDetDescr = nonEcoDet.substring( 0, nonEcoDet.indexOf("_SEP_") );
                nonEcoDetDays = nonEcoDet.substring( nonEcoDet.indexOf("_SEP_") + 5 );
            }
            else
            {
                nonEcoDetDays = nonEcoDet;
            }
            if ( nonEcoType == "CUST" || nonEcoDetDescr == null || nonEcoDetDescr == "" )
            {
                if( "-1" == nonEcoDetDays )
                {
                    nonEcoDetDescr = "NO ORDER";
                }
                else
                {
                    nonEcoDetDescr = nonEcoDetDays + " DAYS NO ORDER";
                }
            }
            
            nonEcoDetHtmlStr += '<div style="'+ getLastVisitBgColor( nonEcoDetDays ) +'; border-radius: 20px; padding: 0px 8px; line-height: 20px; margin: 3px 6px 3px 0px; height: 20px;">';
            nonEcoDetHtmlStr += '<span style="font-size: 10px;">'+ nonEcoDetDescr +'</span>';
            nonEcoDetHtmlStr += '</div>';
        }
        nonEcoDetHtmlStr += '</div>';
    }
    console.log( "nonEcoDetHtmlStr : ["+ nonEcoDetHtmlStr +"]" );
    return nonEcoDetHtmlStr;
}

function getProductNonEcoDetHtml( isProductEco, ecoDays )
{
    console.log( "getProductNonEcoDetHtml : isProductEco ["+ isProductEco +"], ecoDays ["+ ecoDays +"]" );
    if ( "N" == isProductEco )
    {
        var productNonEcoDet = "PROD-"+ ecoDays;
        console.log( "getSKUNonEcoDetHtml : productNonEcoDet ["+ productNonEcoDet +"]" );
        return getNonEcoDetHtml( productNonEcoDet );
    }
    return "";
}

function getSKUNonEcoDetHtml( isSKUEco, ecoDays )
{
    console.log( "getSKUNonEcoDetHtml : isSKUEco ["+ isSKUEco +"], ecoDays ["+ ecoDays +"]" );
    if ( "N" == isSKUEco )
    {
        var skuNonEcoDet = "ITEM-"+ ecoDays;
        console.log( "getSKUNonEcoDetHtml : skuNonEcoDet ["+ skuNonEcoDet +"]" );
        return getNonEcoDetHtml( skuNonEcoDet );
    }
    return "";
}

function showItemDetails( quantity, rate, value, stockQty )
{
    console.log("showItemDetails :: quantity : ["+ quantity +"], rate ["+ rate +"], value ["+ value +"], stockQty : ["+ stockQty +"]");
    quantity = quantity || 0;
    value = value || 0;
    stockQty = stockQty || 0;
    if ( (quantity != null && quantity > 0) || (value != null && value > 0) || (stockQty != null && stockQty > 0) )
    {
        return "<b>"+ quantity +" </b><span style='color: #666'>Nos @ </span><b>"+ rate +"</b><span style='color: #666'> = INR </span><b>"+ value +"</b><span style='float: right;'><span style='color: #666'>Stocks</span> <b>"+ stockQty +"</b></span>";
    }
    else
    {
        return "";
    }
}

//Added by Prasad on 11/08/2021 [to display non visited customers] START
function expandNonVisitedRouteDetails(ele)
{
    expandDetails(ele.getAttribute("contentDivId"), ele.getAttribute("buttonId"));
}

function getNonVisitedRoute()
{
    console.log("In getNonVisitedRoute");
    
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        console.log("this.status[",this.status,"]");
        console.log("this ",this);
        if (this.status == 200) 
        {
            console.log("responsetext : ", this.responseText);
            let elm =  document.getElementById( "section-n1-not-visited" );
            let tableViewElm =  document.getElementById( "section-n2-not-visited" );
            console.log("elm::", elm);
            //elm.innerHTML = this.responseText;
            let response = this.responseText.substring( this.responseText.indexOf("[") );
            console.log("response : ", response);
            //obj = JSON.parse(response)
            //let response = this.responseText;
            if ( response )
            {
                elm.innerHTML = "";
                tableViewElm.innerHTML = "";

                let arr = JSON.parse(response);
                console.log("responsetext :arr ", arr);
                if ( arr.length > 0 )
                {
                    var dtls = document.createElement("div");
                    let headerDiv = document.createElement("div");
                    headerDiv.setAttribute("class","headerdata datafontsize");
                    headerDiv.setAttribute("style","color: #f85719;");
                    var headerDivContent = 
                        '<img class="outerIcon align-imgtext" src="/ibase/webitm/images/Summary/subform_team.svg">'+ (arr.length) +' Customer(s) Not visited'+
                        '<div class="tab">'+
                            '<button onclick="expandNonVisitedRouteDetails( this )" contentDivId="not_visited_section_n1_content" buttonId="not_visited_section_n1_btn" class="rmvborder" type="button">'+
                                '<div class="btnborder align-imgtext">'+
                                    '<img class="collapsibleIconRadius align-imgtext" id="not_visited_section_n1_btn" src="/ibase/webitm/images/Summary/collapse.svg">'+
                                '</div>'+
                            '</button>'+
                        '</div>';

                    headerDiv.innerHTML = headerDivContent;
                    dtls.appendChild(headerDiv);
                    
                    var dtlsTableDiv = document.createElement("div");
                    let headerTableDiv = document.createElement("div");
                    headerTableDiv.setAttribute("class","headerdata datafontsize");
                    headerTableDiv.setAttribute("style","color: #f85719;");

                    var headerTableDivContent = (arr.length) +' Customer(s) Not visited';
                    headerTableDiv.innerHTML = headerTableDivContent;
                    
                    dtlsTableDiv.appendChild(headerTableDiv);

                    let contentDiv = document.createElement("div");
                    contentDiv.id = "not_visited_section_n1_content";
                    contentDiv.setAttribute("class","containerfeed datafontsize");
                    
                    let contentTableDiv = contentDiv.cloneNode(true);
                    contentTableDiv.setAttribute("class","containertable");
                    
                    let contentTableInnerDiv = document.createElement("div");
                    contentTableInnerDiv.setAttribute("style","-webkit-overflow-scrolling: touch; overscroll-behavior-x: none; scroll-snap-type: none; margin: 0 !important;");
                    contentTableInnerDiv.setAttribute("class","doctorcontainer");
                    
                    contentTableDiv.appendChild( contentTableInnerDiv );
                    
                    var rowTableHdrDiv = document.createElement("div");
                    rowTableHdrDiv.setAttribute("class","datafontsize");
                    
                    var htmlTableHdrStr = getTableHdrHTML();
                    rowTableHdrDiv.innerHTML = htmlTableHdrStr;
                    
                    contentTableInnerDiv.appendChild( rowTableHdrDiv );
                    
                    for( i = 0; i < arr.length; i++ )
                    {
                        let detailJson = arr[i];
                        var rowDiv = document.createElement("div");
                        rowDiv.setAttribute("class","datafontsize");
                        if ( i != ( arr.length - 1 ) )
                        {
                            rowDiv.setAttribute("style","padding: 0 0 12px 0");
                        }
                        
                        let rowTableDiv = rowDiv.cloneNode(true);
                        rowTableDiv.removeAttribute("style");
                        
                        var strgCode = detailJson["strg_code"] ? detailJson["strg_code"] : "";
                        var strgName = detailJson["strg_name"] ? detailJson["strg_name"] : "";
                        var localityDescr = detailJson["locality_descr"] ? detailJson["locality_descr"] : "";
                        var specialityDescr = detailJson["speciality_descr"] ? detailJson["speciality_descr"] : "";
                        var classCode = detailJson["class_code_descr"] ? detailJson["class_code_descr"] : "";
                        var nonEcoDet = detailJson["non_eco_det"] ? detailJson["non_eco_det"] : "";

                        var htmlStr = getFeedHTML( strgCode, strgName, localityDescr, specialityDescr, classCode, nonEcoDet );
                        rowDiv.innerHTML = htmlStr;
                        
                        contentDiv.appendChild( rowDiv );
                        
                        var htmlTableStr = getTableHTML( strgName, localityDescr, specialityDescr, classCode, nonEcoDet );
                        rowTableDiv.innerHTML = htmlTableStr;
                        
                        contentTableInnerDiv.appendChild( rowTableDiv );
                    }
                    dtls.appendChild(contentDiv);
                    elm.appendChild(dtls);
                    
                    dtlsTableDiv.appendChild(contentTableDiv);
                    tableViewElm.appendChild(dtlsTableDiv);
                }
            }
            //elm.innerHTML = this.responseText;
        }
    };
    
    var salesPers = (document.getElementById("sales_pers") || document.getElementById("SALES_PERS")).value;
    var dcrDate = (document.getElementById("dcr_event_date") || document.getElementById("event_date") || document.getElementById("EVENT_DATE")).value;
    
    xhttp.open("GET", '/ibase/rest/E12WSFACommonService/getNonVisitedRoute?SALES_PERS='+salesPers+'&EVENT_DATE='+dcrDate, true);
    xhttp.send();
}

function getFeedHTML( strgCode, strgName, localityDescr, specialityDescr, classCode, nonEcoDet )
{
	var htmlStr = '<div class="customerDiv">'+
	    '<div class="iconborder bluebg-icon">'+
	    	'<img class="bradius align-imgtext" onerror="this.src=&quot;../images/map/user.png&quot;" src="/ibase/CustomMenuImageServlet?fldValue='+ strgCode +'&object=wsfa_strg_customer&objName=wsfa_strg_customer&ALT_FLD_VALUE='+ strgName +'" >'+
	    '</div>'+
	    '<div class="addspace large-font">'+
	        '<div>'+
	            strgName +'<br/>'+
	            '<div class="align-customer" style="font-size: 12px;">'+
	                '<img class="cust-location align-imgtext" src="/ibase/webitm/images/Summary/summary_place_alt.svg">'+ localityDescr +
	            '</div>'+
	        '</div>'+
	        /*'<div class="small-font">'+
	            '<span class="textcolor">Speciality  </span>'+ specialityDescr +', '+ 
	            '<span class="textcolor">Class  </span>'+ classCode +
	        '</div>'+*/
	    '</div>'+
	    '<div class="rightcol-spacing">'+
	        '<div>'+ getNonEcoDetImg( nonEcoDet ) +'</div>'+
	    '</div>'+
	'</div>';
	
	return htmlStr;
}

function getTableHdrHTML()
{
	var htmlStr = '<div class="headerfontsize doctordetails textcolor">'+
		'<div class="headingwidth firstcolumn docname" style="width: 50%">NAME</div>'+
		/*'<div class="headingwidth class" style="width: 10%">CLASS</div>'+
		'<div class="headingwidth speciality lastcolumn" style="width: 15%">SPECIALITY</div>'+*/
        '<div class="headingwidth lastcolumn" style="width: 30%">Eco/Non-Eco</div>'+
	'</div>';
	
	return htmlStr;
}

function getTableHTML( strgName, localityDescr, specialityDescr, classCode, nonEcoDet )
{
	var htmlStr = '<div class="stickysubforms">'+
		'<div class=" datafontsize docdatadetails">'+
			'<div class="detailswidth firstcolumn docname hideoverflow" style="width: 50%">'+ strgName +'</div>'+
			/*'<div class="detailswidth class hideoverflow" style="width: 10%">'+ classCode +'</div>'+
			'<div class="detailswidth speciality lastcolumn hideoverflow" style="width: 15%">'+ specialityDescr +'</div>'+*/
            '<div class="detailswidth lastcolumn hideoverflow" style="width: 30%">'+ getNonEcoDetImg( nonEcoDet ) +'</div>'+
		'</div>'+
	'</div>';
	
	return htmlStr;
}

function getNonEcoDetImg( nonEcoInput )
{
    var nonEcoDetHtmlStr = "";
    if ( nonEcoInput != null && nonEcoInput.length > 0 )
    {
        nonEcoDetHtmlStr = '<div style="display: flex; flex-direction: row; height: auto; flex-wrap: wrap; margin: 4px 0 0 0;">';
        var nonEcoType = nonEcoInput.substring( 0, nonEcoInput.indexOf("-") );
        var imageName = "Brand_icon.svg";
        if ( nonEcoType == "CUST" )
        {
            imageName = "Team_icon.svg";
        }
        console.log( "imageName : ["+ imageName +"]" );
        var colrCode = getNonEchoBgColorCode( nonEcoType );
        nonEcoDetHtmlStr += '<div style="'+ getNonEchoBgColor( nonEcoType ) +' border-radius: 20px; padding: 0px 8px; line-height: 20px; margin: 3px 6px 3px 0px; background-image: linear-gradient(135deg, '+ colrCode +' 56%, red 56%, '+ colrCode +' 58%); height: 20px;">';
         nonEcoDetHtmlStr += '<img style="width: 10px; height: 10px; top: 2px; position: relative; margin: 0 4px 0 0;" src="/ibase/E12BROWSER/images/'+ imageName +'">';
        nonEcoDetHtmlStr += '<span style="font-size: 10px;">ECO</span>';
        nonEcoDetHtmlStr += '</div>';
     
        nonEcoDetHtmlStr += '</div>';
    }
    return nonEcoDetHtmlStr;
}
//Added by Prasad on 11/08/2021 [to display non visited customers] END

//Added By Nilesh for Chc Changes 

function showItemUOMDescr( item_size )
{
    var itemSizeArray = item_size.split('#');

	var itemSizeUOMDescr= itemSizeArray[1];
	
    if (  itemSizeUOMDescr != null  )
    {
        return "<span style='color: #666'>"+ itemSizeUOMDescr +" </span>";
    }
    else
    {
        return "";
    }
}

function showItemSize( item_size )
{
    
	var itemSizeArray = item_size.split('#');

	var itemSize = itemSizeArray[0];

    if (  itemSize != null  )
    {
        return " <div style ='display: flex;'> <div style='white-space: normal !important;width: 50%;font-weight: 600;'>"+ itemSize +" </div>";
    }
    else
    {
        return "";
    }
}
function getTotalPOBValue(allFormDetaildataDom, objContext)
{
    var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
	console.log("detailElement =["+detailElement+"]");	
    var totalPOBValue = 0;		
    for (var i = 0; i < detailElement.length; i++)
    {
        var quantity = "";
        var rate = "";
       
        var discount = "";
        var detail = detailElement[i];
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");
        //alert("domIDVal =["+domIDVal+"]");

        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("landing_rate")[0] != null && detail.getElementsByTagName("landing_rate")[0].childNodes[0] != null && detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null)
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        else if( detail.getElementsByTagName("landing_rate")[0] != null && detail.getElementsByTagName("landing_rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("landing_rate")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("disc_perc")[0] != null && detail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
        {
            discount = detail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
        }
        
		if(attributeVal != null && attributeVal != 'D')
		{
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				//value=parseFloat(quantity) * parseFloat(rate);
				//totalPOBValue = totalPOBValue + (parseFloat(quantity) * parseFloat(rate));
				if ( quantity > 0 && rate > 0)
				{
					totalPOBValue = totalPOBValue + (parseFloat(quantity) * parseFloat(rate) - (discount * (rate * quantity) /100));
					totalPOBValue = Number(Math.round(totalPOBValue+'e'+2)+'e-'+2);
				}
			}
		}
		/*if(attributeVal != null && attributeVal == 'D')
		{
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				//value=parseFloat(quantity) * parseFloat(rate);
			//	totalPOBValue = totalPOBValue + (parseFloat(quantity) * parseFloat(rate));
				if ( quantity > 0 && rate > 0)
				{
					totalPOBValue = totalPOBValue - (parseFloat(quantity) * parseFloat(rate) - (discount * (rate * quantity) /100));
					totalPOBValue = Number(Math.round(totalPOBValue+'e'+2)+'e-'+2);
				}
			}
		}*/
    }
    return totalPOBValue;
}
function getTotalBasicAmt(allFormDetaildataDom, objContext)
{
    var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
	console.log("detailElement in Invoice getTotalBasicAmt =["+detailElement+"]");	
    var totalBasicAmt = 0;		
    for (var i = 0; i < detailElement.length; i++)
    {
        var quantity = "";
        var rate = "";
       
        var detail = detailElement[i];
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");

        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        
		if(attributeVal != null && attributeVal != 'D')
		{
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				if ( quantity > 0 && rate > 0)
				{
					totalBasicAmt = totalBasicAmt + ((parseFloat(quantity) * parseFloat(rate)));
					totalBasicAmt = Number(Math.round(totalBasicAmt+'e'+2)+'e-'+2);
				}
			}
		}
    }
    return totalBasicAmt;
}
/*function getTotalGSTValue(allFormDetaildataDom, objContext)
{
    var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
	console.log("detailElement in Invoice gettotalGSTValue =["+detailElement+"]");	
    var totalGSTValue = 0;		
    for (var i = 0; i < detailElement.length; i++)
    {
        var taxAmount ="";
        var quantity ="";
        var rate ="";
        var detail = detailElement[i];
        console.log("detail =["+detail+"]");
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");
        console.log("domIDVal =["+domIDVal+"]");

        if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
        {
        	taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        
        console.log("taxAmount =["+taxAmount+"], attributeVal=["+attributeVal+"]");
		if(attributeVal != null && attributeVal != 'D')
		{
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				if( taxAmount != 'undefined' && taxAmount != null && taxAmount != "")
				{
						totalGSTValue = totalGSTValue + ((parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /100))));
						totalGSTValue = Number(Math.round(totalGSTValue+'e'+2)+'e-'+2);
				}
			}
		}
    }
    return totalGSTValue;
}*/
function getTotalSGSTValue(allFormDetaildataDom, objContext)
{
	
    var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
	console.log("detailElement in Invoice gettotalSGSTValue =["+detailElement+"]");	
    var totalSGSTValue = 0;		
    for (var i = 0; i < detailElement.length; i++)
    {
        var quantity ="";
        var rate ="";
        var taxAmount ="";
        var detail = detailElement[i];
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");

        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
        {
        	taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
        }
        
		if(attributeVal != null && attributeVal != 'D')
		{
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				if ( quantity > 0 && rate > 0)
				{
					//totalGSTValue = totalGSTValue + (parseFloat(taxAmount /100));
					totalSGSTValue = totalSGSTValue + ((parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /200))));
					totalSGSTValue = Number(Math.round(totalSGSTValue+'e'+2)+'e-'+2);
				}
			}
		}
    }
    return totalSGSTValue;
}
/*function getTotalCGSTValue(allFormDetaildataDom, objContext, parentFormNo)
{
	var parentElement  =allFormDetaildataDom.getElementByTagName("Detail"+parentFormNo);
	var cgstAmt="";
	for (var i = 0; i < parentElement.length; i++)
	{
		var parent = parentElement[i];
		if( parent.getElementsByTagName("total_cgst")[0] != null && parent.getElementsByTagName("total_cgst")[0].childNodes[0] != null )
		{
			cgstAmt = parent.getElementsByTagName("total_cgst")[0].childNodes[0].nodeValue;
		}
		
	}
	console.log("parentForm cgst in methodl::"+cgst);
    var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
	console.log("detailElement in Invoice gettotalSGSTValue =["+detailElement+"]");	
	var totalCGSTValue = 0;		
    for (var i = 0; i < detailElement.length; i++)
    {
        var quantity ="";
        var rate ="";
        var detail = detailElement[i];
        console.log("detail =["+detail+"]");
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");
        console.log("domIDVal =["+domIDVal+"]");

        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        
        console.log("taxAmount =["+taxAmount+"], attributeVal=["+attributeVal+"]");
		if(attributeVal != null && attributeVal != 'D')
		{
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				if ( quantity > 0 && rate > 0)
				{
					//totalGSTValue = totalGSTValue + (parseFloat(taxAmount /100));
					totalCGSTValue = totalCGSTValue + ((parseFloat(quantity) * parseFloat(rate) * (parseFloat(cgstAmt /100))));
					totalCGSTValue = Number(Math.round(totalCGSTValue+'e'+2)+'e-'+2);
				}
			}
			console.log("totalSGSTValue Is in method =["+totalCGSTValue+"]");
		}
    }
    return totalCGSTValue;
}*/
function getTotalAmount(allFormDetaildataDom, objContext)
{
    var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
	console.log("detailElement in Invoice totalAmount =["+detailElement+"]");	
    var totalAmount = 0;		
    for (var i = 0; i < detailElement.length; i++)
    {
        var quantity = "";
        var rate = "";
       
        var discount = "";
        var taxAmount ="";
        var detail = detailElement[i];
        console.log("detail =["+detail+"]");
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");

        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
        {
        	taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
        }
        
		if(attributeVal != null && attributeVal != 'D')
		{
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				if ( quantity > 0 && rate > 0)
				{
					totalAmount = totalAmount + ((parseFloat(quantity) * parseFloat(rate)) + ((parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /100)))) );
					totalAmount = Number(Math.round(totalAmount+'e'+2)+'e-'+2);
				}
			}
		}
    }
    return totalAmount;
}
function getTotaCurrStock(allFormDetaildataDom, objContext)
{
    var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
    var totalStock = 0;		
    for (var i = 0; i < detailElement.length; i++)
    {
        var quantity = "0";
         var currStock = "0";
       
        var detail = detailElement[i];
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");

        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
        {
            currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
        }
       
        console.log("quantity =["+quantity+"], currStock=["+currStock+"]");
		if(attributeVal != null && attributeVal != 'D')
		{
			if( quantity != 'undefined' && quantity != null && currStock != 'null' && currStock != 'undefined' && quantity != "" && currStock != "")
			{
				if ( quantity > 0 && currStock > 0)
				{
					totalStock = ((parseFloat(currStock) - parseFloat(quantity)));
					
				}
			}
		}
    }
    return totalStock;
}
let a = [
         "",
         "One ",
         "Two ",
         "Three ",
         "Four ",
         "Five ",
         "Six ",
         "Seven ",
         "Eight ",
         "Nine ",
         "Ten ",
         "Eleven ",
         "Twelve ",
         "Thirteen ",
         "Fourteen ",
         "Fifteen ",
         "Sixteen ",
         "Seventeen ",
         "Eighteen ",
         "Nineteen ",
       ];
       let b = [
         "",
         "",
         "Twenty",
         "Thirty",
         "Forty",
         "Fifty",
         "Sixty",
         "Seventy",
         "Eighty",
         "Ninety",
       ];

function inWords(num)
{
     if ((num = num.toString()).length > 9) return "overflow";
 let n = ("000000000" + num)
   .substr(-9)
   .match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
 if (!n) return;
 var str = "";
 str +=
   n[1] != 0
     ? (a[Number(n[1])] || b[n[1][0]] + " " + a[n[1][1]]) + "Crore "
 : "";
 str +=
   n[2] != 0
     ? (a[Number(n[2])] || b[n[2][0]] + " " + a[n[2][1]]) + "Lakh "
 : "";
 str +=
   n[3] != 0
     ? (a[Number(n[3])] || b[n[3][0]] + " " + a[n[3][1]]) + "Thousand "
 : "";
 str +=
   n[4] != 0
     ? (a[Number(n[4])] || b[n[4][0]] + " " + a[n[4][1]]) + "Hundred "
 : "";
 str +=
   n[5] != 0
     ? (str != "" ? "and " : "") +
   (a[Number(n[5])] || b[n[5][0]] + " " + a[n[5][1]])
 : "";
     return str;
   }
//Added by mrunalini Sinkar for 1)Invoice id genration :InvoiceIDGenration ::Start
function InvoiceIDGenration(allFormDetaildataDom, objContext,invoiceNoref,maxInvoiceNo,cashInvoiceAmnt)
{
	console.log("InvoiceIDGenration maxInvoiceNo["+maxInvoiceNo+"]invoiceNoref["+invoiceNoref+"]");
	var itemWIthInvoice=[];
	var invoiceIDDetails=[];
	 var totalValuesInvoiceIDList =[];
	var amountWithInvoiceList=[];
	var invoiceList=[];
	var minMaxInvIdList=[];
	var InvoiceNum="";
	var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
    for (var i = 0; i < detailElement.length; i++)
    {
        var quantity = "";
        var rate = "";
        var itemCode="";
        var itemDscr="";
       
        var taxAmount ="";
        
         var totalValue = "0";
         var basicValue = "0";
         var gstValue ="0";
         
         var maxCashAMount="";
         
      if(cashInvoiceAmnt!=null && cashInvoiceAmnt!="")
      {
      	maxCashAMount=cashInvoiceAmnt
      }
      else
      {
      	maxCashAMount=40000;
      }	

       	maxCashAMount=parseFloat(maxCashAMount);
       	
        var detail = detailElement[i];
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");

         if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
        {
        	taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
        }
         if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
        {
            itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
        }
       if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
        {
            itemDscr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
        }
        
		if(attributeVal != null && attributeVal != 'D')
		{
			var flagFalse=false;
			
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				if ( quantity > 0 && rate > 0)
				{
					basicValue = (parseFloat(quantity) * parseFloat(rate));
					basicValue = Number(Math.round(basicValue+'e'+2)+'e-'+2);
					gstValue =  (parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /100)));
					gstValue = Number(Math.round(gstValue+'e'+2)+'e-'+2);
					totalValue = ((parseFloat(quantity) * parseFloat(rate)) + ((parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /100)))) );
					totalValue = Number(Math.round(totalValue+'e'+2)+'e-'+2);
				}
			}

			if(invoiceList!=null && invoiceList!= "" )	
			{
       		 	var totalAmountInvoiceList=[];
				for(var j=0;j < invoiceList.length;j++)
				{
					var invoiceCOdeFrmList = invoiceList[j];
					var invoiceTotalSumValue=0;
					if(amountWithInvoiceList!=null && amountWithInvoiceList!= "" )	
						{
							for(var k=0;k < amountWithInvoiceList.length;k++)
							{
								var amountCodeFrmList = amountWithInvoiceList[k];
								
								var invoiceOfAmount=amountCodeFrmList.split("@")[0];
								if(invoiceCOdeFrmList == invoiceOfAmount)
								{
									var invoicetotalValue=amountCodeFrmList.split("@")[1];
									
									invoiceTotalSumValue=((parseFloat(invoiceTotalSumValue) + parseFloat(invoicetotalValue)));
								}//if loop invoiceCOdeFrmList
								
							}//for loop k
							
							
						}// if loop amountWithInvoiceList
					totalAmountInvoiceList.push(invoiceCOdeFrmList+"@"+invoiceTotalSumValue);
				}// for loop invoiceList
		
			}// if loop invoiceList

			if(totalAmountInvoiceList!=null && totalAmountInvoiceList!="" )
			{
				
				for(var m=0;m < totalAmountInvoiceList.length;m++)
				{
					var InvoiceamountCodeFrmList = totalAmountInvoiceList[m];
					
					var listInvoiceID=InvoiceamountCodeFrmList.split("@")[0];
					var invoiceOfTotalAmount=InvoiceamountCodeFrmList.split("@")[1];
					
					var totalValueSumList=((parseFloat(invoiceOfTotalAmount) + parseFloat(totalValue)));
					if(totalValueSumList <=  maxCashAMount)
					{
						var listamount=listInvoiceID+"@"+totalValue;
						amountWithInvoiceList.push(listamount);	
						var checkamtDetails=listInvoiceID+"@"+basicValue+"@"+gstValue+"@"+totalValue;
						var listItem=domIDVal+"@"+itemCode+"@"+listInvoiceID;
						if(itemWIthInvoice.indexOf(listItem)  ==-1)
			        	{
			        		itemWIthInvoice.push(listItem);
			        		invoiceIDDetails.push(checkamtDetails);
							flagFalse=true;
							break;
			        	}
					}
					
				}
				
			}	
			if( totalValue != 'undefined' && totalValue != null && totalValue != "" && flagFalse==false)
			{
				
				if ( totalValue >= 0)
				{

				if(InvoiceNum!=null && InvoiceNum!= "" )	
				{
					var lastDigitInv=InvoiceNum.substring(invNumberStart.length, InvoiceNum.length);
							var newDigitInv=parseInt(lastDigitInv)+parseInt("1");
							var invGenrate='' + newDigitInv;
							var newInvGen=invGenrate.length;
							var maxLength=10-newInvGen;
							var resultInv = InvoiceNum.substring(0, maxLength);
							InvoiceNum= resultInv + newDigitInv;

				}
				else
				{
						var invNumberStart="";
						if(invoiceNoref.indexOf("/")!=-1)
						{
							invNumberStart=invoiceNoref.split("/")[1];
						}
						 
						else
						{
							invNumberStart=invoiceNoref;
						}
						
						 if(invNumberStart!=null && invNumberStart!="")
						 {
						 	invNumberStart=invNumberStart;
						 }
						 else
						 {
						 	invNumberStart="1101";
						 }
						if(maxInvoiceNo!=null &&  maxInvoiceNo!="" )
						{
							maxInvoiceNo=maxInvoiceNo.substring(invNumberStart.length, maxInvoiceNo.length);
							var invoiceGenrate=parseInt(maxInvoiceNo)+parseInt("1");
							var my_string = '' + invNumberStart;
		    				while (my_string.length < 10) 
		    				{
		        				my_string =  my_string+'0';
		   					}
							var invGenrate='' + invoiceGenrate;
							var newInvGen=invGenrate.length;
							var maxLength=10-newInvGen;
							var result = my_string.substring(0, maxLength);
							InvoiceNum= result + invoiceGenrate;
						}
						else
						{
							
							var my_string = '' + invNumberStart;
		    				while (my_string.length < 10) 
		    				{
		        				my_string =  my_string+'0';
		   					}
							var lastDigit = my_string.toString().slice(-1);
							var newDigit=parseFloat(lastDigit)+1;
							var result = my_string.substring(0, 9);
							InvoiceNum= result + newDigit;
							
						}

				}
					
					console.log("InvoiceNum["+InvoiceNum+"]");
					
					
					

					var totalValueSum = parseFloat(totalValue);

			        if(totalValueSum <=  maxCashAMount)
			        {

						var listItem=domIDVal+"@"+itemCode+"@"+InvoiceNum;
						var invDetailsID=InvoiceNum+"@"+basicValue+"@"+gstValue+"@"+totalValueSum;
			        	if(itemWIthInvoice.indexOf(listItem)  ==-1)
			        	{
			        		itemWIthInvoice.push(listItem);
			        	}
			        	invoiceIDDetails.push(invDetailsID);
			        	var listamount=InvoiceNum+"@"+totalValue;
			        	amountWithInvoiceList.push(listamount);	
			        	if(invoiceList.indexOf(InvoiceNum)  ==-1)
			        	{
			        		invoiceList.push(InvoiceNum);	
			        	}
			        }
			        if(totalValueSum >  maxCashAMount)
			        {
			        	var listItem=domIDVal+"@"+itemCode+"@"+InvoiceNum;
						var invDetailsID=InvoiceNum+"@"+basicValue+"@"+gstValue+"@"+totalValueSum;
			        	if(itemWIthInvoice.indexOf(listItem)  ==-1)
			        	{
			        		itemWIthInvoice.push(listItem);
			        	}
			        	invoiceIDDetails.push(invDetailsID);
			        	var listamount=InvoiceNum+"@"+totalValue;
			        	amountWithInvoiceList.push(listamount);	
			        	if(invoiceList.indexOf(InvoiceNum)  ==-1)
			        	{
			        		invoiceList.push(InvoiceNum);	
			        	}
			        }			        
				}
				
			}
			        
			
		}
    }
    var minValue="",maxValue="";
    console.log("invoiceList for final["+invoiceList+"]");
	if(invoiceList!=null && invoiceList!= "" )	
	{
			for(var j=0;j < invoiceList.length;j++)
			{
				var minMaxInv = invoiceList[j];
				minMaxInv=''+minMaxInv;
				minMaxInvIdList.push(minMaxInv);
			}
		}
		
	if(minMaxInvIdList!=null && minMaxInvIdList!= "" )	
	{
		var min = minMaxInvIdList[0];
			for (var i = 1; i < minMaxInvIdList.length; ++i)
			 {
				if (minMaxInvIdList[i] <min)
				{
					min = minMaxInvIdList[i];
				}
			}

		minValue=min
		var max = minMaxInvIdList[0];
			for (var i = 1; i < minMaxInvIdList.length; ++i) 
			{
				if (minMaxInvIdList[i] >max) 
				{
					max = minMaxInvIdList[i];
				}
			}
			
			maxValue=max;
	}
	console.log("invoiceIDDetails before check values all transaction:::  ["+invoiceIDDetails+"]");
	console.log("invoiceList before check values all transaction  ["+invoiceList+"]");
	if(invoiceList!=null && invoiceList!= "" )	
	{
		
		for(var j=0;j < invoiceList.length;j++)
		{
					var invoiceCOdeFrmList = invoiceList[j];
					console.log("invoiceCOdeFrmList when invoiceIdlist is not null["+invoiceCOdeFrmList+"]");
					var invoiceTotSumValue=0;
					var invoiceBasicSumValue=0;
					var invoiceGstSumValue=0;
			if(invoiceIDDetails!=null && invoiceIDDetails!= "" )	
			{
			    console.log("invoiceIDDetails when invoiceIDDetails is not null["+invoiceIDDetails+"]");
				for(var k=0;k < invoiceIDDetails.length;k++)
				{
					var invoiceIdFrmList = invoiceIDDetails[k];
					console.log("invoiceIdFrmList when invoiceIDDetails in for loop ["+invoiceIdFrmList+"]");
					
					var invoiceIdAmt=invoiceIdFrmList.split("@")[0];
					console.log("invoiceIdAmt when invoice id generate and have invoiceid["+invoiceIdAmt+"]");
					if(invoiceCOdeFrmList == invoiceIdAmt)
					{
						var invoicebasicValue=invoiceIdFrmList.split("@")[1];
						
						invoiceBasicSumValue=((parseFloat(invoiceBasicSumValue) + parseFloat(invoicebasicValue)));
						invoiceBasicSumValue = Number(Math.round(invoiceBasicSumValue+'e'+2)+'e-'+2);
						
						var invoiceGstValue=invoiceIdFrmList.split("@")[2];
						
						invoiceGstSumValue=((parseFloat(invoiceGstSumValue) + parseFloat(invoiceGstValue)));
						invoiceGstSumValue = Number(Math.round(invoiceGstSumValue+'e'+2)+'e-'+2);
						
						var invoicetotValue=invoiceIdFrmList.split("@")[3];
						
						invoiceTotSumValue=((parseFloat(invoiceTotSumValue) + parseFloat(invoicetotValue)));
						invoiceTotSumValue = Number(Math.round(invoiceTotSumValue+'e'+2)+'e-'+2);
					}//if loop invoiceCOdeFrmList
					
				}//for loop k
				
				
			}// if loop amountWithInvoiceList
			totalValuesInvoiceIDList.push(invoiceCOdeFrmList+"@"+invoiceBasicSumValue+"@"+invoiceGstSumValue+"@"+invoiceTotSumValue);
			
		}//outer for loop
	}//invoice list
		
	console.log("invoiceIDDetails after all transaction:::  ["+invoiceIDDetails+"]");
	console.log("totalValuesInvoiceIDList after all transaction:::  ["+totalValuesInvoiceIDList+"]");
	
    var returnValue=itemWIthInvoice+"#"+minValue+"#"+maxValue+"#"+invoiceList+"#"+totalValuesInvoiceIDList;
	console.log("returnValue["+returnValue+"]minValue["+minValue+"]");
    
    return returnValue;
}   

//Added by mrunalini Sinkar for 1)Invoice id genration :InvoiceIDGenration ::END

function updateTableFormState(formNo, xmlDoc)
{
    console.log('Inside updateTableFormState');
    var detailElement = xmlDoc.getElementsByTagName("Detail"+formNo);
    if(detailElement)
    {
        var detail = detailElement[0];
        var priKeyColValue = "";
        var collectionFormNo = "";
        if( detail.getElementsByTagName("collection_form_no")[0] != null && detail.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
        {
        	collectionFormNo=detail.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
        }
        console.log('Inside updateTableFormState collectionFormNo:::['+ collectionFormNo+']');
        
        if( detail.getElementsByTagName("strg_code")[0] != null && detail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
        {
            priKeyColValue = detail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
            console.log('Inside updateTableFormState priKeyColValue:::['+ priKeyColValue+']');

            if(window.isTableFormStateExist)
            {
                var isTableFormExists = window.isTableFormStateExist(priKeyColValue, collectionFormNo);
                if(isTableFormExists && window.removeTableFormState)
                {
                    return window.removeTableFormState(priKeyColValue, collectionFormNo);
                }
            }
        }
    }
    return false;
}
//Added by mrunalini Sinkar for 1)To update collection form data on invoice :updateTableFormState ::END


//Added by mrunalini Sinkar for 1)To update Data model On finish:updateDataModel ::Start
function updateDataModel(formNo, objName, responseText, offlineDataXML)
{
	globalObjName = objName;
	if(objName ==='strg_meet_dcr_realtime_wiz')
	{
		console.log("Inside updateDataModel local js");
		var userId = localStorage.getItem('userName').trim();
		console.log("userId is["+userId+"]responseText["+responseText+"]offlineDataXML["+offlineDataXML+"]");
		if(offlineDataXML==null)
		{
			offlineDataXML=responseText;
		}
		updateInvoiceDataModelFile(userId,responseText,offlineDataXML);
		updateVenStockDataModelFile(userId,responseText,offlineDataXML);
		updateStockItemeDataModelFile(userId,responseText,offlineDataXML);
		updateDailySalesDataModelFile(userId,responseText,offlineDataXML);
		updateDailySalesRetailerDataModelFile(userId,responseText,offlineDataXML);
		updateDailySalesPaymentDataModelFile(userId,responseText,offlineDataXML);
		updateDailySalesCardDataModelFile(userId,responseText,offlineDataXML);
		updateDailySalesSubCardDataModelFile(userId,responseText,offlineDataXML);
		updateInvoiceDMDataModelFile(userId,responseText,offlineDataXML);
		updateCustomerCodesDataModel(userId,responseText,offlineDataXML);
	}
	else if(objName ==='stocks_transfer_wiz')
	{
		console.log("Inside updateDataModel of local stock transfer js");
		var userId = localStorage.getItem('userName');
		console.log("userId in stock transfer["+userId+"]responseText["+responseText+"]offlineDataXML["+offlineDataXML+"]");
		if(offlineDataXML==null)
		{
			offlineDataXML=responseText;
		}
		updateItemDataModelFile(userId,responseText,offlineDataXML);
		updateRealInvoiceDataModel(userId, responseText,offlineDataXML);
		updateVenStockDataModel(userId, responseText,offlineDataXML);
	}
	else if(objName ==='stocks_receive_wiz')
	{
		console.log("Inside updateDataModel of local stock receive js");
		var userId = localStorage.getItem('userName');
		console.log("userId in stock receive["+userId+"]responseText["+responseText+"]offlineDataXML["+offlineDataXML+"]");
		if(offlineDataXML==null)
		{
			offlineDataXML=responseText;
		}
		updateItemDataModelFileReceive(userId,responseText,offlineDataXML);
		updateRealInvoiceDataModelReceive(userId, responseText,offlineDataXML);
		updateVenStockDataModelReceive(userId, responseText,offlineDataXML);
	}

}
//Added by Bhagyashri t for Update datamodel n finish for item form[Start]
function updateItemDataModelFile(userId, responseText,offlineDataXML)
{
	var dataModelxmlDoc = "";
	var dispCount = 1;
	
	console.log("Inside updateItemDataModelFile in stock transfer js");
	var offlineDatDom = "";
		
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/stocks_transfer_wiz_item.xml';
	onSuccess = function(dataModelData)
	{
		console.log("dataModelData data is not null before change"+ dataModelData);
		var xmlVersion = dataModelData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		console.log("xmlVersion data is not null"+ xmlVersion);
		
		if( dataModelData != null && dataModelData.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( dataModelData.indexOf("<Root>") == -1 )
				{
					dataModelData = "<Root>"+dataModelData+"</Root>";
				}
			}
		}
		else
		{
			console.log("null dataModelData");
		}
		
		console.log("offlineDataXML data is not null"+ offlineDataXML);
		
		var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		console.log("xmlVersion data is not null"+ xmlVersionofflineDataXML);				
		if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
		{
			if( xmlVersionofflineDataXML != 0 )
			{
				if( offlineDataXML.indexOf("<Root>") == -1 )
				{
					offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
				}
			}
		}
		else
		{
			console.log("null parentFormData");
		}
		
		if ( window.DOMParser )
		{
			parser = new DOMParser();
			try
			{
				if( dataModelData != null && dataModelData.trim().length > 0 )
				{
					dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
				}
				if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
				{
					offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
				}
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}//end window.DOMParser
		if(dataModelxmlDoc!= null)
		{
			
			var locCodeFrom="";
			var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
			console.log("parentDetailElement["+parentDetailElement.length+"]");
			for( var k= 0;k < parentDetailElement.length; k++)
			{
				var parentDetail = parentDetailElement[k];
				if( parentDetail.getElementsByTagName("loc_code__fr")[0] != null && parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
				{
					locCodeFrom = parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					locCodeFrom=locCodeFrom.trim();
				}
			}// for loop first offline data is finish
			console.log("Loc code from on stock form["+locCodeFrom+"]");
			var ItemDetailElement = offlineDatDom.getElementsByTagName( "Detail2");
			console.log("ItemForm Element Length["+ItemDetailElement.length+"]");
			var itemWithStock=[];
			var currentOfflineSTock="",itemCodeOfflineData="";
			for (var v = 0; v < ItemDetailElement.length; v++)
			{

				var itemDetail = ItemDetailElement[v];
				var attributeVal = itemDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
      		var domIDVal = itemDetail.getAttribute("domID");
      		if(attributeVal != null && attributeVal != 'D')
      		{
      			if( itemDetail.getElementsByTagName("curr_stock")[0] != null && itemDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
					{
						currentOfflineSTock = itemDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
					}
					if( itemDetail.getElementsByTagName("item_code")[0] != null && itemDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
					{
						itemCodeOfflineData = itemDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
						itemCodeOfflineData=itemCodeOfflineData.trim();
					}
      			itemWithStock.push(itemCodeOfflineData+"@"+currentOfflineSTock);
      		
      		}
			}// for loop item offline data is finish
			var detailElement = dataModelxmlDoc.getElementsByTagName( "Detail2");
			console.log("Item Element Length["+detailElement.length+"]");
			var itemDescr="",currStock="",orgStock="",itemCode="",locCodeFr="",lotNoFr="",lotSlFr="";
			var lotNoTo="",lotSlTo="",locCodeTo="",siteCode="",acctCodeCr="",cctrCodeCr="",acctCodeDr="";
			var cctrCodeDr="",qtpPerArt="";
			dataModelData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
			var existingItemList=[];
			for (var i = 0; i < detailElement.length; i++)
			{

				var detail = detailElement[i];
				if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
				{
					itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
				{
					currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
				{
					orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
				{
					locCodeFr = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					locCodeFr =locCodeFr.trim();
				}
				if( detail.getElementsByTagName("lot_no__fr")[0] != null && detail.getElementsByTagName("lot_no__fr")[0].childNodes[0] != null )
				{
					lotNoFr = detail.getElementsByTagName("lot_no__fr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_sl__fr")[0] != null && detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0] != null )
				{
					lotSlFr = detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_no__to")[0] != null && detail.getElementsByTagName("lot_no__to")[0].childNodes[0] != null )
				{
					lotNoTo = detail.getElementsByTagName("lot_no__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_sl__to")[0] != null && detail.getElementsByTagName("lot_sl__to")[0].childNodes[0] != null )
				{
					lotSlTo = detail.getElementsByTagName("lot_sl__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
				{
					locCodeTo = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("site_code")[0] != null && detail.getElementsByTagName("site_code")[0].childNodes[0] != null )
				{
					siteCode = detail.getElementsByTagName("site_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("acct_code__cr")[0] != null && detail.getElementsByTagName("acct_code__cr")[0].childNodes[0] != null )
				{
					acctCodeCr = detail.getElementsByTagName("acct_code__cr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cctr_code__cr")[0] != null && detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0] != null )
				{
					cctrCodeCr = detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("acct_code__dr")[0] != null && detail.getElementsByTagName("acct_code__dr")[0].childNodes[0] != null )
				{
					acctCodeDr = detail.getElementsByTagName("acct_code__dr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cctr_code__dr")[0] != null && detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0] != null )
				{
					cctrCodeDr = detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("qty_per_art")[0] != null && detail.getElementsByTagName("qty_per_art")[0].childNodes[0] != null )
				{
					qtpPerArt = detail.getElementsByTagName("qty_per_art")[0].childNodes[0].nodeValue;
				}
					console.log("itemWithStock List:::::::::::;["+itemWithStock+"]");
					
					if(itemWithStock!=null && itemWithStock!= "" )
					{
					console.log("Inside itemwithtsock not null in stock transfer");
						
						for(var j=0;j < itemWithStock.length;j++)
						{
							var itemStockList = itemWithStock[j];
							console.log("Inside itemStockList not null in stock transfer["+itemStockList+"]");
							
							var listItemCode=itemStockList.split("@")[0];
							var listStock=itemStockList.split("@")[1];
							console.log("Inside listItemCode not null["+listItemCode+"]listStock["+listStock+"]itemCode["+itemCode+"]currStock["+currStock+"]orgStock["+orgStock+"]");
							console.log("Loc code from on stock form before update :["+locCodeFrom+"]");
							console.log("Loc code fr on item form before update :["+locCodeFr+"]");
							if(listItemCode == itemCode && locCodeFrom == locCodeFr)
							{
								console.log("Inside if both listItemCode and item code is same in stock transfer");
								currStock=listStock;
								orgStock=listStock;
								break;
							}
						}
						
					}
					console.log("itemCode["+itemCode+"]currStock["+currStock+"]orgStock["+orgStock+"]");
					
					
					dataModelData += "<Detail2 domID='" + dispCount + "' selected = 'N' formName='item' >\r\n"+
						"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
						"<tran_id><![CDATA[]]></tran_id>\r\n"+
						"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
						"<quantity><![CDATA[]]></quantity>\r\n"+
						"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\r\n"+
						"<org_stock><![CDATA["+orgStock+"]]></org_stock>\r\n"+
						"<item_code><![CDATA["+itemCode+"]]></item_code>"+
						"<loc_code__fr><![CDATA["+locCodeFr+"]]></loc_code__fr>"+
						"<lot_no__fr><![CDATA["+lotNoFr+"]]></lot_no__fr>\r\n"+
						"<lot_sl__fr><![CDATA["+lotSlFr+"]]></lot_sl__fr>\r\n"+
						"<lot_no__to><![CDATA["+lotNoTo+"]]></lot_no__to>\r\n"+
						"<lot_sl__to><![CDATA["+lotSlTo+"]]></lot_sl__to>\r\n"+
						"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
						"<loc_code__to><![CDATA[]]></loc_code__to>\r\n"+
						"<site_code><![CDATA["+siteCode+"]]></site_code>"+
						"<acct_code__cr><![CDATA["+acctCodeCr+"]]></acct_code__cr>\r\n"+
						"<cctr_code__cr><![CDATA["+cctrCodeCr+"]]></cctr_code__cr>"+
						"<acct_code__dr><![CDATA["+acctCodeDr+"]]></acct_code__dr>"+
						"<cctr_code__dr><![CDATA["+cctrCodeDr+"]]></cctr_code__dr>"+
						"<qty_per_art><![CDATA["+qtpPerArt+"]]></qty_per_art>"+											
						"</Detail2>";
						dispCount++;
			}//end of for loop of datamodel
			dataModelData += "</Root>";
			
			console.log("dataModelData after changes in stock transfer["+dataModelData+"]");
			//write logic to update data in dataModelData
			backUpAndWriteFile(filePath, dataModelData); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
		}//end dataModelXmlDoc not null
		onFailure = function(error)
		{
			console.log('error in readFile ',error);
		}//end OnFailure
	}//end onSuccess
	readFile(filePath,onSuccess,onFailure);
}
function updateRealInvoiceDataModel(userId, responseText,offlineDataXML)
{
	console.log("Update updateRealInvoiceDataModel From stock transfer");
	var dataModelxmlDoc = "";
	var dispCount = 1;
	
	console.log("Inside updateInvoiceDataModel from  stock transfer");
	var offlineDatDom = "";
		
		var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/strg_meet_dcr_realtime_wiz_invoice.xml';


		onSuccess = function(dataModelData)
		{
			console.log("dataModelData data is not null before change"+ dataModelData);
			var xmlVersion = dataModelData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			console.log("xmlVersion data is not null"+ xmlVersion);
			
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				//console.log("cureentform data is not null"+ formDetailData);
				if( xmlVersion != 0 )
				{
					if( dataModelData.indexOf("<Root>") == -1 )
					{
						dataModelData = "<Root>"+dataModelData+"</Root>";
					}
				}
			}
			else
			{
				console.log("null dataModelData");
			}
			
			console.log("offlineDataXML data is not null"+ offlineDataXML);
			
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			console.log("xmlVersion data is not null"+ xmlVersionofflineDataXML);				
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}

	if ( window.DOMParser )
	{
		parser = new DOMParser();
		try
		{
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
			}
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
			}
		}
		catch(ex)
		{
			alert("Exception occurs while parsing xml data");
		}
	}
			
				
		if(dataModelxmlDoc!= null)
		{
			var invoiceFormNo="";
			var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
			console.log("parentDetailElement["+parentDetailElement.length+"]");
			for( var k= 0;k < parentDetailElement.length; k++)
			{
				var parentDetail = parentDetailElement[k];
				if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
				{
					invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
				}
				
			}// for loop first offline data is finish
			console.log("invoiceFormNo in stock transfer["+invoiceFormNo+"]");
			
			var InvoiceDetailElement = offlineDatDom.getElementsByTagName( "Detail2" );
			console.log("Item form stock transfer Element Length["+InvoiceDetailElement.length+"]");
			var itemWithStock=[];
			var currentOfflineSTock="",itemCodeOfflineData="";
			for (var v = 0; v < InvoiceDetailElement.length; v++)
			{

				var invoiceDetail = InvoiceDetailElement[v];
				var attributeVal = invoiceDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        		var domIDVal = invoiceDetail.getAttribute("domID");
        		if(attributeVal != null && attributeVal != 'D')
        		{
        			if( invoiceDetail.getElementsByTagName("curr_stock")[0] != null && invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
					{
						currentOfflineSTock = invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
					}
					if( invoiceDetail.getElementsByTagName("item_code")[0] != null && invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
					{
						itemCodeOfflineData = invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
						itemCodeOfflineData=itemCodeOfflineData.trim();
					}
        			itemWithStock.push(itemCodeOfflineData+"@"+currentOfflineSTock);
        		
        		}
			}// for loop invoice offline data is finish
			console.log("Invoice form number in stock transfer["+invoiceFormNo+"]");
			var detailElement = dataModelxmlDoc.getElementsByTagName( "Detail"+invoiceFormNo );
			console.log("Invoice Element Length["+detailElement.length+"]");
			var priceList="",rate="",itemDescr="",lotNo="",discPerc="",currStock="",orgStock="",itemCode="",taxAmntInvoice="",hsnNumber="",pkgSize="";
			var childItem="",itmChildDescr="",childProceList="",itemCHildRate="",childHSNNumber="",childPkgSize="",subItmCHild="";
			var subChildDescr="",subPriceList="",subChildRate="",subHsnNumber="",subPkgSize="",loadQTY="",cashInvoiceAmount="",maximumInvoice="",salesPersonCode="";
			dataModelData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
			var existingItemList=[];
			for (var i = 0; i < detailElement.length; i++)
			{
				var detail = detailElement[i];
				if( detail.getElementsByTagName("price_list")[0] != null && detail.getElementsByTagName("price_list")[0].childNodes[0] != null )
				{
					priceList = detail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
					priceList=priceList.trim();
				}
				if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
				{
					itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
				{
					rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("disc_perc")[0] != null && detail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
				{
					discPerc = detail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_no")[0] != null && detail.getElementsByTagName("lot_no")[0].childNodes[0] != null )
				{
					lotNo = detail.getElementsByTagName("lot_no")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
				{
					currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
				{
					orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
				{
					taxAmntInvoice = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("hsn_number")[0] != null && detail.getElementsByTagName("hsn_number")[0].childNodes[0] != null )
				{
					hsnNumber = detail.getElementsByTagName("hsn_number")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("pkg_size")[0] != null && detail.getElementsByTagName("pkg_size")[0].childNodes[0] != null )
				{
					pkgSize = detail.getElementsByTagName("pkg_size")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child")[0] != null && detail.getElementsByTagName("itm_child")[0].childNodes[0] != null )
				{
					childItem = detail.getElementsByTagName("itm_child")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child_descr")[0] != null && detail.getElementsByTagName("itm_child_descr")[0].childNodes[0] != null )
				{
					itmChildDescr = detail.getElementsByTagName("itm_child_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_price_list")[0] != null && detail.getElementsByTagName("child_price_list")[0].childNodes[0] != null )
				{
					childProceList = detail.getElementsByTagName("child_price_list")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child_rate")[0] != null && detail.getElementsByTagName("itm_child_rate")[0].childNodes[0] != null )
				{
					itemCHildRate = detail.getElementsByTagName("itm_child_rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_hsn_number")[0] != null && detail.getElementsByTagName("child_hsn_number")[0].childNodes[0] != null )
				{
					childHSNNumber = detail.getElementsByTagName("child_hsn_number")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_pack_size")[0] != null && detail.getElementsByTagName("child_pack_size")[0].childNodes[0] != null )
				{
					childPkgSize = detail.getElementsByTagName("child_pack_size")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("sub_itm_child")[0] != null && detail.getElementsByTagName("sub_itm_child")[0].childNodes[0] != null )
				{
					subItmCHild = detail.getElementsByTagName("sub_itm_child")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_child_descr")[0] != null && detail.getElementsByTagName("sub_child_descr")[0].childNodes[0] != null )
				{
					subChildDescr = detail.getElementsByTagName("sub_child_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_price_list")[0] != null && detail.getElementsByTagName("sub_price_list")[0].childNodes[0] != null )
				{
					subPriceList = detail.getElementsByTagName("sub_price_list")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_child_rate")[0] != null && detail.getElementsByTagName("sub_child_rate")[0].childNodes[0] != null )
				{
					subChildRate = detail.getElementsByTagName("sub_child_rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_hsn_number")[0] != null && detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0] != null )
				{
					subHsnNumber = detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("sub_pack_size")[0] != null && detail.getElementsByTagName("sub_pack_size")[0].childNodes[0] != null )
				{
					subPkgSize = detail.getElementsByTagName("sub_pack_size")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("load_qty")[0] != null && detail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
				{
					loadQTY = detail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cash_invoice_amount")[0] != null && detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
				{
					cashInvoiceAmount = detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("max_invoice_id")[0] != null && detail.getElementsByTagName("max_invoice_id")[0].childNodes[0] != null )
				{
					maximumInvoice = detail.getElementsByTagName("max_invoice_id")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
				{
					salesPersonCode = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
				}
					console.log("itemWithStock List:::::::::::;["+itemWithStock+"]");
					
					if(itemWithStock!=null && itemWithStock!= "" )
					{
					console.log("Inside itemwithtsock not null");
						
						for(var j=0;j < itemWithStock.length;j++)
						{
							var itemStockList = itemWithStock[j];
							console.log("Inside itemStockList not null["+itemStockList+"]");
							
							var listItemCode=itemStockList.split("@")[0];
							var listStock=itemStockList.split("@")[1];
							console.log("Inside listItemCode not null["+listItemCode+"]listStock["+listStock+"]itemCode["+itemCode+"]currStock["+currStock+"]orgStock["+orgStock+"]");
							
							if(listItemCode == itemCode)
							{
								console.log("Inside if both listItemCode and item code is same");
								currStock=listStock;
								orgStock=listStock;
								break;
							}
						}
						
					}
					console.log("itemCode["+itemCode+"]currStock["+currStock+"]orgStock["+orgStock+"]");
					
					dataModelData += "<Detail"+invoiceFormNo+" domID='" + dispCount + "' selected = 'N'>\r\n"+ 
					"<strg_code><![CDATA[]]></strg_code>\n"+
					"<tran_id><![CDATA[]]></tran_id>\r\n"+
					"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
					"<quantity><![CDATA[]]></quantity>\r\n"+
					"<rate><![CDATA["+rate+"]]></rate>\r\n"+
					"<disc_perc><![CDATA["+discPerc+"]]></disc_perc>\r\n"+
					"<lot_no><![CDATA["+lotNo+"]]></lot_no>\r\n"+
					"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\r\n"+
					"<org_stock><![CDATA["+orgStock+"]]></org_stock>\r\n"+
					"<value><![CDATA[]]></value>\r\n"+
					"<total_amount><![CDATA[]]></total_amount>\r\n"+
					"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
					"<dcr_id><![CDATA[]]></dcr_id>\r\n"+ 
					"<item_code><![CDATA["+itemCode+"]]></item_code>"+
					"<sales_pers><![CDATA["+salesPersonCode+"]]></sales_pers>"+
					"<tax_amt_inv><![CDATA["+taxAmntInvoice+"]]></tax_amt_inv>\r\n"+
					"<net_amt><![CDATA[]]></net_amt>\r\n"+
					"<basic_value><![CDATA[]]></basic_value>\r\n"+
					"<total_gst><![CDATA[]]></total_gst>\r\n"+
					"<total_amount><![CDATA[]]></total_amount>\r\n"+
					"<remarks_inv><![CDATA[]]></remarks_inv>\r\n"+
					"<price_list><![CDATA["+priceList+"]]></price_list>"+
					"<hsn_number><![CDATA["+hsnNumber+"]]></hsn_number>\r\n"+
					"<pkg_size><![CDATA["+pkgSize+"]]></pkg_size>"+
					"<itm_child><![CDATA["+childItem+"]]></itm_child>"+
					"<itm_child_descr><![CDATA["+itmChildDescr+"]]></itm_child_descr>"+
					"<itm_child_rate><![CDATA["+itemCHildRate+"]]></itm_child_rate>"+
					"<child_hsn_number><![CDATA["+childHSNNumber+"]]></child_hsn_number>"+
					"<child_pack_size><![CDATA["+childPkgSize+"]]></child_pack_size>"+
					"<child_price_list><![CDATA["+childProceList+"]]></child_price_list>"+
					"<sub_itm_child><![CDATA["+subItmCHild+"]]></sub_itm_child>"+					
					"<sub_child_descr><![CDATA["+subChildDescr+"]]></sub_child_descr>"+					
					"<sub_hsn_number><![CDATA["+subHsnNumber+"]]></sub_hsn_number>"+
					"<sub_child_rate><![CDATA["+subChildRate+"]]></sub_child_rate>"+					
					"<sub_price_list><![CDATA["+subPriceList+"]]></sub_price_list>"+					
					"<sub_pack_size><![CDATA["+subPkgSize+"]]></sub_pack_size>"+
					"<is_broken><![CDATA[N]]></is_broken>"+
					"<load_qty><![CDATA["+loadQTY+"]]></load_qty>"+	
					"<max_invoice_id><![CDATA["+maximumInvoice+"]]></max_invoice_id>"+				
					"<cash_invoice_amount><![CDATA["+cashInvoiceAmount+"]]></cash_invoice_amount>"+												
					"</Detail"+invoiceFormNo+">";
					dispCount++;
		}// for loop data model invoice offline data is finish
		
		dataModelData += "</Root>";
		
		console.log("dataModelData after changes for invoice from stock["+dataModelData+"]");
		
		//write logic to update data in dataModelData
		backUpAndWriteFile(filePath, dataModelData); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
		}
		
		onFailure = function(error)
		{
		console.log('error in readFile ',error);
		}
	}
		readFile(filePath,onSuccess,onFailure);
}
function updateVenStockDataModel(userId, responseText,offlineDataXML)
{
	console.log("Inside updateVenStockDataModel in stock transfer");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/VAN_STOCK.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					var ItemDetailElement = offlineDatDom.getElementsByTagName( "Detail2" );
					//var itemWithStock=[];
					var currentOfflineStock="",itemCodeOfflineData="",quantity="",itemDescr="",loadQTY="";
					for (var v = 0; v < ItemDetailElement.length; v++)
					{
						var dataModelExistFlag=false;
						var itemDetail = ItemDetailElement[v];
						var attributeVal = itemDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
		        		var domIDVal = itemDetail.getAttribute("domID");
		        		if(attributeVal != null && attributeVal != 'D')
		        		{
		        			if( itemDetail.getElementsByTagName("curr_stock")[0] != null && itemDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
							{
								currentOfflineSTock = itemDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
							}
							if( itemDetail.getElementsByTagName("item_code")[0] != null && itemDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
							{
								itemCodeOfflineData = itemDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
								itemCodeOfflineData=itemCodeOfflineData.trim();
							}
							if( itemDetail.getElementsByTagName("quantity")[0] != null && itemDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								quantity = itemDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}
							if( itemDetail.getElementsByTagName("item_descr")[0] != null && itemDetail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								itemDescr = itemDetail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
							}
							if( itemDetail.getElementsByTagName("load_qty")[0] != null && itemDetail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
							{
								loadQTY = itemDetail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
							}
							if(quantity==null ||  quantity.trim().length==0)
							{
								quantity="0";
							}
	
								console.log("updateVenStockDataModel when finish stock dataModelJSONArray::["+JSON.stringify(dataModelJSONArray)+"]");
									if(dataModelJSONArray!=null && dataModelJSONArray!="")
										{
											for(var i = 0; i < dataModelJSONArray.length; i++)
											{
												  
												const jsonObj = dataModelJSONArray[i];
												
												var itemCode = jsonObj.ITEM_CODE != undefined ? jsonObj.ITEM_CODE.trim() : '';
												if(itemCodeOfflineData == itemCode)
													{
													var loadQTY=jsonObj.LOAD_QUANTITY;
													var saleValue=jsonObj.SALE;
													var transferIn=jsonObj.TRANSFER_IN;
													var transferOut=jsonObj.TRANSFER_OUT;
													var breakAddQtyValue=jsonObj.BREAK_ADD_QTY;
													var breakDeductQty=jsonObj.BREAK_DEDUCT_QTY;
													var stockValue=jsonObj.STOCK;
													
													if(loadQTY!=null && loadQTY!= "" )
													{
														loadQTY=loadQTY;
													}
													else
													{
														loadQTY="0";
													}
	
													if(saleValue!=null && saleValue!= "" )
													{
														saleValue=saleValue;
													}
													else
													{
														saleValue="0";
													}
	
													if(transferIn!=null && transferIn!= "" )
													{
														transferIn=transferIn;
													}
													else
													{
														transferIn="0";
													}
	
													if(transferOut!=null && transferOut!= "" )
													{
														transferOut=transferOut;
													}
													else
													{
														transferOut="0";
													}
	
													if(breakAddQtyValue!=null && breakAddQtyValue!= "")
													{
														breakAddQtyValue=breakAddQtyValue;
													}
													else
													{
														breakAddQtyValue="0";
													}
	
													if(breakDeductQty!=null && breakDeductQty!= "" )
													{
														breakDeductQty=breakDeductQty;
													}
													else
													{
														breakDeductQty="0";
													}
													
													if(stockValue!=null && stockValue!= "" )
													{
														stockValue=stockValue;
													}
													stockValue=parseInt(stockValue)-parseInt(quantity);
													transferOut=parseInt(transferOut)+parseInt(quantity);						    
	
														jsonObj.SALE = saleValue;
														jsonObj.TRANSFER_IN = transferIn;
														jsonObj.ITEM_DESCR = itemDescr;
														jsonObj.TRANSFER_OUT = transferOut;
														jsonObj.BREAK_ADD_QTY = breakAddQtyValue;
													    jsonObj.BREAK_DEDUCT_QTY = breakDeductQty;
														jsonObj.ITEM_CODE = itemCodeOfflineData;
														jsonObj.LOAD_QUANTITY = loadQTY;
														jsonObj.STOCK = stockValue;
														
														dataModelExistFlag=true;
													}
											}
										}
										
										if(dataModelExistFlag==false)
										{
											console.log("updateVenStockDataModel if dataModelExistFlag is false in stock");	
											
											var stockValue=parseInt(currentOfflineSTock)-parseInt(quantity);
											
											dataModelJSONArray.push({"SALE":"0","ITEM_DESCR":itemDescr,"BREAK_ADD_QTY":"0","BREAK_DEDUCT_QTY":"0","TRANSFER_IN":"0","TRANSFER_OUT":quantity,"ITEM_CODE":itemCodeOfflineData,"LOAD_QUANTITY":loadQTY,"STOCK":stockValue});
										}
											
				        			}
							}// for loop Ven stock offline data is finish
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateVenStockDataModel if dataModelJSONArray from stock["+updatedDataModel+"]");
				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateVenStockDataModel error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}
//Added by Bhagyashri t for Update datamodel n finish for item form[End]

// added by mrunalini sinkar to updat dta model of invoice,stock and dasboard ::::::::::::Start
function updateInvoiceDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for INVOICE form data model updation
{
	var dataModelxmlDoc = "";
	var dispCount = 1;
	
	console.log("Inside updateInvoiceDataModelFile");
	var offlineDatDom = "";
		
		var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/strg_meet_dcr_realtime_wiz_invoice.xml';


		onSuccess = function(dataModelData)
		{
			var xmlVersion = dataModelData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				//console.log("cureentform data is not null"+ formDetailData);
				if( xmlVersion != 0 )
				{
					if( dataModelData.indexOf("<Root>") == -1 )
					{
						dataModelData = "<Root>"+dataModelData+"</Root>";
					}
				}
			}
			else
			{
				console.log("null dataModelData");
			}
			
			console.log("dataModelData before changes in updateInvoiceDataModelFile["+dataModelData+"]");
			
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}

	if ( window.DOMParser )
	{
		parser = new DOMParser();
		try
		{
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
			}
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
			}
		}
		catch(ex)
		{
			alert("Exception occurs while parsing xml data");
		}
	}
			
				
		if(dataModelxmlDoc!= null)
		{
				var invoiceFormNo="",maximumInvoice="",minimumInvoice="",collectionFormNo="",priceListPrnt="";
				var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
					{
						invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("minimum_invoice")[0] != null && parentDetail.getElementsByTagName("minimum_invoice")[0].childNodes[0] != null )
					{
						minimumInvoice = parentDetail.getElementsByTagName("minimum_invoice")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("maximum_invoice")[0] != null && parentDetail.getElementsByTagName("maximum_invoice")[0].childNodes[0] != null )
					{
						maximumInvoice = parentDetail.getElementsByTagName("maximum_invoice")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("collection_form_no")[0] != null && parentDetail.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
					{
						collectionFormNo = parentDetail.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
					}
					if( parentDetail.getElementsByTagName("price_list")[0] != null && parentDetail.getElementsByTagName("price_list")[0].childNodes[0] != null )
					{
						priceListPrnt = parentDetail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
						priceListPrnt=priceListPrnt.trim();
						
					}
				}// for loop first offline data is finish
			console.log("invoiceFormNo["+invoiceFormNo+"]maximumInvoice["+maximumInvoice+"]minimumInvoice["+minimumInvoice+"]collectionFormNo["+collectionFormNo+"]priceListPrnt["+priceListPrnt+"]");
				
			var collectionDetailElement = offlineDatDom.getElementsByTagName( "Detail"+collectionFormNo );
			console.log("Collection Element Length["+collectionDetailElement.length+"]");
			var paymentMode="";
			for (var c = 0; c < collectionDetailElement.length; c++)
			{
				var collectionDetail = collectionDetailElement[c];
				var attributeVal = collectionDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
      		var domIDVal = collectionDetail.getAttribute("domID");
				if(attributeVal != null && attributeVal != 'D')
				{
					if( collectionDetail.getElementsByTagName("pay_mode")[0] != null && collectionDetail.getElementsByTagName("pay_mode")[0].childNodes[0] != null )
					{
						paymentMode = collectionDetail.getElementsByTagName("pay_mode")[0].childNodes[0].nodeValue;
					}
				}
				
			}// for loop collection offline data is finish
			console.log("paymentMode Element Length["+paymentMode+"]");
			
			if(paymentMode!="C")
			{
				maximumInvoice=minimumInvoice;
			}
			else
			{
				maximumInvoice=maximumInvoice;
			}
			
			var InvoiceDetailElement = offlineDatDom.getElementsByTagName( "Detail"+invoiceFormNo );
			var itemWithStock=[];
			var currentOfflineSTock="",itemCodeOfflineData="";
			for (var v = 0; v < InvoiceDetailElement.length; v++)
			{

				var invoiceDetail = InvoiceDetailElement[v];
				var attributeVal = invoiceDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
      		var domIDVal = invoiceDetail.getAttribute("domID");
      		if(attributeVal != null && attributeVal != 'D')
      		{
      			if( invoiceDetail.getElementsByTagName("curr_stock")[0] != null && invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
					{
						currentOfflineSTock = invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
					}
					if( invoiceDetail.getElementsByTagName("item_code")[0] != null && invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
					{
						itemCodeOfflineData = invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
						itemCodeOfflineData=itemCodeOfflineData.trim();
					}
      			itemWithStock.push(itemCodeOfflineData+"@"+currentOfflineSTock);
      		
      		}
			}// for loop invoice offline data is finish
			var detailElement = dataModelxmlDoc.getElementsByTagName( "Detail"+invoiceFormNo );
			dataModelData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
			var existingItemList=[];
			for (var i = 0; i < detailElement.length; i++)
			{
			var priceList="",rate="",itemDescr="",lotNo="",discPerc="",currStock="",orgStock="",itemCode="",taxAmntInvoice="",hsnNumber="",pkgSize="";
			var childItem="",itmChildDescr="",childProceList="",itemCHildRate="",childHSNNumber="",childPkgSize="",subItmCHild="";
			var subChildDescr="",subPriceList="",subChildRate="",subHsnNumber="",subPkgSize="",loadQTY="",cashInvoiceAmount="",salesPersonCode="";

				var detail = detailElement[i];
				if( detail.getElementsByTagName("price_list")[0] != null && detail.getElementsByTagName("price_list")[0].childNodes[0] != null )
				{
					priceList = detail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
					priceList=priceList.trim();
				}
				if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
				{
					itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
				{
					rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("disc_perc")[0] != null && detail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
				{
					discPerc = detail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_no")[0] != null && detail.getElementsByTagName("lot_no")[0].childNodes[0] != null )
				{
					lotNo = detail.getElementsByTagName("lot_no")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
				{
					currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
				{
					orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
				{
					taxAmntInvoice = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("hsn_number")[0] != null && detail.getElementsByTagName("hsn_number")[0].childNodes[0] != null )
				{
					hsnNumber = detail.getElementsByTagName("hsn_number")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("pkg_size")[0] != null && detail.getElementsByTagName("pkg_size")[0].childNodes[0] != null )
				{
					pkgSize = detail.getElementsByTagName("pkg_size")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child")[0] != null && detail.getElementsByTagName("itm_child")[0].childNodes[0] != null )
				{
					childItem = detail.getElementsByTagName("itm_child")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child_descr")[0] != null && detail.getElementsByTagName("itm_child_descr")[0].childNodes[0] != null )
				{
					itmChildDescr = detail.getElementsByTagName("itm_child_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_price_list")[0] != null && detail.getElementsByTagName("child_price_list")[0].childNodes[0] != null )
				{
					childProceList = detail.getElementsByTagName("child_price_list")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child_rate")[0] != null && detail.getElementsByTagName("itm_child_rate")[0].childNodes[0] != null )
				{
					itemCHildRate = detail.getElementsByTagName("itm_child_rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_hsn_number")[0] != null && detail.getElementsByTagName("child_hsn_number")[0].childNodes[0] != null )
				{
					childHSNNumber = detail.getElementsByTagName("child_hsn_number")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_pack_size")[0] != null && detail.getElementsByTagName("child_pack_size")[0].childNodes[0] != null )
				{
					childPkgSize = detail.getElementsByTagName("child_pack_size")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("sub_itm_child")[0] != null && detail.getElementsByTagName("sub_itm_child")[0].childNodes[0] != null )
				{
					subItmCHild = detail.getElementsByTagName("sub_itm_child")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_child_descr")[0] != null && detail.getElementsByTagName("sub_child_descr")[0].childNodes[0] != null )
				{
					subChildDescr = detail.getElementsByTagName("sub_child_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_price_list")[0] != null && detail.getElementsByTagName("sub_price_list")[0].childNodes[0] != null )
				{
					subPriceList = detail.getElementsByTagName("sub_price_list")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_child_rate")[0] != null && detail.getElementsByTagName("sub_child_rate")[0].childNodes[0] != null )
				{
					subChildRate = detail.getElementsByTagName("sub_child_rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_hsn_number")[0] != null && detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0] != null )
				{
					subHsnNumber = detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("sub_pack_size")[0] != null && detail.getElementsByTagName("sub_pack_size")[0].childNodes[0] != null )
				{
					subPkgSize = detail.getElementsByTagName("sub_pack_size")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("load_qty")[0] != null && detail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
				{
					loadQTY = detail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cash_invoice_amount")[0] != null && detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
				{
					cashInvoiceAmount = detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
				{
					salesPersonCode = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
				}
					
					if(itemWithStock!=null && itemWithStock!= "" )
					{
						
						for(var j=0;j < itemWithStock.length;j++)
						{
							var itemStockList = itemWithStock[j];
							
							var listItemCode=itemStockList.split("@")[0];
							var listStock=itemStockList.split("@")[1];
							
							if(listItemCode == itemCode)
							{
								currStock=listStock;
								orgStock=listStock;
								break;
							}
						}
						
					}
					
					dataModelData += "<Detail"+invoiceFormNo+" domID='" + dispCount + "' selected = 'N'>\r\n"+
					"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
					"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
					"<strg_code><![CDATA[]]></strg_code>\n"+
					"<tran_id><![CDATA[]]></tran_id>\r\n"+
					"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
					"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
					"<quantity><![CDATA[]]></quantity>\r\n"+
					"<rate><![CDATA["+rate+"]]></rate>\r\n"+
					"<disc_perc><![CDATA["+discPerc+"]]></disc_perc>\r\n"+
					"<lot_no><![CDATA["+lotNo+"]]></lot_no>\r\n"+
					"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\r\n"+
					"<org_stock><![CDATA["+orgStock+"]]></org_stock>\r\n"+
					"<total_amount><![CDATA[]]></total_amount>\r\n"+
					"<value><![CDATA[]]></value>\r\n"+
					"<item_code><![CDATA["+itemCode+"]]></item_code>"+
					"<sales_pers><![CDATA["+salesPersonCode+"]]></sales_pers>"+
					"<tax_amt_inv><![CDATA["+taxAmntInvoice+"]]></tax_amt_inv>\r\n"+
					"<net_amt><![CDATA[]]></net_amt>\r\n"+
					"<basic_value><![CDATA[]]></basic_value>\r\n"+
					"<total_gst><![CDATA[]]></total_gst>\r\n"+
					"<total_amount><![CDATA[]]></total_amount>\r\n"+
					"<remarks_inv><![CDATA[]]></remarks_inv>\r\n"+
					"<price_list><![CDATA["+priceList+"]]></price_list>"+
					"<hsn_number><![CDATA["+hsnNumber+"]]></hsn_number>\r\n"+
					"<pkg_size><![CDATA["+pkgSize+"]]></pkg_size>"+
					"<itm_child><![CDATA["+childItem+"]]></itm_child>"+
					"<itm_child_descr><![CDATA["+itmChildDescr+"]]></itm_child_descr>"+
					"<itm_child_rate><![CDATA["+itemCHildRate+"]]></itm_child_rate>"+
					"<child_hsn_number><![CDATA["+childHSNNumber+"]]></child_hsn_number>"+
					"<child_pack_size><![CDATA["+childPkgSize+"]]></child_pack_size>"+
					"<child_price_list><![CDATA["+childProceList+"]]></child_price_list>"+
					"<sub_itm_child><![CDATA["+subItmCHild+"]]></sub_itm_child>"+					
					"<sub_child_descr><![CDATA["+subChildDescr+"]]></sub_child_descr>"+					
					"<sub_hsn_number><![CDATA["+subHsnNumber+"]]></sub_hsn_number>"+
					"<sub_child_rate><![CDATA["+subChildRate+"]]></sub_child_rate>"+					
					"<sub_price_list><![CDATA["+subPriceList+"]]></sub_price_list>"+					
					"<sub_pack_size><![CDATA["+subPkgSize+"]]></sub_pack_size>"+
					"<is_broken><![CDATA[N]]></is_broken>"+
					"<load_qty><![CDATA["+loadQTY+"]]></load_qty>"+	
					"<max_invoice_id><![CDATA["+maximumInvoice+"]]></max_invoice_id>"+				
					"<cash_invoice_amount><![CDATA["+cashInvoiceAmount+"]]></cash_invoice_amount>"+												
					"</Detail"+invoiceFormNo+">";
					dispCount++;
					
					if(existingItemList.indexOf(itemCode.trim()) == -1)
					{
						existingItemList.push(itemCode.trim());	
					}
		}// for loop data model invoice offline data is finish
		
		if(itemWithStock!=null && itemWithStock!= "" )
		{
			for(var m=0;m < itemWithStock.length;m++)
			{
				var itemStockListBreak = itemWithStock[m];
				var listItemCodeBreak=itemStockListBreak.split("@")[0];
				
				if(existingItemList.indexOf(listItemCodeBreak.trim()) == -1)
				{
					var InvoicebreakDetailElement = offlineDatDom.getElementsByTagName( "Detail"+invoiceFormNo );
					for (var n = 0; n < InvoicebreakDetailElement.length; n++)
					{
		
					var priceListBreak="",rateBreak="",itemDescrBreak="",lotNoBreak="",discPercBreak="",currStockBreak="",orgStockBreak="",itemCodeBreak="",taxAmntInvoiceBreak="",hsnNumberBreak="",pkgSizeBreak="";
					var childItemBreak="",itmChildDescrBreak="",childProceListBreak="",itemCHildRateBreak="",childHSNNumberBreak="",childPkgSizeBreak="",subItmCHildBreak="";
					var subChildDescrBreak="",subPriceListBreak="",subChildRateBreak="",subHsnNumberBreak="",subPkgSizeBreak="",loadQTYBreak="",cashInvoiceAmountBreak="",salesPersonCodeBreak="";

						var InvoicebreakDetail = InvoicebreakDetailElement[n];
						var breakattributeVal = InvoicebreakDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
		        		var breakdomIDVal = InvoicebreakDetail.getAttribute("domID");
		        		if(breakattributeVal != null && breakattributeVal != 'D')
		        		{
								if( InvoicebreakDetail.getElementsByTagName("price_list")[0] != null && InvoicebreakDetail.getElementsByTagName("price_list")[0].childNodes[0] != null )
								{
									priceListBreak = InvoicebreakDetail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
									priceListBreak=priceListBreak.trim();
								}
								if( InvoicebreakDetail.getElementsByTagName("item_descr")[0] != null && InvoicebreakDetail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
								{
									itemDescrBreak = InvoicebreakDetail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("rate")[0] != null && InvoicebreakDetail.getElementsByTagName("rate")[0].childNodes[0] != null )
								{
									rateBreak = InvoicebreakDetail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("disc_perc")[0] != null && InvoicebreakDetail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
								{
									discPercBreak = InvoicebreakDetail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("lot_no")[0] != null && InvoicebreakDetail.getElementsByTagName("lot_no")[0].childNodes[0] != null )
								{
									lotNoBreak = InvoicebreakDetail.getElementsByTagName("lot_no")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("curr_stock")[0] != null && InvoicebreakDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
								{
									currStockBreak = InvoicebreakDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("org_stock")[0] != null && InvoicebreakDetail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
								{
									orgStockBreak = InvoicebreakDetail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("item_code")[0] != null && InvoicebreakDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
								{
									itemCodeBreak = InvoicebreakDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("tax_amt_inv")[0] != null && InvoicebreakDetail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
								{
									taxAmntInvoiceBreak = InvoicebreakDetail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("hsn_number")[0] != null && InvoicebreakDetail.getElementsByTagName("hsn_number")[0].childNodes[0] != null )
								{
									hsnNumberBreak = InvoicebreakDetail.getElementsByTagName("hsn_number")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("pkg_size")[0] != null && InvoicebreakDetail.getElementsByTagName("pkg_size")[0].childNodes[0] != null )
								{
									pkgSizeBreak = InvoicebreakDetail.getElementsByTagName("pkg_size")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("itm_child")[0] != null && InvoicebreakDetail.getElementsByTagName("itm_child")[0].childNodes[0] != null )
								{
									childItemBreak = InvoicebreakDetail.getElementsByTagName("itm_child")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("itm_child_descr")[0] != null && InvoicebreakDetail.getElementsByTagName("itm_child_descr")[0].childNodes[0] != null )
								{
									itmChildDescrBreak = InvoicebreakDetail.getElementsByTagName("itm_child_descr")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("child_price_list")[0] != null && InvoicebreakDetail.getElementsByTagName("child_price_list")[0].childNodes[0] != null )
								{
									childProceListBreak = InvoicebreakDetail.getElementsByTagName("child_price_list")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("itm_child_rate")[0] != null && InvoicebreakDetail.getElementsByTagName("itm_child_rate")[0].childNodes[0] != null )
								{
									itemCHildRateBreak = InvoicebreakDetail.getElementsByTagName("itm_child_rate")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("child_hsn_number")[0] != null && InvoicebreakDetail.getElementsByTagName("child_hsn_number")[0].childNodes[0] != null )
								{
									childHSNNumberBreak = InvoicebreakDetail.getElementsByTagName("child_hsn_number")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("child_pack_size")[0] != null && InvoicebreakDetail.getElementsByTagName("child_pack_size")[0].childNodes[0] != null )
								{
									childPkgSizeBreak = InvoicebreakDetail.getElementsByTagName("child_pack_size")[0].childNodes[0].nodeValue;
								}				
								if( InvoicebreakDetail.getElementsByTagName("sub_itm_child")[0] != null && InvoicebreakDetail.getElementsByTagName("sub_itm_child")[0].childNodes[0] != null )
								{
									subItmCHildBreak = InvoicebreakDetail.getElementsByTagName("sub_itm_child")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("sub_child_descr")[0] != null && InvoicebreakDetail.getElementsByTagName("sub_child_descr")[0].childNodes[0] != null )
								{
									subChildDescrBreak = InvoicebreakDetail.getElementsByTagName("sub_child_descr")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("sub_price_list")[0] != null && InvoicebreakDetail.getElementsByTagName("sub_price_list")[0].childNodes[0] != null )
								{
									subPriceListBreak = InvoicebreakDetail.getElementsByTagName("sub_price_list")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("sub_child_rate")[0] != null && InvoicebreakDetail.getElementsByTagName("sub_child_rate")[0].childNodes[0] != null )
								{
									subChildRateBreak = InvoicebreakDetail.getElementsByTagName("sub_child_rate")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("sub_hsn_number")[0] != null && InvoicebreakDetail.getElementsByTagName("sub_hsn_number")[0].childNodes[0] != null )
								{
									subHsnNumberBreak = InvoicebreakDetail.getElementsByTagName("sub_hsn_number")[0].childNodes[0].nodeValue;
								}				
								if( InvoicebreakDetail.getElementsByTagName("sub_pack_size")[0] != null && InvoicebreakDetail.getElementsByTagName("sub_pack_size")[0].childNodes[0] != null )
								{
									subPkgSizeBreak = InvoicebreakDetail.getElementsByTagName("sub_pack_size")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("load_qty")[0] != null && InvoicebreakDetail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
								{
									loadQTYBreak = InvoicebreakDetail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
								}
								if( InvoicebreakDetail.getElementsByTagName("cash_invoice_amount")[0] != null && InvoicebreakDetail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
								{
									cashInvoiceAmountBreak = InvoicebreakDetail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
								}
								if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
								{
									salesPersonCodeBreak = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
								}
								if(itemCodeBreak==listItemCodeBreak)
								{
									dataModelData += "<Detail"+invoiceFormNo+" domID='" + dispCount + "' selected = 'N'>\r\n"+
									"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
									"<dcr_id><![CDATA[]]></dcr_id>\r\n"+
									"<strg_code><![CDATA[]]></strg_code>\n"+
									"<tran_id><![CDATA[]]></tran_id>\r\n"+
									"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
									"<item_descr><![CDATA["+itemDescrBreak+"]]></item_descr>\r\n"+
									"<quantity><![CDATA[]]></quantity>\r\n"+
									"<rate><![CDATA["+rateBreak+"]]></rate>\r\n"+
									"<disc_perc><![CDATA["+discPercBreak+"]]></disc_perc>\r\n"+
									"<lot_no><![CDATA["+lotNoBreak+"]]></lot_no>\r\n"+
									"<curr_stock><![CDATA["+currStockBreak+"]]></curr_stock>\r\n"+
									"<org_stock><![CDATA["+currStockBreak+"]]></org_stock>\r\n"+
									"<total_amount><![CDATA[]]></total_amount>\r\n"+
									"<value><![CDATA[]]></value>\r\n"+
									"<item_code><![CDATA["+itemCodeBreak+"]]></item_code>"+
									"<sales_pers><![CDATA["+salesPersonCodeBreak+"]]></sales_pers>"+
									"<tax_amt_inv><![CDATA["+taxAmntInvoiceBreak+"]]></tax_amt_inv>\r\n"+
									"<net_amt><![CDATA[]]></net_amt>\r\n"+
									"<basic_value><![CDATA[]]></basic_value>\r\n"+
									"<total_gst><![CDATA[]]></total_gst>\r\n"+
									"<total_amount><![CDATA[]]></total_amount>\r\n"+
									"<remarks_inv><![CDATA[]]></remarks_inv>\r\n"+
									"<price_list><![CDATA["+priceListBreak+"]]></price_list>"+
									"<hsn_number><![CDATA["+hsnNumberBreak+"]]></hsn_number>\r\n"+
									"<pkg_size><![CDATA["+pkgSizeBreak+"]]></pkg_size>"+
									"<itm_child><![CDATA["+childItemBreak+"]]></itm_child>"+
									"<itm_child_descr><![CDATA["+itmChildDescrBreak+"]]></itm_child_descr>"+
									"<itm_child_rate><![CDATA["+itemCHildRateBreak+"]]></itm_child_rate>"+
									"<child_hsn_number><![CDATA["+childHSNNumberBreak+"]]></child_hsn_number>"+
									"<child_pack_size><![CDATA["+childPkgSizeBreak+"]]></child_pack_size>"+
									"<child_price_list><![CDATA["+childProceListBreak+"]]></child_price_list>"+
									"<sub_itm_child><![CDATA["+subItmCHildBreak+"]]></sub_itm_child>"+					
									"<sub_child_descr><![CDATA["+subChildDescrBreak+"]]></sub_child_descr>"+					
									"<sub_hsn_number><![CDATA["+subHsnNumberBreak+"]]></sub_hsn_number>"+
									"<sub_child_rate><![CDATA["+subChildRateBreak+"]]></sub_child_rate>"+					
									"<sub_price_list><![CDATA["+subPriceListBreak+"]]></sub_price_list>"+					
									"<sub_pack_size><![CDATA["+subPkgSizeBreak+"]]></sub_pack_size>"+
									"<is_broken><![CDATA[N]]></is_broken>"+
									"<load_qty><![CDATA["+loadQTYBreak+"]]></load_qty>"+	
									"<max_invoice_id><![CDATA["+maximumInvoice+"]]></max_invoice_id>"+				
									"<cash_invoice_amount><![CDATA["+cashInvoiceAmountBreak+"]]></cash_invoice_amount>"+												
									"</Detail"+invoiceFormNo+">";
									dispCount++;
									break;
								
								}

								
		        		
		        		}
					}
				}// if existing itemlist end
			}
		}
		dataModelData += "</Root>";
		
		console.log("dataModelData after changes updateInvoiceDataModelFile["+dataModelData+"]");
		
		//write logic to update data in dataModelData
		backUpAndWriteFile(filePath, dataModelData); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
		}
		
		onFailure = function(error)
		{
		console.log('error in readFile ',error);
		}
	}
		readFile(filePath,onSuccess,onFailure);
}
function updateStockItemeDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for Stock form data model updation
{
	var dataModelxmlDoc = "";
	var dispCount = 1;
	
	var offlineDatDom = "";
		
		var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/stocks_transfer_wiz_item.xml';

		onSuccess = function(dataModelData)
		{
			console.log("updateStockItemeDataModelFile dataModelData data is not null before change"+ dataModelData);
			var xmlVersion = dataModelData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				//console.log("cureentform data is not null"+ formDetailData);
				if( xmlVersion != 0 )
				{
					if( dataModelData.indexOf("<Root>") == -1 )
					{
						dataModelData = "<Root>"+dataModelData+"</Root>";
					}
				}
			}
			else
			{
				console.log("null dataModelData");
			}
			
			
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}

	if ( window.DOMParser )
	{
		parser = new DOMParser();
		try
		{
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
			}
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
			}
		}
		catch(ex)
		{
			alert("Exception occurs while parsing xml data");
		}
	}
			
				
		if(dataModelxmlDoc!= null)
		{
				var invoiceFormNo="";
				var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
				for( var k= 0;k < parentDetailElement.length; k++)
				{
					var parentDetail = parentDetailElement[k];
					if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
					{
						invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
					}
					
				}// for loop first offline data is finish
				
			
			
			var InvoiceDetailElement = offlineDatDom.getElementsByTagName( "Detail"+invoiceFormNo );
			var itemWithStock=[];
      		var salesPers="";

			for (var v = 0; v < InvoiceDetailElement.length; v++)
			{

				var invoiceDetail = InvoiceDetailElement[v];
				var attributeVal = invoiceDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
      		var domIDVal = invoiceDetail.getAttribute("domID");
      			if(attributeVal != null && attributeVal != 'D')
      			{
      			var currentOfflineSTock="",itemCodeOfflineData="";
      			
      			if( invoiceDetail.getElementsByTagName("curr_stock")[0] != null && invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
					{
						currentOfflineSTock = invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
					}
					if( invoiceDetail.getElementsByTagName("item_code")[0] != null && invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
					{
						itemCodeOfflineData = invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
						itemCodeOfflineData=itemCodeOfflineData.trim();
					}
	      			if( invoiceDetail.getElementsByTagName("sales_pers")[0] != null && invoiceDetail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
					{
	      				salesPers = invoiceDetail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
	      				salesPers=salesPers.trim();
					}
      			itemWithStock.push(itemCodeOfflineData+"@"+currentOfflineSTock);
      		
      		}
			}// for loop invoice offline data is finish
			var detailElement = dataModelxmlDoc.getElementsByTagName( "Detail2");
			dataModelData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
			for (var i = 0; i < detailElement.length; i++)
			{
				var tranId="",itemDescr="",quantity="",currStock="",orgStock="",itemCode="",locationCodeFrom="",lotNoFrom="";
				var lotSlFr="",lotNoTo="",lotSLTo="",locCodetTo="",siteCode="",cctrCodeCr="",acctCodeCr="",acctCodeDr="",cctrCodeDr="",qtyPerArt="";
				
				var detail = detailElement[i];
				if( detail.getElementsByTagName("tran_id")[0] != null && detail.getElementsByTagName("tran_id")[0].childNodes[0] != null )
				{
					tranId = detail.getElementsByTagName("tran_id")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
				{
					itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
				{
					quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
				{
					currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
				{
					orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
					itemCode=itemCode.trim();
				}
				if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
				{
					locationCodeFrom = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					locationCodeFrom=locationCodeFrom.trim();
				}
				if( detail.getElementsByTagName("lot_no__fr")[0] != null && detail.getElementsByTagName("lot_no__fr")[0].childNodes[0] != null )
				{
					lotNoFrom = detail.getElementsByTagName("lot_no__fr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_sl__fr")[0] != null && detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0] != null )
				{
					lotSlFr = detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_no__to")[0] != null && detail.getElementsByTagName("lot_no__to")[0].childNodes[0] != null )
				{
					lotNoTo = detail.getElementsByTagName("lot_no__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_sl__to")[0] != null && detail.getElementsByTagName("lot_sl__to")[0].childNodes[0] != null )
				{
					lotSLTo = detail.getElementsByTagName("lot_sl__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
				{
					locCodetTo = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("site_code")[0] != null && detail.getElementsByTagName("site_code")[0].childNodes[0] != null )
				{
					siteCode = detail.getElementsByTagName("site_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("acct_code__cr")[0] != null && detail.getElementsByTagName("acct_code__cr")[0].childNodes[0] != null )
				{
					acctCodeCr = detail.getElementsByTagName("acct_code__cr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cctr_code__cr")[0] != null && detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0] != null )
				{
					cctrCodeCr = detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("acct_code__dr")[0] != null && detail.getElementsByTagName("acct_code__dr")[0].childNodes[0] != null )
				{
					acctCodeDr = detail.getElementsByTagName("acct_code__dr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("qty_per_art")[0] != null && detail.getElementsByTagName("qty_per_art")[0].childNodes[0] != null )
				{
					qtyPerArt = detail.getElementsByTagName("qty_per_art")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cctr_code__dr")[0] != null && detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0] != null )
				{
					cctrCodeDr = detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0].nodeValue;
				}	

					
					if(itemWithStock!=null && itemWithStock!= "" && salesPers==locationCodeFrom)
					{
						
						for(var j=0;j < itemWithStock.length;j++)
						{
							var itemStockList = itemWithStock[j];
							
							var listItemCode=itemStockList.split("@")[0];
							var listStock=itemStockList.split("@")[1];
							
							if(listItemCode == itemCode)
							{
								currStock=listStock;
								orgStock=listStock;
								break;
							}
						}
						
					}
					
					dataModelData += "<Detail2 domID='" + dispCount + "' selected = 'N'>\r\n"+
					"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
					"<tran_id><![CDATA["+tranId+"]]></tran_id>\r\n"+
					"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
					"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
					"<quantity><![CDATA["+quantity+"]]></quantity>\r\n"+
					"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\r\n"+
					"<org_stock><![CDATA["+orgStock+"]]></org_stock>\r\n"+
					"<item_code><![CDATA["+itemCode+"]]></item_code>"+
					"<loc_code__fr><![CDATA["+locationCodeFrom+"]]></loc_code__fr>"+
					"<lot_no__fr><![CDATA["+lotNoFrom+"]]></lot_no__fr>\r\n"+
					"<lot_sl__fr><![CDATA["+lotSlFr+"]]></lot_sl__fr>\r\n"+
					"<lot_no__to><![CDATA["+lotNoTo+"]]></lot_no__to>\r\n"+
					"<lot_sl__to><![CDATA["+lotSLTo+"]]></lot_sl__to>\r\n"+
					"<loc_code__to><![CDATA["+locCodetTo+"]]></loc_code__to>"+
					"<site_code><![CDATA["+siteCode+"]]></site_code>\r\n"+
					"<acct_code__cr><![CDATA["+acctCodeCr+"]]></acct_code__cr>"+
					"<cctr_code__cr><![CDATA["+cctrCodeCr+"]]></cctr_code__cr>"+
					"<acct_code__dr><![CDATA["+acctCodeDr+"]]></acct_code__dr>"+
					"<qty_per_art><![CDATA["+qtyPerArt+"]]></qty_per_art>"+
					"<cctr_code__dr><![CDATA["+cctrCodeDr+"]]></cctr_code__dr>"+										
					"</Detail2>";
					dispCount++;
					
		}// for loop data model invoice offline data is finish
		
		dataModelData += "</Root>";
		
		console.log("updateStockItemeDataModelFile dataModelData after changes["+dataModelData+"]");
		
		//write logic to update data in dataModelData
		backUpAndWriteFile(filePath, dataModelData); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
		}
		
		onFailure = function(error)
		{
		console.log('updateStockItemeDataModelFile error in readFile ',error);
		}
	}
		readFile(filePath,onSuccess,onFailure);
}
function updateVenStockDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for invoice form data model updation
{


	console.log("Inside updateVenStockDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/VAN_STOCK.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					
					
					var invoiceFormNo="";	
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
						{
							invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
						}
					}	
						
					var InvoiceDetailElement = offlineDatDom.getElementsByTagName( "Detail"+invoiceFormNo );
					//var itemWithStock=[];
					for (var v = 0; v < InvoiceDetailElement.length; v++)
					{
						var currentOfflineStock="",itemCodeOfflineData="",loadQTY="",itemDescr="",brokenQTY="",quantity="",breakItemRef="",isStockBreak="";
						
						var dataModelExistFlag=false;
						var invoiceDetail = InvoiceDetailElement[v];
						var attributeVal = invoiceDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
		        		var domIDVal = invoiceDetail.getAttribute("domID");
		        		if(attributeVal != null && attributeVal != 'D')
		        		{
		        			if( invoiceDetail.getElementsByTagName("curr_stock")[0] != null && invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
							{
								currentOfflineSTock = invoiceDetail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
							}
							if( invoiceDetail.getElementsByTagName("item_code")[0] != null && invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
							{
								itemCodeOfflineData = invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
								itemCodeOfflineData=itemCodeOfflineData.trim();
							}
							if( invoiceDetail.getElementsByTagName("load_qty")[0] != null && invoiceDetail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
							{
								loadQTY = invoiceDetail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
							}
							if( invoiceDetail.getElementsByTagName("item_descr")[0] != null && invoiceDetail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								itemDescr = invoiceDetail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
							}
							if( invoiceDetail.getElementsByTagName("broken_qty")[0] != null && invoiceDetail.getElementsByTagName("broken_qty")[0].childNodes[0] != null )
							{
								brokenQTY = invoiceDetail.getElementsByTagName("broken_qty")[0].childNodes[0].nodeValue;
							}
							if( invoiceDetail.getElementsByTagName("quantity")[0] != null && invoiceDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								quantity = invoiceDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}
							if( invoiceDetail.getElementsByTagName("break_item__ref")[0] != null && invoiceDetail.getElementsByTagName("break_item__ref")[0].childNodes[0] != null )
							{
								breakItemRef = invoiceDetail.getElementsByTagName("break_item__ref")[0].childNodes[0].nodeValue;
							}
							if( invoiceDetail.getElementsByTagName("stock_break")[0] != null && invoiceDetail.getElementsByTagName("stock_break")[0].childNodes[0] != null )
							{
								isStockBreak = invoiceDetail.getElementsByTagName("stock_break")[0].childNodes[0].nodeValue;
							}
							
							if(quantity==null ||  quantity.trim().length==0)
							{
								quantity="0";
							}
							if(brokenQTY==null ||  brokenQTY.trim().length==0)
							{
								brokenQTY="0";
							}
							if(loadQTY==null ||  loadQTY.trim().length==0)
							{
								loadQTY="0";
							}
							console.log("loadQTY["+loadQTY+"]itemCodeOfflineData["+itemCodeOfflineData+"]");
	
		        				//itemWithStock.push(itemCodeOfflineData+"@"+currentOfflineSTock);

									if(dataModelJSONArray!=null && dataModelJSONArray!="")
									{
											for(var i = 0; i < dataModelJSONArray.length; i++)
											{
												  
												    const jsonObj = dataModelJSONArray[i];
												    
												    var itemCode = jsonObj.ITEM_CODE != undefined ? jsonObj.ITEM_CODE.trim() : '';
													    													  
                                                    if(itemCodeOfflineData == itemCode)
													 {
														var saleValue=jsonObj.SALE;
														var breakAddQtyValue=jsonObj.BREAK_ADD_QTY;
														var breakDeductQty=jsonObj.BREAK_DEDUCT_QTY;
														var transferIn=jsonObj.TRANSFER_IN;
														var transferOut=jsonObj.TRANSFER_OUT;
														
																											                            
														if(saleValue!=null && saleValue!= "" )
														{
															saleValue=saleValue;
														}
														else
														{
															saleValue="0";
														}
														if(breakAddQtyValue!=null && breakAddQtyValue!= "")
														{
															breakAddQtyValue=breakAddQtyValue;

														}
														else
														{
															breakAddQtyValue="0";
														}
														if(breakDeductQty!=null && breakDeductQty!= "" )
														{
															breakDeductQty=breakDeductQty;
														}
														else
														{
															breakDeductQty="0";
														}
														if(transferIn!=null && transferIn!= "" )
														{
															transferIn=transferIn;
														}
														else
														{
															transferIn="0";
														}
														
														if(transferOut!=null && transferOut!= "" )
														{
															transferOut=transferOut;
														}
														else
														{
															transferOut="0";
														}
														
														
														saleValue=parseInt(saleValue)+parseInt(quantity);
														breakAddQtyValue=parseInt(breakAddQtyValue)+parseInt(brokenQTY);
														if(isStockBreak=="Y")
														{
															breakDeductQty=parseInt(breakDeductQty)+1;
														}
														var stockValue=parseInt(loadQTY)+parseInt(transferIn)+parseInt(breakAddQtyValue)-parseInt(saleValue)-parseInt(transferOut)-parseInt(breakDeductQty);
																						    
													    
				
															
													        jsonObj.SALE = saleValue;
													        jsonObj.ITEM_DESCR = itemDescr;
													        jsonObj.BREAK_ADD_QTY = breakAddQtyValue;
													        jsonObj.BREAK_DEDUCT_QTY = breakDeductQty;
															jsonObj.TRANSFER_IN = transferIn;
													        jsonObj.TRANSFER_OUT = transferOut;
													        jsonObj.ITEM_CODE = itemCodeOfflineData;
													        jsonObj.LOAD_QUANTITY = loadQTY;
													        jsonObj.STOCK = stockValue;
													        
													        dataModelExistFlag=true;
													    }
											}
										}
										
											if(dataModelExistFlag==false)
											{

												var breakDeductQty="0";
												if(isStockBreak=="Y")
												{
													breakDeductQty=parseInt(breakDeductQty)+1;
												}
												var stockValue=parseInt(loadQTY)+parseInt(brokenQTY)-parseInt(quantity)-parseInt(breakDeductQty);
												
												dataModelJSONArray.push({"SALE":quantity,"ITEM_DESCR":itemDescr,"BREAK_ADD_QTY":brokenQTY,"BREAK_DEDUCT_QTY":breakDeductQty,"TRANSFER_IN":"0","TRANSFER_OUT":"0","ITEM_CODE":itemCodeOfflineData,"LOAD_QUANTITY":loadQTY,"STOCK":stockValue});
											}
											
				        		}
							}// for loop Ven stock offline data is finish
				

						
						
			
						 
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateVenStockDataModelFile if dataModelJSONArray is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateVenStockDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}

function updateDailySalesDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for invoice form data model updation
{


	console.log("Inside updateDailySalesDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/DAILY_SALES.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					
					
					var invoiceFormNo="";	
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
						{
							invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
						}
					}	
						
					var InvoiceDetailElement = offlineDatDom.getElementsByTagName( "Detail"+invoiceFormNo );
					//var itemWithStock=[];

					for (var v = 0; v < InvoiceDetailElement.length; v++)
					{
						var itemCodeOfflineData="",rate="",itemDescr="",quantity="",taxAmount="",totalValue="";
						
						var dataModelExistFlag=false;
						var invoiceDetail = InvoiceDetailElement[v];
						var attributeVal = invoiceDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
		        		var domIDVal = invoiceDetail.getAttribute("domID");
		        		if(attributeVal != null && attributeVal != 'D')
		        		{
							if( invoiceDetail.getElementsByTagName("item_code")[0] != null && invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
							{
								itemCodeOfflineData = invoiceDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
								itemCodeOfflineData=itemCodeOfflineData.trim();
							}							
							if( invoiceDetail.getElementsByTagName("item_descr")[0] != null && invoiceDetail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								itemDescr = invoiceDetail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
							}
							if( invoiceDetail.getElementsByTagName("quantity")[0] != null && invoiceDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								quantity = invoiceDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}
					        if( invoiceDetail.getElementsByTagName("rate")[0] != null && invoiceDetail.getElementsByTagName("rate")[0].childNodes[0] != null )
					        {
					            rate = invoiceDetail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
					        }
					        if( invoiceDetail.getElementsByTagName("tax_amt_inv")[0] != null && invoiceDetail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
					        {
					        	taxAmount = invoiceDetail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
					        }
	
							if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
							{
								if ( quantity > 0 && rate > 0)
								{
									totalValue = ((parseFloat(quantity) * parseFloat(rate)) + ((parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /100)))) );
									totalValue = Number(Math.round(totalValue+'e'+2)+'e-'+2);
								}
							}
							if(quantity!=null && quantity!= "" )
							{
								quantity=quantity;
							}
							else
							{
								quantity="0";
							}
							
							if(totalValue!=null && totalValue!= "" )
							{
								totalValue=totalValue;
							}
							else
							{
								totalValue="0";
							}
	
	
		        				//itemWithStock.push(itemCodeOfflineData+"@"+currentOfflineSTock);

									console.log("updateDailySalesDataModelFile dataModelJSONArray::["+JSON.stringify(dataModelJSONArray)+"]");
									if(dataModelJSONArray!=null && dataModelJSONArray!="")
									{
											for(var i = 0; i < dataModelJSONArray.length; i++)
											{
												  
												    const jsonObj = dataModelJSONArray[i];
												    
												    var itemCode = jsonObj.ITEM_CODE != undefined ? jsonObj.ITEM_CODE.trim() : '';
													
													var saleValue=jsonObj.SALE;
													var itemQuantity=jsonObj.ITEM_QUANTITY;
													
													
													if(saleValue!=null && saleValue!= "" )
													{
														saleValue=saleValue;
													}
													else
													{
														saleValue="0";
													}
													
													if(itemQuantity!=null && itemQuantity!= "")
													{
														itemQuantity=itemQuantity;
													}
													else
													{
														itemQuantity="0";
													}

													
													
													saleValue=parseFloat(saleValue)+parseFloat(totalValue);
													itemQuantity=parseInt(itemQuantity)+parseInt(quantity);

																					    
												    if(itemCodeOfflineData == itemCode)
												    {
			
														
												        jsonObj.SALE = saleValue;
												        jsonObj.ITEM_DESCR = itemDescr;
												        jsonObj.ITEM_QUANTITY = itemQuantity;
												        jsonObj.ITEM_CODE = itemCodeOfflineData;
												        dataModelExistFlag=true;
												    }
											}
										}
										
											if(dataModelExistFlag==false)
											{
												console.log("updateDailySalesDataModelFile if dataModelExistFlag is false");	

												
												dataModelJSONArray.push({"SALE":totalValue,"ITEM_DESCR":itemDescr,"ITEM_QUANTITY":quantity,"ITEM_CODE":itemCodeOfflineData});
											}
											
				        		}
							}// for loop Ven stock offline data is finish
				

						
						
			
						 
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateDailySalesDataModelFile is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateDailySalesDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}
function updateDailySalesRetailerDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for invoice form data model updation
{

	console.log("Inside updateDailySalesRetailerDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/DAILY_SALES_RETAILER.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					
					
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var amount="",strgName="",strgCode="";	
						
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("strg_code")[0] != null && parentDetail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							strgCode = parentDetail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("strg_name")[0] != null && parentDetail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
						{
							strgName = parentDetail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("amount")[0] != null && parentDetail.getElementsByTagName("amount")[0].childNodes[0] != null )
						{
							amount = parentDetail.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
						}
						
						var dataModelExistFlag=false;
						if(dataModelJSONArray!=null && dataModelJSONArray!="")
						{
								for(var i = 0; i < dataModelJSONArray.length; i++)
								{
									  
									    const jsonObj = dataModelJSONArray[i];
									    
									    var custCode = jsonObj.STRG_CODE != undefined ? jsonObj.STRG_CODE.trim() : '';
									    if(custCode == strgCode)
									    {

											var existAmount=jsonObj.AMOUNT;
											var totalAmountJson =parseInt(existAmount)+parseInt(amount);							    

									        jsonObj.STRG_CODE = strgCode;
									        jsonObj.STRG_NAME = strgName;
									        jsonObj.AMOUNT = totalAmountJson;
									        dataModelExistFlag=true;
									    }
								}
							}
							
								if(dataModelExistFlag==false)
								{								
									dataModelJSONArray.push({"STRG_CODE":strgCode,"STRG_NAME":strgName,"AMOUNT":amount});
								}
					}	
						
						 
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateDailySalesRetailerDataModelFile is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateDailySalesRetailerDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}
function updateDailySalesPaymentDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for invoice form data model updation
{


	console.log("Inside updateDailySalesDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/DAILY_SALES_PAYMENT.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					
					
					var collectionFormNo="";	
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("collection_form_no")[0] != null && parentDetail.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
						{
							collectionFormNo = parentDetail.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
						}
					}	
					var collectionDetailElement = offlineDatDom.getElementsByTagName( "Detail"+collectionFormNo );
					for (var c = 0; c < collectionDetailElement.length; c++)
					{
						var paymentMode="",amountCollection="",payModeDescr="";
						
						var collectionDetail = collectionDetailElement[c];
						var attributeVal = collectionDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
		        		var domIDVal = collectionDetail.getAttribute("domID");
						if(attributeVal != null && attributeVal != 'D')
						{
							if( collectionDetail.getElementsByTagName("pay_mode")[0] != null && collectionDetail.getElementsByTagName("pay_mode")[0].childNodes[0] != null )
							{
								paymentMode = collectionDetail.getElementsByTagName("pay_mode")[0].childNodes[0].nodeValue;
								paymentMode=paymentMode.trim();
							}
							if( collectionDetail.getElementsByTagName("amount")[0] != null && collectionDetail.getElementsByTagName("amount")[0].childNodes[0] != null )
							{
								amountCollection = collectionDetail.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
							}
							
							if(paymentMode=="C")
							{
								payModeDescr="CASH";
							}
							else if(paymentMode=="Q")
							{
								payModeDescr="CHEQUE";
							}
							else if(paymentMode=="O")
							{
								payModeDescr="ONLINE";
								
							}
							else if(paymentMode=="R")
							{
								payModeDescr="RTGS";
							}
							else if(paymentMode=="N")
							{
								payModeDescr="NEFT";
							}
							else
							{
								payModeDescr="UPI";
							}
							var dataModelExistFlag=false;

							console.log("updateDailySalesDataModelFile dataModelJSONArray::["+JSON.stringify(dataModelJSONArray)+"]");
							if(dataModelJSONArray!=null && dataModelJSONArray!="")
							{
									for(var i = 0; i < dataModelJSONArray.length; i++)
									{
										  
										    const jsonObj = dataModelJSONArray[i];
										    
										    var modePayment = jsonObj.MODE_PAYMENT != undefined ? jsonObj.MODE_PAYMENT.trim() : '';
											
											var amountJson=jsonObj.AMOUNT;
											var collCount=jsonObj.COUNT;
											var payMode=jsonObj.PAY_MODE;
											
											if(collCount!=null && collCount!= "" )
											{
												collCount=collCount;
											}
											else
											{
												collCount="0";
											}
											if(amountJson!=null && amountJson!= "" )
											{
												amountJson=amountJson;
											}
											else
											{
												amountJson="0";
											}
											collCount =	parseInt(collCount)+1;	
											amountJson =parseInt(amountJson)+parseInt(amountCollection);							    

										    if(paymentMode == modePayment)
										    {
	
												
										        jsonObj.PAY_MODE = payModeDescr;
										        jsonObj.COUNT = collCount;
										        jsonObj.AMOUNT = amountJson;
										        jsonObj.MODE_PAYMENT = paymentMode;
										        dataModelExistFlag=true;
										    }
									}
								}
								
									if(dataModelExistFlag==false)
									{
										console.log("updateDailySalesDataModelFile if dataModelExistFlag is false");	

										
										dataModelJSONArray.push({"PAY_MODE":payModeDescr,"COUNT":"1","AMOUNT":amountCollection,"MODE_PAYMENT":paymentMode});
									}
						}
						
					}
						
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateDailySalesDataModelFile is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateVenStockDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}
function updateDailySalesCardDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for invoice form data model updation
{


	console.log("Inside updateDailySalesCardDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/DAILY_SALES_CARD.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					
					
					var amount="",invoiceFormNo="";	
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("amount")[0] != null && parentDetail.getElementsByTagName("amount")[0].childNodes[0] != null )
						{
							amount = parentDetail.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
						{
							invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
						}
				        if(amount!=null && amount!="")
				        {
				        	amount=amount;
				        }
				        else
				        {
				        	amount="0";
				        }
					}	

					var InvoiceDetailElement = offlineDatDom.getElementsByTagName( "Detail"+invoiceFormNo );
					var quantity="",totalQuantity="0";

					for (var v = 0; v < InvoiceDetailElement.length; v++)
					{
						//var dataModelExistFlag=false;
						var invoiceDetail = InvoiceDetailElement[v];
						var attributeVal = invoiceDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
		        		var domIDVal = invoiceDetail.getAttribute("domID");
		        		if(attributeVal != null && attributeVal != 'D')
		        		{

							if( invoiceDetail.getElementsByTagName("quantity")[0] != null && invoiceDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								quantity = invoiceDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
							}

	
							if( quantity != 'undefined' && quantity != null )
							{
								
								totalQuantity=parseInt(totalQuantity)+parseInt(quantity);
							}
		        		}
					}
					console.log("After updateDailySalesCardDataModelFile is totalQuantity["+totalQuantity+"]amount["+amount+"]");	
					var dataModelAmountExistFlag=false;
					var dataModelQuantityExistFlag=false;

					if(dataModelJSONArray!=null && dataModelJSONArray!="")
					{
							for(var i = 0; i < dataModelJSONArray.length; i++)
							{
								  
								    const jsonObj = dataModelJSONArray[i];
								    
								    var columnName = jsonObj.COLUMNAME != undefined ? jsonObj.COLUMNAME.trim() : '';
							        var business=jsonObj.AMOUNT;
							        var theameColor=jsonObj.THEME_COLOR;
							        var iconImage=jsonObj.ICON_IMAGE;
							        if(business!=null && business!="")
							        {
							        	business=business;
							        }
							        else
							        {
							        	business="0";
							        }
							        
								    if(columnName == "Total Business")
								    {
								    	console.log("inside total business statment");
								    	var totalBusiness=parseInt(business)+parseInt(amount);
								        jsonObj.AMOUNT = totalBusiness;
								        jsonObj.THEME_COLOR = theameColor;
								        jsonObj.ICON_IMAGE = iconImage;
								        jsonObj.COLUMNAME = "Total Business";

								        dataModelAmountExistFlag=true;


								    }
						    

								    if(columnName == "Quantity")
								    {
								    	console.log("inside Quantity statment");
								        if(totalQuantity!=null && totalQuantity!="")
								        {
								        	totalQuantity=totalQuantity;
								        }
								        else
								        {
								        	totalQuantity="0";
								        }
								    	var totalQuantity=parseInt(business)+parseInt(totalQuantity);
								    	
								        jsonObj.AMOUNT = totalQuantity;
								        jsonObj.THEME_COLOR = theameColor;
								        jsonObj.ICON_IMAGE = iconImage;
								        jsonObj.COLUMNAME = "Quantity";

								        dataModelQuantityExistFlag=true;


								    }
							}
						}
						
							if(dataModelAmountExistFlag==false)
							{
								console.log("updateDailySalesCardDataModelFile if dataModelExistFlag is false");	

								
								dataModelJSONArray.push({"AMOUNT":amount,"THEME_COLOR":"purple","ICON_IMAGE":"RupeeIcon.svg","COLUMNAME":"Total Business"});
							}
							if(dataModelQuantityExistFlag==false)
							{
								console.log("updateDailySalesCardDataModelFile if dataModelExistFlag is false");	

								
								dataModelJSONArray.push({"AMOUNT":totalQuantity,"THEME_COLOR":"lightgreen","ICON_IMAGE":"Quantity.svg","COLUMNAME":"Quantity"});
							}
						
						
			
						 
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateDailySalesCardDataModelFile is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateDailySalesCardDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}
function updateDailySalesSubCardDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for invoice form data model updation
{


	console.log("Inside updateDailySalesSubCardDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/DAILY_SALES_SUBCARD.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					
					var parentFormCount="0";
					var invoiceFormNo="";	
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
							if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
							{
								invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
							}
		        			parentFormCount++;
		        		
					}	

					var InvoiceDetailElement = offlineDatDom.getElementsByTagName( "Detail"+invoiceFormNo );
					var invoiceFrmCnt="0";
					for (var v = 0; v < InvoiceDetailElement.length; v++)
					{
						var invoiceDetail = InvoiceDetailElement[v];
						var attributeVal = invoiceDetail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
		        		var domIDVal = invoiceDetail.getAttribute("domID");
		        		if(attributeVal != null && attributeVal != 'D')
		        		{

		        			invoiceFrmCnt++;
		        		}
					}
					console.log("Inside updateDailySalesSubCardDataModelFile parentFormCount["+parentFormCount+"]invoiceFrmCnt["+invoiceFrmCnt+"]");

					var dataModelTCExistFlag=false;
					var dataModelPCExistFlag=false;
					var dataModelNPCExistFlag=false;
					var dataModelNAExistFlag=false;

					if(dataModelJSONArray!=null && dataModelJSONArray!="")
					{
							for(var i = 0; i < dataModelJSONArray.length; i++)
							{
								  
								    const jsonObj = dataModelJSONArray[i];
								    
								    var columnName = jsonObj.COLUMNAME != undefined ? jsonObj.COLUMNAME.trim() : '';
							        var tcColumn=jsonObj.TC;
							        var theameColor=jsonObj.THEME_COLOR;
							        if(tcColumn!=null && tcColumn!="")
							        {
							        	tcColumn=tcColumn;
							        }
							        else
							        {
							        	tcColumn="0";
							        }
							        
								    if(columnName == "TC")
								    {
								    	var totalCall="0";
								    	if(parentFormCount>0)
								    	{
								    		totalCall=parseInt(tcColumn)+1;
								    	}
								    	console.log("inside total Call statment");
								        jsonObj.TC = totalCall;
								        jsonObj.THEME_COLOR = theameColor;
								        jsonObj.COLUMNAME = "TC";

								        dataModelTCExistFlag=true;


								    }
								    if(columnName == "PC")
								    {
								    	var productiveCall="0";
								    	if(invoiceFrmCnt>0)
								    	{
								    		productiveCall=parseInt(tcColumn)+1;
								    	}
								    	console.log("inside Productive Call statment");
								        jsonObj.TC = productiveCall;
								        jsonObj.THEME_COLOR = theameColor;
								        jsonObj.COLUMNAME = "PC";

								        dataModelPCExistFlag=true;


								    }

								    if(columnName == "NPC")
								    {
								    	console.log("inside Non Productive Call statment");
								    	var npcCall="0";
								    	if(parentFormCount>0 && invoiceFrmCnt<=0)
								    	{
								    		npcCall="1";
								    	}
								    	var nonProductiveCall=parseInt(tcColumn)+parseInt(npcCall);

								        jsonObj.TC = nonProductiveCall;
								        jsonObj.THEME_COLOR = theameColor;
								        jsonObj.COLUMNAME = "NPC";

								        dataModelNPCExistFlag=true;


								    }
								    if(columnName == "NA")
								    {
								    	console.log("inside Non NA statment");


								        jsonObj.TC = "0";
								        jsonObj.THEME_COLOR = theameColor;
								        jsonObj.COLUMNAME = "NA";

								        dataModelNAExistFlag=true;


								    }
							}
						}
						
							if(dataModelTCExistFlag==false)
							{
								console.log("updateDailySalesCardDataModelFile if dataModelExistFlag is false");	

								if(parentFormCount>0)
								{
									dataModelJSONArray.push({"TC":"1","THEME_COLOR":"darkblue","COLUMNAME":"TC"});

								}
							}
							if(dataModelPCExistFlag==false)
							{
								console.log("updateDailySalesCardDataModelFile if dataModelExistFlag is false");	
								if(invoiceFrmCnt>0)
								{
									dataModelJSONArray.push({"TC":"1","THEME_COLOR":"darkblue","COLUMNAME":"PC"});

								}
								
							}
							if(dataModelNPCExistFlag==false)
							{
								console.log("updateDailySalesCardDataModelFile if dataModelExistFlag is false");	
								if(parentFormCount>0 && invoiceFrmCnt<=0)
								{
									dataModelJSONArray.push({"TC":"1","THEME_COLOR":"darkblue","COLUMNAME":"NPC"});

								}
								
							}
							if(dataModelNAExistFlag==false)
							{
								console.log("updateDailySalesCardDataModelFile if dataModelExistFlag is false");	
								dataModelJSONArray.push({"TC":"0","THEME_COLOR":"darkblue","COLUMNAME":"NA"});
							}
			
						 
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateDailySalesCardDataModelFile is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateDailySalesCardDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}
function updateInvoiceDMDataModelFile(userId, responseText,offlineDataXML)//Added function by mrunalini sinkar for invoice form data model updation
{


	console.log("Inside updateInvoiceDMDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/INVOICE_DM.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					
					
					var amount="",strgName="",strgCode="",localityDescr="",minInvoice="";	
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("strg_code")[0] != null && parentDetail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							strgCode = parentDetail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("strg_name")[0] != null && parentDetail.getElementsByTagName("strg_name")[0].childNodes[0] != null )
						{
							strgName = parentDetail.getElementsByTagName("strg_name")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("amount")[0] != null && parentDetail.getElementsByTagName("amount")[0].childNodes[0] != null )
						{
							amount = parentDetail.getElementsByTagName("amount")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("locality_descr")[0] != null && parentDetail.getElementsByTagName("locality_descr")[0].childNodes[0] != null )
						{
							localityDescr = parentDetail.getElementsByTagName("locality_descr")[0].childNodes[0].nodeValue;
						}
						if( parentDetail.getElementsByTagName("minimum_invoice")[0] != null && parentDetail.getElementsByTagName("minimum_invoice")[0].childNodes[0] != null )
						{
							minInvoice = parentDetail.getElementsByTagName("minimum_invoice")[0].childNodes[0].nodeValue;
						}
						var dataModelExistFlag=false;
						console.log("updateInvoiceDMDataModelFile dataModelJSONArray::["+JSON.stringify(dataModelJSONArray)+"]");
						if(dataModelJSONArray!=null && dataModelJSONArray!="")
						{
								for(var i = 0; i < dataModelJSONArray.length; i++)
								{
									  
									    const jsonObj = dataModelJSONArray[i];
									    
									    var custCode = jsonObj.STRG_CODE != undefined ? jsonObj.STRG_CODE.trim() : '';
									    var jsonInvoiceID = jsonObj.INVOICE_ID != undefined ? jsonObj.INVOICE_ID.trim() : '';
									    if(custCode == strgCode && jsonInvoiceID == minInvoice)
									    {

											
									        jsonObj.STRG_CODE = strgCode;
									        jsonObj.STRG_NAME = strgName;
									        jsonObj.LOCALITY = localityDescr;
									        jsonObj.AMOUNT = amount;
									        jsonObj.INVOICE_ID = minInvoice;

									        dataModelExistFlag=true;
									    }
								}
							}
							
								if(dataModelExistFlag==false)
								{
									console.log("updateInvoiceDMDataModelFile if dataModelExistFlag is false");	

									
									dataModelJSONArray.push({"STRG_CODE":strgCode,"STRG_NAME":strgName,"LOCALITY":localityDescr,"AMOUNT":amount,"INVOICE_ID":minInvoice});
								}
					}	
						
						 
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateInvoiceDMDataModelFile is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateInvoiceDMDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}

//Added by Jay.Kesur to update the last_meet_date in data-model [23-Dec-22]-[Start]
function updateCustomerCodesDataModel(userId,responseText,offlineDataXML)
{
	console.log("Inside updateInvoiceDMDataModelFile");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/CUSTOMERCODES.json';


		onSuccess = function(dataModelData)
		{
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					
					var strgCode="",eventDate="";
					var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					for( var k= 0;k < parentDetailElement.length; k++)
					{
						var parentDetail = parentDetailElement[k];
						if( parentDetail.getElementsByTagName("strg_code")[0] != null && parentDetail.getElementsByTagName("strg_code")[0].childNodes[0] != null )
						{
							strgCode = parentDetail.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
							console.log('strgcode is:::',strgCode);
							
						}
						if( parentDetail.getElementsByTagName("event_date")[0] != null && parentDetail.getElementsByTagName("event_date")[0].childNodes[0] != null )
						{
							eventDate = parentDetail.getElementsByTagName("event_date")[0].childNodes[0].nodeValue;
							console.log('eventDate is:::',eventDate);
							
						}
						
						
					}	
					
					const dataModelJSONObj = JSON.parse(dataModelData);
					console.log("dataModelJSONObj:: ",dataModelJSONObj);

					var dataModelJSONArray = dataModelJSONObj.DETAILS
					console.log("dataModelJSONArray (details):: ",dataModelJSONArray);					
					
					var updateIndex = -1;
					
					for(var i = 0; i < dataModelJSONArray.length; i++)
					{
					    const jsonObj = dataModelJSONArray[i];
					    console.log('i::',i);
					    
					    var custCodestrgCode = jsonObj.strg_code != undefined ? jsonObj.strg_code : '';
					    console.log('customerID::',custCodestrgCode);
						
					     if(custCodestrgCode == strgCode)
					    {
					     console.log("Inside if condition to update datamodel");
						 jsonObj.last_meet_date = eventDate;
						 updateIndex = i;
						}
																	
					}	
					if(updateIndex != -1)
					{
						console.log("Inside if condition to add object");
						var updatedObj = dataModelJSONArray[updateIndex];
						console.log("updated object is",updatedObj);	
							
						const index = dataModelJSONArray.indexOf(updatedObj);
										
						dataModelJSONArray.splice(index,1);
						
						dataModelJSONArray.push(updatedObj);
					}
									
				var updatedDataModel = JSON.stringify(dataModelJSONObj);
				console.log("After updateInvoiceDMDataModelFile is dataModelJSONArray["+updatedDataModel+"]");	

				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in customerCodes.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateInvoiceDMDataModelFile error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);	
	}		
	
//Added by Jay.Kesur to update the last_meet_date in data-model [23-Dec-22]-[End]

// added by mrunalini sinkar to updat dta model of invoice,stock and dasboard ::::::::::::End
function updateItemDataModelFileReceive(userId, responseText,offlineDataXML)
{
	var dataModelxmlDoc = "";
	var dispCount = 1;
	
	console.log("Inside updateItemDataModelFile in stock receive js");
	var offlineDatDom = "";
		
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/stocks_transfer_wiz_item.xml';
	onSuccess = function(dataModelData)
	{
		console.log("dataModelData data is not null before change"+ dataModelData);
		var xmlVersion = dataModelData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		console.log("xmlVersion data is not null"+ xmlVersion);
		
		if( dataModelData != null && dataModelData.trim().length > 0 )
		{
			//console.log("cureentform data is not null"+ formDetailData);
			if( xmlVersion != 0 )
			{
				if( dataModelData.indexOf("<Root>") == -1 )
				{
					dataModelData = "<Root>"+dataModelData+"</Root>";
				}
			}
		}
		else
		{
			console.log("null dataModelData");
		}
		
		console.log("offlineDataXML data is not null"+ offlineDataXML);
		
		var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
		console.log("xmlVersion data is not null"+ xmlVersionofflineDataXML);				
		if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
		{
			if( xmlVersionofflineDataXML != 0 )
			{
				if( offlineDataXML.indexOf("<Root>") == -1 )
				{
					offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
				}
			}
		}
		else
		{
			console.log("null parentFormData");
		}
		
		if ( window.DOMParser )
		{
			parser = new DOMParser();
			try
			{
				if( dataModelData != null && dataModelData.trim().length > 0 )
				{
					dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
				}
				if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
				{
					offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
				}
			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}//end window.DOMParser
		if(dataModelxmlDoc!= null)
		{
			
			var locCodeFrom="",locCodTo="",itemCodeOfflineData="",quantity=""; 
			var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
			console.log("parentDetailElement["+parentDetailElement.length+"]");
			for( var k= 0;k < parentDetailElement.length; k++)
			{
				var parentDetail = parentDetailElement[k];
				console.log("parentDetail["+parentDetail+"]");
				if( parentDetail.getElementsByTagName("loc_code__fr")[0] != null && parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
				{
					locCodeFrom = parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					locCodeFrom=locCodeFrom.trim();
					console.log("parentDetailElement locCodeFrom["+locCodeFrom+"]");
				}
				if( parentDetail.getElementsByTagName("loc_code__to")[0] != null && parentDetail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
				{
					locCodTo = parentDetail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
					locCodTo=locCodTo.trim();
					console.log("parentDetailElement locCodeTo["+locCodTo+"]");
				}
				if( parentDetail.getElementsByTagName("item_code")[0] != null && parentDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCodeOfflineData = parentDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
					itemCodeOfflineData=itemCodeOfflineData.trim();
					console.log("parentDetailElement itemCodeOfflineData["+itemCodeOfflineData+"]");
				}
				if( parentDetail.getElementsByTagName("quantity")[0] != null && parentDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
				{
					quantity = parentDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
					console.log("parentDetailElement quantity["+quantity+"]");
				}
			}// for loop first offline data is finish
			
			var detailElement = dataModelxmlDoc.getElementsByTagName( "Detail2");
			console.log("Item Element Length["+detailElement.length+"]");
			var itemDescr="",currStock="",orgStock="",itemCode="",locCodeFr="",lotNoFr="",lotSlFr="";
			var lotNoTo="",lotSlTo="",locCodeTo="",siteCode="",acctCodeCr="",cctrCodeCr="",acctCodeDr="";
			var cctrCodeDr="",qtpPerArt="",loadQty="";
			dataModelData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
			var existingItemList=[];
			for (var i = 0; i < detailElement.length; i++)
			{

				var detail = detailElement[i];
				console.log("detailElement detail["+detail+"]");
				if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
				{
					itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
				{
					currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
				{
					orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("loc_code__fr")[0] != null && detail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
				{
					locCodeFr = detail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					locCodeFr =locCodeFr.trim();
					console.log("detail locCodeFr["+locCodeFr+"]");
				}
				if( detail.getElementsByTagName("lot_no__fr")[0] != null && detail.getElementsByTagName("lot_no__fr")[0].childNodes[0] != null )
				{
					lotNoFr = detail.getElementsByTagName("lot_no__fr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_sl__fr")[0] != null && detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0] != null )
				{
					lotSlFr = detail.getElementsByTagName("lot_sl__fr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_no__to")[0] != null && detail.getElementsByTagName("lot_no__to")[0].childNodes[0] != null )
				{
					lotNoTo = detail.getElementsByTagName("lot_no__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_sl__to")[0] != null && detail.getElementsByTagName("lot_sl__to")[0].childNodes[0] != null )
				{
					lotSlTo = detail.getElementsByTagName("lot_sl__to")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("loc_code__to")[0] != null && detail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
				{
					locCodeTo = detail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
					locCodeTo =locCodeTo.trim();
					console.log("detail locCodeTo["+locCodeTo+"]");
				}
				if( detail.getElementsByTagName("site_code")[0] != null && detail.getElementsByTagName("site_code")[0].childNodes[0] != null )
				{
					siteCode = detail.getElementsByTagName("site_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("acct_code__cr")[0] != null && detail.getElementsByTagName("acct_code__cr")[0].childNodes[0] != null )
				{
					acctCodeCr = detail.getElementsByTagName("acct_code__cr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cctr_code__cr")[0] != null && detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0] != null )
				{
					cctrCodeCr = detail.getElementsByTagName("cctr_code__cr")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("acct_code__dr")[0] != null && detail.getElementsByTagName("acct_code__dr")[0].childNodes[0] != null )
				{
					acctCodeDr = detail.getElementsByTagName("acct_code__dr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cctr_code__dr")[0] != null && detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0] != null )
				{
					cctrCodeDr = detail.getElementsByTagName("cctr_code__dr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("qty_per_art")[0] != null && detail.getElementsByTagName("qty_per_art")[0].childNodes[0] != null )
				{
					qtpPerArt = detail.getElementsByTagName("qty_per_art")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("load_qty")[0] != null && detail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
				{
					loadQty = detail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
				}
					
					if(itemCodeOfflineData == itemCode && locCodTo == locCodeFr)
					{
						console.log("Inside if both listItemCode and item code is same in stock receive");
						currStock=parseInt(currStock)+parseInt(quantity);
						orgStock=parseInt(orgStock)+parseInt(quantity);
					}
					console.log("itemCode["+itemCode+"]currStock["+currStock+"]orgStock["+orgStock+"]");
					
					dataModelData += "<Detail2 domID='" + dispCount + "' selected = 'N' formName='item' >\r\n"+
						"<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n"+
						"<tran_id><![CDATA[]]></tran_id>\r\n"+
						"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
						"<quantity><![CDATA[]]></quantity>\r\n"+
						"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\r\n"+
						"<org_stock><![CDATA["+orgStock+"]]></org_stock>\r\n"+
						"<item_code><![CDATA["+itemCode+"]]></item_code>"+
						"<loc_code__fr><![CDATA["+locCodeFr+"]]></loc_code__fr>"+
						"<lot_no__fr><![CDATA["+lotNoFr+"]]></lot_no__fr>\r\n"+
						"<lot_sl__fr><![CDATA["+lotSlFr+"]]></lot_sl__fr>\r\n"+
						"<lot_no__to><![CDATA["+lotNoTo+"]]></lot_no__to>\r\n"+
						"<lot_sl__to><![CDATA["+lotSlTo+"]]></lot_sl__to>\r\n"+
						"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
						"<loc_code__to><![CDATA[]]></loc_code__to>\r\n"+
						"<site_code><![CDATA["+siteCode+"]]></site_code>"+
						"<acct_code__cr><![CDATA["+acctCodeCr+"]]></acct_code__cr>\r\n"+
						"<cctr_code__cr><![CDATA["+cctrCodeCr+"]]></cctr_code__cr>"+
						"<acct_code__dr><![CDATA["+acctCodeDr+"]]></acct_code__dr>"+
						"<cctr_code__dr><![CDATA["+cctrCodeDr+"]]></cctr_code__dr>"+
						"<qty_per_art><![CDATA["+qtpPerArt+"]]></qty_per_art>"+	
						"<load_qty><![CDATA["+loadQty+"]]></load_qty>"+										
						"</Detail2>";
						dispCount++;
			}//end of for loop of datamodel
			dataModelData += "</Root>";
			
			console.log("dataModelData after changes in stock transfer["+dataModelData+"]");
			//write logic to update data in dataModelData
			backUpAndWriteFile(filePath, dataModelData); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
		}//end dataModelXmlDoc not null
		onFailure = function(error)
		{
			console.log('error in readFile ',error);
		}//end OnFailure
	}//end onSuccess
	readFile(filePath,onSuccess,onFailure);
}
function updateRealInvoiceDataModelReceive(userId, responseText,offlineDataXML)
{
	console.log("Update updateRealInvoiceDataModel From stock receiver");
	var dataModelxmlDoc = "";
	var dispCount = 1;
	
	console.log("Inside updateInvoiceDataModel from  stock receiver");
	var offlineDatDom = "";
		
		var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/strg_meet_dcr_realtime_wiz_invoice.xml';


		onSuccess = function(dataModelData)
		{
			console.log("dataModelData data is not null before change"+ dataModelData);
			var xmlVersion = dataModelData.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			console.log("xmlVersion data is not null"+ xmlVersion);
			
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				//console.log("cureentform data is not null"+ formDetailData);
				if( xmlVersion != 0 )
				{
					if( dataModelData.indexOf("<Root>") == -1 )
					{
						dataModelData = "<Root>"+dataModelData+"</Root>";
					}
				}
			}
			else
			{
				console.log("null dataModelData");
			}
			
			console.log("offlineDataXML data is not null"+ offlineDataXML);
			
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			console.log("xmlVersion data is not null"+ xmlVersionofflineDataXML);				
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}

	if ( window.DOMParser )
	{
		parser = new DOMParser();
		try
		{
			if( dataModelData != null && dataModelData.trim().length > 0 )
			{
				dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
			}
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
			}
		}
		catch(ex)
		{
			alert("Exception occurs while parsing xml data");
		}
	}
			
				
		if(dataModelxmlDoc!= null)
		{
			var invoiceFormNo="",locCodeFrom="",locCodeTo="",itemCodeOfflineData="",quantity="";
			var parentDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
			console.log("parentDetailElement["+parentDetailElement.length+"]");
			for( var k= 0;k < parentDetailElement.length; k++)
			{
				var parentDetail = parentDetailElement[k];
				if( parentDetail.getElementsByTagName("invoice_form_no")[0] != null && parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
				{
					invoiceFormNo = parentDetail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
				}
				if( parentDetail.getElementsByTagName("loc_code__fr")[0] != null && parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
				{
					locCodeFrom = parentDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
					locCodeFrom=locCodeFrom.trim();
				}
				if( parentDetail.getElementsByTagName("loc_code__to")[0] != null && parentDetail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
				{
					locCodeTo = parentDetail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
					locCodeTo=locCodeTo.trim();
				}
				if( parentDetail.getElementsByTagName("item_code")[0] != null && parentDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCodeOfflineData = parentDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
					itemCodeOfflineData=itemCodeOfflineData.trim();
				}
				if( parentDetail.getElementsByTagName("quantity")[0] != null && parentDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
				{
					quantity = parentDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
				}
				
			}// for loop first offline data is finish
			console.log("invoiceFormNo in stock receive as::["+invoiceFormNo+"]");

			var detailElement = dataModelxmlDoc.getElementsByTagName( "Detail"+invoiceFormNo );
			console.log("Invoice Element Length["+detailElement.length+"]");
			var priceList="",rate="",itemDescr="",lotNo="",discPerc="",currStock="",orgStock="",itemCode="",taxAmntInvoice="",hsnNumber="",pkgSize="";
			var childItem="",itmChildDescr="",childProceList="",itemCHildRate="",childHSNNumber="",childPkgSize="",subItmCHild="";
			var subChildDescr="",subPriceList="",subChildRate="",subHsnNumber="",subPkgSize="",loadQTY="",cashInvoiceAmount="",maximumInvoice="",salesPers="";
			dataModelData = "<Root><Header><editFlag>A</editFlag></Header><Errors></Errors>";
			var existingItemList=[];
			for (var i = 0; i < detailElement.length; i++)
			{
				var detail = detailElement[i];
				if( detail.getElementsByTagName("price_list")[0] != null && detail.getElementsByTagName("price_list")[0].childNodes[0] != null )
				{
					priceList = detail.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
					priceList=priceList.trim();
				}
				if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
				{
					itemDescr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
				{
					rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("disc_perc")[0] != null && detail.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
				{
					discPerc = detail.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("lot_no")[0] != null && detail.getElementsByTagName("lot_no")[0].childNodes[0] != null )
				{
					lotNo = detail.getElementsByTagName("lot_no")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("curr_stock")[0] != null && detail.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
				{
					currStock = detail.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("org_stock")[0] != null && detail.getElementsByTagName("org_stock")[0].childNodes[0] != null )
				{
					orgStock = detail.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
					itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
				{
					taxAmntInvoice = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("hsn_number")[0] != null && detail.getElementsByTagName("hsn_number")[0].childNodes[0] != null )
				{
					hsnNumber = detail.getElementsByTagName("hsn_number")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("pkg_size")[0] != null && detail.getElementsByTagName("pkg_size")[0].childNodes[0] != null )
				{
					pkgSize = detail.getElementsByTagName("pkg_size")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child")[0] != null && detail.getElementsByTagName("itm_child")[0].childNodes[0] != null )
				{
					childItem = detail.getElementsByTagName("itm_child")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child_descr")[0] != null && detail.getElementsByTagName("itm_child_descr")[0].childNodes[0] != null )
				{
					itmChildDescr = detail.getElementsByTagName("itm_child_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_price_list")[0] != null && detail.getElementsByTagName("child_price_list")[0].childNodes[0] != null )
				{
					childProceList = detail.getElementsByTagName("child_price_list")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("itm_child_rate")[0] != null && detail.getElementsByTagName("itm_child_rate")[0].childNodes[0] != null )
				{
					itemCHildRate = detail.getElementsByTagName("itm_child_rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_hsn_number")[0] != null && detail.getElementsByTagName("child_hsn_number")[0].childNodes[0] != null )
				{
					childHSNNumber = detail.getElementsByTagName("child_hsn_number")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("child_pack_size")[0] != null && detail.getElementsByTagName("child_pack_size")[0].childNodes[0] != null )
				{
					childPkgSize = detail.getElementsByTagName("child_pack_size")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("sub_itm_child")[0] != null && detail.getElementsByTagName("sub_itm_child")[0].childNodes[0] != null )
				{
					subItmCHild = detail.getElementsByTagName("sub_itm_child")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_child_descr")[0] != null && detail.getElementsByTagName("sub_child_descr")[0].childNodes[0] != null )
				{
					subChildDescr = detail.getElementsByTagName("sub_child_descr")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_price_list")[0] != null && detail.getElementsByTagName("sub_price_list")[0].childNodes[0] != null )
				{
					subPriceList = detail.getElementsByTagName("sub_price_list")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_child_rate")[0] != null && detail.getElementsByTagName("sub_child_rate")[0].childNodes[0] != null )
				{
					subChildRate = detail.getElementsByTagName("sub_child_rate")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sub_hsn_number")[0] != null && detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0] != null )
				{
					subHsnNumber = detail.getElementsByTagName("sub_hsn_number")[0].childNodes[0].nodeValue;
				}				
				if( detail.getElementsByTagName("sub_pack_size")[0] != null && detail.getElementsByTagName("sub_pack_size")[0].childNodes[0] != null )
				{
					subPkgSize = detail.getElementsByTagName("sub_pack_size")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("load_qty")[0] != null && detail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
				{
					loadQTY = detail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("cash_invoice_amount")[0] != null && detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
				{
					cashInvoiceAmount = detail.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("max_invoice_id")[0] != null && detail.getElementsByTagName("max_invoice_id")[0].childNodes[0] != null )
				{
					maximumInvoice = detail.getElementsByTagName("max_invoice_id")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("sales_pers")[0] != null && detail.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
				{
					salesPers = detail.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
				}
					
					if(itemCodeOfflineData == itemCode)
					{
						console.log("Inside if both listItemCode and item code is same");
						currStock=parseInt(currStock)+parseInt(quantity);
						orgStock=parseInt(orgStock)+parseInt(quantity);
					}
					console.log("itemCode["+itemCode+"]currStock["+currStock+"]orgStock["+orgStock+"]");
					
					dataModelData += "<Detail"+invoiceFormNo+" domID='" + dispCount + "' selected = 'N'>\r\n"+ 
					"<strg_code><![CDATA[]]></strg_code>\n"+
					"<tran_id><![CDATA[]]></tran_id>\r\n"+
					"<item_descr><![CDATA["+itemDescr+"]]></item_descr>\r\n"+
					"<quantity><![CDATA[]]></quantity>\r\n"+
					"<rate><![CDATA["+rate+"]]></rate>\r\n"+
					"<disc_perc><![CDATA["+discPerc+"]]></disc_perc>\r\n"+
					"<lot_no><![CDATA["+lotNo+"]]></lot_no>\r\n"+
					"<curr_stock><![CDATA["+currStock+"]]></curr_stock>\r\n"+
					"<org_stock><![CDATA["+orgStock+"]]></org_stock>\r\n"+
					"<value><![CDATA[]]></value>\r\n"+
					"<total_amount><![CDATA[]]></total_amount>\r\n"+
					"<line_no><![CDATA["+dispCount+"]]></line_no>\r\n"+
					"<dcr_id><![CDATA[]]></dcr_id>\r\n"+ 
					"<item_code><![CDATA["+itemCode+"]]></item_code>"+
					"<sales_pers><![CDATA["+salesPers+"]]></sales_pers>"+
					"<tax_amt_inv><![CDATA["+taxAmntInvoice+"]]></tax_amt_inv>\r\n"+
					"<net_amt><![CDATA[]]></net_amt>\r\n"+
					"<basic_value><![CDATA[]]></basic_value>\r\n"+
					"<total_gst><![CDATA[]]></total_gst>\r\n"+
					"<total_amount><![CDATA[]]></total_amount>\r\n"+
					"<remarks_inv><![CDATA[]]></remarks_inv>\r\n"+
					"<price_list><![CDATA["+priceList+"]]></price_list>"+
					"<hsn_number><![CDATA["+hsnNumber+"]]></hsn_number>\r\n"+
					"<pkg_size><![CDATA["+pkgSize+"]]></pkg_size>"+
					"<itm_child><![CDATA["+childItem+"]]></itm_child>"+
					"<itm_child_descr><![CDATA["+itmChildDescr+"]]></itm_child_descr>"+
					"<itm_child_rate><![CDATA["+itemCHildRate+"]]></itm_child_rate>"+
					"<child_hsn_number><![CDATA["+childHSNNumber+"]]></child_hsn_number>"+
					"<child_pack_size><![CDATA["+childPkgSize+"]]></child_pack_size>"+
					"<child_price_list><![CDATA["+childProceList+"]]></child_price_list>"+
					"<sub_itm_child><![CDATA["+subItmCHild+"]]></sub_itm_child>"+					
					"<sub_child_descr><![CDATA["+subChildDescr+"]]></sub_child_descr>"+					
					"<sub_hsn_number><![CDATA["+subHsnNumber+"]]></sub_hsn_number>"+
					"<sub_child_rate><![CDATA["+subChildRate+"]]></sub_child_rate>"+					
					"<sub_price_list><![CDATA["+subPriceList+"]]></sub_price_list>"+					
					"<sub_pack_size><![CDATA["+subPkgSize+"]]></sub_pack_size>"+
					"<is_broken><![CDATA[N]]></is_broken>"+
					"<load_qty><![CDATA["+loadQTY+"]]></load_qty>"+	
					"<max_invoice_id><![CDATA["+maximumInvoice+"]]></max_invoice_id>"+				
					"<cash_invoice_amount><![CDATA["+cashInvoiceAmount+"]]></cash_invoice_amount>"+												
					"</Detail"+invoiceFormNo+">";
					dispCount++;
		}// for loop data model invoice offline data is finish
		
		dataModelData += "</Root>";
		
		console.log("dataModelData after changes for invoice from stock["+dataModelData+"]");
		
		//write logic to update data in dataModelData
		backUpAndWriteFile(filePath, dataModelData); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
		}
		
		onFailure = function(error)
		{
		console.log('error in readFile ',error);
		}
	}
		readFile(filePath,onSuccess,onFailure);
}
function updateVenStockDataModelReceive(userId, responseText,offlineDataXML)
{
	console.log("Inside updateVenStockDataModel in stock receive");
	var offlineDatDom = "";
	var filePath = 'file:///data/user/0/ibase.android.Proteus/base/scopeData/'+userId+'/VAN_STOCK.json';


		onSuccess = function(dataModelData)
		{
			console.log("offlineDataXML data is not null in update ven Stock"+ offlineDataXML);
			var xmlVersionofflineDataXML = offlineDataXML.indexOf("<?xml version='1.0' encoding='UTF-8'?>");
			if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
			{
				if( xmlVersionofflineDataXML != 0 )
				{
					if( offlineDataXML.indexOf("<Root>") == -1 )
					{
						offlineDataXML = "<Root>"+offlineDataXML+"</Root>";
					}
				}
			}
			else
			{
				console.log("null parentFormData");
			}
					if ( window.DOMParser )
					{
						parser = new DOMParser();
						try
						{
							if( dataModelData != null && dataModelData.trim().length > 0 )
							{
								dataModelxmlDoc = parser.parseFromString( dataModelData, "text/xml" );
							}
							if( offlineDataXML != null && offlineDataXML.trim().length > 0 )
							{
								offlineDatDom = parser.parseFromString( offlineDataXML, "text/xml" );
							}
						}
						catch(ex)
						{
							alert("Exception occurs while parsing xml data");
						}
					}
					
				if(dataModelxmlDoc!= null)
				{
					var dataModelJSONArray = JSON.parse(dataModelData);
					console.log("offlineDatDom data is not null in update ven Stock"+ offlineDatDom);
					var ItemDetailElement = offlineDatDom.getElementsByTagName( "Detail1" );
					console.log("ItemDetailElement ItemDetailElement.length["+ItemDetailElement.length+"]");
					//var itemWithStock=[];
					var itemCodeOfflineData="",quantity="",itemDescr="",loadQTY="";
					for (var v = 0; v < ItemDetailElement.length; v++)
					{
						var dataModelExistFlag=false;
						var itemDetail = ItemDetailElement[v];
						console.log("ItemDetailElement itemDetail["+itemDetail+"]");
		        		var domIDVal = itemDetail.getAttribute("domID");
						console.log("ItemDetailElement itemDetail domIDVal venStock["+domIDVal+"]");
		        		if(domIDVal != null && domIDVal.trim().length > 0 )
		        		{
							if( itemDetail.getElementsByTagName("loc_code__fr")[0] != null && itemDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0] != null )
							{
								locCodeFrom = itemDetail.getElementsByTagName("loc_code__fr")[0].childNodes[0].nodeValue;
								locCodeFrom=locCodeFrom.trim();
								console.log("ItemDetailElement locCodeFrom["+locCodeFrom+"]");
							}
							if( itemDetail.getElementsByTagName("loc_code__to")[0] != null && itemDetail.getElementsByTagName("loc_code__to")[0].childNodes[0] != null )
							{
								locCodeTo = itemDetail.getElementsByTagName("loc_code__to")[0].childNodes[0].nodeValue;
								locCodeTo=locCodeTo.trim();
								console.log("ItemDetailElement locCodeTo["+locCodeTo+"]");
							}
							if( itemDetail.getElementsByTagName("item_code")[0] != null && itemDetail.getElementsByTagName("item_code")[0].childNodes[0] != null )
							{
								itemCodeOfflineData = itemDetail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
								itemCodeOfflineData=itemCodeOfflineData.trim();
								console.log("ItemDetailElement itemCodeOfflineData["+itemCodeOfflineData+"]");
							}
							if( itemDetail.getElementsByTagName("quantity")[0] != null && itemDetail.getElementsByTagName("quantity")[0].childNodes[0] != null )
							{
								quantity = itemDetail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
								console.log("ItemDetailElement quantity["+quantity+"]");
							}
							if( itemDetail.getElementsByTagName("item_descr")[0] != null && itemDetail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
							{
								itemDescr = itemDetail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
								console.log("ItemDetailElement itemDescr["+itemDescr+"]");
							}
							if( itemDetail.getElementsByTagName("load_qty")[0] != null && itemDetail.getElementsByTagName("load_qty")[0].childNodes[0] != null )
							{
								loadQTY = itemDetail.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
								console.log("ItemDetailElement loadQTY["+loadQTY+"]");
							}
	
							if(quantity==null ||  quantity.trim().length==0)
							{
								quantity="0";
							}
	
								console.log("updateVenStockDataModel when finish stock receive dataModelJSONArray::["+JSON.stringify(dataModelJSONArray)+"]");
									if(dataModelJSONArray!=null && dataModelJSONArray!="")
										{
											console.log("dataModelJSONArray is not null in ven stock");
											for(var i = 0; i < dataModelJSONArray.length; i++)
											{
												  
												const jsonObj = dataModelJSONArray[i];
												
												var itemCode = jsonObj.ITEM_CODE != undefined ? jsonObj.ITEM_CODE.trim() : '';
												console.log("dataModelJSONArray is not null in ven stock having itemCode::"+itemCode);
												if(itemCodeOfflineData == itemCode)
													{
													var loadQTY=jsonObj.LOAD_QUANTITY;
													var saleValue=jsonObj.SALE;
													var transferIn=jsonObj.TRANSFER_IN;
													var transferOut=jsonObj.TRANSFER_OUT;
													var breakAddQtyValue=jsonObj.BREAK_ADD_QTY;
													var breakDeductQty=jsonObj.BREAK_DEDUCT_QTY;
													var stockValue=jsonObj.STOCK;
													console.log("dataModelJSONArray is not null in ven stock having transferIn::"+transferIn);
													if(loadQTY!=null && loadQTY!= "" )
													{
														loadQTY=loadQTY;
													}
													else
													{
														loadQTY="0";
													}
	
													if(saleValue!=null && saleValue!= "" )
													{
														saleValue=saleValue;
													}
													else
													{
														saleValue="0";
													}
	
													if(transferIn!=null && transferIn!= "" )
													{
														transferIn=transferIn;
													}
													else
													{
														transferIn="0";
													}
	
													if(transferOut!=null && transferOut!= "" )
													{
														transferOut=transferOut;
													}
													else
													{
														transferOut="0";
													}
	
													if(breakAddQtyValue!=null && breakAddQtyValue!= "")
													{
														breakAddQtyValue=breakAddQtyValue;
													}
													else
													{
														breakAddQtyValue="0";
													}
	
													if(breakDeductQty!=null && breakDeductQty!= "" )
													{
														breakDeductQty=breakDeductQty;
													}
													else
													{
														breakDeductQty="0";
													}
													
													if(stockValue!=null && stockValue!= "" )
													{
														stockValue=stockValue;
													}
													stockValue=parseInt(stockValue)+parseInt(quantity);
													console.log("dataModelJSONArray is not null in ven stock having stockValue::"+stockValue);
													transferIn=parseInt(transferIn)+parseInt(quantity);	
													console.log("dataModelJSONArray is not null in ven stock having transferIn after::"+transferIn);
													console.log("itemCodeOfflineData is not null in ven stock having  after::"+itemCodeOfflineData);					    
	
														console.log("itemCodeOfflineData is equal to item code ::"+itemCodeOfflineData);	
														jsonObj.SALE = saleValue;
														jsonObj.TRANSFER_IN = transferIn;
														jsonObj.ITEM_DESCR = itemDescr;
														jsonObj.TRANSFER_OUT = transferOut;
														jsonObj.BREAK_ADD_QTY = breakAddQtyValue;
													    jsonObj.BREAK_DEDUCT_QTY = breakDeductQty;
														jsonObj.ITEM_CODE = itemCodeOfflineData;
														jsonObj.LOAD_QUANTITY = loadQTY;
														jsonObj.STOCK = stockValue;
														
														dataModelExistFlag=true;
													}
												console.log("itemCodeOfflineData is not null in ven stock having  outside if::"+itemCode);
											}
										}
											
				        			}
							}// for loop Ven stock offline data is finish
				var updatedDataModel = JSON.stringify(dataModelJSONArray);
				console.log("After updateVenStockDataModel if dataModelJSONArray from stock["+updatedDataModel+"]");
				backUpAndWriteFile(filePath, updatedDataModel); //This function will backup the data by creating a folder 'backup' inside userdId folder and then write the updated data in PROMO_CODE.json
			}
		}
		
		onFailure = function(error)
		{
		console.log('updateVenStockDataModel error in readFile ',error);
		}
	
		readFile(filePath,onSuccess,onFailure);
}
//Added by Bhagyashri t for Update datamodel n finish for item form[End]

//Added by prachi for invoiceIdGeneration and split on finish
function OnFinishValData(hdrFormXml, currentFormData, objContext, action, objName, objFormName, allFormDetailXml, returnVal)
{
	console.log("inside onFinishValData");
	console.log("allFormDetailXml::::::: "+allFormDetailXml);
	console.log("returnVal::"+returnVal);
	var newResponseData="";
	console.log("globalObjName::"+globalObjName);
	if(globalObjName ==='strg_meet_dcr_realtime_wiz')
	{
		var allFormResponseData = allFormDetailXml;
		if (window.DOMParser)
		{
			parser=new DOMParser();
			try
			{
				if(allFormResponseData != null && allFormResponseData.trim().length > 0)
				{
					xmlDoc = parser.parseFromString(allFormResponseData,"text/xml");
					console.log("xmlDoc =["+xmlDoc+"]");

				}

			}
			catch(ex)
			{
				alert("Exception occurs while parsing xml data");
			}
		}
		else // Internet Explorer
		{
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async=false;
			xmlDoc.loadXML(txt);
		}
		if(xmlDoc != null)
		{
			console.log("inside prachi walfinish changes");
			
			var invoiceFormNo="",collectionFormNo="";
			var detailElement = xmlDoc.getElementsByTagName("Detail1");
			for (var i = 0; i < 1; i++)
			{
				var detail = detailElement[i];
				
				if( detail.getElementsByTagName("invoice_form_no")[0] != null && detail.getElementsByTagName("invoice_form_no")[0].childNodes[0] != null )
				{
					invoiceFormNo = detail.getElementsByTagName("invoice_form_no")[0].childNodes[0].nodeValue;
				}
				if( detail.getElementsByTagName("collection_form_no")[0] != null && detail.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
				{
					collectionFormNo = detail.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
				}
			}	
            console.log("invoiceFormNo::"+invoiceFormNo+" collectionFormNo::"+collectionFormNo);
			var invoiceItem="",splitxml="",allFormResponseData1="";
			var detailElementIn = xmlDoc.getElementsByTagName("Detail"+invoiceFormNo);
			for (var i = 0; i < 1; i++)
			{
				var detailIv = detailElementIn[i];
				var invoiceNoref="",maxInvoiceNo="",cashInvoiceAmnt="";
				if( detailIv.getElementsByTagName("subform_invoice_no")[0] != null && detailIv.getElementsByTagName("subform_invoice_no")[0].childNodes[0] != null )
				{
					invoiceNoref = detailIv.getElementsByTagName("subform_invoice_no")[0].childNodes[0].nodeValue;
				}
				if( detailIv.getElementsByTagName("max_invoice_id")[0] != null && detailIv.getElementsByTagName("max_invoice_id")[0].childNodes[0] != null )
				{
					maxInvoiceNo = detailIv.getElementsByTagName("max_invoice_id")[0].childNodes[0].nodeValue;
				}
				if( detailIv.getElementsByTagName("cash_invoice_amount")[0] != null && detailIv.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
				{
					cashInvoiceAmnt = detailIv.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
				}
				if(invoiceNoref != 'undefined' && invoiceNoref != null)
				{
					if(invoiceNoref.indexOf("/")!=-1)
					{
						routeRefNo=invoiceNoref.split("/")[0];
					}
				}
				console.log("here allformDetailDataIs::: "+allFormResponseData);
				try
				{
					allFormResponseData1 = parser.parseFromString(allFormResponseData, "text/xml");
				}
				catch (e)
				{
					alert("XML parsing error.");
				}
				invoiceItem=InvoiceIDGenrationWithSplit(allFormResponseData1,invoiceFormNo,invoiceNoref,maxInvoiceNo,cashInvoiceAmnt,collectionFormNo);
				console.log("invoiceItem when generate invoiceId:::::::::::["+invoiceItem+"]");
			}
			
			var detailElementInvoice = xmlDoc.getElementsByTagName("Detail"+invoiceFormNo);
			console.log("length of parent detail:::"+detailElementInvoice.length);
			
			for (var i = 0; i < detailElementInvoice.length; i++)
			{
				console.log("i::"+i);
				var detailIv = detailElementInvoice[i];
				var attributeVal = detailIv.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
				var domIDVal = detailIv.getAttribute("domID");
				var selVal = detailIv.getAttribute("selected");
				
				var selectBx ="",invoiceNoref="",maxInvoiceNo="",cashInvoiceAmnt="";
				var miInvoice="",maxInvoice="",invIdList="",rate="";
				var currentListDomId="";
				var currentListiteCode="";
				var currentListInvID="", domIdItmC="";
				var currentListbasicValue="",currentListgstValue="",currentListtotalValue="";
				var currentListinvoiceValue="",currentListrndOffValue="",currentListamtWordValue="";
				if( detailIv.getElementsByTagName("subform_invoice_no")[0] != null && detailIv.getElementsByTagName("subform_invoice_no")[0].childNodes[0] != null )
				{
					invoiceNoref = detailIv.getElementsByTagName("subform_invoice_no")[0].childNodes[0].nodeValue;
				}
				if( detailIv.getElementsByTagName("max_invoice_id")[0] != null && detailIv.getElementsByTagName("max_invoice_id")[0].childNodes[0] != null )
				{
					maxInvoiceNo = detailIv.getElementsByTagName("max_invoice_id")[0].childNodes[0].nodeValue;
				}
				if( detailIv.getElementsByTagName("cash_invoice_amount")[0] != null && detailIv.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
				{
					cashInvoiceAmnt = detailIv.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
				}
				if( detailIv.getElementsByTagName("selectbox")[0] != null && detailIv.getElementsByTagName("selectbox")[0].childNodes[0] != null )
				{
					selectBx = detailIv.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
				}
		
			    if( detailIv.getElementsByTagName("rate")[0] != null && detailIv.getElementsByTagName("rate")[0].childNodes[0] != null )
			    {
				  rate = detailIv.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
			    }
			    if( detailIv.getElementsByTagName("tax_amt_inv")[0] != null && detailIv.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
				{
					taxAmountIv = detailIv.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
				}
			    if( detailIv.getElementsByTagName("item_code")[0] != null && detailIv.getElementsByTagName("item_code")[0].childNodes[0] != null )
				{
			    	domIdItmC = detailIv.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
				}
				
				console.log("selVal::"+selVal+" selectBx:"+selectBx+" domIDVal::"+domIDVal);
				if(selVal=='Y' && selectBx=='true')
				{
					console.log("Selected condition satisfy::"+domIDVal)
					/*
					if(invoiceNoref != 'undefined' && invoiceNoref != null)
					{
						if(invoiceNoref.indexOf("/")!=-1)
						{
							routeRefNo=invoiceNoref.split("/")[0];
						}
					}
					console.log("here allformDetailDataIs::: "+allFormResponseData);
					try
					{
						allFormResponseData = parser.parseFromString(allFormResponseData, "text/xml");
					}
					catch (e)
					{
						alert("XML parsing error.");
					}
					invoiceItem=InvoiceIDGenration(allFormResponseData, "9",invoiceNoref,maxInvoiceNo,cashInvoiceAmnt);
					console.log("invoiceItem when generate invoiceId:::::::::::["+invoiceItem+"]");
					*/
					var listInvoiceData="",invoicedataList="",allDetailInvList="", domIdListExisting="";
					var selValue = "",item="",selSgstAmt ="",selCgstAmt ="",selValueTotal="";
					if(invoiceItem.indexOf("#")!=-1)
					{
						listInvoiceData=invoiceItem.split("#");
						console.log("listInvoiceData when split primary stage:::::::::::["+listInvoiceData+"]")

						invoicedataList=listInvoiceData[0];
						miInvoice=listInvoiceData[1];
						maxInvoice=listInvoiceData[2];
						invIdList=listInvoiceData[3];
						allDetailInvList=listInvoiceData[4];
						domIdListExisting=listInvoiceData[5];

					}

					console.log("invoicedataList:::::::::::["+invoicedataList+"]");
					console.log("miInvoice:::::::::::["+miInvoice+"]");
					console.log("maxInvoice:::::::::::["+maxInvoice+"]");
					console.log("invIdList for all invoice Id:::::::::::["+invIdList+"]");
					console.log("allDetailInvList:::::::::::["+allDetailInvList+"]");
					console.log("domIdListExisting:::::::::::["+domIdListExisting+"]");
					
					invIdList=invIdList+",";

					var invoiceItemList=[];
					if(invoiceItem.indexOf(",")!=-1)
					{
						invoiceItemList=invoicedataList.split(",");

					}
					else
					{
						invoicedataList=invoicedataList+",";
						invoiceItemList=invoicedataList.split(",");

					}
					console.log("invoiceItemList:::::::::::["+invoiceItemList+"]");

					var allDetailInvData=[];
					if(allDetailInvList.indexOf(",")!=-1)
					{
						allDetailInvData=allDetailInvList.split(",");

					}
					else
					{
						allDetailInvList=allDetailInvList+",";
						allDetailInvData=allDetailInvList.split(",");

					}
					console.log("allDetailInvData:::::::::::["+allDetailInvData+"]");
					
					var allDomInvData=[];
					if(domIdListExisting.indexOf(",")!=-1)
					{
						allDomInvData=domIdListExisting.split(",");

					}
					else
					{
						domIdListExisting=domIdListExisting+",";
						allDomInvData=domIdListExisting.split(",");

					}
					console.log("allDomInvData:::::::::::["+allDomInvData+"]");
					
					
					for(var q=0;q < invoiceItemList.length;q++)
					{

						var itemInList=invoiceItemList[q].split("@");
						console.log("listInvoiceData:::::::::::["+itemInList+"]");
						if(itemInList!=null && itemInList!="" )
						{
							var invoiceDomId=itemInList[0];
							var invoiceItem1=itemInList[1];
							var invoiceID=itemInList[2];
							var newSplitQty=itemInList[3];
							var orignalQty=itemInList[4];
							console.log(" newSplitQty::"+newSplitQty+" orignalQty::"+orignalQty);
							
							var detailsBasicValue="",detailsGstValue="",detaislTotalValue="";
							var detaitsInvoiceValue="",detailsRoundOff="",detailsAmtInWrd="";
						console.log("invoiceItem1::"+invoiceItem1+"domIdItmC"+domIdItmC);	
						if(domIdItmC==invoiceItem1)
						{	
							for(var r=0;r < allDetailInvData.length;r++)
							{
								var detailsIDList=allDetailInvData[r].split("@");
								console.log("detailsIDList:::::::::::["+detailsIDList+"]");
								var detailsInvId="";
								if(detailsIDList!=null && detailsIDList!="" )
								{
									detailsInvId=detailsIDList[0];

								}
								console.log("detailsIDList detailsInvId:::::::::::["+detailsInvId+"]");
								console.log("invoiceID detailsInvId:::::::::::["+invoiceID+"]");
								if(invoiceID == detailsInvId)
								{
									console.log("invoiceID detailsInvId are equal:::::::::::["+detailsIDList+"]");
									detailsBasicValue=detailsIDList[1];
									detailsGstValue=detailsIDList[2];
									detaislTotalValue=detailsIDList[3];
									detaitsInvoiceValue= Number(Math.round(detaislTotalValue));
									detailsRoundOff =(detaitsInvoiceValue-detaislTotalValue);
									detailsRoundOff = Number(Math.round(detailsRoundOff+'e'+2)+'e-'+2);
									detailsAmtInWrd= inWords(detaitsInvoiceValue);
									break;
								}
								console.log("invoiceID detailsInvId after break:::::::::::["+detailsInvId+"]");	
								
							}
							
							var invoiceFormId=invoiceID;
							//var invoiceFormId=routeRefNo+"/"+invoiceID;
							/*
							console.log("invoiceFormId for all:::::::::::["+invoiceFormId+"]");

							var allDetailElement = xmlDoc.getElementsByTagName("Detail9");
							console.log("allDetailElement::"+allDetailElement);
							for (var j = 0; j < allDetailElement.length; j++)
							{

								var allDetail = allDetailElement[j];
								console.log("allDetail::"+allDetail);
								
                                console.log("domIDVal::"+domIDVal);
                                console.log("invoiceDomId::"+invoiceDomId);
                                if(domIDVal==invoiceDomId)
								{
									currentListDomId=invoiceDomId;
									currentListiteCode=invoiceItem;
									currentListInvID=invoiceFormId;
									currentListbasicValue=detailsBasicValue;
									currentListgstValue=detailsGstValue;
									currentListtotalValue=detaislTotalValue;
									currentListinvoiceValue=detaitsInvoiceValue;
									currentListrndOffValue=detailsRoundOff;
									currentListamtWordValue=detailsAmtInWrd;
									break;
								}
								if(invoiceDomId==alldomIDVal && invoiceItem==allItemCode && domIDVal!=invoiceDomId)
								{
									console.log("line 121112");
									break;
								}
							}
							
                           */
						console.log("!allDomInvData.includes(invoiceDomId)::"+(!allDomInvData.includes(invoiceDomId))+" invoiceDomId:"+invoiceDomId+" domIDVal::"+domIDVal);	
						
						

						currentListDomId=invoiceDomId;
						currentListiteCode=invoiceItem1;
						currentListInvID=invoiceFormId;
						currentListbasicValue=detailsBasicValue;
						currentListgstValue=detailsGstValue;
						currentListtotalValue=detaislTotalValue;
						currentListinvoiceValue=detaitsInvoiceValue;
						currentListrndOffValue=detailsRoundOff;
						currentListamtWordValue=detailsAmtInWrd;
						
						
						
						if(domIDVal==invoiceDomId)
						{	
							selValue= (parseFloat(newSplitQty) * parseFloat(rate));
							selValue = Number(Math.round(selValue+'e'+2)+'e-'+2);
							console.log("Basic Amount inside invoice::=["+selValue+"]");
							selSgstAmt=(parseFloat(newSplitQty) * parseFloat(rate) * (taxAmountIv/200));
							selSgstAmt = Number(Math.round(selSgstAmt+'e'+2)+'e-'+2);
							console.log("SGST inside invoice::=["+selSgstAmt+"]");
							selCgstAmt = selSgstAmt;
							console.log("CGST inside invoice::=["+selCgstAmt+"]");
							selValueTotal= (parseFloat(selValue) + parseFloat(selSgstAmt) + parseFloat(selCgstAmt));
							selValueTotal = Number(Math.round(selValueTotal+'e'+2)+'e-'+2);
							
							if( currentListInvID != null )
							{
								detailIv.getElementsByTagName("invoice_id")[0].childNodes[0].nodeValue = currentListInvID;
							}
							if( currentListbasicValue != null )
							{
								detailIv.getElementsByTagName("inv_basic_value")[0].childNodes[0].nodeValue = currentListbasicValue;
							}
							if( currentListgstValue != null )
							{
								detailIv.getElementsByTagName("inv_total_gst")[0].childNodes[0].nodeValue = currentListgstValue;
							}
							if( currentListtotalValue != null )
							{
								detailIv.getElementsByTagName("inv_total_value")[0].childNodes[0].nodeValue = currentListtotalValue;
							}
							if( currentListinvoiceValue != null )
							{
								detailIv.getElementsByTagName("inv_invoice_value")[0].childNodes[0].nodeValue = currentListinvoiceValue;
							}
							if( currentListrndOffValue != null )
							{
								detailIv.getElementsByTagName("inv_rndoff_value")[0].childNodes[0].nodeValue = currentListrndOffValue;
							}
							if( currentListamtWordValue != null )
							{
								detailIv.getElementsByTagName("inv_amtword_value")[0].childNodes[0].nodeValue = currentListamtWordValue;
							}
							
							if( selValue != null )
							{
								detailIv.getElementsByTagName("value")[0].childNodes[0].nodeValue = selValue;
							}
							if( selSgstAmt != null )
							{
								detailIv.getElementsByTagName("total_sgst_amount")[0].childNodes[0].nodeValue = selSgstAmt;
							}
							if( selCgstAmt != null )
							{
								detailIv.getElementsByTagName("total_cgst_amount")[0].childNodes[0].nodeValue = selCgstAmt;
							}
							if( newSplitQty != null )
							{
								detailIv.getElementsByTagName("quantity")[0].childNodes[0].nodeValue = newSplitQty;
							}
							
							
							
							
							var detailElementDoctor = xmlDoc.getElementsByTagName("Detail1");
							for (var k = 0; k < detailElementDoctor.length; k++)
							{
								var detailDocter = detailElementDoctor[k];
								console.log("miInvoice::"+miInvoice+" detailDocter:"+detailDocter);
								if( miInvoice != null )
								{
									console.log("here");
									detailDocter.getElementsByTagName("minimum_invoice")[0].childNodes[0].nodeValue = miInvoice;
								}
								if( maxInvoice != null )
								{
									detailDocter.getElementsByTagName("maximum_invoice")[0].childNodes[0].nodeValue = maxInvoice;
								}
								if( invIdList != null )
								{
									detailDocter.getElementsByTagName("reference_no")[0].childNodes[0].nodeValue = invIdList;
								}
							}	
						}
						else if(!allDomInvData.includes(invoiceDomId))
						{
							console.log("line 12215");
							console.log("inclue value :: "+(!allDomInvData.includes(","+invoiceDomId+",")));
							var detailElementEls = xmlDoc.getElementsByTagName("Detail"+invoiceFormNo);
							for (var p = 0; p < detailElementEls.length; p++)
							{
								var detailIvE = detailElementEls[p];
								var attributeValE = detailIvE.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
								var selcVal = detailIvE.getAttribute("selected");
								
								var itemCd="",isSelect="";
								if( detailIvE.getElementsByTagName("item_code")[0] != null && detailIvE.getElementsByTagName("item_code")[0].childNodes[0] != null )
								{
									itemCd = detailIvE.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
								}
								if( detailIvE.getElementsByTagName("selectbox")[0] != null && detailIvE.getElementsByTagName("selectbox")[0].childNodes[0] != null )
								{
									isSelect = detailIvE.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
								}
								if( detailIvE.getElementsByTagName("selectbox")[0] != null && detailIvE.getElementsByTagName("selectbox")[0].childNodes[0] != null )
								{
									isSelect = detailIvE.getElementsByTagName("selectbox")[0].childNodes[0].nodeValue;
								}
								console.log("invoiceItem1::"+invoiceItem1+" itemCd::"+itemCd+" selcVal::"+selcVal+" isSelect::"+isSelect);
								if(invoiceItem1==itemCd && selcVal=='Y' && isSelect=='true')
								{
									var taxAmtIvN="",strgCodN="",itemDescrN="",orgStockN="",rateN="",slpersN="",pkgSizeN="",cashAmtN="";
									var collecFormN="",custNameN="",priclistN="",brokenN="",loadqtN="",currStockN="";
									
									var remarksInvN="",hsnNumberN="",taxAmtInvN="",discPercN="",basicValueN="",totalGstN="",totalValueN="",descriptionN="";
									var lotNoN="",tranIdN="",selltypeN="",strgCodeDummyN="",isStockinfoN="",netamtN="",productDescrN="",pricelistN="",orderqtyN="",itemAttribDescrN="";
									var productCodeN="",dcridN="",stockbreakN="",breakitemrefN="",brokenQtyN="",itmchildN="";
									var itmChildDescr="",childPriceList="", itmchildrate="",item_parntN="",childhsnnumberN="",subchilddescrN="",subpricelistN="",subchildrateN="",subitmchildN="";
									var childpacksizeN="",subpacksizeN="",subhsnnumberN="",subformInvoicenoN="",maxInvoiceIdN="";
									var custNameN="";
									
									if( detailIvE.getElementsByTagName("strg_code")[0] != null && detailIvE.getElementsByTagName("strg_code")[0].childNodes[0] != null )
									{
										strgCodN = detailIvE.getElementsByTagName("strg_code")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("item_descr")[0] != null && detailIvE.getElementsByTagName("item_descr")[0].childNodes[0] != null )
									{
										itemDescrN = detailIvE.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("org_stock")[0] != null && detailIvE.getElementsByTagName("org_stock")[0].childNodes[0] != null )
									{
										orgStockN = detailIvE.getElementsByTagName("org_stock")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("rate")[0] != null && detailIvE.getElementsByTagName("rate")[0].childNodes[0] != null )
									{
										rateN = detailIvE.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sales_pers")[0] != null && detailIvE.getElementsByTagName("sales_pers")[0].childNodes[0] != null )
									{
										slpersN = detailIvE.getElementsByTagName("sales_pers")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("pkg_size")[0] != null && detailIvE.getElementsByTagName("pkg_size")[0].childNodes[0] != null )
									{
										pkgSizeN = detailIvE.getElementsByTagName("pkg_size")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("cash_invoice_amount")[0] != null && detailIvE.getElementsByTagName("cash_invoice_amount")[0].childNodes[0] != null )
									{
										cashAmtN = detailIvE.getElementsByTagName("cash_invoice_amount")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("collection_form_no")[0] != null && detailIvE.getElementsByTagName("collection_form_no")[0].childNodes[0] != null )
									{
										collecFormN = detailIvE.getElementsByTagName("collection_form_no")[0].childNodes[0].nodeValue;
									}
									
									if( detailIvE.getElementsByTagName("price_list")[0] != null && detailIvE.getElementsByTagName("price_list")[0].childNodes[0] != null )
									{
										priclistN = detailIvE.getElementsByTagName("price_list")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("is_broken")[0] != null && detailIvE.getElementsByTagName("is_broken")[0].childNodes[0] != null )
									{
										brokenN = detailIvE.getElementsByTagName("is_broken")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("load_qty")[0] != null && detailIvE.getElementsByTagName("load_qty")[0].childNodes[0] != null )
									{
										loadqtN = detailIvE.getElementsByTagName("load_qty")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("tax_amt_inv")[0] != null && detailIvE.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
									{
										taxAmtIvN = detailIvE.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("curr_stock")[0] != null && detailIvE.getElementsByTagName("curr_stock")[0].childNodes[0] != null )
									{
										currStockN = detailIvE.getElementsByTagName("curr_stock")[0].childNodes[0].nodeValue;
									}
									
									if( detailIvE.getElementsByTagName("remarks_inv")[0] != null && detailIvE.getElementsByTagName("remarks_inv")[0].childNodes[0] != null )
									{
										remarksInvN = detailIvE.getElementsByTagName("remarks_inv")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("hsn_number")[0] != null && detailIvE.getElementsByTagName("hsn_number")[0].childNodes[0] != null )
									{
										hsnNumberN = detailIvE.getElementsByTagName("hsn_number")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("disc_perc")[0] != null && detailIvE.getElementsByTagName("disc_perc")[0].childNodes[0] != null )
									{
										discPercN = detailIvE.getElementsByTagName("disc_perc")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("basic_value")[0] != null && detailIvE.getElementsByTagName("basic_value")[0].childNodes[0] != null )
									{
										basicValueN = detailIvE.getElementsByTagName("basic_value")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("total_gst")[0] != null && detailIvE.getElementsByTagName("total_gst")[0].childNodes[0] != null )
									{
										totalGstN = detailIvE.getElementsByTagName("total_gst")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("total_value")[0] != null && detailIvE.getElementsByTagName("total_value")[0].childNodes[0] != null )
									{
										totalValueN = detailIvE.getElementsByTagName("total_value")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("description")[0] != null && detailIvE.getElementsByTagName("description")[0].childNodes[0] != null )
									{
										descriptionN = detailIvE.getElementsByTagName("description")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("lot_no")[0] != null && detailIvE.getElementsByTagName("lot_no")[0].childNodes[0] != null )
									{
										lotNoN = detailIvE.getElementsByTagName("lot_no")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("tran_id")[0] != null && detailIvE.getElementsByTagName("tran_id")[0].childNodes[0] != null )
									{
										tranIdN = detailIvE.getElementsByTagName("tran_id")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sell_type")[0] != null && detailIvE.getElementsByTagName("sell_type")[0].childNodes[0] != null )
									{
										selltypeN = detailIvE.getElementsByTagName("sell_type")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("strg_code_dummy")[0] != null && detailIvE.getElementsByTagName("strg_code_dummy")[0].childNodes[0] != null )
									{
										strgCodeDummyN = detailIvE.getElementsByTagName("strg_code_dummy")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("is_stock_info")[0] != null && detailIvE.getElementsByTagName("is_stock_info")[0].childNodes[0] != null )
									{
										isStockinfoN = detailIvE.getElementsByTagName("is_stock_info")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("net_amt")[0] != null && detailIvE.getElementsByTagName("net_amt")[0].childNodes[0] != null )
									{
										netamtN = detailIvE.getElementsByTagName("net_amt")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("product_descr")[0] != null && detailIvE.getElementsByTagName("product_descr")[0].childNodes[0] != null )
									{
										productDescrN = detailIvE.getElementsByTagName("product_descr")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("order_qty")[0] != null && detailIvE.getElementsByTagName("order_qty")[0].childNodes[0] != null )
									{
										orderqtyN = detailIvE.getElementsByTagName("order_qty")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("item_attrib_descr")[0] != null && detailIvE.getElementsByTagName("item_attrib_descr")[0].childNodes[0] != null )
									{
										itemAttribDescrN = detailIvE.getElementsByTagName("item_attrib_descr")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("product_code")[0] != null && detailIvE.getElementsByTagName("product_code")[0].childNodes[0] != null )
									{
										productCodeN = detailIvE.getElementsByTagName("product_code")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("dcr_id")[0] != null && detailIvE.getElementsByTagName("dcr_id")[0].childNodes[0] != null )
									{
										dcridN = detailIvE.getElementsByTagName("dcr_id")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("stock_break")[0] != null && detailIvE.getElementsByTagName("stock_break")[0].childNodes[0] != null )
									{
										stockbreakN = detailIvE.getElementsByTagName("stock_break")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("break_item__ref")[0] != null && detailIvE.getElementsByTagName("break_item__ref")[0].childNodes[0] != null )
									{
										breakitemrefN = detailIvE.getElementsByTagName("break_item__ref")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("broken_qty")[0] != null && detailIvE.getElementsByTagName("broken_qty")[0].childNodes[0] != null )
									{
										brokenQtyN = detailIvE.getElementsByTagName("broken_qty")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("itm_child")[0] != null && detailIvE.getElementsByTagName("itm_child")[0].childNodes[0] != null )
									{
										itmchildN = detailIvE.getElementsByTagName("itm_child")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("itm_child_descr")[0] != null && detailIvE.getElementsByTagName("itm_child_descr")[0].childNodes[0] != null )
									{
										itmChildDescr = detailIvE.getElementsByTagName("itm_child_descr")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("child_price_list")[0] != null && detailIvE.getElementsByTagName("child_price_list")[0].childNodes[0] != null )
									{
										childPriceList = detailIvE.getElementsByTagName("child_price_list")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("itm_child_rate")[0] != null && detailIvE.getElementsByTagName("itm_child_rate")[0].childNodes[0] != null )
									{
										itmchildrate = detailIvE.getElementsByTagName("itm_child_rate")[0].childNodes[0].nodeValue;
									}
									
									if( detailIvE.getElementsByTagName("item_parnt")[0] != null && detailIvE.getElementsByTagName("item_parnt")[0].childNodes[0] != null )
									{
										item_parntN = detailIvE.getElementsByTagName("item_parnt")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("child_hsn_number")[0] != null && detailIvE.getElementsByTagName("child_hsn_number")[0].childNodes[0] != null )
									{
										childhsnnumberN = detailIvE.getElementsByTagName("child_hsn_number")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sub_child_descr")[0] != null && detailIvE.getElementsByTagName("sub_child_descr")[0].childNodes[0] != null )
									{
										subchilddescrN = detailIvE.getElementsByTagName("sub_child_descr")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sub_price_list")[0] != null && detailIvE.getElementsByTagName("sub_price_list")[0].childNodes[0] != null )
									{
										subpricelistN = detailIvE.getElementsByTagName("sub_price_list")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sub_child_rate")[0] != null && detailIvE.getElementsByTagName("sub_child_rate")[0].childNodes[0] != null )
									{
										subchildrateN = detailIvE.getElementsByTagName("sub_child_rate")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sub_itm_child")[0] != null && detailIvE.getElementsByTagName("sub_itm_child")[0].childNodes[0] != null )
									{
										subitmchildN = detailIvE.getElementsByTagName("sub_itm_child")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("child_pack_size")[0] != null && detailIvE.getElementsByTagName("child_pack_size")[0].childNodes[0] != null )
									{
										childpacksizeN = detailIvE.getElementsByTagName("child_pack_size")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sub_pack_size")[0] != null && detailIvE.getElementsByTagName("sub_pack_size")[0].childNodes[0] != null )
									{
										subpacksizeN = detailIvE.getElementsByTagName("sub_pack_size")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("sub_hsn_number")[0] != null && detailIvE.getElementsByTagName("sub_hsn_number")[0].childNodes[0] != null )
									{
										subhsnnumberN = detailIvE.getElementsByTagName("sub_hsn_number")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("subform_invoice_no")[0] != null && detailIvE.getElementsByTagName("subform_invoice_no")[0].childNodes[0] != null )
									{
										subformInvoicenoN = detailIvE.getElementsByTagName("subform_invoice_no")[0].childNodes[0].nodeValue;
									}
									if( detailIvE.getElementsByTagName("cust_name")[0] != null && detailIvE.getElementsByTagName("cust_name")[0].childNodes[0] != null )
									{
										custNameN = detailIvE.getElementsByTagName("cust_name")[0].childNodes[0].nodeValue;
									}
                                     
									selValue= (parseFloat(newSplitQty) * parseFloat(rateN));
									selValue = Number(Math.round(selValue+'e'+2)+'e-'+2);
									console.log("Basic Amount inside invoice::=["+selValue+"]");
									selSgstAmt=(parseFloat(newSplitQty) * parseFloat(rateN) * (taxAmtIvN/200));
									selSgstAmt = Number(Math.round(selSgstAmt+'e'+2)+'e-'+2);
									console.log("SGST inside invoice::=["+selSgstAmt+"]");
									selCgstAmt = selSgstAmt;
									console.log("CGST inside invoice::=["+selCgstAmt+"]");
									selValueTotal= (parseFloat(selValue) + parseFloat(selSgstAmt) + parseFloat(selCgstAmt));
									selValueTotal = Number(Math.round(selValueTotal+'e'+2)+'e-'+2);
									
									
									var idForXml = "Detail"+invoiceFormNo+"_SEP1_"+invoiceDomId+"_SEP1_";
									console.log("strgCodN::"+strgCodN+" itemDescrN::"+itemDescrN+" orgStockN::"+orgStockN+" rateN::"+rateN+" slpersN:"+slpersN+" pkgSizeN::"+pkgSizeN+" cashAmtN::"+cashAmtN+" collecFormN:"+collecFormN+" custNameN:"+custNameN);
									console.log("priclistN::"+priclistN+" brokenN::"+brokenN+" loadqtN::"+loadqtN+" taxAmtIvN::"+taxAmtIvN+" currStockN:"+currStockN+" newSplitQty::"+newSplitQty);

									splitxml += "<Detail"+invoiceFormNo+" domID='"+invoiceDomId+"' dbID='' formName='invoice' selected='Y'  objContext='"+invoiceFormNo+"'>"+
			                         "<attribute IS_CHANGE='Y' selected='N' updateFlag='A' status='N' pkNames=''/>"+
			                         "<checkbox><![CDATA[true]]></checkbox>"+
			                         "<line_no id='"+idForXml+'line_no'+"'><![CDATA["+invoiceDomId+"]]></line_no>"+
					                 "<selectbox id='"+idForXml+'selectbox'+"'><![CDATA[true]]></selectbox>"+
			                          "<quantity id='"+idForXml+'quantity'+"'><![CDATA["+newSplitQty+"]]></quantity>" +
			                         "<value id='"+idForXml+'value'+"'><![CDATA["+selValue+"]]></value>" +
			                         "<curr_stock id='"+idForXml+'curr_stock'+"'><![CDATA["+currStockN+"]]></curr_stock>" +
			                         "<org_stock id='"+idForXml+'org_stock'+"'><![CDATA["+orgStockN+"]]></org_stock>" +
			                         "<item_code id='"+idForXml+'item_code'+"'><![CDATA["+invoiceItem1+"]]></item_code>" +
			                         "<rate id='"+idForXml+'rate'+"'><![CDATA["+rateN+"]]></rate>" +
			                         "<tax_amt_inv id='"+idForXml+'tax_amt_inv'+"'><![CDATA["+taxAmtIvN+"]]></tax_amt_inv>" +
			                         "<strg_code id='"+idForXml+'strg_code'+"'><![CDATA["+strgCodN+"]]></strg_code>" +
			                         "<sales_pers id='"+idForXml+'sales_pers'+"'><![CDATA["+slpersN+"]]></sales_pers>" +
			                         "<price_list id='"+idForXml+'price_list'+"'><![CDATA["+priclistN+"]]></price_list>" +
			                         "<load_qty id='"+idForXml+'load_qty'+"'><![CDATA["+loadqtN+"]]></load_qty>" +
			                         "<collection_form_no id='"+idForXml+'collection_form_no'+"'><![CDATA["+collecFormN+"]]></collection_form_no>" +
			                         "<is_broken id='"+idForXml+'is_broken'+"'><![CDATA["+brokenN+"]]></is_broken>" +
			                         "<cash_invoice_amount id='"+idForXml+'cash_invoice_amount'+"'><![CDATA["+cashAmtN+"]]></cash_invoice_amount>" +
			                         "<pkg_size id='"+idForXml+'pkg_size'+"'><![CDATA["+pkgSizeN+"]]></pkg_size>" +
			                         "<item_descr id='"+idForXml+'item_descr'+"'><![CDATA["+itemDescrN+"]]></item_descr>" +
			                         "<remarks_inv id='"+idForXml+'remarks_inv'+"'><![CDATA["+remarksInvN+"]]></remarks_inv>" +
			                         "<hsn_number id='"+idForXml+'hsn_number'+"'><![CDATA["+hsnNumberN+"]]></hsn_number>" +
			                         "<disc_perc id='"+idForXml+'disc_perc'+"'><![CDATA["+discPercN+"]]></disc_perc>" +
			                         "<basic_value id='"+idForXml+'basic_value'+"'><![CDATA["+basicValueN+"]]></basic_value>" +
			                         "<total_gst id='"+idForXml+'total_gst'+"'><![CDATA["+totalGstN+"]]></total_gst>" +
			                         "<total_value id='"+idForXml+'total_value'+"'><![CDATA["+totalValueN+"]]></total_value>" +
			                         "<description id='"+idForXml+'description'+"'><![CDATA["+descriptionN+"]]></description>" +
			                         "<lot_no id='"+idForXml+'lot_no'+"'><![CDATA["+lotNoN+"]]></lot_no>" +
			                         "<tran_id id='"+idForXml+'tran_id'+"'><![CDATA["+tranIdN+"]]></tran_id>" +
			                         "<sell_type id='"+idForXml+'sell_type'+"'><![CDATA["+selltypeN+"]]></sell_type>" +
			                         "<strg_code_dummy id='"+idForXml+'strg_code_dummy'+"'><![CDATA["+strgCodeDummyN+"]]></strg_code_dummy>" +
			                         "<is_stock_info id='"+idForXml+'is_stock_info'+"'><![CDATA["+isStockinfoN+"]]></is_stock_info>" +
			                         "<net_amt id='"+idForXml+'net_amt'+"'><![CDATA["+netamtN+"]]></net_amt>" +
			                         "<product_descr id='"+idForXml+'product_descr'+"'><![CDATA["+productDescrN+"]]></product_descr>" +
			                         "<order_qty id='"+idForXml+'order_qty'+"'><![CDATA["+orderqtyN+"]]></order_qty>"+
					                 "<item_attrib_descr id='"+idForXml+'item_attrib_descr'+"'><![CDATA["+itemAttribDescrN+"]]></item_attrib_descr>"+
			                          "<product_code id='"+idForXml+'product_code'+"'><![CDATA["+productCodeN+"]]></product_code>" +
			                         "<dcr_id id='"+idForXml+'dcr_id'+"'><![CDATA["+dcridN+"]]></dcr_id>" +
			                         "<stock_break id='"+idForXml+'stock_break'+"'><![CDATA["+stockbreakN+"]]></stock_break>" +
			                         "<break_item__ref id='"+idForXml+'break_item__ref'+"'><![CDATA["+breakitemrefN+"]]></break_item__ref>" +
			                         "<broken_qty id='"+idForXml+'broken_qty'+"'><![CDATA["+brokenQtyN+"]]></broken_qty>" +
			                         "<itm_child id='"+idForXml+'itm_child'+"'><![CDATA["+itmchildN+"]]></itm_child>" +
			                         "<itm_child_descr id='"+idForXml+'itm_child_descr'+"'><![CDATA["+itmChildDescr+"]]></itm_child_descr>" +
			                         "<child_price_list id='"+idForXml+'child_price_list'+"'><![CDATA["+childPriceList+"]]></child_price_list>" +
			                         "<itm_child_rate id='"+idForXml+'itm_child_rate'+"'><![CDATA["+itmchildrate+"]]></itm_child_rate>" +
			                         "<item_parnt id='"+idForXml+'item_parnt'+"'><![CDATA["+item_parntN+"]]></item_parnt>" +
			                         "<child_hsn_number id='"+idForXml+'child_hsn_number'+"'><![CDATA["+childhsnnumberN+"]]></child_hsn_number>" +
			                         "<sub_child_descr id='"+idForXml+'sub_child_descr'+"'><![CDATA["+subchilddescrN+"]]></sub_child_descr>" +
			                         "<sub_price_list id='"+idForXml+'sub_price_list'+"'><![CDATA["+subpricelistN+"]]></sub_price_list>" +
			                         "<sub_child_rate id='"+idForXml+'sub_child_rate'+"'><![CDATA["+subchildrateN+"]]></sub_child_rate>" +
                                    "<sub_itm_child id='"+idForXml+'sub_itm_child'+"'><![CDATA["+subitmchildN+"]]></sub_itm_child>" +
			                         "<child_pack_size id='"+idForXml+'child_pack_size'+"'><![CDATA["+childpacksizeN+"]]></child_pack_size>" +
			                         "<sub_pack_size id='"+idForXml+'sub_pack_size'+"'><![CDATA["+subpacksizeN+"]]></sub_pack_size>" +
			                         "<sub_hsn_number id='"+idForXml+'sub_hsn_number'+"'><![CDATA["+subhsnnumberN+"]]></sub_hsn_number>" +
			                         "<subform_invoice_no id='"+idForXml+'subform_invoice_no'+"'><![CDATA["+subformInvoicenoN+"]]></subform_invoice_no>" +
			                         "<max_invoice_id id='"+idForXml+'max_invoice_id'+"'><![CDATA["+maxInvoice+"]]></max_invoice_id>" +
			                         "<cust_name id='"+idForXml+'cust_name'+"'><![CDATA["+custNameN+"]]></cust_name>" +
			                         "<invoice_id id='"+idForXml+'invoice_id'+"'><![CDATA["+currentListInvID+"]]></invoice_id>" +
			                         "<inv_basic_value id='"+idForXml+'inv_basic_value'+"'><![CDATA["+currentListbasicValue+"]]></inv_basic_value>" +
			                         "<inv_total_gst id='"+idForXml+'inv_total_gst'+"'><![CDATA["+currentListgstValue+"]]></inv_total_gst>" +
			                         "<inv_total_value id='"+idForXml+'inv_total_value'+"'><![CDATA["+currentListtotalValue+"]]></inv_total_value>" +
			                         "<inv_invoice_value id='"+idForXml+'inv_invoice_value'+"'><![CDATA["+currentListinvoiceValue+"]]></inv_invoice_value>" +
			                         "<inv_rndoff_value id='"+idForXml+'inv_rndoff_value'+"'><![CDATA["+currentListrndOffValue+"]]></inv_rndoff_value>" +
			                         "<inv_amtword_value id='"+idForXml+'inv_amtword_value'+"'><![CDATA["+currentListamtWordValue+"]]></inv_amtword_value>" +
			                         "<total_amount id='"+idForXml+'total_amount'+"'><![CDATA["+selValueTotal+"]]></total_amount>" +
			                         "<total_sgst_amount id='"+idForXml+'total_sgst_amount'+"'><![CDATA["+selSgstAmt+"]]></total_sgst_amount>" +
			                         "<total_cgst_amount id='"+idForXml+'total_cgst_amount'+"'><![CDATA["+selCgstAmt+"]]></total_cgst_amount>" +
			                         "<ORIG_ATTRIBUTE_NODE id='"+idForXml+'ORIG_ATTRIBUTE_NODE'+"'> <![CDATA[<attribute selected='N' updateFlag='A' status='N' pkNames=''/>]]></ORIG_ATTRIBUTE_NODE>"+
			                        // "<Detail1.1.minimum_invoice id='Detail1_SEP1_1_SEP1_minimum_invoice'><![CDATA["+miInvoice+"]]></Detail1.1.minimum_invoice>" +
			                        //"<Detail1.1.maximum_invoice id='Detail1_SEP1_1_SEP1_maximum_invoice'><![CDATA["+maxInvoice+"]]></Detail1.1.maximum_invoice>" +
			                        //"<Detail1.1.reference_no id='Detail1_SEP1_1_SEP1_reference_no'><![CDATA["+invIdList+"]]></Detail1.1.reference_no>" +
			                         "</Detail"+invoiceFormNo+">" ;
									/*
									splitxml += "<Detail"+invoiceFormNo+" domID='"+invoiceDomId+"' dbID='' formName='invoice' selected='Y'  objContext='"+invoiceFormNo+"'>"+
							                         "<attribute IS_CHANGE='Y' selected='N' updateFlag='A' status='N' pkNames=''/>"+
							                         "<checkbox><![CDATA[true]]></checkbox>"+
							                         "<line_no ><![CDATA["+invoiceDomId+"]]></line_no>"+
									                 "<selectbox><![CDATA[true]]></selectbox>"+
							                          "<quantity><![CDATA["+newSplitQty+"]]></quantity>" +
							                         "<value><![CDATA["+selValue+"]]></value>" +
							                         "<curr_stock><![CDATA["+currStockN+"]]></curr_stock>" +
							                         "<org_stock><![CDATA["+orgStockN+"]]></org_stock>" +
							                         "<item_code><![CDATA["+invoiceItem1+"]]></item_code>" +
							                         "<rate><![CDATA["+rateN+"]]></rate>" +
							                         "<tax_amt_inv><![CDATA["+taxAmtIvN+"]]></tax_amt_inv>" +
							                         "<strg_code><![CDATA["+strgCodN+"]]></strg_code>" +
							                         "<sales_pers><![CDATA["+slpersN+"]]></sales_pers>" +
							                         "<price_list><![CDATA["+priclistN+"]]></price_list>" +
							                         "<load_qty><![CDATA["+loadqtN+"]]></load_qty>" +
							                         "<collection_form_no><![CDATA["+collecFormN+"]]></collection_form_no>" +
							                         "<is_broken><![CDATA["+brokenN+"]]></is_broken>" +
							                         "<cash_invoice_amount><![CDATA["+cashAmtN+"]]></cash_invoice_amount>" +
							                         "<pkg_size><![CDATA["+pkgSizeN+"]]></pkg_size>" +
							                         "<item_descr><![CDATA["+itemDescrN+"]]></item_descr>" +
							                         "<remarks_inv><![CDATA["+remarksInvN+"]]></remarks_inv>" +
							                         "<hsn_number><![CDATA["+hsnNumberN+"]]></hsn_number>" +
							                         "<disc_perc><![CDATA["+discPercN+"]]></disc_perc>" +
							                         "<basic_value><![CDATA["+basicValueN+"]]></basic_value>" +
							                         "<total_gst><![CDATA["+totalGstN+"]]></total_gst>" +
							                         "<total_value><![CDATA["+totalValueN+"]]></total_value>" +
							                         "<description><![CDATA["+descriptionN+"]]></description>" +
							                         "<lot_no><![CDATA["+lotNoN+"]]></lot_no>" +
							                         "<tran_id><![CDATA["+tranIdN+"]]></tran_id>" +
							                         "<sell_type><![CDATA["+selltypeN+"]]></sell_type>" +
							                         "<strg_code_dummy><![CDATA["+strgCodeDummyN+"]]></strg_code_dummy>" +
							                         "<is_stock_info><![CDATA["+isStockinfoN+"]]></is_stock_info>" +
							                         "<net_amt><![CDATA["+netamtN+"]]></net_amt>" +
							                         "<product_descr><![CDATA["+productDescrN+"]]></product_descr>" +
							                         "<order_qty><![CDATA["+orderqtyN+"]]></order_qty>"+
									                 "<item_attrib_descr><![CDATA["+itemAttribDescrN+"]]></item_attrib_descr>"+
							                          "<product_code><![CDATA["+productCodeN+"]]></product_code>" +
							                         "<dcr_id><![CDATA["+dcridN+"]]></dcr_id>" +
							                         "<stock_break><![CDATA["+stockbreakN+"]]></stock_break>" +
							                         "<break_item__ref><![CDATA["+breakitemrefN+"]]></break_item__ref>" +
							                         "<broken_qty><![CDATA["+brokenQtyN+"]]></broken_qty>" +
							                         "<itm_child><![CDATA["+itmchildN+"]]></itm_child>" +
							                         "<itm_child_descr><![CDATA["+itmChildDescr+"]]></itm_child_descr>" +
							                         "<child_price_list><![CDATA["+childPriceList+"]]></child_price_list>" +
							                         "<itm_child_rate><![CDATA["+itmchildrate+"]]></itm_child_rate>" +
							                         "<item_parnt><![CDATA["+item_parntN+"]]></item_parnt>" +
							                         "<child_hsn_number><![CDATA["+childhsnnumberN+"]]></child_hsn_number>" +
							                         "<sub_child_descr><![CDATA["+subchilddescrN+"]]></sub_child_descr>" +
							                         "<sub_price_list><![CDATA["+subpricelistN+"]]></sub_price_list>" +
							                         "<sub_child_rate><![CDATA["+subchildrateN+"]]></sub_child_rate>" +
                                                     "<sub_itm_child><![CDATA["+subitmchildN+"]]></sub_itm_child>" +
							                         "<child_pack_size><![CDATA["+childpacksizeN+"]]></child_pack_size>" +
							                         "<sub_pack_size><![CDATA["+subpacksizeN+"]]></sub_pack_size>" +
							                         "<sub_hsn_number><![CDATA["+subhsnnumberN+"]]></sub_hsn_number>" +
							                         "<subform_invoice_no><![CDATA["+subformInvoicenoN+"]]></subform_invoice_no>" +
							                         "<max_invoice_id><![CDATA["+maxInvoice+"]]></max_invoice_id>" +
							                         "<cust_name><![CDATA["+custNameN+"]]></cust_name>" +
							                         "<invoice_id><![CDATA["+currentListInvID+"]]></invoice_id>" +
							                         "<inv_basic_value><![CDATA["+currentListbasicValue+"]]></inv_basic_value>" +
							                         "<inv_total_gst><![CDATA["+currentListgstValue+"]]></inv_total_gst>" +
							                         "<inv_total_value><![CDATA["+currentListtotalValue+"]]></inv_total_value>" +
							                         "<inv_invoice_value><![CDATA["+currentListinvoiceValue+"]]></inv_invoice_value>" +
							                         "<inv_rndoff_value><![CDATA["+currentListrndOffValue+"]]></inv_rndoff_value>" +
							                         "<inv_amtword_value><![CDATA["+currentListamtWordValue+"]]></inv_amtword_value>" +
							                         "<total_amount><![CDATA["+selValueTotal+"]]></total_amount>" +
							                         "<total_sgst_amount><![CDATA["+selSgstAmt+"]]></total_sgst_amount>" +
							                         "<total_cgst_amount><![CDATA["+selCgstAmt+"]]></total_cgst_amount>" +
							                         "<Detail1.1.minimum_invoice><![CDATA["+miInvoice+"]]></Detail1.1.minimum_invoice>" +
							                         "<Detail1.1.maximum_invoice><![CDATA["+maxInvoice+"]]></Detail1.1.maximum_invoice>" +
							                         "<Detail1.1.reference_no><![CDATA["+invIdList+"]]></Detail1.1.reference_no>" +
							                         "</Detail"+invoiceFormNo+">" ;
								         */
								
								}	
							}
						   }
						}
					}//end of if

					}
					
					
				}//end of selected if
			
			}
			
			xmlDoc.normalize();
			allFormResponseData = new XMLSerializer().serializeToString( xmlDoc );
			var splitArr = allFormResponseData.split('</Root>');
			newResponseData = splitArr[0]+splitxml+"</Root>";
			console.log("new xml string after split is ::: ["+newResponseData+"]");
        
			
		}
	}
	console.log("new xml string after split is return::: ["+newResponseData+"]");
	return newResponseData;
}
//end

//function added by prachi for InvoiceIDGenrationWithSplit on 14-March-2023 ::Start
function InvoiceIDGenrationWithSplit(allFormDetaildataDom, objContext,invoiceNoref,maxInvoiceNo,cashInvoiceAmnt,collectionFormNo)
{
	console.log("InvoiceIDGenration maxInvoiceNo["+maxInvoiceNo+"]invoiceNoref["+invoiceNoref+"]");
	var itemWIthInvoice=[];
	var domIdInvoice=[];
	var domIdInvoiceExt=[];
	var invoiceIDDetails=[];
	 var totalValuesInvoiceIDList =[];
	var amountWithInvoiceList=[];
	var invoiceList=[];
	var minMaxInvIdList=[];
	var InvoiceNum="",payModeC="";
	
	var detailElementCollc = allFormDetaildataDom.getElementsByTagName("Detail"+collectionFormNo);
	for (var i = 0; i < detailElementCollc.length; i++)
	{
	    var detailcol = detailElementCollc[i];
	    if( detailcol.getElementsByTagName("pay_mode")[0] != null && detailcol.getElementsByTagName("pay_mode")[0].childNodes[0] != null )
        {
            payModeC = detailcol.getElementsByTagName("pay_mode")[0].childNodes[0].nodeValue;
        }
	} 
	 console.log("payModeC::"+payModeC);
	var detailElement = allFormDetaildataDom.getElementsByTagName("Detail"+objContext);
	for (var i = 0; i < detailElement.length; i++)
	{
	    var detail = detailElement[i];
	    var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
	    var domIDVal = detail.getAttribute("domID");
	    console.log("interation domID:"+domIDVal);
	    domIdInvoice.push(parseInt(domIDVal));
	    domIdInvoiceExt.push(parseInt(domIDVal));
	 }
		console.log("domIdInvoice:"+domIdInvoice);
		
    for (var i = 0; i < detailElement.length; i++)
    {
    	console.log("inside for loop");
        var quantity = "";
        var rate = "";
        var itemCode="";
        var itemDscr="";
       
        var taxAmount ="";
        
         var totalValue = "0";
         var basicValue = "0";
         var gstValue ="0";
         
         var maxCashAMount="";
         
      if(cashInvoiceAmnt!=null && cashInvoiceAmnt!="")
      {
      	maxCashAMount=cashInvoiceAmnt
      }
      else
      {
      	maxCashAMount=40000;
      }	

       	maxCashAMount=parseFloat(maxCashAMount);
       	
        var detail = detailElement[i];
        var attributeVal = detail.getElementsByTagName("attribute")[0].getAttribute("updateFlag");
        var domIDVal = detail.getAttribute("domID");

        if( detail.getElementsByTagName("quantity")[0] != null && detail.getElementsByTagName("quantity")[0].childNodes[0] != null )
        {
            quantity = detail.getElementsByTagName("quantity")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("rate")[0] != null && detail.getElementsByTagName("rate")[0].childNodes[0] != null )
        {
            rate = detail.getElementsByTagName("rate")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("tax_amt_inv")[0] != null && detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0] != null )
        {
        	taxAmount = detail.getElementsByTagName("tax_amt_inv")[0].childNodes[0].nodeValue;
        }
        if( detail.getElementsByTagName("item_code")[0] != null && detail.getElementsByTagName("item_code")[0].childNodes[0] != null )
        {
            itemCode = detail.getElementsByTagName("item_code")[0].childNodes[0].nodeValue;
        }
       if( detail.getElementsByTagName("item_descr")[0] != null && detail.getElementsByTagName("item_descr")[0].childNodes[0] != null )
        {
            itemDscr = detail.getElementsByTagName("item_descr")[0].childNodes[0].nodeValue;
        }
       console.log("line 19989");
		if(attributeVal != null && attributeVal != 'D')
		{
			var flagFalse=false;
			
			if( quantity != 'undefined' && quantity != null && rate != 'null' && rate != 'undefined' && quantity != "" && rate != "")
			{
				if ( quantity > 0 && rate > 0)
				{
					basicValue = (parseFloat(quantity) * parseFloat(rate));
					basicValue = Number(Math.round(basicValue+'e'+2)+'e-'+2);
					gstValue =  (parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /100)));
					gstValue = Number(Math.round(gstValue+'e'+2)+'e-'+2);
					totalValue = ((parseFloat(quantity) * parseFloat(rate)) + ((parseFloat(quantity) * parseFloat(rate) * (parseFloat(taxAmount /100)))) );
					totalValue = Number(Math.round(totalValue+'e'+2)+'e-'+2);
				}
			}

			if(invoiceList!=null && invoiceList!= "" )	
			{
       		 	var totalAmountInvoiceList=[];
				for(var j=0;j < invoiceList.length;j++)
				{
					var invoiceCOdeFrmList = invoiceList[j];
					var invoiceTotalSumValue=0;
					if(amountWithInvoiceList!=null && amountWithInvoiceList!= "" )	
						{
							for(var k=0;k < amountWithInvoiceList.length;k++)
							{
								var amountCodeFrmList = amountWithInvoiceList[k];
								
								var invoiceOfAmount=amountCodeFrmList.split("@")[0];
								if(invoiceCOdeFrmList == invoiceOfAmount)
								{
									var invoicetotalValue=amountCodeFrmList.split("@")[1];
									
									invoiceTotalSumValue=((parseFloat(invoiceTotalSumValue) + parseFloat(invoicetotalValue)));
								}//if loop invoiceCOdeFrmList
								
							}//for loop k
							
							
						}// if loop amountWithInvoiceList
					totalAmountInvoiceList.push(invoiceCOdeFrmList+"@"+invoiceTotalSumValue);
				}// for loop invoiceList
		
			}// if loop invoiceList

			if(totalAmountInvoiceList!=null && totalAmountInvoiceList!="")
			{
				
				for(var m=0;m < totalAmountInvoiceList.length;m++)
				{
					var InvoiceamountCodeFrmList = totalAmountInvoiceList[m];
					
					var listInvoiceID=InvoiceamountCodeFrmList.split("@")[0];
					var invoiceOfTotalAmount=InvoiceamountCodeFrmList.split("@")[1];
					
					var totalValueSumList=((parseFloat(invoiceOfTotalAmount) + parseFloat(totalValue)));
					if(totalValueSumList <=  maxCashAMount)
					{
						console.log("20305:: "+listInvoiceID);
						var listamount=listInvoiceID+"@"+totalValue;
						amountWithInvoiceList.push(listamount);	
						var checkamtDetails=listInvoiceID+"@"+basicValue+"@"+gstValue+"@"+totalValue;
						var listItem=domIDVal+"@"+itemCode+"@"+listInvoiceID+"@"+quantity+"@"+quantity;
						if(itemWIthInvoice.indexOf(listItem)  ==-1)
			        	{
			        		itemWIthInvoice.push(listItem);
			        		invoiceIDDetails.push(checkamtDetails);
							flagFalse=true;
							break;
			        	}
					}
					
				}
				
			}	
			if( totalValue != 'undefined' && totalValue != null && totalValue != "" && flagFalse==false)
			{
				
				if ( totalValue >= 0)
				{

				if(InvoiceNum!=null && InvoiceNum!= ""  && payModeC=="C")	
				{
					console.log("InvoiceNum if ["+InvoiceNum+"]");
					var lastDigitInv=InvoiceNum.substring(invNumberStart.length, InvoiceNum.length);
							var newDigitInv=parseInt(lastDigitInv)+parseInt("1");
							var invGenrate='' + newDigitInv;
							var newInvGen=invGenrate.length;
							var maxLength=10-newInvGen;
							var resultInv = InvoiceNum.substring(0, maxLength);
							InvoiceNum= resultInv + newDigitInv;
                    console.log("InvoiceNum if end["+InvoiceNum+"]");
				}
				else
				{
					console.log("InvoiceNum else["+InvoiceNum+"] maxInvoiceNo:"+maxInvoiceNo);
						var invNumberStart="";
						if(invoiceNoref.indexOf("/")!=-1)
						{
							invNumberStart=invoiceNoref.split("/")[1];
						}
						 
						else
						{
							invNumberStart=invoiceNoref;
						}
						
						 if(invNumberStart!=null && invNumberStart!="")
						 {
						 	invNumberStart=invNumberStart;
						 }
						 else
						 {
						 	invNumberStart="1101";
						 }
						if(maxInvoiceNo!=null &&  maxInvoiceNo!="" )
						{
							maxInvoiceNo=maxInvoiceNo.substring(invNumberStart.length, maxInvoiceNo.length);
							var invoiceGenrate=parseInt(maxInvoiceNo)+parseInt("1");
							var my_string = '' + invNumberStart;
		    				while (my_string.length < 10) 
		    				{
		        				my_string =  my_string+'0';
		   					}
							var invGenrate='' + invoiceGenrate;
							var newInvGen=invGenrate.length;
							var maxLength=10-newInvGen;
							var result = my_string.substring(0, maxLength);
							InvoiceNum= result + invoiceGenrate;
						}
						else
						{
							
							var my_string = '' + invNumberStart;
		    				while (my_string.length < 10) 
		    				{
		        				my_string =  my_string+'0';
		   					}
							var lastDigit = my_string.toString().slice(-1);
							var newDigit=parseFloat(lastDigit)+1;
							var result = my_string.substring(0, 9);
							InvoiceNum= result + newDigit;
							
						}

				}
					
					console.log("InvoiceNum["+InvoiceNum+"]");
					
					
					

					var totalValueSum = parseFloat(totalValue);

			        if(totalValueSum <=  maxCashAMount)
			        {

						var listItem=domIDVal+"@"+itemCode+"@"+InvoiceNum+"@"+quantity+"@"+quantity;
						var invDetailsID=InvoiceNum+"@"+basicValue+"@"+gstValue+"@"+totalValueSum;
			        	if(itemWIthInvoice.indexOf(listItem)  ==-1)
			        	{
			        		itemWIthInvoice.push(listItem);
			        	}
			        	invoiceIDDetails.push(invDetailsID);
			        	var listamount=InvoiceNum+"@"+totalValue;
			        	amountWithInvoiceList.push(listamount);	
			        	if(invoiceList.indexOf(InvoiceNum)  ==-1)
			        	{
			        		invoiceList.push(InvoiceNum);	
			        	}
			        }
			        if(totalValueSum >  maxCashAMount)
			        {
			        	/*
                        var listItem=domIDVal+"@"+itemCode+"@"+InvoiceNum+"@"+quantity;
						var invDetailsID=InvoiceNum+"@"+basicValue+"@"+gstValue+"@"+totalValueSum;
			        	if(itemWIthInvoice.indexOf(listItem)  ==-1)
			        	{
			        		itemWIthInvoice.push(listItem);
			        	}
			        	invoiceIDDetails.push(invDetailsID);
			        	var listamount=InvoiceNum+"@"+totalValue;
			        	amountWithInvoiceList.push(listamount);	
			        	if(invoiceList.indexOf(InvoiceNum)  ==-1)
			        	{
			        		invoiceList.push(InvoiceNum);	
			        	}
			        	*/
						if(payModeC=="C")
						{
			        	var inc=1;
                        var sumQty=0
                        var totalValSum=totalValueSum;
						var firstSplit=1;	
						console.log("totalValSum::"+totalValSum+" maxCashAMount:"+maxCashAMount);
						while(totalValSum>maxCashAMount)
						{
                            console.log("in while totalValSum:"+totalValSum+" value inc: "+inc);
							var newRemQty=quantity-inc;
							var newRembasicVal = (parseFloat(newRemQty) * parseFloat(rate));
							    newRembasicVal = Number(Math.round(newRembasicVal+'e'+2)+'e-'+2);
							    var newRemGstVal =  (parseFloat(newRemQty) * parseFloat(rate) * (parseFloat(taxAmount /100)));
							    newRemGstVal  = Number(Math.round(newRemGstVal+'e'+2)+'e-'+2);
							    var newRemtotalVal  = ((parseFloat(newRemQty) * parseFloat(rate)) + ((parseFloat(newRemQty) * parseFloat(rate) * (parseFloat(taxAmount /100)))) );
                                 newRemtotalVal = Number(Math.round(newRemtotalVal+'e'+2)+'e-'+2);
                                console.log("newRemtotalVal: "+newRemtotalVal+" newRemQty:"+newRemQty+" rate::"+rate);
							    console.log("newRembasicVal::"+newRembasicVal);
							if(newRemtotalVal<=maxCashAMount && newRemtotalVal>0)
							{
								
								console.log("InvoiceNum::"+InvoiceNum+" firstSplit::"+firstSplit);
								if(firstSplit>1)
								{
								var lastDigitInv=InvoiceNum.substring(invNumberStart.length, InvoiceNum.length);
								var newDigitInv=parseInt(lastDigitInv)+parseInt("1");
								var invGenrate='' + newDigitInv;
								var newInvGen=invGenrate.length;
								var maxLength=10-newInvGen;
								var resultInv = InvoiceNum.substring(0, maxLength);
								InvoiceNum= resultInv + newDigitInv;
								}	
								firstSplit++;
								console.log("InvoiceNum new::"+InvoiceNum);
								
								console.log("totalValSum: "+totalValSum+" newRemtotalVal:"+newRemtotalVal);
	                            var finaltotalRemSum = totalValSum-newRemtotalVal;
	                            totalValSum=Number(Math.round(finaltotalRemSum+'e'+2)+'e-'+2);	
	                            var listItem="";
	                            if(totalValSum==0)
	                            {
	                            	listItem=domIDVal+"@"+itemCode+"@"+InvoiceNum+"@"+newRemQty+"@"+quantity;
	                            }
	                            else
	                            {
	                            	var maxDomId = Math.max(...domIdInvoice)+1;
	                            	console.log("new max domId :"+maxDomId);
									domIdInvoice.push(maxDomId);
	                            	listItem=maxDomId+"@"+itemCode+"@"+InvoiceNum+"@"+newRemQty+"@"+quantity;
	                            }	
	                            console.log("listItem:: "+listItem);
	                            
								//var listItem=domIDVal+"@"+itemCode+"@"+InvoiceNum;
								var invDetailsID=InvoiceNum+"@"+newRembasicVal+"@"+newRemGstVal+"@"+newRemtotalVal;
								console.log("out itemWIthInvoice: "+itemWIthInvoice);
								if(itemWIthInvoice.indexOf(listItem)  ==-1)
								{
								    itemWIthInvoice.push(listItem);
								}
								console.log("in itemWIthInvoice: "+itemWIthInvoice);
								invoiceIDDetails.push(invDetailsID);
								var listamount=InvoiceNum+"@"+newRemtotalVal;
								amountWithInvoiceList.push(listamount);	
								if(invoiceList.indexOf(InvoiceNum)  ==-1)
								{
								  invoiceList.push(InvoiceNum);	
								}
                               
								inc=1;
                                sumQty=sumQty+newRemQty;
                                console.log("finaltotalRemSum: "+finaltotalRemSum+" sumQty:"+sumQty);
                                if(finaltotalRemSum<=maxCashAMount && finaltotalRemSum>0)
                                {
                                  console.log("InvoiceNum in final::"+InvoiceNum);
								  var lastDigitInvo=InvoiceNum.substring(invNumberStart.length, InvoiceNum.length);
								  var newDigitInvo=parseInt(lastDigitInvo)+parseInt("1");
								  var invGenrates='' + newDigitInvo;
								  var newInvGens=invGenrates.length;
								  var maxLength=10-newInvGens;
								  var resultInvo = InvoiceNum.substring(0, maxLength);
								  InvoiceNum= resultInvo + newDigitInvo;
								  console.log("InvoiceNum new::"+InvoiceNum);
                                  
                                  var finalRemQty=quantity-sumQty;
                                  console.log("finalRemQty:"+finalRemQty);
                                  var finalRembasicVal = (parseFloat(finalRemQty) * parseFloat(rate));
							      finalRembasicVal = Number(Math.round(finalRembasicVal+'e'+2)+'e-'+2);
							      var finalRemGstVal =  (parseFloat(finalRemQty) * parseFloat(rate) * (parseFloat(taxAmount /100)));
							      finalRemGstVal  = Number(Math.round(finalRemGstVal+'e'+2)+'e-'+2);
							      var finalRemtotalVal  = ((parseFloat(finalRemQty) * parseFloat(rate)) + ((parseFloat(finalRemQty) * parseFloat(rate) * (parseFloat(taxAmount /100)))) );
                                  finalRemtotalVal = Number(Math.round(finalRemtotalVal+'e'+2)+'e-'+2);
                                  console.log("finalRemtotalVal: "+finalRemtotalVal);
							
											
								var listItemfinal=domIDVal+"@"+itemCode+"@"+InvoiceNum+"@"+finalRemQty+"@"+quantity;
								var invDetailsID=InvoiceNum+"@"+finalRembasicVal+"@"+finalRemGstVal+"@"+finalRemtotalVal;
								console.log("final out itemWIthInvoice: "+itemWIthInvoice);
								if(itemWIthInvoice.indexOf(listItemfinal)  ==-1)
								{
								    itemWIthInvoice.push(listItemfinal);
								}
								console.log("final in itemWIthInvoice: "+itemWIthInvoice);
								invoiceIDDetails.push(invDetailsID);
								var listamount=InvoiceNum+"@"+finalRemtotalVal;
								amountWithInvoiceList.push(listamount);	
								if(invoiceList.indexOf(InvoiceNum)  ==-1)
								{
								  invoiceList.push(InvoiceNum);	
								}
								break;	
                              }
							
							}
							else
							{
								//totalValSum=newRemtotalVal;
								inc++;
							}
						}
					}//if of cash mode	
					else
						{
						var listItem=domIDVal+"@"+itemCode+"@"+InvoiceNum+"@"+quantity+"@"+quantity;
						var invDetailsID=InvoiceNum+"@"+basicValue+"@"+gstValue+"@"+totalValueSum;
			        	if(itemWIthInvoice.indexOf(listItem)  ==-1)
			        	{
			        		itemWIthInvoice.push(listItem);
			        	}
			        	invoiceIDDetails.push(invDetailsID);
			        	var listamount=InvoiceNum+"@"+totalValue;
			        	amountWithInvoiceList.push(listamount);	
			        	if(invoiceList.indexOf(InvoiceNum)  ==-1)
			        	{
			        		invoiceList.push(InvoiceNum);	
			        	}
						}		
						
			        }			        
				}
				
			}
			        
			
		}
    }
    var minValue="",maxValue="";
    console.log("invoiceList for final["+invoiceList+"]");
	if(invoiceList!=null && invoiceList!= "" )	
	{
			for(var j=0;j < invoiceList.length;j++)
			{
				var minMaxInv = invoiceList[j];
				minMaxInv=''+minMaxInv;
				minMaxInvIdList.push(minMaxInv);
			}
		}
		
	if(minMaxInvIdList!=null && minMaxInvIdList!= "" )	
	{
		var min = minMaxInvIdList[0];
			for (var i = 1; i < minMaxInvIdList.length; ++i)
			 {
				if (minMaxInvIdList[i] <min)
				{
					min = minMaxInvIdList[i];
				}
			}

		minValue=min
		var max = minMaxInvIdList[0];
			for (var i = 1; i < minMaxInvIdList.length; ++i) 
			{
				if (minMaxInvIdList[i] >max) 
				{
					max = minMaxInvIdList[i];
				}
			}
			
			maxValue=max;
	}
	console.log("invoiceIDDetails before check values all transaction:::  ["+invoiceIDDetails+"]");
	console.log("invoiceList before check values all transaction  ["+invoiceList+"]");
	if(invoiceList!=null && invoiceList!= "" )	
	{
		
		for(var j=0;j < invoiceList.length;j++)
		{
					var invoiceCOdeFrmList = invoiceList[j];
					console.log("invoiceCOdeFrmList when invoiceIdlist is not null["+invoiceCOdeFrmList+"]");
					var invoiceTotSumValue=0;
					var invoiceBasicSumValue=0;
					var invoiceGstSumValue=0;
			if(invoiceIDDetails!=null && invoiceIDDetails!= "" )	
			{
			    console.log("invoiceIDDetails when invoiceIDDetails is not null["+invoiceIDDetails+"]");
				for(var k=0;k < invoiceIDDetails.length;k++)
				{
					var invoiceIdFrmList = invoiceIDDetails[k];
					console.log("invoiceIdFrmList when invoiceIDDetails in for loop ["+invoiceIdFrmList+"]");
					
					var invoiceIdAmt=invoiceIdFrmList.split("@")[0];
					console.log("invoiceIdAmt when invoice id generate and have invoiceid["+invoiceIdAmt+"]");
					if(invoiceCOdeFrmList == invoiceIdAmt)
					{
						var invoicebasicValue=invoiceIdFrmList.split("@")[1];
						
						invoiceBasicSumValue=((parseFloat(invoiceBasicSumValue) + parseFloat(invoicebasicValue)));
						invoiceBasicSumValue = Number(Math.round(invoiceBasicSumValue+'e'+2)+'e-'+2);
						
						var invoiceGstValue=invoiceIdFrmList.split("@")[2];
						
						invoiceGstSumValue=((parseFloat(invoiceGstSumValue) + parseFloat(invoiceGstValue)));
						invoiceGstSumValue = Number(Math.round(invoiceGstSumValue+'e'+2)+'e-'+2);
						
						var invoicetotValue=invoiceIdFrmList.split("@")[3];
						
						invoiceTotSumValue=((parseFloat(invoiceTotSumValue) + parseFloat(invoicetotValue)));
						invoiceTotSumValue = Number(Math.round(invoiceTotSumValue+'e'+2)+'e-'+2);
					}//if loop invoiceCOdeFrmList
					
				}//for loop k
				
				
			}// if loop amountWithInvoiceList
			totalValuesInvoiceIDList.push(invoiceCOdeFrmList+"@"+invoiceBasicSumValue+"@"+invoiceGstSumValue+"@"+invoiceTotSumValue);
			
		}//outer for loop
	}//invoice list
		
	console.log("invoiceIDDetails after all transaction:::  ["+invoiceIDDetails+"]");
	console.log("totalValuesInvoiceIDList after all transaction:::  ["+totalValuesInvoiceIDList+"]");
	
    var returnValue=itemWIthInvoice+"#"+minValue+"#"+maxValue+"#"+invoiceList+"#"+totalValuesInvoiceIDList+"#"+domIdInvoiceExt;
	console.log("returnValue["+returnValue+"]minValue["+minValue+"]");
    
    return returnValue;
}  // function added by prachi for InvoiceIDGenerationWithSplit on 14-March-23


// Added by Gagan B. for generating QR code [START]
function genQR(input)
	{
    	new QRCode("qrdiv", input);
		document.getElementById("genqrbtn").style.display = "none";
	}
	var QRCode;
	! function() {
		function a(a) {
			this.mode = c.MODE_8BIT_BYTE, this.data = a, this.parsedData = [];
			for (var b = [], d = 0, e = this.data.length; e > d; d++) {
				var f = this.data.charCodeAt(d);
				f > 65536 ? (b[0] = 240 | (1835008 & f) >>> 18, b[1] = 128 | (258048 & f) >>> 12, b[2] = 128 | (4032 & f) >>> 6, b[3] = 128 | 63 & f) : f > 2048 ? (b[0] = 224 | (61440 & f) >>> 12, b[1] = 128 | (4032 & f) >>> 6, b[2] = 128 | 63 & f) : f > 128 ? (b[0] = 192 | (1984 & f) >>> 6, b[1] = 128 | 63 & f) : b[0] = f, this.parsedData = this.parsedData.concat(b)
			}
			this.parsedData.length != this.data.length && (this.parsedData.unshift(191), this.parsedData.unshift(187), this.parsedData.unshift(239))
		}
	
		function b(a, b) {
			this.typeNumber = a, this.errorCorrectLevel = b, this.modules = null, this.moduleCount = 0, this.dataCache = null, this.dataList = []
		}
	
		function i(a, b) {
			if (void 0 == a.length) throw new Error(a.length + "/" + b);
			for (var c = 0; c < a.length && 0 == a[c];) c++;
			this.num = new Array(a.length - c + b);
			for (var d = 0; d < a.length - c; d++) this.num[d] = a[d + c]
		}
	
		function j(a, b) {
			this.totalCount = a, this.dataCount = b
		}
	
		function k() {
			this.buffer = [], this.length = 0
		}
	
		function m() {
			return "undefined" != typeof CanvasRenderingContext2D
		}
	
		function n() {
			var a = !1,
				b = navigator.userAgent;
			return /android/i.test(b) && (a = !0, aMat = b.toString().match(/android ([0-9]\.[0-9])/i), aMat && aMat[1] && (a = parseFloat(aMat[1]))), a
		}
	
		function r(a, b) {
			for (var c = 1, e = s(a), f = 0, g = l.length; g >= f; f++) {
				var h = 0;
				switch (b) {
					case d.L:
						h = l[f][0];
						break;
					case d.M:
						h = l[f][1];
						break;
					case d.Q:
						h = l[f][2];
						break;
					case d.H:
						h = l[f][3]
				}
				if (h >= e) break;
				c++
			}
			if (c > l.length) throw new Error("Too long data");
			return c
		}
	
		function s(a) {
			var b = encodeURI(a).toString().replace(/\%[0-9a-fA-F]{2}/g, "a");
			return b.length + (b.length != a ? 3 : 0)
		}
		a.prototype = {
			getLength: function() {
				return this.parsedData.length
			},
			write: function(a) {
				for (var b = 0, c = this.parsedData.length; c > b; b++) a.put(this.parsedData[b], 8)
			}
		}, b.prototype = {
			addData: function(b) {
				var c = new a(b);
				this.dataList.push(c), this.dataCache = null
			},
			isDark: function(a, b) {
				if (0 > a || this.moduleCount <= a || 0 > b || this.moduleCount <= b) throw new Error(a + "," + b);
				return this.modules[a][b]
			},
			getModuleCount: function() {
				return this.moduleCount
			},
			make: function() {
				this.makeImpl(!1, this.getBestMaskPattern())
			},
			makeImpl: function(a, c) {
				this.moduleCount = 4 * this.typeNumber + 17, this.modules = new Array(this.moduleCount);
				for (var d = 0; d < this.moduleCount; d++) {
					this.modules[d] = new Array(this.moduleCount);
					for (var e = 0; e < this.moduleCount; e++) this.modules[d][e] = null
				}
				this.setupPositionProbePattern(0, 0), this.setupPositionProbePattern(this.moduleCount - 7, 0), this.setupPositionProbePattern(0, this.moduleCount - 7), this.setupPositionAdjustPattern(), this.setupTimingPattern(), this.setupTypeInfo(a, c), this.typeNumber >= 7 && this.setupTypeNumber(a), null == this.dataCache && (this.dataCache = b.createData(this.typeNumber, this.errorCorrectLevel, this.dataList)), this.mapData(this.dataCache, c)
			},
			setupPositionProbePattern: function(a, b) {
				for (var c = -1; 7 >= c; c++)
					if (!(-1 >= a + c || this.moduleCount <= a + c))
						for (var d = -1; 7 >= d; d++) - 1 >= b + d || this.moduleCount <= b + d || (this.modules[a + c][b + d] = c >= 0 && 6 >= c && (0 == d || 6 == d) || d >= 0 && 6 >= d && (0 == c || 6 == c) || c >= 2 && 4 >= c && d >= 2 && 4 >= d ? !0 : !1)
			},
			getBestMaskPattern: function() {
				for (var a = 0, b = 0, c = 0; 8 > c; c++) {
					this.makeImpl(!0, c);
					var d = f.getLostPoint(this);
					(0 == c || a > d) && (a = d, b = c)
				}
				return b
			},
			createMovieClip: function(a, b, c) {
				var d = a.createEmptyMovieClip(b, c),
					e = 1;
				this.make();
				for (var f = 0; f < this.modules.length; f++)
					for (var g = f * e, h = 0; h < this.modules[f].length; h++) {
						var i = h * e,
							j = this.modules[f][h];
						j && (d.beginFill(0, 100), d.moveTo(i, g), d.lineTo(i + e, g), d.lineTo(i + e, g + e), d.lineTo(i, g + e), d.endFill())
					}
				return d
			},
			setupTimingPattern: function() {
				for (var a = 8; a < this.moduleCount - 8; a++) null == this.modules[a][6] && (this.modules[a][6] = 0 == a % 2);
				for (var b = 8; b < this.moduleCount - 8; b++) null == this.modules[6][b] && (this.modules[6][b] = 0 == b % 2)
			},
			setupPositionAdjustPattern: function() {
				for (var a = f.getPatternPosition(this.typeNumber), b = 0; b < a.length; b++)
					for (var c = 0; c < a.length; c++) {
						var d = a[b],
							e = a[c];
						if (null == this.modules[d][e])
							for (var g = -2; 2 >= g; g++)
								for (var h = -2; 2 >= h; h++) this.modules[d + g][e + h] = -2 == g || 2 == g || -2 == h || 2 == h || 0 == g && 0 == h ? !0 : !1
					}
			},
			setupTypeNumber: function(a) {
				for (var b = f.getBCHTypeNumber(this.typeNumber), c = 0; 18 > c; c++) {
					var d = !a && 1 == (1 & b >> c);
					this.modules[Math.floor(c / 3)][c % 3 + this.moduleCount - 8 - 3] = d
				}
				for (var c = 0; 18 > c; c++) {
					var d = !a && 1 == (1 & b >> c);
					this.modules[c % 3 + this.moduleCount - 8 - 3][Math.floor(c / 3)] = d
				}
			},
			setupTypeInfo: function(a, b) {
				for (var c = this.errorCorrectLevel << 3 | b, d = f.getBCHTypeInfo(c), e = 0; 15 > e; e++) {
					var g = !a && 1 == (1 & d >> e);
					6 > e ? this.modules[e][8] = g : 8 > e ? this.modules[e + 1][8] = g : this.modules[this.moduleCount - 15 + e][8] = g
				}
				for (var e = 0; 15 > e; e++) {
					var g = !a && 1 == (1 & d >> e);
					8 > e ? this.modules[8][this.moduleCount - e - 1] = g : 9 > e ? this.modules[8][15 - e - 1 + 1] = g : this.modules[8][15 - e - 1] = g
				}
				this.modules[this.moduleCount - 8][8] = !a
			},
			mapData: function(a, b) {
				for (var c = -1, d = this.moduleCount - 1, e = 7, g = 0, h = this.moduleCount - 1; h > 0; h -= 2)
					for (6 == h && h--;;) {
						for (var i = 0; 2 > i; i++)
							if (null == this.modules[d][h - i]) {
								var j = !1;
								g < a.length && (j = 1 == (1 & a[g] >>> e));
								var k = f.getMask(b, d, h - i);
								k && (j = !j), this.modules[d][h - i] = j, e--, -1 == e && (g++, e = 7)
							} if (d += c, 0 > d || this.moduleCount <= d) {
							d -= c, c = -c;
							break
						}
					}
			}
		}, b.PAD0 = 236, b.PAD1 = 17, b.createData = function(a, c, d) {
			for (var e = j.getRSBlocks(a, c), g = new k, h = 0; h < d.length; h++) {
				var i = d[h];
				g.put(i.mode, 4), g.put(i.getLength(), f.getLengthInBits(i.mode, a)), i.write(g)
			}
			for (var l = 0, h = 0; h < e.length; h++) l += e[h].dataCount;
			if (g.getLengthInBits() > 8 * l) throw new Error("code length overflow. (" + g.getLengthInBits() + ">" + 8 * l + ")");
			for (g.getLengthInBits() + 4 <= 8 * l && g.put(0, 4); 0 != g.getLengthInBits() % 8;) g.putBit(!1);
			for (;;) {
				if (g.getLengthInBits() >= 8 * l) break;
				if (g.put(b.PAD0, 8), g.getLengthInBits() >= 8 * l) break;
				g.put(b.PAD1, 8)
			}
			return b.createBytes(g, e)
		}, b.createBytes = function(a, b) {
			for (var c = 0, d = 0, e = 0, g = new Array(b.length), h = new Array(b.length), j = 0; j < b.length; j++) {
				var k = b[j].dataCount,
					l = b[j].totalCount - k;
				d = Math.max(d, k), e = Math.max(e, l), g[j] = new Array(k);
				for (var m = 0; m < g[j].length; m++) g[j][m] = 255 & a.buffer[m + c];
				c += k;
				var n = f.getErrorCorrectPolynomial(l),
					o = new i(g[j], n.getLength() - 1),
					p = o.mod(n);
				h[j] = new Array(n.getLength() - 1);
				for (var m = 0; m < h[j].length; m++) {
					var q = m + p.getLength() - h[j].length;
					h[j][m] = q >= 0 ? p.get(q) : 0
				}
			}
			for (var r = 0, m = 0; m < b.length; m++) r += b[m].totalCount;
			for (var s = new Array(r), t = 0, m = 0; d > m; m++)
				for (var j = 0; j < b.length; j++) m < g[j].length && (s[t++] = g[j][m]);
			for (var m = 0; e > m; m++)
				for (var j = 0; j < b.length; j++) m < h[j].length && (s[t++] = h[j][m]);
			return s
		};
		for (var c = {
				MODE_NUMBER: 1,
				MODE_ALPHA_NUM: 2,
				MODE_8BIT_BYTE: 4,
				MODE_KANJI: 8
			}, d = {
				L: 1,
				M: 0,
				Q: 3,
				H: 2
			}, e = {
				PATTERN000: 0,
				PATTERN001: 1,
				PATTERN010: 2,
				PATTERN011: 3,
				PATTERN100: 4,
				PATTERN101: 5,
				PATTERN110: 6,
				PATTERN111: 7
			}, f = {
				PATTERN_POSITION_TABLE: [
					[],
					[6, 18],
					[6, 22],
					[6, 26],
					[6, 30],
					[6, 34],
					[6, 22, 38],
					[6, 24, 42],
					[6, 26, 46],
					[6, 28, 50],
					[6, 30, 54],
					[6, 32, 58],
					[6, 34, 62],
					[6, 26, 46, 66],
					[6, 26, 48, 70],
					[6, 26, 50, 74],
					[6, 30, 54, 78],
					[6, 30, 56, 82],
					[6, 30, 58, 86],
					[6, 34, 62, 90],
					[6, 28, 50, 72, 94],
					[6, 26, 50, 74, 98],
					[6, 30, 54, 78, 102],
					[6, 28, 54, 80, 106],
					[6, 32, 58, 84, 110],
					[6, 30, 58, 86, 114],
					[6, 34, 62, 90, 118],
					[6, 26, 50, 74, 98, 122],
					[6, 30, 54, 78, 102, 126],
					[6, 26, 52, 78, 104, 130],
					[6, 30, 56, 82, 108, 134],
					[6, 34, 60, 86, 112, 138],
					[6, 30, 58, 86, 114, 142],
					[6, 34, 62, 90, 118, 146],
					[6, 30, 54, 78, 102, 126, 150],
					[6, 24, 50, 76, 102, 128, 154],
					[6, 28, 54, 80, 106, 132, 158],
					[6, 32, 58, 84, 110, 136, 162],
					[6, 26, 54, 82, 110, 138, 166],
					[6, 30, 58, 86, 114, 142, 170]
				],
				G15: 1335,
				G18: 7973,
				G15_MASK: 21522,
				getBCHTypeInfo: function(a) {
					for (var b = a << 10; f.getBCHDigit(b) - f.getBCHDigit(f.G15) >= 0;) b ^= f.G15 << f.getBCHDigit(b) - f.getBCHDigit(f.G15);
					return (a << 10 | b) ^ f.G15_MASK
				},
				getBCHTypeNumber: function(a) {
					for (var b = a << 12; f.getBCHDigit(b) - f.getBCHDigit(f.G18) >= 0;) b ^= f.G18 << f.getBCHDigit(b) - f.getBCHDigit(f.G18);
					return a << 12 | b
				},
				getBCHDigit: function(a) {
					for (var b = 0; 0 != a;) b++, a >>>= 1;
					return b
				},
				getPatternPosition: function(a) {
					return f.PATTERN_POSITION_TABLE[a - 1]
				},
				getMask: function(a, b, c) {
					switch (a) {
						case e.PATTERN000:
							return 0 == (b + c) % 2;
						case e.PATTERN001:
							return 0 == b % 2;
						case e.PATTERN010:
							return 0 == c % 3;
						case e.PATTERN011:
							return 0 == (b + c) % 3;
						case e.PATTERN100:
							return 0 == (Math.floor(b / 2) + Math.floor(c / 3)) % 2;
						case e.PATTERN101:
							return 0 == b * c % 2 + b * c % 3;
						case e.PATTERN110:
							return 0 == (b * c % 2 + b * c % 3) % 2;
						case e.PATTERN111:
							return 0 == (b * c % 3 + (b + c) % 2) % 2;
						default:
							throw new Error("bad maskPattern:" + a)
					}
				},
				getErrorCorrectPolynomial: function(a) {
					for (var b = new i([1], 0), c = 0; a > c; c++) b = b.multiply(new i([1, g.gexp(c)], 0));
					return b
				},
				getLengthInBits: function(a, b) {
					if (b >= 1 && 10 > b) switch (a) {
						case c.MODE_NUMBER:
							return 10;
						case c.MODE_ALPHA_NUM:
							return 9;
						case c.MODE_8BIT_BYTE:
							return 8;
						case c.MODE_KANJI:
							return 8;
						default:
							throw new Error("mode:" + a)
					} else if (27 > b) switch (a) {
						case c.MODE_NUMBER:
							return 12;
						case c.MODE_ALPHA_NUM:
							return 11;
						case c.MODE_8BIT_BYTE:
							return 16;
						case c.MODE_KANJI:
							return 10;
						default:
							throw new Error("mode:" + a)
					} else {
						if (!(41 > b)) throw new Error("type:" + b);
						switch (a) {
							case c.MODE_NUMBER:
								return 14;
							case c.MODE_ALPHA_NUM:
								return 13;
							case c.MODE_8BIT_BYTE:
								return 16;
							case c.MODE_KANJI:
								return 12;
							default:
								throw new Error("mode:" + a)
						}
					}
				},
				getLostPoint: function(a) {
					for (var b = a.getModuleCount(), c = 0, d = 0; b > d; d++)
						for (var e = 0; b > e; e++) {
							for (var f = 0, g = a.isDark(d, e), h = -1; 1 >= h; h++)
								if (!(0 > d + h || d + h >= b))
									for (var i = -1; 1 >= i; i++) 0 > e + i || e + i >= b || (0 != h || 0 != i) && g == a.isDark(d + h, e + i) && f++;
							f > 5 && (c += 3 + f - 5)
						}
					for (var d = 0; b - 1 > d; d++)
						for (var e = 0; b - 1 > e; e++) {
							var j = 0;
							a.isDark(d, e) && j++, a.isDark(d + 1, e) && j++, a.isDark(d, e + 1) && j++, a.isDark(d + 1, e + 1) && j++, (0 == j || 4 == j) && (c += 3)
						}
					for (var d = 0; b > d; d++)
						for (var e = 0; b - 6 > e; e++) a.isDark(d, e) && !a.isDark(d, e + 1) && a.isDark(d, e + 2) && a.isDark(d, e + 3) && a.isDark(d, e + 4) && !a.isDark(d, e + 5) && a.isDark(d, e + 6) && (c += 40);
					for (var e = 0; b > e; e++)
						for (var d = 0; b - 6 > d; d++) a.isDark(d, e) && !a.isDark(d + 1, e) && a.isDark(d + 2, e) && a.isDark(d + 3, e) && a.isDark(d + 4, e) && !a.isDark(d + 5, e) && a.isDark(d + 6, e) && (c += 40);
					for (var k = 0, e = 0; b > e; e++)
						for (var d = 0; b > d; d++) a.isDark(d, e) && k++;
					var l = Math.abs(100 * k / b / b - 50) / 5;
					return c += 10 * l
				}
			}, g = {
				glog: function(a) {
					if (1 > a) throw new Error("glog(" + a + ")");
					return g.LOG_TABLE[a]
				},
				gexp: function(a) {
					for (; 0 > a;) a += 255;
					for (; a >= 256;) a -= 255;
					return g.EXP_TABLE[a]
				},
				EXP_TABLE: new Array(256),
				LOG_TABLE: new Array(256)
			}, h = 0; 8 > h; h++) g.EXP_TABLE[h] = 1 << h;
		for (var h = 8; 256 > h; h++) g.EXP_TABLE[h] = g.EXP_TABLE[h - 4] ^ g.EXP_TABLE[h - 5] ^ g.EXP_TABLE[h - 6] ^ g.EXP_TABLE[h - 8];
		for (var h = 0; 255 > h; h++) g.LOG_TABLE[g.EXP_TABLE[h]] = h;
		i.prototype = {
			get: function(a) {
				return this.num[a]
			},
			getLength: function() {
				return this.num.length
			},
			multiply: function(a) {
				for (var b = new Array(this.getLength() + a.getLength() - 1), c = 0; c < this.getLength(); c++)
					for (var d = 0; d < a.getLength(); d++) b[c + d] ^= g.gexp(g.glog(this.get(c)) + g.glog(a.get(d)));
				return new i(b, 0)
			},
			mod: function(a) {
				if (this.getLength() - a.getLength() < 0) return this;
				for (var b = g.glog(this.get(0)) - g.glog(a.get(0)), c = new Array(this.getLength()), d = 0; d < this.getLength(); d++) c[d] = this.get(d);
				for (var d = 0; d < a.getLength(); d++) c[d] ^= g.gexp(g.glog(a.get(d)) + b);
				return new i(c, 0).mod(a)
			}
		}, j.RS_BLOCK_TABLE = [
			[1, 26, 19],
			[1, 26, 16],
			[1, 26, 13],
			[1, 26, 9],
			[1, 44, 34],
			[1, 44, 28],
			[1, 44, 22],
			[1, 44, 16],
			[1, 70, 55],
			[1, 70, 44],
			[2, 35, 17],
			[2, 35, 13],
			[1, 100, 80],
			[2, 50, 32],
			[2, 50, 24],
			[4, 25, 9],
			[1, 134, 108],
			[2, 67, 43],
			[2, 33, 15, 2, 34, 16],
			[2, 33, 11, 2, 34, 12],
			[2, 86, 68],
			[4, 43, 27],
			[4, 43, 19],
			[4, 43, 15],
			[2, 98, 78],
			[4, 49, 31],
			[2, 32, 14, 4, 33, 15],
			[4, 39, 13, 1, 40, 14],
			[2, 121, 97],
			[2, 60, 38, 2, 61, 39],
			[4, 40, 18, 2, 41, 19],
			[4, 40, 14, 2, 41, 15],
			[2, 146, 116],
			[3, 58, 36, 2, 59, 37],
			[4, 36, 16, 4, 37, 17],
			[4, 36, 12, 4, 37, 13],
			[2, 86, 68, 2, 87, 69],
			[4, 69, 43, 1, 70, 44],
			[6, 43, 19, 2, 44, 20],
			[6, 43, 15, 2, 44, 16],
			[4, 101, 81],
			[1, 80, 50, 4, 81, 51],
			[4, 50, 22, 4, 51, 23],
			[3, 36, 12, 8, 37, 13],
			[2, 116, 92, 2, 117, 93],
			[6, 58, 36, 2, 59, 37],
			[4, 46, 20, 6, 47, 21],
			[7, 42, 14, 4, 43, 15],
			[4, 133, 107],
			[8, 59, 37, 1, 60, 38],
			[8, 44, 20, 4, 45, 21],
			[12, 33, 11, 4, 34, 12],
			[3, 145, 115, 1, 146, 116],
			[4, 64, 40, 5, 65, 41],
			[11, 36, 16, 5, 37, 17],
			[11, 36, 12, 5, 37, 13],
			[5, 109, 87, 1, 110, 88],
			[5, 65, 41, 5, 66, 42],
			[5, 54, 24, 7, 55, 25],
			[11, 36, 12],
			[5, 122, 98, 1, 123, 99],
			[7, 73, 45, 3, 74, 46],
			[15, 43, 19, 2, 44, 20],
			[3, 45, 15, 13, 46, 16],
			[1, 135, 107, 5, 136, 108],
			[10, 74, 46, 1, 75, 47],
			[1, 50, 22, 15, 51, 23],
			[2, 42, 14, 17, 43, 15],
			[5, 150, 120, 1, 151, 121],
			[9, 69, 43, 4, 70, 44],
			[17, 50, 22, 1, 51, 23],
			[2, 42, 14, 19, 43, 15],
			[3, 141, 113, 4, 142, 114],
			[3, 70, 44, 11, 71, 45],
			[17, 47, 21, 4, 48, 22],
			[9, 39, 13, 16, 40, 14],
			[3, 135, 107, 5, 136, 108],
			[3, 67, 41, 13, 68, 42],
			[15, 54, 24, 5, 55, 25],
			[15, 43, 15, 10, 44, 16],
			[4, 144, 116, 4, 145, 117],
			[17, 68, 42],
			[17, 50, 22, 6, 51, 23],
			[19, 46, 16, 6, 47, 17],
			[2, 139, 111, 7, 140, 112],
			[17, 74, 46],
			[7, 54, 24, 16, 55, 25],
			[34, 37, 13],
			[4, 151, 121, 5, 152, 122],
			[4, 75, 47, 14, 76, 48],
			[11, 54, 24, 14, 55, 25],
			[16, 45, 15, 14, 46, 16],
			[6, 147, 117, 4, 148, 118],
			[6, 73, 45, 14, 74, 46],
			[11, 54, 24, 16, 55, 25],
			[30, 46, 16, 2, 47, 17],
			[8, 132, 106, 4, 133, 107],
			[8, 75, 47, 13, 76, 48],
			[7, 54, 24, 22, 55, 25],
			[22, 45, 15, 13, 46, 16],
			[10, 142, 114, 2, 143, 115],
			[19, 74, 46, 4, 75, 47],
			[28, 50, 22, 6, 51, 23],
			[33, 46, 16, 4, 47, 17],
			[8, 152, 122, 4, 153, 123],
			[22, 73, 45, 3, 74, 46],
			[8, 53, 23, 26, 54, 24],
			[12, 45, 15, 28, 46, 16],
			[3, 147, 117, 10, 148, 118],
			[3, 73, 45, 23, 74, 46],
			[4, 54, 24, 31, 55, 25],
			[11, 45, 15, 31, 46, 16],
			[7, 146, 116, 7, 147, 117],
			[21, 73, 45, 7, 74, 46],
			[1, 53, 23, 37, 54, 24],
			[19, 45, 15, 26, 46, 16],
			[5, 145, 115, 10, 146, 116],
			[19, 75, 47, 10, 76, 48],
			[15, 54, 24, 25, 55, 25],
			[23, 45, 15, 25, 46, 16],
			[13, 145, 115, 3, 146, 116],
			[2, 74, 46, 29, 75, 47],
			[42, 54, 24, 1, 55, 25],
			[23, 45, 15, 28, 46, 16],
			[17, 145, 115],
			[10, 74, 46, 23, 75, 47],
			[10, 54, 24, 35, 55, 25],
			[19, 45, 15, 35, 46, 16],
			[17, 145, 115, 1, 146, 116],
			[14, 74, 46, 21, 75, 47],
			[29, 54, 24, 19, 55, 25],
			[11, 45, 15, 46, 46, 16],
			[13, 145, 115, 6, 146, 116],
			[14, 74, 46, 23, 75, 47],
			[44, 54, 24, 7, 55, 25],
			[59, 46, 16, 1, 47, 17],
			[12, 151, 121, 7, 152, 122],
			[12, 75, 47, 26, 76, 48],
			[39, 54, 24, 14, 55, 25],
			[22, 45, 15, 41, 46, 16],
			[6, 151, 121, 14, 152, 122],
			[6, 75, 47, 34, 76, 48],
			[46, 54, 24, 10, 55, 25],
			[2, 45, 15, 64, 46, 16],
			[17, 152, 122, 4, 153, 123],
			[29, 74, 46, 14, 75, 47],
			[49, 54, 24, 10, 55, 25],
			[24, 45, 15, 46, 46, 16],
			[4, 152, 122, 18, 153, 123],
			[13, 74, 46, 32, 75, 47],
			[48, 54, 24, 14, 55, 25],
			[42, 45, 15, 32, 46, 16],
			[20, 147, 117, 4, 148, 118],
			[40, 75, 47, 7, 76, 48],
			[43, 54, 24, 22, 55, 25],
			[10, 45, 15, 67, 46, 16],
			[19, 148, 118, 6, 149, 119],
			[18, 75, 47, 31, 76, 48],
			[34, 54, 24, 34, 55, 25],
			[20, 45, 15, 61, 46, 16]
		], j.getRSBlocks = function(a, b) {
			var c = j.getRsBlockTable(a, b);
			if (void 0 == c) throw new Error("bad rs block @ typeNumber:" + a + "/errorCorrectLevel:" + b);
			for (var d = c.length / 3, e = [], f = 0; d > f; f++)
				for (var g = c[3 * f + 0], h = c[3 * f + 1], i = c[3 * f + 2], k = 0; g > k; k++) e.push(new j(h, i));
			return e
		}, j.getRsBlockTable = function(a, b) {
			switch (b) {
				case d.L:
					return j.RS_BLOCK_TABLE[4 * (a - 1) + 0];
				case d.M:
					return j.RS_BLOCK_TABLE[4 * (a - 1) + 1];
				case d.Q:
					return j.RS_BLOCK_TABLE[4 * (a - 1) + 2];
				case d.H:
					return j.RS_BLOCK_TABLE[4 * (a - 1) + 3];
				default:
					return void 0
			}
		}, k.prototype = {
			get: function(a) {
				var b = Math.floor(a / 8);
				return 1 == (1 & this.buffer[b] >>> 7 - a % 8)
			},
			put: function(a, b) {
				for (var c = 0; b > c; c++) this.putBit(1 == (1 & a >>> b - c - 1))
			},
			getLengthInBits: function() {
				return this.length
			},
			putBit: function(a) {
				var b = Math.floor(this.length / 8);
				this.buffer.length <= b && this.buffer.push(0), a && (this.buffer[b] |= 128 >>> this.length % 8), this.length++
			}
		};
		var l = [
				[17, 14, 11, 7],
				[32, 26, 20, 14],
				[53, 42, 32, 24],
				[78, 62, 46, 34],
				[106, 84, 60, 44],
				[134, 106, 74, 58],
				[154, 122, 86, 64],
				[192, 152, 108, 84],
				[230, 180, 130, 98],
				[271, 213, 151, 119],
				[321, 251, 177, 137],
				[367, 287, 203, 155],
				[425, 331, 241, 177],
				[458, 362, 258, 194],
				[520, 412, 292, 220],
				[586, 450, 322, 250],
				[644, 504, 364, 280],
				[718, 560, 394, 310],
				[792, 624, 442, 338],
				[858, 666, 482, 382],
				[929, 711, 509, 403],
				[1003, 779, 565, 439],
				[1091, 857, 611, 461],
				[1171, 911, 661, 511],
				[1273, 997, 715, 535],
				[1367, 1059, 751, 593],
				[1465, 1125, 805, 625],
				[1528, 1190, 868, 658],
				[1628, 1264, 908, 698],
				[1732, 1370, 982, 742],
				[1840, 1452, 1030, 790],
				[1952, 1538, 1112, 842],
				[2068, 1628, 1168, 898],
				[2188, 1722, 1228, 958],
				[2303, 1809, 1283, 983],
				[2431, 1911, 1351, 1051],
				[2563, 1989, 1423, 1093],
				[2699, 2099, 1499, 1139],
				[2809, 2213, 1579, 1219],
				[2953, 2331, 1663, 1273]
			],
			o = function() {
				var a = function(a, b) {
					this._el = a, this._htOption = b
				};
				return a.prototype.draw = function(a) {
					function g(a, b) {
						var c = document.createElementNS("http://www.w3.org/2000/svg", a);
						for (var d in b) b.hasOwnProperty(d) && c.setAttribute(d, b[d]);
						return c
					}
					var b = this._htOption,
						c = this._el,
						d = a.getModuleCount();
					Math.floor(b.width / d), Math.floor(b.height / d), this.clear();
					var h = g("svg", {
						viewBox: "0 0 " + String(d) + " " + String(d),
						width: "100%",
						height: "100%",
						fill: b.colorLight
					});
					h.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink"), c.appendChild(h), h.appendChild(g("rect", {
						fill: b.colorDark,
						width: "1",
						height: "1",
						id: "template"
					}));
					for (var i = 0; d > i; i++)
						for (var j = 0; d > j; j++)
							if (a.isDark(i, j)) {
								var k = g("use", {
									x: String(i),
									y: String(j)
								});
								k.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template"), h.appendChild(k)
							}
				}, a.prototype.clear = function() {
					for (; this._el.hasChildNodes();) this._el.removeChild(this._el.lastChild)
				}, a
			}(),
			p = "svg" === document.documentElement.tagName.toLowerCase(),
			q = p ? o : m() ? function() {
				function a() {
					this._elImage.src = this._elCanvas.toDataURL("image/png"), this._elImage.style.display = "block", this._elCanvas.style.display = "none"
				}
	
				function d(a, b) {
					var c = this;
					if (c._fFail = b, c._fSuccess = a, null === c._bSupportDataURI) {
						var d = document.createElement("img"),
							e = function() {
								c._bSupportDataURI = !1, c._fFail && _fFail.call(c)
							},
							f = function() {
								c._bSupportDataURI = !0, c._fSuccess && c._fSuccess.call(c)
							};
						return d.onabort = e, d.onerror = e, d.onload = f, d.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", void 0
					}
					c._bSupportDataURI === !0 && c._fSuccess ? c._fSuccess.call(c) : c._bSupportDataURI === !1 && c._fFail && c._fFail.call(c)
				}
				if (this._android && this._android <= 2.1) {
					var b = 1 / window.devicePixelRatio,
						c = CanvasRenderingContext2D.prototype.drawImage;
					CanvasRenderingContext2D.prototype.drawImage = function(a, d, e, f, g, h, i, j) {
						if ("nodeName" in a && /img/i.test(a.nodeName))
							for (var l = arguments.length - 1; l >= 1; l--) arguments[l] = arguments[l] * b;
						else "undefined" == typeof j && (arguments[1] *= b, arguments[2] *= b, arguments[3] *= b, arguments[4] *= b);
						c.apply(this, arguments)
					}
				}
				var e = function(a, b) {
					this._bIsPainted = !1, this._android = n(), this._htOption = b, this._elCanvas = document.createElement("canvas"), this._elCanvas.width = b.width, this._elCanvas.height = b.height, a.appendChild(this._elCanvas), this._el = a, this._oContext = this._elCanvas.getContext("2d"), this._bIsPainted = !1, this._elImage = document.createElement("img"), this._elImage.style.display = "none", this._el.appendChild(this._elImage), this._bSupportDataURI = null
				};
				return e.prototype.draw = function(a) {
					var b = this._elImage,
						c = this._oContext,
						d = this._htOption,
						e = a.getModuleCount(),
						f = d.width / e,
						g = d.height / e,
						h = Math.round(f),
						i = Math.round(g);
					b.style.display = "none", this.clear();
					for (var j = 0; e > j; j++)
						for (var k = 0; e > k; k++) {
							var l = a.isDark(j, k),
								m = k * f,
								n = j * g;
							c.strokeStyle = l ? d.colorDark : d.colorLight, c.lineWidth = 1, c.fillStyle = l ? d.colorDark : d.colorLight, c.fillRect(m, n, f, g), c.strokeRect(Math.floor(m) + .5, Math.floor(n) + .5, h, i), c.strokeRect(Math.ceil(m) - .5, Math.ceil(n) - .5, h, i)
						}
					this._bIsPainted = !0
				}, e.prototype.makeImage = function() {
					this._bIsPainted && d.call(this, a)
				}, e.prototype.isPainted = function() {
					return this._bIsPainted
				}, e.prototype.clear = function() {
					this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height), this._bIsPainted = !1
				}, e.prototype.round = function(a) {
					return a ? Math.floor(1e3 * a) / 1e3 : a
				}, e
			}() : function() {
				var a = function(a, b) {
					this._el = a, this._htOption = b
				};
				return a.prototype.draw = function(a) {
					for (var b = this._htOption, c = this._el, d = a.getModuleCount(), e = Math.floor(b.width / d), f = Math.floor(b.height / d), g = ['<table style="border:0;border-collapse:collapse;">'], h = 0; d > h; h++) {
						g.push("<tr>");
						for (var i = 0; d > i; i++) g.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:' + e + "px;height:" + f + "px;background-color:" + (a.isDark(h, i) ? b.colorDark : b.colorLight) + ';"></td>');
						g.push("</tr>")
					}
					g.push("</table>"), c.innerHTML = g.join("");
					var j = c.childNodes[0],
						k = (b.width - j.offsetWidth) / 2,
						l = (b.height - j.offsetHeight) / 2;
					k > 0 && l > 0 && (j.style.margin = l + "px " + k + "px")
				}, a.prototype.clear = function() {
					this._el.innerHTML = ""
				}, a
			}();
		QRCode = function(a, b) {
			if (this._htOption = {
					width: 256,
					height: 256,
					typeNumber: 4,
					colorDark: "#000000",
					colorLight: "#ffffff",
					correctLevel: d.H
				}, "string" == typeof b && (b = {
					text: b
				}), b)
				for (var c in b) this._htOption[c] = b[c];
			"string" == typeof a && (a = document.getElementById(a)), this._android = n(), this._el = a, this._oQRCode = null, this._oDrawing = new q(this._el, this._htOption), this._htOption.text && this.makeCode(this._htOption.text)
		}, QRCode.prototype.makeCode = function(a) {
			this._oQRCode = new b(r(a, this._htOption.correctLevel), this._htOption.correctLevel), this._oQRCode.addData(a), this._oQRCode.make(), this._el.title = a, this._oDrawing.draw(this._oQRCode), this.makeImage()
		}, QRCode.prototype.makeImage = function() {
			"function" == typeof this._oDrawing.makeImage && (!this._android || this._android >= 3) && this._oDrawing.makeImage()
		}, QRCode.prototype.clear = function() {
			this._oDrawing.clear()
		}, QRCode.CorrectLevel = d
	}();

	// Added by Gagan B. for generating QR code [END]
	
	function getCollectionPayMode(formNo, currentFormData)
	{
	    console.log('Inside getCollectionPayMode!!!! [[['+formNo);
		
		var payMode = "";
	    
	    var detailElement = currentFormData.getElementsByTagName("Detail"+formNo);
		for (var i = 0; i < detailElement.length; i++)
		{
			var detail = detailElement[i];
			if( detail.getElementsByTagName("pay_mode")[0] != null && detail.getElementsByTagName("pay_mode")[0].childNodes[0] != null )
			{
				payMode = detail.getElementsByTagName("pay_mode")[0].childNodes[0].nodeValue;
			}
		}
	    
        console.log('Inside getCollectionPayMode payMode:::['+ payMode+']');
	    return payMode;
	}
