//rephrase data changes

var PROD_ID = 0;
var STOCKFLOW_ID = 0;
function REPHRASING()
{
	
	//JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_DESCRIPTION") == true)
	{
		DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("T_BODY");
		COUNTER = 1;
		
		while(DGV_ELEMENT_CHILD.length > COUNTER)
		{
			//username merge
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS('AUDIT_TRAIL_DGV_ROW_ACC_ACCOUNT_FIRST_NAME_'+COUNTER)== true)
			{
				var user = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_ACCOUNT_LAST_NAME_'+COUNTER)+', '+JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_ACCOUNT_FIRST_NAME_'+COUNTER)
				JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_ACCOUNT_FIRST_NAME_'+COUNTER,user);
			}
			//for Module
			if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_DESCRIPTION_"+COUNTER) == true)
			{
				var audit_module = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_DESCRIPTION_"+COUNTER);
				audit_module = audit_module.replaceAll('add/edit ','');
				audit_module = audit_module.replaceAll(' record','');
				JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_DESCRIPTION_"+COUNTER,audit_module);
				//for Changes Made
				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == true)
				{

					//--STOCK CARD is always an automatic creation process
					if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40050)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							var prefix = 'Added new record.';
							var prod_id = GET_STOCK_CARD_RECORD_FOR_40050(target_id,COUNTER,prefix);						
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{
							var prefix = 'Deleted record.';
							var prod_id = GET_STOCK_CARD_RECORD_FOR_40050(target_id,COUNTER,prefix);
						}
					}
					//--INVOICE
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40290)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 6);
							
							//if starting with unique means add
							if(description.match(/^Unique.*$/))
							{
								var prefix = 'Added new record.';
								var prod_id = GET_INVOICE_RECORD_FOR_40290(target_id,COUNTER,prefix);
							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+ activity;
								var prod_id = GET_INVOICE_RECORD_FOR_40290_Edited(target_id,COUNTER,prefix);
							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted record.';
							var prod_id = GET_INVOICE_RECORD_FOR_40290(target_id,COUNTER,prefix);
						}
					}
					//--INVOICE LINE
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40310)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 6);
							
							//if starting with unique means add
							if(description.match(/^Invoic.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_INVOICE_LINE_RECORD_FOR_40310(target_id,COUNTER,prefix);
							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_INVOICE_LINE_RECORD_FOR_40310(target_id,COUNTER,prefix);
							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_INVOICE_LINE_RECORD_FOR_40310(target_id,COUNTER,prefix);
						}
					}
					//--PRODUCT
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 21010)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 8);
							//if starting with unique means add
							if(description.match(/^UOM: " 0.*$/))
							{
								var prefix = 'Added new record.  ';
								var prod_id = GET_PRODUCT_RECORD_FOR_21010(target_id,COUNTER,prefix);
							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+activity;
								var prod_id = GET_PRODUCT_RECORD_FOR_21010(target_id,COUNTER,prefix);
							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted  ';
							var prod_id = GET_PRODUCT_RECORD_FOR_21010(target_id,COUNTER,prefix);
						}
					}
					//--PRODUCTION 
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40190)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 11);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Branch: " 0.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_PSCHEDULE_RECORD_FOR_40190(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_PSCHEDULE_RECORD_FOR_40190(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_PSCHEDULE_RECORD_FOR_40190(target_id,COUNTER,prefix);
						}
					}
					//--PRODUCTION SCHEDULE
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40210)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 11);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Branch: " 0.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_PSACTUAL_RECORD_FOR_40210(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_PSACTUAL_RECORD_FOR_40210(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_PSCHEDULE_RECORD_FOR_40190(target_id,COUNTER,prefix);
						}
					}
					//--TRANSACTION
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40010)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 12);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Product: " 0.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_TRANS_LIST_RECORD_FOR_40010(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_TRANS_LIST_RECORD_FOR_40010(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_TRANS_LIST_RECORD_FOR_40010(target_id,COUNTER,prefix);
						}
					}
					//--TRANSACTION LIST
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40030)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 16);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Transaction: " 0.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_TRANS_LIST_RECORD_FOR_40030(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_TRANS_LIST_RECORD_FOR_40030(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_TRANS_LIST_RECORD_FOR_40030(target_id,COUNTER,prefix);
						}
					}
					//--PO
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40330)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 16);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Supplier: " 0.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_PO_RECORD_FOR_40330(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_PO_RECORD_FOR_40330(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_PO_RECORD_FOR_40330(target_id,COUNTER,prefix);
						}
					}
					//--PO ITEMS
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40350)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 19);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Purchase Order: " 0.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_PO_LIST_RECORD_FOR_40350(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_PO_LIST_RECORD_FOR_40350(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_PO_LIST_RECORD_FOR_40350(target_id,COUNTER,prefix);
						}
					}
					//--CHARGE TYPE
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 21110)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 16);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Description: "  .*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_CHARGETYPE_FOR_21110(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited '+activity;
								var prod_id = GET_CHARGETYPE_FOR_21110(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_CHARGETYPE_FOR_21110(target_id,COUNTER,prefix);
						}
					}
					//--CHARGE
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40390)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 13);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Employee: " 0.*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_CHARGE_FOR_40390(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+activity;
								var prod_id = GET_CHARGE_FOR_40390(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_CHARGE_FOR_40390(target_id,COUNTER,prefix);
						}
					}
					//--COMPANY
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 21090)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 16);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Description: "  .*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_COMPANY_FOR_21090(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+activity;
								var prod_id = GET_COMPANY_FOR_21090(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_COMPANY_FOR_21090(target_id,COUNTER,prefix);
						}
					}
					//--EMPLOYEE
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 40070)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 14);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Full Name: "  .*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_CHARGE_EMPLOYEE_FOR_40070(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+activity;
								var prod_id = GET_CHARGE_EMPLOYEE_FOR_40070(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_CHARGE_EMPLOYEE_FOR_40070(target_id,COUNTER,prefix);
						}
					}
					//--STOCKFLOW
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 21070)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 16);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Description: "  .*$/))
							{
								var prefix = 'Added new record. ';
								var prod_id = GET_STOCKFLOW_RECORD_21070(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+activity;
								var prod_id = GET_STOCKFLOW_RECORD_21070(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_STOCKFLOW_RECORD_21070(target_id,COUNTER,prefix);
						}
					}
					//--Uom
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 21050)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 16);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^Description: "  .*$/))
							{
								var prefix = 'Added new record.';
								var prod_id = GET_UOM_21050(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+activity;
								var prod_id = GET_UOM_21050(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted ';
							var prod_id = GET_UOM_21050(target_id,COUNTER,prefix);
						}
					}
					//--USER
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 10060)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 10);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^LEVEL: " 0.*$/))
							{
								var prefix = 'Added new record.';
								var prod_id = GET_USER_10060(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field '+activity;
								var prod_id = GET_USER_10060(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted record';
							var prod_id = GET_USER_10060(target_id,COUNTER,prefix);
						}
					}
					//--LICENSE USER
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 15030)
					{
						var target_id = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_TARGET_ID_'+COUNTER);		
						//preservers ROW # inside the querries
						//add
						if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 1)
						{
							//get what type of activity it is
							var description = JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER);
							description = description.substr(0, 17);
							//console.log(description);
							//if starting with unique means add
							if(description.match(/^User Account: " 0.*$/))
							{
								var prefix = 'Added new record.';
								var prod_id = GET_USER_LICENSE_15030(target_id,COUNTER,prefix);

							}
							else
							{
								//get the default activity
								var activity = JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_'+COUNTER)
								activity = JSVC_STR.VAR_REPLACE(activity," &gt; "," to ");
								var prefix = 'Edited field'+activity;
								var prod_id = GET_USER_LICENSE_15030(target_id,COUNTER,prefix);

							}					
						}
						//delete
						else if(JSOC_ELEMENT.VAR_INNER_HTML('AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_METHOD_ID_'+COUNTER)== 2)
						{	
							var prefix = 'Deleted record.';
							var prod_id = GET_USER_LICENSE_15030(target_id,COUNTER,prefix);
						}
					}
					//--ACCESS RIGHTS
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 10080)
					{
						//hide this row
						JSOC_STYLE.VAR_DISPLAY(JSOC_ELEMENT.VAR_GET("AUDIT_TRAIL_DGV_ROW_"+COUNTER), 'NONE');

					}
					//--ACCESS LEVEL
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 10040)
					{
						//JSOC_STYLE.VAR_DISPLAY(AUDIT_TRAIL_DGV.ROW.ELEMENT(COUNTER), 'NONE');
						JSOC_STYLE.VAR_DISPLAY(JSOC_ELEMENT.VAR_GET("AUDIT_TRAIL_DGV_ROW_"+COUNTER), 'NONE');
						
					}
					//--ACCOUNT GROUP
					else if(JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_SYS_MODULE_ID_"+COUNTER) == 10070)
					{
						JSOC_STYLE.VAR_DISPLAY(JSOC_ELEMENT.VAR_GET("AUDIT_TRAIL_DGV_ROW_"+COUNTER), 'NONE');
					}
				}
			}
			COUNTER ++;
		}
	}
	
}
//-----------------------------------------------------------ACCESS GROUP
//-----------------------------------------------------------ACCESS GROUP
//-----------------------------------------------------------ACCESS LEVEL
//-----------------------------------------------------------ACCESS LEVEL
//-----------------------------------------------------------ACCESS RIGHTS
//-----------------------------------------------------------ACCESS RIGHTS
//-----------------------------------------------------------USER LICENSE
function GET_USER_LICENSE_15030(target_id,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._ADDON._LICENSE_USER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ADD_ULICENSE_ID', target_id);
	JSCUS_SQL._ADDON._LICENSE_USER.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					var stockflowname = '';
					userid = 1;
					GET_USER_15030(userid,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					var stockflowname = '';
					userid = JSRC_JSON.REF_READ(JSON_OBJECT, "ADD_ULICENSE_ACC_ACCOUNT_ID",1);
					GET_USER_15030(userid,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_USER_15030(userid,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._MEMBER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ACC_ACCOUNT_ID', userid);
	JSCUS_SQL._ACCOUNT._MEMBER.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					user = "Unknown";
					LOAD_USER_FOR_15030(user,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					user = JSRC_JSON.REF_READ(JSON_OBJECT, "ACC_ACCOUNT_USERNAME",1);
					LOAD_USER_FOR_15030(user,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_USER_FOR_15030(user,COUNTER,prefix)
{;
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'User: ' +user);
}
//-----------------------------------------------------------USER LICENSE

//-----------------------------------------------------------USER ACCOUNT
function GET_USER_10060(target_id,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._ACCOUNT._MEMBER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ACC_ACCOUNT_ID', target_id);
	JSCUS_SQL._ACCOUNT._MEMBER.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var stockflowname = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					user = 1;
					LOAD_USER_FOR_10060(user,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					user = JSRC_JSON.REF_READ(JSON_OBJECT, "ACC_ACCOUNT_USERNAME",1);
					LOAD_USER_FOR_10060(user,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function LOAD_USER_FOR_10060(user,COUNTER,prefix)
{
	prefix = prefix;
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'User: ' +user);
}
//-----------------------------------------------------------USER ACCOUNT
//-----------------------------------------------------------UOM
function GET_UOM_21050(target_id,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._UOM.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_UOM_ID', target_id);
	JSCUS_SQL._CATEGORY._UOM.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var stockflowname = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					uom = '';
					LOAD_UOM_FOR_21050(uom,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					uom = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_UOM_DESCRIPTION",1);
					LOAD_UOM_FOR_21050(uom,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function LOAD_UOM_FOR_21050(uom,COUNTER,prefix)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Unit of Measure: ' +uom);
}
//-----------------------------------------------------------UOM
//-----------------------------------------------------------STOCKFLOW
function GET_STOCKFLOW_RECORD_21070(target_id,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STOCKFLOW_ID', target_id);
	JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var stockflowname = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					stockflowname = '';
					LOAD_STOCKFLOW_FOR_21070(stockflowname,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					stockflowname = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_STOCKFLOW_DESCRIPTION",1);
					LOAD_STOCKFLOW_FOR_21070(stockflowname,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_STOCKFLOW_FOR_21070(stockflowname,COUNTER,prefix)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Stockflow: ' +stockflowname );
}
//-----------------------------------------------------------STOCKFLOW
//-----------------------------------------------------------EMPLOYEE
function GET_CHARGE_EMPLOYEE_FOR_40070(empid,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._EMPLOYEE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_EMPLOYEE_ID', empid);
	JSCUS_SQL._RECORD._EMPLOYEE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					name = '';
					LOAD_EMPLOYEE_FOR_40070(name,COUNTER,prefix)
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					name = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EMPLOYEE_NAME",1);
					LOAD_EMPLOYEE_FOR_40070(name,COUNTER,prefix)
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_EMPLOYEE_FOR_40070(name,COUNTER,prefix)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Employee: ' +name);
}
//-----------------------------------------------------------EMPLOYEE
//-----------------------------------------------------------COMPANY
function GET_COMPANY_FOR_21090(ref,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._COMPANY.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_COMPANY_ID', ref);
	JSCUS_SQL._CATEGORY._COMPANY.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					ref = '';
					LOAD_COMPANY_FOR_21090(ref,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					ref = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_COMPANY_DESCRIPTION",1);
					LOAD_COMPANY_FOR_21090(ref,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_COMPANY_FOR_21090(ref,COUNTER,prefix)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Company: ' +ref );
}
//-----------------------------------------------------------COMPANY
//-----------------------------------------------------------CHARGE
function GET_CHARGE_FOR_40390(ref,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._CHARGE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_CHARGE_ID', ref);
	JSCUS_SQL._RECORD._CHARGE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					ref = 1;
					empid = 1
					GET_CHARGE_EMPLOYEE_FOR_40390(empid,COUNTER,prefix,ref);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					ref = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CHARGE_REFERENCE",1);
					empid = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CHARGE_REC_EMPLOYEE_ID",1);
					GET_CHARGE_EMPLOYEE_FOR_40390(empid,COUNTER,prefix,ref);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_CHARGE_EMPLOYEE_FOR_40390(empid,COUNTER,prefix,ref)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._EMPLOYEE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_EMPLOYEE_ID', empid);
	JSCUS_SQL._RECORD._EMPLOYEE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					name = '';
					LOAD_CHARGE_FOR_21110(name,COUNTER,prefix,ref)
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					name = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_EMPLOYEE_NAME",1);
					LOAD_CHARGE_FOR_21110(name,COUNTER,prefix,ref)
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_CHARGE_FOR_21110(name,COUNTER,prefix,ref)
{
		// prefix = prefix+' for Employee: ' + name;
		JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
		JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Transaction Code: ' +ref + ',<br> Employee:' +name);
}
//-----------------------------------------------------------CHARGE

//-----------------------------------------------------------CHARGE TYPE
function GET_CHARGETYPE_FOR_21110(ref,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	 var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._CHARGETYPE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_CHRGTYPE_ID', ref);
	JSCUS_SQL._CATEGORY._CHARGETYPE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					desc = '';
					LOAD_CHARGETYPE_FOR_21110(desc,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					desc = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_CHRGTYPE_DESCRIPTION",1);
					LOAD_CHARGETYPE_FOR_21110(desc,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_CHARGETYPE_FOR_21110(desc,COUNTER,prefix,)
{
	//prefix = prefix+'Charge Type: ' +desc;
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Charge Type: ' +desc);
}
//-----------------------------------------------------------CHARGE TYPE
//-----------------------------------------------------------PO ITEMS
function GET_PO_LIST_RECORD_FOR_40350(ref,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	 var GET_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PORDER_LIST_ID', ref);
	JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					po_code = 1;
					prod = 1;
					GET_PO_RECORD_FOR_40350(po_code,COUNTER,prefix,prod);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					po_code = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PORDER_LIST_REC_PORDER_ID",1);
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PORDER_LIST_CAT_PRODUCT_ID",1);
					GET_PO_RECORD_FOR_40350(po_code,COUNTER,prefix,prod);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_PO_RECORD_FOR_40350(po_code,COUNTER,prefix,prod)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	 var GET_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PORDER_ID', po_code);
	JSCUS_SQL._RECORD._PO_ORDER.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					code = '';
					GET_PRODUCT_RECORD_FOR_40350(code,COUNTER,prefix,prod);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					code = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PORDER_CODE",1);
					GET_PRODUCT_RECORD_FOR_40350(code,COUNTER,prefix,prod);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_PRODUCT_RECORD_FOR_40350(code,COUNTER,prefix,prod)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	 var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', prod);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_type = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod_name = '';
					LOAD_PO_ORDER_LIST_FOR_40350(code,COUNTER,prefix,prod_name);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod_name = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
					LOAD_PO_ORDER_LIST_FOR_40350(code,COUNTER,prefix,prod_name);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_PO_ORDER_LIST_FOR_40350(code,COUNTER,prefix,prod_name)
{
		//prefix = prefix+'Product: ' +prod_name+ ' with reference on Purchase Order Transaction Code: '+code;	
		JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
		JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Transaction Code: '+code+', <br>'+'Product: ' +prod_name);
}
//-----------------------------------------------------------PO ITEMS
//-----------------------------------------------------------PO
function GET_PO_RECORD_FOR_40330(ref,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	 var GET_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PORDER_ID', ref);
	JSCUS_SQL._RECORD._PO_ORDER.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					code = '';
					LOAD_PO_ORDER_FOR_40330(code,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					code = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PORDER_CODE",1);
					LOAD_PO_ORDER_FOR_40330(code,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_PO_ORDER_FOR_40330(code,COUNTER,prefix)
{
	//prefix = prefix+'Purchase Order with Transaction Code: '+code;	
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER,'Transaction Code: '+code);
}
//-----------------------------------------------------------PO

//-----------------------------------------------------------TRANSACTION LIST
function GET_TRANS_LIST_RECORD_FOR_40030(ref,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	 var GET_MAP_ARRAY = JSCUS_SQL._RECORD._TRANS_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_TRANSLIST_ID', ref);
	JSCUS_SQL._RECORD._TRANS_LIST.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = 1;
					rec_trans = 1;
					GET_PRODUCT_RECORD_FOR_40030(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_TRANSLIST_CAT_PRODUCT_ID",1);
					rec_trans = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_TRANSLIST_REC_TRANS_ID",1);
					GET_PRODUCT_RECORD_FOR_40030(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_PRODUCT_RECORD_FOR_40030(ref,COUNTER,prefix,rec_trans)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true);
	 var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', ref);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_type = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = '';
					GET_TRANS_RECORD_FOR_40030(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
					GET_TRANS_RECORD_FOR_40030(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_TRANS_FOR_40030(prod,COUNTER,prefix,ref)
{
		//prefix = prefix+'product: '+prod+ ' from Transaction Reference: '+ref;	
		JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
		JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Transaction Code: ' +ref+ ',<br> Product: '+prod);
}
function GET_TRANS_RECORD_FOR_40030(prod,COUNTER,prefix,rec_trans)
{
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		 var GET_MAP_ARRAY = JSCUS_SQL._RECORD._TRANS.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_TRANS_ID', rec_trans);
		JSCUS_SQL._RECORD._TRANS.CUS_GET
		(
			GET_MAP_ARRAY,
			function(IS_SUCCESS, RESPONSE_STRING)
			{				
				if(IS_SUCCESS == true)
				{
					var prod_type = 0;
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);

					if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
					{
						// var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
						ref = '';
						LOAD_TRANS_FOR_40030(prod,COUNTER,prefix,ref);
					}
					else
					{
						// var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
						ref = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_TRANS_REFERENCE_CODE",1);
						LOAD_TRANS_FOR_40030(prod,COUNTER,prefix,ref);
					}
				}
				else
				{
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			},
			true
		);
}
//-----------------------------------------------------------TRANSACTION LIST

//-----------------------------------------------------------TRANSACTION
function GET_TRANS_LIST_RECORD_FOR_40010(ref,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._TRANS_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_TRANSLIST_ID', ref);
	JSCUS_SQL._RECORD._TRANS_LIST.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var rec_trans = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = 1;
					rec_trans = 1;
					GET_PRODUCT_RECORD_FOR_40010(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_TRANSLIST_CAT_PRODUCT_ID",1);
					rec_trans = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_TRANSLIST_REC_TRANS_ID",1);
					GET_PRODUCT_RECORD_FOR_40010(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function LOAD_TRANS_FOR_40010(prod,COUNTER,prefix,ref)
{
	//prefix = prefix+'product: '+prod+ ' from Transaction Reference: '+ref;	
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Transaction Code: ' +ref+ ',<br> Product: '+prod);
}
function GET_TRANS_RECORD_FOR_40010(prod,COUNTER,prefix,rec_trans)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._TRANS.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_TRANS_ID', rec_trans);
	JSCUS_SQL._RECORD._TRANS.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_type = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					ref = '';
					LOAD_TRANS_FOR_40010(prod,COUNTER,prefix,ref);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					ref = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_TRANS_REFERENCE_CODE",1);
					LOAD_TRANS_FOR_40010(prod,COUNTER,prefix,ref);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_PRODUCT_RECORD_FOR_40010(ref,COUNTER,prefix,rec_trans)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', ref);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_type = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = '';
					GET_TRANS_RECORD_FOR_40010(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
					GET_TRANS_RECORD_FOR_40010(prod,COUNTER,prefix,rec_trans);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
//-----------------------------------------------------------TRANSACTION
//-----------------------------------------------------------PRODUCTION SCHEDULE
function GET_PSACTUAL_RECORD_FOR_40210(ref,COUNTER,prefix)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._PSACTUAL.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PSACTUAL_ID', ref);
	JSCUS_SQL._RECORD._PSACTUAL.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var date = '';
				var acc = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = 1;
					date = '';
					acc = 1;
					pdate = JSVC_DATE.VAR_FORMAT(date, "YYYY-MM");
					GET_PRODUCT_RECORD_FOR_40210(prod,COUNTER,prefix,pdate,acc);
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PSACTUAL_CAT_PRODUCT_ID",1);
					date = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PSACTUAL_DATE",1);
					acc = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PSACTUAL_ACC_GROUP_ID",1);
					pdate = JSVC_DATE.VAR_FORMAT(date, "YYYY-MM");
					GET_PRODUCT_RECORD_FOR_40210(prod,COUNTER,prefix,pdate,acc);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_PRODUCT_RECORD_FOR_40210(ref,COUNTER,prefix,pdate,acc)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', ref);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_type = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = '';
					GET_ACC_GROUP_FOR_40210(prod,COUNTER,prefix,pdate,acc);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
					GET_ACC_GROUP_FOR_40210(prod,COUNTER,prefix,pdate,acc);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function GET_ACC_GROUP_FOR_40210(prod,COUNTER,prefix,pdate,acc)
{
	var acc_name = '';
	if(acc == 1){ acc_name ='Regular Users'}
	else if(acc == 2){ acc_name ='System Admin'}
	else if(acc == 3){ acc_name ='Bajada'}
	else if(acc == 4){ acc_name ='Cabantian'}
	else if(acc == 5){ acc_name ='Centerpoint (Matina)'}
	else if(acc == 7){ acc_name ='Lanang'}
	else if(acc == 8){ acc_name ='Marfori'}
	else if(acc == 9){ acc_name ='Matina'}
	else if(acc == 10){ acc_name ='Rizal'}
	else if(acc == 11){ acc_name ='San Pedro'}
	else if(acc == 12){ acc_name ='SPMC'}
	else if(acc == 13){ acc_name ='Tagum G-Mall'}
	else if(acc == 14){ acc_name ='Toril'}
	else if(acc == 15){ acc_name ='Binangkal Malasakit'}
	else if(acc == 16){ acc_name ='Habi and Kapi'}
	LOAD_PS_ACTUAL_FOR_40210(prod,COUNTER,prefix,pdate,acc_name)
}

function LOAD_PS_ACTUAL_FOR_40210(prod,COUNTER,prefix,pdate,acc)
{
	// prefix = prefix+'product: '+prod+ ' for the duration of ' +pdate + ' for the branch of '+acc;
	
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Branch: ' +acc+',<br>'+'Product: '+prod+',<br>'+'Timeline: '+ pdate);
}
//-----------------------------------------------------------PRODUCTION SCHEDULE
//-----------------------------------------------------------PRODUCTION
function GET_PSCHEDULE_RECORD_FOR_40190(ref,COUNTER,prefix)
{	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._PSCHEDULE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_PSCHEDULE_ID', ref);
	JSCUS_SQL._RECORD._PSCHEDULE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var date = '';
				var acc = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = 1;
					date = '';
					acc = 1;
					pdate = JSVC_DATE.VAR_FORMAT(date, "YYYY-MM");
					GET_PRODUCT_RECORD_FOR_40190(prod,COUNTER,prefix,pdate,acc);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PSCHEDULE_CAT_PRODUCT_ID",1);
					date = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PSCHEDULE_DATE",1);
					acc = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_PSCHEDULE_ACC_GROUP_ID",1);
					pdate = JSVC_DATE.VAR_FORMAT(date, "YYYY-MM");
					GET_PRODUCT_RECORD_FOR_40190(prod,COUNTER,prefix,pdate,acc);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function GET_PRODUCT_RECORD_FOR_40190(ref,COUNTER,prefix,pdate,acc)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', ref);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_type = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = '';
					GET_ACC_GROUP_FOR_40190(prod,COUNTER,prefix,pdate,acc);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
					GET_ACC_GROUP_FOR_40190(prod,COUNTER,prefix,pdate,acc);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function GET_ACC_GROUP_FOR_40190(prod,COUNTER,prefix,pdate,acc)
{
	var acc_name = '';
	if(acc == 1){ acc_name ='Regular Users'}
	else if(acc == 2){ acc_name ='System Admin'}
	else if(acc == 3){ acc_name ='Bajada'}
	else if(acc == 4){ acc_name ='Cabantian'}
	else if(acc == 5){ acc_name ='Centerpoint (Matina)'}
	else if(acc == 7){ acc_name ='Lanang'}
	else if(acc == 8){ acc_name ='Marfori'}
	else if(acc == 9){ acc_name ='Matina'}
	else if(acc == 10){ acc_name ='Rizal'}
	else if(acc == 11){ acc_name ='San Pedro'}
	else if(acc == 12){ acc_name ='SPMC'}
	else if(acc == 13){ acc_name ='Tagum G-Mall'}
	else if(acc == 14){ acc_name ='Toril'}
	else if(acc == 15){ acc_name ='Binangkal Malasakit'}
	else if(acc == 16){ acc_name ='Habi and Kapi'}
	LOAD_INVOICE_LINE_FOR_40190(prod,COUNTER,prefix,pdate,acc_name)
}

function LOAD_INVOICE_LINE_FOR_40190(prod,COUNTER,prefix,pdate,acc)
{
	//prefix = prefix+'product: '+prod+ ' for the duration of ' +pdate + ' on the branch of '+acc;
	
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Branch: ' +acc+',<br>'+'Product: '+prod+',<br>'+'Timeline: '+ pdate);
}
//-----------------------------------------------------------PRODUCTION
//-----------------------------------------------------------PRODUCT
function GET_PRODUCT_RECORD_FOR_21010(ref,COUNTER,prefix)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', ref);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_type = 0;
				var cat = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				prod = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
				prod_type = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_HAS_RECIPE",1);
				//inventory
				if(prod_type == 1)
				{
					cat = 'For Inventory Product: '
					LOAD_PRODUCT_FOR_21010(prod,COUNTER,prefix,cat);
				}
				//finished product
				else if(prod_type == 2)
				{
					cat =  ' Finished Product: '
					LOAD_PRODUCT_FOR_21010(prod,COUNTER,prefix,cat);
				}
				//ingredient
				else if(prod_type == 3)
				{
					cat =  ' Ingredient Product: '
					LOAD_PRODUCT_FOR_21010(prod,COUNTER,prefix,cat);
				}
				//
				else(prod_type == 5)
				{
					cat =  ' Services Product: '
					LOAD_PRODUCT_FOR_21010(prod,COUNTER,prefix,cat);
				}
				
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function LOAD_PRODUCT_FOR_21010(ref,COUNTER,prefix,cat)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Product: ' +prod+',<br> Category: ' + cat);
}
//-----------------------------------------------------------PRODUCT
//-----------------------------------------------------------INVOICE LINE
function GET_INVOICE_LINE_RECORD_FOR_40310(target_id,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVOICE_LINE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVOICELIST_ID', target_id);
	JSCUS_SQL._RECORD._INVOICE_LINE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var ref = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					ref = 1;
					prod = 1;
					GET_PRODUCT_RECORD_FOR_40310(ref,prod,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					ref = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_INVOICELIST_REC_INVOICE_ID",1);
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_INVOICELIST_CAT_PRODUCT_ID",1);
					GET_PRODUCT_RECORD_FOR_40310(ref,prod,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}
function GET_PRODUCT_RECORD_FOR_40310(ref,prod,COUNTER,prefix)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', prod);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_id = 0;
				var stockflow_id = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = 1;
					//prefix = prefix + 'Product: '+prod+ ' referenced from Invoice Record: '+ref;
					LOAD_INVOICE_LINE_FOR_40310(ref,COUNTER,prefix,prod);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
					//prefix = prefix + 'Product: '+prod+ ' referenced from Invoice Record: '+ref;
					LOAD_INVOICE_LINE_FOR_40310(ref,COUNTER,prefix,prod);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function LOAD_INVOICE_LINE_FOR_40310(ref,COUNTER,prefix,prod)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Invoice Reference: ' +ref+', <br> Product: '+prod);
}
//-----------------------------------------------------------INVOICE LINE

//-----------------------------------------------------------INVOICE RECORD
function GET_INVOICE_RECORD_FOR_40290(target_id,COUNTER,prefix)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVOICE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVOICE_ID', target_id);
	JSCUS_SQL._RECORD._INVOICE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var ref = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					ref = '';
					LOAD_INVOICE_FOR_40290(ref,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					ref = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_INVOICE_REFERENCE",1);
					LOAD_INVOICE_FOR_40290(ref,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function GET_INVOICE_RECORD_FOR_40290_Edited(target_id,COUNTER,prefix)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._INVOICE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_INVOICE_ID', target_id);
	JSCUS_SQL._RECORD._INVOICE.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var ref = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					ref = '';
					LOAD_INVOICE_FOR_40290(ref,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					ref = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_INVOICE_REFERENCE",1);
					LOAD_INVOICE_FOR_40290(ref,COUNTER,prefix);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function LOAD_INVOICE_FOR_40290(ref,COUNTER,prefix)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER, 'Invoice Reference: ' +ref);
}
//-----------------------------------------------------------INVOICE RECORD

//-----------------------------------------------------------STOCK CARD
//functions 
function GET_STOCK_CARD_RECORD_FOR_40050(target_id,COUNTER,prefix)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_STOCKCARD_ID', target_id);
	JSCUS_SQL._RECORD._STOCK_CARD.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_id = 0;
				var stockflow_id = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = 1;
					stockflow = 1;
					LOAD_STOCK_CARD_FOR_40050(prod,COUNTER,prefix,stockflow);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_STOCKCARD_CAT_PRODUCT_ID",1);
					stockflow = JSRC_JSON.REF_READ(JSON_OBJECT, "REC_STOCKCARD_CAT_STOCKFLOW_ID",1);
					LOAD_STOCK_CARD_FOR_40050(prod,COUNTER,prefix,stockflow);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function GET_PRODUCT_RECORD_40050(target_id,COUNTER,prefix,stockflow)
{
	
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODUCT_ID', target_id);
	JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var prod_id = 0;
				var stockflow_id = 0;
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					prod = '';
					GET_STOCKFLOW_RECORD_40050(prod,COUNTER,prefix,stockflow);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
				else
				{
					prod = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_DESCRIPTION",1);
					GET_STOCKFLOW_RECORD_40050(prod,COUNTER,prefix,stockflow);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}

function GET_STOCKFLOW_RECORD_40050(target_id,COUNTER,prefix,stockflow)
{
	JSOC_DIALOG.VAR_LOADING_SPINNER(true); 
	var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
	JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_STOCKFLOW_ID', stockflow);
	JSCUS_SQL._CATEGORY._STOCKFLOW.CUS_GET
	(
		GET_MAP_ARRAY,
		function(IS_SUCCESS, RESPONSE_STRING)
		{				
			if(IS_SUCCESS == true)
			{
				var stockflowname = '';
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					stockflowname = '';
					LOAD_PROD_FOR_40050(prod,COUNTER,prefix,stockflowname);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);				}
				else
				{
					stockflowname = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_STOCKFLOW_DESCRIPTION",1);
					LOAD_PROD_FOR_40050(prod,COUNTER,prefix,stockflowname);
					JSOC_DIALOG.VAR_LOADING_SPINNER(false);
				}
			}
			else
			{
				JSOC_DIALOG.VAR_LOADING_SPINNER(false);
			}
		},
		true
	);
}


function LOAD_STOCK_CARD_FOR_40050(prod,COUNTER,prefix,stockflow)
{
	GET_PRODUCT_RECORD_40050(prod,COUNTER,prefix,stockflow)
}

function LOAD_PROD_FOR_40050(prod,COUNTER,prefix,stockflowname)
{
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_ACC_TRAIL_PARAMETERS_"+COUNTER, prefix);
	JSOC_ELEMENT.VAR_INNER_HTML("AUDIT_TRAIL_DGV_ROW_CUS_REFERENCE_"+COUNTER,'Product: '+prod+', <br> Stockflow: '+stockflowname);
}	
//-----------------------------------------------------------STOCK CARD	