// NOTE: [This JS must loaded as last item]


	// ===============================================================
	// Initialize Form
	// ===============================================================
	function FORM_LOAD()
	{
		// Initialize
		// _______________________________________________________________________	
		var DGV_ELEMENT_CHILD = null;
		var DGV_ELEMENT_CHILD_INDEX = 0;
		
		
		// Load DataGridVuew
		// _______________________________________________________________________	
		JSTOOL_CUSTOMIZE.DGVREORDER.APPLY("TRANS_LIST_DGV");
		TRANS_LIST_DGV = DataGridView("TRANS_LIST_DGV");
		//TRANS_LIST_DGV.SETTING_ALLOW_USER_TO_ADD_ROWS = true;
		//TRANS_LIST_DGV.SETTING_EDITABLE = true;
	

		// Auto Compute
		// _______________________________________________________________________	
		var AUTO_CALC = JSTOOL_CUSTOMIZE.DGVCALC.APPLY(TRANS_LIST_DGV);
		var AUTO_COMPUTE_BLOCKS = AUTO_CALC[0];
			
		/*
			// Sample Code
			AUTO_COMPUTE_BLOCKS.push
			(
				[
					'COLUMN_A', 					// Target Column
					'`COLUMN_1` + `COLUMN_2`',		// Math
					true							// Apply CFormat
				]
			);
		*/
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_TRANSLIST_PRICE_NET',
				'(`REC_TRANSLIST_ING_PRICE` / `REC_TRANSLIST_ING_NET_CONTENT`) * 1.1 * `REC_TRANSLIST_COST_ACTUAL`',	
				false
			]
		);
		AUTO_COMPUTE_BLOCKS.push
		(
			[
				'REC_TRANSLIST_COST_DISCREPANCY',
				'`REC_TRANSLIST_COST_ACTUAL` - `REC_TRANSLIST_COST_BASE`',	
				false
			]
		);
		TRANS_LIST_DGV.COLUMN.AUTO_COMPUTE_CREATE(AUTO_COMPUTE_BLOCKS);
		
		
		// Auto Total
		// _______________________________________________________________________	
		var AUTO_TOTAL_COLUMNS = AUTO_CALC[1];
		var AUTO_TOTAL_COPY_TO_ELEMENT = AUTO_CALC[2];
		
		/*
			AUTO_TOTAL_COLUMNS.push('COLUMN_A');					// Column to Auto Total
			AUTO_TOTAL_COPY_TO_ELEMENT.push(["COL_ID", "ELEM_ID"]);	// Source Column, Element ID where total is copied to
			
			AUTO_TOTAL_COLUMNS.push('REC_TRANSLIST_COST_BASE');
			AUTO_TOTAL_COLUMNS.push('REC_TRANSLIST_COST_ACTUAL');
			AUTO_TOTAL_COLUMNS.push('REC_TRANSLIST_COST_PC');
			AUTO_TOTAL_COLUMNS.push('REC_TRANSLIST_COST_ALLOWANCE');
			AUTO_TOTAL_COLUMNS.push('REC_TRANSLIST_PRICE_NET');
			AUTO_TOTAL_COLUMNS.push('REC_TRANSLIST_ING_PRICE');
			AUTO_TOTAL_COLUMNS.push('REC_TRANSLIST_ING_NET_CONTENT');
		*/
		/*
		TRANS_LIST_DGV.COLUMN.TOTAL_CREATE
		(
			AUTO_TOTAL_COLUMNS,
			'REC_TRANSLIST_ID',									// Column, where you want to display the caption `Total:`.
			AUTO_TOTAL_COPY_TO_ELEMENT
		);		
		*/
		
		
		TRANS_LIST_DGV.ON_CLICK
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				// Delete Button
				// ...........................................
				if(TRANS_LIST_DGV.COLUMN.NAME(COL_INDEX) == "DELETE_CMD")
				{
					// Delete Unsaved Item
					if
					(
						TRANS_LIST_DGV.COLUMN.IS_EXISTS("REC_TRANSLIST_ID") &&
						JSVC_NUM.VAR_NVALL(TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_ID", ROW_INDEX)) <= 0
					)
					{
						TRANS_LIST_DGV.ROW.REMOVE_AT(ROW_INDEX);
					}
					
					// Delete Saved Item
					else
					{
						HTTP_DELETE
						(
							function(IS_SUCCESS)
							{
								console.log('Record Deleted.');
							}, 
							ROW_INDEX
						);				
					}
				}			

				// Void Button
				// ...........................................
				else if(TRANS_LIST_DGV.COLUMN.NAME(COL_INDEX) == "VOID_CMD")
				{
					// Delete Unsaved Item
					if
					(
						TRANS_LIST_DGV.COLUMN.IS_EXISTS("REC_TRANSLIST_ID") &&
						JSVC_NUM.VAR_NVALL(TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_ID", ROW_INDEX)) <= 0
					)
					{
						TRANS_LIST_DGV.ROW.REMOVE_AT(ROW_INDEX);
					}
					
					// Void Saved Item
					else
					{

					}
				}	
				
				// Link to Child Table
				// ...........................................
				/*
				// Sample Child Code
				else if(TRANS_LIST_DGV.COLUMN.NAME(COL_INDEX) == "CHILD_CMD")
				{
					// Get Current Root path
					var CURRENT_ROOT_PATH = JSCUS_CACHE.ROOT_PATH + JSVC_STR.VAR_MID(JSVC_STR.VAR_DLEFT(JSCUS_CACHE.AUTH_REDIRECT_URL[JSCUS_CACHE.LOGIN_CLASS], JSCUS_CACHE.SERVER_URL.length), 1, 1);
			
					// Cache Primary Key
					JSVC_COOKIE.VAR_ADD
					(
						'PROPERTY_PARENT_ID', 
						TRANS_LIST_DGV.CELL.VALUE('REC_TRANSLIST_ID', ROW_INDEX), 
						5, 
						CURRENT_ROOT_PATH
					);
					JSVC_COOKIE.VAR_ADD
					(
						'PROPERTY_PARENT_DESCRIPTION', 
						TRANS_LIST_DGV.CELL.VALUE('REC_TRANSLIST_ID', ROW_INDEX), 
						5, 
						CURRENT_ROOT_PATH
					);
					
					// Open EditPage
					window.location = JSCUS_CACHE.SERVER_URL + '/p/record/trans_list.html';	
					return;
				}
				*/
			}
		);   

		TRANS_LIST_DGV.ON_CHANGE
		(			
			function(COL_INDEX, ROW_INDEX)
			{
				// Update Change Status
				// ...........................................
				EDIT_HANDLER.REF_IS_MODIFIED = true;
				
				// Update Values
				// ...........................................
				TRANS_LIST_DGV.COLUMN.AUTO_COMPUTE_EXECUTE(ROW_INDEX);
				// TRANS_LIST_DGV.COLUMN.TOTAL_REFRESH();
			}
		);
		
		
		// Show Progress
		// _______________________________________________________________________	
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		
		// Requires Authentication
		// _______________________________________________________________________	
		PAGE_AUTH_REQUIRES_LOGIN(HTTP_POPULATE_RESULT);			


		
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_TRANSLIST_REC_TRANS_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_TRANSLIST_REC_TRANS_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._TRANS.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._RECORD._TRANS.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("REC_TRANSLIST_REC_TRANS_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("TRANS_LIST_DGV_ROW_REC_TRANSLIST_REC_TRANS_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("TRANS_LIST_DGV_ROW_REC_TRANSLIST_REC_TRANS_ID");
						DGV_ELEMENT_CHILD_INDEX = 0;
						while(DGV_ELEMENT_CHILD.length > DGV_ELEMENT_CHILD_INDEX)
						{
							if
							(
								DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].tagName == "SELECT" &&
								JSVC_STR.VAR_IS_BLANK(DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].id.toString())
							)
							{
								JSOC_ELEMENT.VAR_INNER_HTML
								(
									DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX], 
									JSOC_ELEMENT.VAR_INNER_HTML("REC_TRANSLIST_REC_TRANS_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB");
						JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Trans");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_TRANSLIST_REC_TRANS_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB", 0);
						$('.BSSP_SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB').selectpicker('refresh');
					}				
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("TRANS_LIST_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("TRANS_LIST_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_REC_TRANSLIST_REC_TRANS_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"REC_TRANSLIST_REC_TRANS_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_TRANSLIST_REC_TRANS_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Trans");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._RECORD._TRANS.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._RECORD._TRANS.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('.BSSP_SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_TRANSLIST_REC_TRANS_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_TRANSLIST_CAT_PRODUCT_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_TRANSLIST_CAT_PRODUCT_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("REC_TRANSLIST_CAT_PRODUCT_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("TRANS_LIST_DGV_ROW_REC_TRANSLIST_CAT_PRODUCT_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("TRANS_LIST_DGV_ROW_REC_TRANSLIST_CAT_PRODUCT_ID");
						DGV_ELEMENT_CHILD_INDEX = 0;
						while(DGV_ELEMENT_CHILD.length > DGV_ELEMENT_CHILD_INDEX)
						{
							if
							(
								DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].tagName == "SELECT" &&
								JSVC_STR.VAR_IS_BLANK(DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].id.toString())
							)
							{
								JSOC_ELEMENT.VAR_INNER_HTML
								(
									DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX], 
									JSOC_ELEMENT.VAR_INNER_HTML("REC_TRANSLIST_CAT_PRODUCT_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB");
						JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Product");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_TRANSLIST_CAT_PRODUCT_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB", 0);
						$('.BSSP_SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB').selectpicker('refresh');
					}				
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("TRANS_LIST_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("TRANS_LIST_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_REC_TRANSLIST_CAT_PRODUCT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"REC_TRANSLIST_CAT_PRODUCT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_TRANSLIST_CAT_PRODUCT_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Product");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._CATEGORY._PRODUCT.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('.BSSP_SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_TRANSLIST_CAT_PRODUCT_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		
		// Foreign Key [Fixed]
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_TRANSLIST_CAT_UOM_ID_CMB") == true)
		{
			// Set Default Item, if used in DataGridView
			JSOC_CMB.VAR_ADD("REC_TRANSLIST_CAT_UOM_ID_CMB", FLAG_BIGINT_NULL.toString(), "-");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._UOM.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._CATEGORY._UOM.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("REC_TRANSLIST_CAT_UOM_ID_CMB", 0);
					
					// Clone to DGV Cell if ComboBox Exists
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("TRANS_LIST_DGV_ROW_REC_TRANSLIST_CAT_UOM_ID") == true)
					{
						DGV_ELEMENT_CHILD = JSOC_ELEMENT.VAR_SUB_ELEMENTS("TRANS_LIST_DGV_ROW_REC_TRANSLIST_CAT_UOM_ID");
						DGV_ELEMENT_CHILD_INDEX = 0;
						while(DGV_ELEMENT_CHILD.length > DGV_ELEMENT_CHILD_INDEX)
						{
							if
							(
								DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].tagName == "SELECT" &&
								JSVC_STR.VAR_IS_BLANK(DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX].id.toString())
							)
							{
								JSOC_ELEMENT.VAR_INNER_HTML
								(
									DGV_ELEMENT_CHILD[DGV_ELEMENT_CHILD_INDEX], 
									JSOC_ELEMENT.VAR_INNER_HTML("REC_TRANSLIST_CAT_UOM_ID_CMB")
								);
							}	
							DGV_ELEMENT_CHILD_INDEX ++;
						}
					}
					
					// Copy items to edit control
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB") == true)
					{
						JSOC_CMB.VAR_CLEAR("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB");
						JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Uom");
						JSOC_ELEMENT.VAR_INNER_HTML("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB", JSOC_ELEMENT.VAR_INNER_HTML("REC_TRANSLIST_CAT_UOM_ID_CMB"), true);
						JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB", 0);
						$('.BSSP_SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB').selectpicker('refresh');
					}				
					
					// Update Modal Settings
					if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("TRANS_LIST_MODAL") == true)
					{
						INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("TRANS_LIST_MODAL");
					}
					
					// Forward populate complete event.
					$('.BSSP_REC_TRANSLIST_CAT_UOM_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();		
				},
				"REC_TRANSLIST_CAT_UOM_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB") == true &&
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_TRANSLIST_CAT_UOM_ID_CMB") == false
		)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB", FLAG_BIGINT_NULL.toString(),"Any Uom");
			// To use custom populate
			// var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._UOM.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
			// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_', JSCUS_SQL._SYSTEM._STATUS.STATUS_ACTIVE);	
			JSCUS_SQL._CATEGORY._UOM.CUS_GET_THEN_POPULATE_COMBOBOX
			(
				function(IS_SUCCESS, RESPONSE_STRING)
				{
					// Set Default index
					JSOC_CMB.VAR_SELECTED_INDEX("SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB", 0);
					
					// Forward populate complete event.		
					$('.BSSP_SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB').selectpicker('refresh');
					HTTP_POPULATE_RESULT();
				},		
				"SEARCH_REC_TRANSLIST_CAT_UOM_ID_CMB",
				true, 2
				// , GET_MAP_ARRAY 
			);
		}
		
		// Status		
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_STATUS_CMB") == true)
		{
			JSOC_CMB.VAR_CLEAR("SEARCH_REC_TRANSLIST_STATUS_CMB");
			JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_STATUS_CMB", "0","Any Status");
			JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_STATUS_CMB", "1","Inactive");
			JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_STATUS_CMB", "2","Active");
			// JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_STATUS_CMB", "3","Closed");
			// JSOC_CMB.VAR_ADD("SEARCH_REC_TRANSLIST_STATUS_CMB", "4","Completed");
			JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_REC_TRANSLIST_STATUS_CMB", "2");
		}			
		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REC_TRANSLIST_STATUS_CMB") == true)
		{
			JSOC_CMB.VAR_CLEAR("REC_TRANSLIST_STATUS_CMB");
			JSOC_CMB.VAR_ADD("REC_TRANSLIST_STATUS_CMB", "1","Inactive");
			JSOC_CMB.VAR_ADD("REC_TRANSLIST_STATUS_CMB", "2","Active");
			// JSOC_CMB.VAR_ADD("REC_TRANSLIST_STATUS_CMB", "3","Closed");
			// JSOC_CMB.VAR_ADD("REC_TRANSLIST_STATUS_CMB", "4","Completed");
			JSOC_CMB.VAR_SELECTED_VALUE("REC_TRANSLIST_STATUS_CMB", "2");
		}
		
		
		
		// Get Modal Instance (Add Modal Adjustment before this line)
		// _______________________________________________________________________	
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("TRANS_LIST_MODAL") == true)
		{
			INPUT_INSTANCE = JSOC_WINDOW.VAR_INPUT_INSTANCE_CLONE("TRANS_LIST_MODAL");
		}
		
		// Add Search Events for the SEARCH_DESCRIPTION_TXT - TextInput
		// _______________________________________________________________________		
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_REC_TRANSLIST_ID_TXT"))
		{
			var SEARCH_REC_TRANSLIST_ID_TXT = JSOC_ELEMENT.VAR_GET("SEARCH_REC_TRANSLIST_ID_TXT");
			SEARCH_REC_TRANSLIST_ID_TXT.onkeydown = 
				function() 
				{ 
					return function(e) 
					{
						if
						(
							(
								e.which == 13 || 
								e.keyCode == 13 || 
								e.key === "Enter"
							) &&
							JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_CMD")
						)
						{
							HTTP_SEARCH();
						}
					};
				}();
		}
		
		
		// Pre-Load Items (uncomment if no foreign key pre-fetch)
		// _______________________________________________________________________	
		if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
		{
			HTTP_SEARCH();
		}
		
		
		// Disable Dialogs
		// _______________________________________________________________________	
		CUS_SEND_DIALOG_TRY_DISMISS();
	};
	
	
	// ===============================================================
	// Populate Foreign Keys
	// ===============================================================
	function HTTP_POPULATE_RESULT(IS_SUCCESS, HTTP_RESPONSE)
	{
		// Disable Dialogs
		CUS_SEND_DIALOG_TRY_DISMISS();
			
		// Handle Error
		if(IS_SUCCESS === false)
		{
			alert("Unable to populate lists.");
		}
		else
		{
			// Disable Dialogs
			if(CUS_SEND_REQUEST_HAS_QUEUE() == false)
			{
				HTTP_SEARCH();
			}
		}
	};

	
	// ===============================================================
	// Request Search - PART.A
	// ===============================================================
	function HTTP_SEARCH()
	{
		// Callback method
		// _______________________________________________________________________
		var CALLBACK_METHOD = function(IS_SUCCESS, RESPONSE_STRING, KEEP_DGV_ITEMS = false)
		{
			// Disable Dialogs
			// ...........................................
			CUS_SEND_DIALOG_TRY_DISMISS();
			
			// Validate
			// ...........................................
			if(IS_SUCCESS === false)
			{
				console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
				return;
			}
			
			// Validate JSON Response
			// ...........................................
			var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
			if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
			{
				console.error("REQUEST ERROR: \n" + RESPONSE_STRING);
				return;
			}
			
			// Back to DGV Top
			// ...........................................
			JSOC_ELEMENT.VAR_GET("TRANS_LIST_DGV").scrollIntoView
			(
				{
			  		behavior: 'auto', 
			  		block: 'start'
				}
			);		
			
			// JSON Empty (Clears the DataGrodView)
			// ...........................................
			if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
			{
				HTTP_MIXTURE_SEARCH();
				return;
			}
			
			// Populate DGV
			// ...........................................
			TRANS_LIST_DGV.POPULATE_FROM_QUERY
			(
					JSON_OBJECT, 
					'',
					KEEP_DGV_ITEMS,
					false,
					1,
					[2, 1]
			);
			
			// For Applying CFormat
			// ...........................................	
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_COST_BASE");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_COST_PC");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_COST_ALLOWANCE");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_PRICE_NET");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_ING_PRICE");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_ING_NET_CONTENT");
			
			// Initialize
			// ...........................................
			var WEBTABLE_DATE = null;
			var CURRENT_CELL_VALUE = null;
			var ROW_INDEX = 0;
			
			
			// Color Coding (Uncomment to use)
			// ...........................................
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
	
	
			// Auto-total tool
			// ...........................................
			if(TRANS_LIST_DGV.COLUMN.TOTAL_IS_READY())
			{
				TRANS_LIST_DGV.COLUMN.TOTAL_REFRESH();
			}
		};
		
		
		// Actual Function
		// _______________________________________________________________________
		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_REC_TRANS_ID', PROPERTY_PARENT_ID);
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				
		// REGULAR Search Mode
		// _______________________________________________________________________		
		JSCUS_SQL._RECORD._TRANS_LIST.CUS_GET
		(
			GET_MAP_ARRAY,
			CALLBACK_METHOD
		); 			

	};


	// ===============================================================
	// Request Search - PART.A
	// ===============================================================
	function HTTP_MIXTURE_SEARCH()
	{
		// Callback method
		// _______________________________________________________________________
		var CALLBACK_METHOD = function(IS_SUCCESS, RESPONSE_STRING, KEEP_DGV_ITEMS = false)
		{
			// Disable Dialogs
			// ...........................................
			CUS_SEND_DIALOG_TRY_DISMISS();
			
			// Validate
			// ...........................................
			if(IS_SUCCESS === false)
			{
				console.error("CONNECTION ERROR: \n" + RESPONSE_STRING);
				return;
			}
			
			// Validate JSON Response
			// ...........................................
			var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
			if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
			{
				console.error("REQUEST ERROR: \n" + RESPONSE_STRING);
				return;
			}
			
			// Back to DGV Top
			// ...........................................
			JSOC_ELEMENT.VAR_GET("TRANS_LIST_DGV").scrollIntoView
			(
				{
			  		behavior: 'auto', 
			  		block: 'start'
				}
			);		
			
			// JSON Empty (Clears the DataGrodView)
			// ...........................................
			if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
			{
				TRANS_LIST_DGV.ROW.CLEAR();
				if(TRANS_LIST_DGV.COLUMN.TOTAL_IS_READY())
				{
					TRANS_LIST_DGV.COLUMN.TOTAL_REFRESH();
				}
				return;
			}
			
			
			// Initialize
			// ...........................................
			var WEBTABLE_DATE = null;
			var CURRENT_CELL_VALUE = null;
			var JSON_COUNT = JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "JSON_COUNT");
			var JSON_INDEX = 1;
			var ROW_INDEX = 0;
			
			
			// Populate DGV
			// ...........................................
			TRANS_LIST_DGV.ROW.CLEAR();
			while(JSON_COUNT >= JSON_INDEX)
			{
				TRANS_LIST_DGV.ROW.ADD();
				ROW_INDEX = TRANS_LIST_DGV.ROW.COUNT() - 1;
				
				TRANS_LIST_DGV.CELL.VALUE("ROW_COUNT", ROW_INDEX, ROW_INDEX + 1);
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_ID", ROW_INDEX, "-1");
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_REC_TRANS_ID", ROW_INDEX, PROPERTY_PARENT_ID);
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_CAT_PRODUCT_ID", ROW_INDEX, JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID", JSON_INDEX));
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_CAT_UOM_ID", ROW_INDEX, JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_CAT_UOM_ID", JSON_INDEX));
				
				TRANS_LIST_DGV.CELL.VALUE("CAT_PRODUCT_DESCRIPTION", ROW_INDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_DESCRIPTION", JSON_INDEX));
				
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_COST_ACTUAL", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_QUANTITY", JSON_INDEX));
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_COST_BASE", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_QUANTITY", JSON_INDEX));
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_COST_DISCREPANCY", ROW_INDEX, 0);
				
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_ING_PRICE", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_PRICE", JSON_INDEX));
				TRANS_LIST_DGV.CELL.VALUE("REC_TRANSLIST_ING_NET_CONTENT", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_NET_CONTENT", JSON_INDEX));
				TRANS_LIST_DGV.CELL.VALUE("CAT_UOM_DESCRIPTION", ROW_INDEX, JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_UOM_DESCRIPTION", JSON_INDEX));	
				
				TRANS_LIST_DGV.CELL.VALUE
				(
					"REC_TRANSLIST_COST_PC", ROW_INDEX, 
					JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_PRICE", JSON_INDEX) / 
					JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_NET_CONTENT", JSON_INDEX)
				);
				TRANS_LIST_DGV.CELL.VALUE
				(
					"REC_TRANSLIST_COST_ALLOWANCE", ROW_INDEX, 
					(
						JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_PRICE", JSON_INDEX) / 
						JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_NET_CONTENT", JSON_INDEX)
					) * 1.1
				);
				TRANS_LIST_DGV.CELL.VALUE
				(
					"REC_TRANSLIST_PRICE_NET", ROW_INDEX, 
					(
						JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_PRICE", JSON_INDEX) / 
						JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_ING_CAT_PRODUCT_ID_CAT_PRODUCT_ING_NET_CONTENT", JSON_INDEX)
					) * 1.1 * JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "CAT_MIXTURE_QUANTITY", JSON_INDEX)
				);
				
				JSON_INDEX ++;	
			}


			// For Applying CFormat
			// ...........................................	
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_COST_BASE");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_COST_PC");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_COST_ALLOWANCE");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_PRICE_NET");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_ING_PRICE");
			TRANS_LIST_DGV.COLUMN.CFORMAT("REC_TRANSLIST_ING_NET_CONTENT");
			

			
			// Color Coding (Uncomment to use)
			// ...........................................
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#1cc88a"; // Safe
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#5a5c69"; // Neutral
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#f6c23e"; // Caution
			//TRANS_LIST_DGV.CELL.ELEMENT("COLUMN_NAME", ROW_INDEX).style.color = "#e74a3b"; // Warning
	
	
			// Auto-total tool
			// ...........................................
			if(TRANS_LIST_DGV.COLUMN.TOTAL_IS_READY())
			{
				TRANS_LIST_DGV.COLUMN.TOTAL_REFRESH();
			}
			EDIT_HANDLER.REF_IS_MODIFIED = true;
		};
		
		// Actual Function
		// _______________________________________________________________________
		GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._MIXTURE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();			
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_MIXTURE_BASE_CAT_PRODUCT_ID', PROPERTY_CAT_PRODUCT_ID);
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				
		// REGULAR Search Mode
		// _______________________________________________________________________		
		JSCUS_SQL._CATEGORY._MIXTURE.CUS_GET
		(
			GET_MAP_ARRAY,
			CALLBACK_METHOD
		); 			

	};
	
		
	// ===============================================================
	// Begin Processing the Page
	// ===============================================================
	FORM_INITIALIZE();
	FORM_LOAD();