	
	function IF_EXISTS(CALLBACK_METHOD, R_INDEX)
	{
		var GET_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();	
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_ACC_GROUP_ID", PROPERTY_PARENT_ID);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_CAT_PRODUCT_ID", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_CAT_PRODUCT_ID', R_INDEX)));
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_CAT_PRICEMDL_ID", JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_CAT_PRICEMDL_ID_CMB")));
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_STATUS", 1);

		// Declare Post Request Handler
		// _______________________________________________________________________
		var IF_EXISTS_RESPONSE = 			
			function(IS_SUCCESS, RESPONSE_STRING)
			{
				// Validate
				// _______________________________________________________________________
				if(IS_SUCCESS === false)
				{
					alert("CONNECTION ERROR: \n" + RESPONSE_STRING);
					CALLBACK_METHOD(false);
					return;
				}
				
				// Validate JSON Response
				// _______________________________________________________________________
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					alert("REQUEST ERROR: \n" + RESPONSE_STRING);
					CALLBACK_METHOD(false);
					return;
				}
				
				// JSON Empty (Clears the DataGrodView)
				// _______________________________________________________________________
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					HTTP_SAVE(CALLBACK_METHOD, R_INDEX, true);
				}
				// Read Response And Assign ID
				// ...........................................
				else
				{
					//ASSIGN ID IN GRID
					PRODUCT_BRANCH_DGV.CELL.VALUE("CAT_PRODBRANCH_ID", R_INDEX, JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODBRANCH_ID", 1)));
					HTTP_SAVE(CALLBACK_METHOD, R_INDEX, true);
				}
			};

		JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_GET
		(
			GET_MAP_ARRAY,
			IF_EXISTS_RESPONSE,
			true
		); 
	}

	function HTTP_SAVE(CALLBACK_METHOD, R_INDEX, ITEM_IDENTIFIER)
	{
		if(ITEM_IDENTIFIER === false)
		{
			//CHECK IF EDITED
			if
			(
				JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_AMOUNT_PRICE_HOLDER', R_INDEX)) == JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_AMOUNT_PRICE', R_INDEX)) &&
				JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_REORDER_POINT_HOLDER', R_INDEX)) == JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_REORDER_POINT', R_INDEX)) &&
				JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_REORDER_QUANTITY_HOLDER', R_INDEX)) == JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_REORDER_QUANTITY', R_INDEX)) 
			)
			{
				CALLBACK_METHOD(true);
				return;
			}
		}

		// Save item [Prepare]
		// _______________________________________________________________________
		var SAVE_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_ID", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_ID', R_INDEX)));				
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_ACC_GROUP_ID", PROPERTY_PARENT_ID);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_CAT_PRICEMDL_ID", JSVC_NUM.VAR_NVAL(JSOC_CMB.VAR_SELECTED_VALUE("SEARCH_CAT_PRICEMDL_ID_CMB")));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_CAT_PRODUCT_ID", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_CAT_PRODUCT_ID', R_INDEX)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_AMOUNT_PRICE", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_AMOUNT_PRICE', R_INDEX)));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_REORDER_POINT", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_REORDER_POINT', R_INDEX)));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_REORDER_QUANTITY", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_REORDER_QUANTITY', R_INDEX)));	
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_STATUS", 2); //ALWAYS ACTIVE PAG INSERT
		
		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = 			
			function(IS_SUCCESS, HTTP_RESPONSE)
			{
				// Handle Error
				// ...........................................
				if(IS_SUCCESS === false)
				{
					METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);	
					return;
				}
				
				// Catch JSON Error
				// ...........................................
				else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
				{
					METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
					return;			
				}
					
				// Read Response
				// ...........................................
				else
				{
					// Load Response
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
					{
						METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
						return;
					}
					// Post Save Action
					else
					{
						//GET INSERTED ID IF LINE DONT HAVE ID
						if(JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_ID', R_INDEX)) <= 0)
						{
							PRODUCT_BRANCH_DGV.CELL.VALUE("CAT_PRODBRANCH_ID", R_INDEX, JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1")));
						}

						CALLBACK_METHOD(true);										
					}
				}
			};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
	}

	function HTTP_DELETE(CALLBACK_METHOD, ROW_INDEX)
	{
		// Escape if nothing selected
		// _______________________________________________________________________
		if(ROW_INDEX < 0)
		{
			JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_NOTHING_SELECTED(true);
			CALLBACK_METHOD(false);
			return;
		}

		var SAVE_MAP_ARRAY = JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_ID", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_ID', ROW_INDEX)));				
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_CAT_PRODBRANCH_STATUS", 1); //DEACTIVATE

		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = function
		(
			IS_SUCCESS, 
			HTTP_RESPONSE
		)
		{
			// Disable Dialogs
			// ...........................................
			CUS_SEND_DIALOG_TRY_DISMISS();
				
			// Handle Error
			// ...........................................
			if(IS_SUCCESS === false)
			{
				METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);
				return;
			}
			// Catch JSON Error
			// ...........................................
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
				return;			
			}
			// Read Response
			// ...........................................
			else
			{
				// Load Response
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
					return;
				}
				// Post Delete Action
				else
				{
					PRODUCT_BRANCH_DGV.ROW.REMOVE_AT(ROW_INDEX);
					PRODUCT_BRANCH_DGV.COLUMN.ROW_COUNT_PRINT('ROW_COUNT');
				}
			}
		};

		// Request User Verification for Delete
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_MESSAGE_BOX
		(
			'Are you sure you want to deactivate this product?', 
			'Information',
			'YES NO', 'QUESTION',
			function(MESSAGE_RESPONSE)
			{
				if(MESSAGE_RESPONSE == 2)
				{
					JSOC_DIALOG.VAR_LOADING_SPINNER(true);
					JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_SAVE 
					(
						SAVE_MAP_ARRAY,
						RESPONSE_HANDLER
					);
				}
			}
		);
	}