	// ===============================================================
	// Load Parent Information Flags
	// ===============================================================	
	function HTTP_PARENT_LOAD()
	{
	}
	

	// ===============================================================
	// EditHandler Flags
	// ===============================================================	
	function HTTP_LOAD()
	{
		// Escape if new item
		// ...........................................
		if(JSRC_FLAG.IS_NULL_BIGINT(PROPERTY_REC_PORDER_ID, 1, 1))
		{
			return;
		}
		
		
		// Load DB data of item
		// ...........................................
		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_REC_PORDER_ID', PROPERTY_REC_PORDER_ID);

		// 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;
					}
					else
					{
						PRODUCT_BRANCH_DGV.ROW.CLEAR();

						PO_ORDER_LIST_DGV.POPULATE_FROM_QUERY
						(
							JSON_OBJECT, 
							'',
							false,
							false,
							1,
							[2, 1]
						);

						PO_ORDER_LIST_DGV.COLUMN.CFORMAT("REC_PORDER_LIST_QUANTITY_EXPECT");
					}
				}
			};


		JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);

		// Clear Changes due to loading
		// ...........................................
	}

	// ===============================================================
	// New Item Handler Flags
	// ===============================================================	
	function HTTP_NEW_LOAD(CALLBACK_FUNCTION)
	{		
		// Load DB data of item
		// ...........................................
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		
		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', JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID));
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_STATUS', 2);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_CAT_PRODBRANCH_CAT_PRICEMDL_ID', 1);
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_FIELD', 'CAT_PRODUCT_DESCRIPTION');
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_ORDER_TYPE', 'ASC');

		// 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;
					}
					else
					{
						PO_ORDER_LIST_DGV.ROW.CLEAR();

						PRODUCT_BRANCH_DGV.POPULATE_FROM_QUERY
						(
							JSON_OBJECT, 
							'',
							false,
							false,
							1,
							[2, 1]
						);

						var WEBTABLE_DATE = null;
						var ROW_INDEX = 0;

						while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
						{
							if(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_CAT_PRODUCT_ID_DESCRIPTION', ROW_INDEX).includes(" (Free)") == true)
							{
								$('#PRODUCT_BRANCH_DGV_ROW_'+JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('ROW_COUNT', ROW_INDEX))).addClass('d-none');
							}
							
							/*if
							(
								JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_IS_INVENTORY_ONLY", ROW_INDEX)) == 1 && 
								JSVC_NUM.VAR_NVAL(JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_AMOUNT_PRICE", ROW_INDEX)) == 0
							)
							{
								$('#PRODUCT_BRANCH_DGV_ROW_'+JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('ROW_COUNT', ROW_INDEX))).addClass('d-none');
							}
							else {
								if(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_CAT_PRODUCT_ID_DESCRIPTION', ROW_INDEX).includes("Free"))
								{
									$('#PRODUCT_BRANCH_DGV_ROW_'+JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('ROW_COUNT', ROW_INDEX))).addClass('d-none');
								}
							}*/
							

							ROW_INDEX ++;
						}

						CALLBACK_FUNCTION(true);
					}
				}
			};


		JSCUS_SQL._CATEGORY._PRODUCT_BRANCH.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);

		// Clear Changes due to loading
		// ...........................................
	}


	// ===============================================================
	// Trims empty spaces and perform convertion for numeric fields.
	// ===============================================================
	function FIX_INPUT()
	{
		// Fix String Fields
		// ...........................................
		
		
		// Fix Numeric Fields (if field type is not number.)
		// ...........................................


		// Fix Password Fields
		// ...........................................
	}

		
	// ===============================================================
	// Request Save
	// ===============================================================
	function HTTP_SAVE(CALLBACK_METHOD)
	{
		if(PROPERTY_REC_PORDER_ID > 0) {
			if(PO_ORDER_LIST_DGV.COLUMN.SUM("REC_PORDER_LIST_QUANTITY_EXPECT") == 0)
			{
				JSOC_DIALOG.VAR_MESSAGE_BOX
				(
					'Nothing to save.',
					'Information',
					'OK', 'ERROR',
					function()
					{
						CALLBACK_METHOD(false);
					}
				);
				return;
			}
		}
		else {
			if(PRODUCT_BRANCH_DGV.COLUMN.SUM("CAT_PRODBRANCH_QUANTITY") == 0)
			{
				JSOC_DIALOG.VAR_MESSAGE_BOX
				(
					'Nothing to save.',
					'Information',
					'OK', 'ERROR',
					function()
					{
						CALLBACK_METHOD(false);
					}
				);
				return;
			}
		}
		 
		
		// Save item [Prepare]
		// _______________________________________________________________________
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

		if(PROPERTY_REC_PORDER_ID > 0)
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_ID", PROPERTY_REC_PORDER_ID);
		
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_DATE_EXPECT", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE("REC_PORDER_DATE_EXPECT_DTP")), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_REMARKS", JSOC_ELEMENT.VAR_VALUE("REC_PORDER_REMARKS_TXT"));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_STATUS", 1);
		/*if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_REC_PORDER_ID_FILE_FP"))
		{
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_ID_FILE", PARAM_REC_PORDER_ID_FILE_FP);
		}*/
		
		
		// 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 Save Action
					else
					{		
						var PARENT_ID_HOLDER = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1"));
						HTTP_SAVE_LIST(CALLBACK_METHOD, PARENT_ID_HOLDER);									
					}
				}
			};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._PO_ORDER.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);
		
	}


	function HTTP_SAVE_LIST(CALLBACK_METHOD, PARENT_ID_HOLDER)
	{
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];

		var ROW_INDEX = 0;

		if(PRODUCT_BRANCH_DGV.COLUMN.SUM("CAT_PRODBRANCH_QUANTITY") > 0)
		{
			while(PRODUCT_BRANCH_DGV.ROW.COUNT() > ROW_INDEX)
			{
				if(PRODUCT_BRANCH_DGV.CELL.VALUE("CAT_PRODBRANCH_QUANTITY", ROW_INDEX) > 0)
				{
					SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_REC_PORDER_ID", PARENT_ID_HOLDER);
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_CAT_PRODUCT_ID", JSVC_NUM.VAR_NVALL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_CAT_PRODUCT_ID', ROW_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_COST", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE('CAT_PRODBRANCH_AMOUNT_PRICE', ROW_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_QUANTITY_EXPECT", JSVC_NUM.VAR_NVAL(PRODUCT_BRANCH_DGV.CELL.VALUE("CAT_PRODBRANCH_QUANTITY", ROW_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_STATUS", 2); // 2 - default.

					BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);
				}

				ROW_INDEX++;
			}
		}
		
		if(PO_ORDER_LIST_DGV.COLUMN.SUM("REC_PORDER_LIST_QUANTITY_EXPECT") > 0)
		{
			while(PO_ORDER_LIST_DGV.ROW.COUNT() > ROW_INDEX)
			{
				if(PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_QUANTITY_EXPECT", ROW_INDEX) > 0)
				{
					SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_ID", JSVC_NUM.VAR_NVALL(PO_ORDER_LIST_DGV.CELL.VALUE('REC_PORDER_LIST_ID', ROW_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_REC_PORDER_ID", PARENT_ID_HOLDER);
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_CAT_PRODUCT_ID", JSVC_NUM.VAR_NVALL(PO_ORDER_LIST_DGV.CELL.VALUE('REC_PORDER_LIST_CAT_PRODUCT_ID', ROW_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_COST", JSVC_NUM.VAR_NVAL(PO_ORDER_LIST_DGV.CELL.VALUE('REC_PORDER_LIST_COST', ROW_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_QUANTITY_EXPECT", JSVC_NUM.VAR_NVAL(PO_ORDER_LIST_DGV.CELL.VALUE("REC_PORDER_LIST_QUANTITY_EXPECT", ROW_INDEX)));
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PORDER_LIST_STATUS", 2); // 2 - default.

					BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);
				}

				ROW_INDEX++;
			}
		}

		// 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 Save Action
					else
					{				
						// Add new line
						HTTP_SEARCH();

						// Lift edit and Exit EditMode
						EDIT_HANDLER.REF_IS_MODIFIED = false;
						EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;			
						if
						(
							JSOC_ELEMENT.VAR_ELEMENT_EXISTS('PO_ORDER_MODAL') == true
						)
						{
							JSOC_DIALOG.VAR_MODAL('PO_ORDER_MODAL', false);
						}
						
						//SWAP_EDIT_MODE(false);
						CALLBACK_METHOD(true);											
					}
				}
			};


		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._PO_ORDER_LIST.CUS_SAVE
		(
			BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
	}
	
	
	// ===============================================================
	// Request Delete
	// ===============================================================
	/*function HTTP_DELETE(CALLBACK_METHOD, ROW_INDEX)
	{
		// Escape if Disabled
		// _______________________________________________________________________
		if(JSVC_VAR.VAR_ISSET(DELETE_BBI) && DELETE_BBI.Enabled == false)
		{
			CALLBACK_METHOD(false);
			return;
		}

		// Escape if nothing selected
		// _______________________________________________________________________
		if(ROW_INDEX < 0)
		{
			JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_NOTHING_SELECTED(true);
			CALLBACK_METHOD(false);
			return;
		}
		
		// Initialize
		// _______________________________________________________________________
		var DELETE_ITEM_DESCRIPTION = PO_ORDER_DGV.CELL.VALUE('REC_PORDER_CODE', ROW_INDEX);
		
		
		
		// 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
				{
					PO_ORDER_DGV.ROW.REMOVE_AT(ROW_INDEX);
					PO_ORDER_DGV.COLUMN.ROW_COUNT_PRINT('ROW_COUNT');
					JSVC_INFO.VAR_RECORD_DELETED
					(
						DELETE_ITEM_DESCRIPTION, 
						function()
						{
							CALLBACK_METHOD(true);
						}
					);		
				}
			}
		};
		
		
		// Request User Verification for Delete
		// _______________________________________________________________________
		JSVC_INFO.VAR_VERIFY_DELETE
		(
			DELETE_ITEM_DESCRIPTION,
			function(VERIFY_RESULT) 
			{
				// Abort if rejected by user.
				// ...........................................
				if(VERIFY_RESULT != JSOC_DIALOG.MSGBOX_YES)
				{

					CALLBACK_METHOD(false);
					return;
				}
				
				
				//Delete Item
				// ...........................................
				JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				JSCUS_SQL._RECORD._PO_ORDER.CUS_DELETE
				(
					PO_ORDER_DGV.CELL.VALUE('REC_PORDER_ID', ROW_INDEX),
					RESPONSE_HANDLER
				)
			}
		);
	}*/
	
	
	// ===============================================================
	// Request Void
	// ===============================================================
	/*function HTTP_VOID(CALLBACK_METHOD, ROW_INDEX)
	{
		
		// Escape if Disabled
		// _______________________________________________________________________
		if
		(
			JSVC_VAR.VAR_ISSET(PO_ORDER_DGV.CELL.ELEMENT('REC_PORDER_STATUS', ROW_INDEX)) && 
			PO_ORDER_DGV.CELL.ELEMENT('REC_PORDER_STATUS', ROW_INDEX).Enabled == false
		)
		{
			CALLBACK_METHOD(false);
			return;
		}

		// Escape if nothing selected
		// _______________________________________________________________________
		if(ROW_INDEX < 0)
		{
			JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_NOTHING_SELECTED(true);
			CALLBACK_METHOD(false);
			return;
		}
		
		// Abort if already Voided (Status = 3)
		// _______________________________________________________________________
		if(PO_ORDER_DGV.CELL.VALUE('REC_PORDER_STATUS', ROW_INDEX) == 3)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'This item is already Voided', 
				'Information',
				'OK', 'INFO',
				null
			);		
			return;
		}		
		
		// Notify User to Void	
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_MESSAGE_BOX
		(
			'Do you want to void the selected item?', 
			'Information',
			'YESNO', 'QUESTION',
			function(VERIFY_RESULT)
			{
				if(VERIFY_RESULT == JSOC_DIALOG.MSGBOX_YES)
				{
					PROPERTY_REC_VOUCHER_ID = PO_ORDER_DGV.CELL.VALUE('5077', ROW_INDEX);
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;
					HTTP_LOAD
					(
						function()
						{
							JSOC_CMB.VAR_SELECTED_VALUE(REC_PORDER_STATUS_CMB, 3);
							JSOC_DIALOG.VAR_MODAL("PO_ORDER_MODAL", true);
							EDIT_HANDLER.REF_IS_MODIFIED = true;				
						}
					);
				}
			}
		);
		
	}*/

	
	// ===============================================================
	// End Shift
	// ===============================================================
	function HTTP_END_SHIFT()
	{
		var cents = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_CENTS"]').val());
		var ones = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_1"]').val());
		var fives = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_5"]').val());
		var tens = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_10"]').val());
		var twenties = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_20"]').val());
		var fifties = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_50"]').val());
		var hundreds = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_100"]').val());
		var twohundreds = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_200"]').val());
		var fivehundreds = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_500"]').val());
		var thousands = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_1000"]').val());
		var check_qty = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_CHECKS_QTY"]').val());
		var check_amt = JSVC_NUM.VAR_NVAL($('#CASH_BREAKDOWN_MODAL input[id="CASHBREAKDOWN_CHECKS"]').val());

		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_SHIFT.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_ACC_GROUP_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ACC_GROUP_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_ACC_DEVICE_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_ACC_ACCOUNT_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_ID", SHIFT_ID);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_TIME_END", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_TO_DATE(JSOC_ELEMENT.VAR_VALUE('SHIFT_END_END_TIME')), "YYYY-MM-DD HH:mm:ss"));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_1KS", thousands);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_500S", fivehundreds);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_200S", twohundreds);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_100S", hundreds);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_50S", fifties);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_20S", twenties);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_10S", tens);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_5S", fives);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_1S", ones);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_CENTS", cents);			
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_CHECK_COUNT", check_qty);			
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_CREDIT_CHECK_AMOUNT", check_amt);	

		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_SHIFT_STATUS", 1); //log out

		var RESPONSE_HANDLER =
			function(IS_SUCCESS, RESPONSE_STRING)
			{
				if(IS_SUCCESS === false) {
					alert("CONNECTION ERROR: \n" + RESPONSE_STRING);
					return;
				}

				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);

				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false) {
					alert("REQUEST ERROR: \n" + RESPONSE_STRING); 
					return;
				}
				else {
					var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
																
					if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false) {
						METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
						return;
					}

					JSOC_DIALOG.VAR_MODAL("SHIFT_END_MODAL_2", false);
					JSCUS_SQL._ACCOUNT._LOGIN.CUS_LOGOUT(CUS_SEND_DIALOG_TRY_DISMISS(), JSCUS_CACHE.LOGOUT_REDIRECT_URL[JSCUS_CACHE.LOGIN_CLASS]);
				}
			};

		JSCUS_SQL._RECORD._POS_SHIFT.CUS_SAVE
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
	}


	// ===============================================================
	// Calculate Cash Breakdown
	// ===============================================================
	function HTTP_CALCULATE_CASH(id)
	{
		var input = $('#SHIFT_END_MODAL input[id="'+id+'"]');
		var output = $('#SHIFT_END_MODAL input[id="'+id+'_TOTAL"]');

		var amount = JSVC_NUM.VAR_NVAL(id.replace('CASHBREAKDOWN_', ''));
		var multiplier = JSVC_NUM.VAR_NVAL(input.val());

		var TOTAL = 0;

		if(id === 'CASHBREAKDOWN_CENTS')
			TOTAL = multiplier * 0.01;
		else if(id === 'CASHBREAKDOWN_CHECKS')
			TOTAL = multiplier;
		else
			TOTAL = amount * multiplier;

		output.val(TOTAL);
		output.next().html(JSVC_NUM.VAR_FORMAT(TOTAL, 2));

		HTTP_CALCULATE_TOTAL_CASH();
	}

	function HTTP_CALCULATE_TOTAL_CASH() 
	{
		var output = $('#SHIFT_END_MODAL #CASHBREAKDOWN_TOTAL');
		var amounts = [1000, 500, 200, 100, 50, 20, 10, 5, 1, 'CENTS', 'CHECKS'];

		var TOTAL = 0;
		var value = 0;
		
		$.each(amounts, function(i, item) {
			value = JSVC_NUM.VAR_NVAL($('input[id="CASHBREAKDOWN_'+item+'_TOTAL"]').val());
			TOTAL += value;
		});

		//send to end shift modal
		SHIFT_TIME_END_AMOUNT = TOTAL;
		output.html(JSVC_NUM.VAR_CFORMAT(TOTAL));
	}


	// ===============================================================
	// Print Cash Breakdown
	// ===============================================================
	function HTTP_PRINT_CASHBREAKDOWN(CALLBACK_METHOD)
	{
		var RECEIPT = '';

		var REPORT_DATE = JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss") + '.999999';;

		var DENOMINATIONS = [1000, 500, 200, 100, 50, 20, 10, 5, 1, 'CENTS', 'CHECKS'];
		var SUBTOTAL = 0;

		var TOTAL = 0;
		var QTY = 0;

		RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			RECEIPT += '<tr><td style="text-align: center;">'+JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_DESCRIPTION+'</td></tr>';
			RECEIPT += '<tr><td style="text-align: center;">'+JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ADDRESS+'</td></tr>';
			RECEIPT += '<tr><td style="text-align: center;">'+JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_CONTACT+'</td></tr>';
			RECEIPT += '<tr><td style="text-align: center;">VAT Reg TIN: '+JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_TIN+'</td></tr>';
		RECEIPT += '</table>';

		RECEIPT += '<br>';
		
		RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			RECEIPT += '<tr><td style="text-align: center;">CASH BREAKDOWN</td></tr>';
		RECEIPT += '</table>';

		RECEIPT += '<hr style="border: 1px dashed black;">';

		RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			RECEIPT += '<tr><td>DATE AND TIME: '+JSVC_DATE.VAR_FORMAT(REPORT_DATE, "MMM DD, YYYY hh:mm TT")+'</td></tr>';
			RECEIPT += '<tr><td>CASHIER: '+JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_NAME+'</td></tr>';
			RECEIPT += '<tr><td>TERMINAL ID: '+JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_MACHINE_ID+'</td></tr>';
		RECEIPT += '</table>';

		RECEIPT += '<hr style="border: 1px dashed black;">';
		RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 0 !important;">';

		$.each(DENOMINATIONS, function(i, item) {
			TOTAL = JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE('CASHBREAKDOWN_'+item+'_TOTAL'));
			QTY = JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE('CASHBREAKDOWN_'+item));

			if(item === 'CENTS') {
				RECEIPT += '<tr>';
					RECEIPT += '<td colspan="3" style="text-align: left; vertical-align: middle; width: 60%;">'+item+'</td>';
					RECEIPT += '<td style="text-align: center; vertical-align: middle; width: 20%;">=</td>'
					RECEIPT += '<td width="20%" style="text-align: right; vertical-align: middle;">'+JSVC_NUM.VAR_CFORMAT(TOTAL)+'</td>';
				RECEIPT += '</tr>';
			}
			else if(item === 'CHECKS') {
				RECEIPT += '<tr>';
					RECEIPT += '<td style="text-left: right; vertical-align: middle; width: 20%;">'+item+'</td>';
					RECEIPT += '<td style="text-align: center; vertical-align: middle; width: 20%;"><small>QTY: '+JSOC_ELEMENT.VAR_VALUE('CASHBREAKDOWN_CHECKS_QTY')+'</small></td>';
					RECEIPT += '<td width="20%" style="text-align: right; vertical-align: middle;">'+JSVC_NUM.VAR_CFORMAT(QTY)+'</td>';
					RECEIPT += '<td style="text-align: center; vertical-align: middle; width: 10%;">=</td>'
					RECEIPT += '<td style="text-align: right; vertical-align: middle; width: 20%;">'+JSVC_NUM.VAR_CFORMAT(TOTAL)+'</td>';
				RECEIPT += '</tr>';
			}
			else {
				RECEIPT += '<tr>';
					RECEIPT += '<td style="text-align: right; vertical-align: middle; width: 20%;">'+JSVC_NUM.VAR_CFORMAT(item)+'</td>';
					RECEIPT += '<td style="text-align: center; vertical-align: middle; width: 20%;">x</td>';
					RECEIPT += '<td style="text-align: right; vertical-align: middle; width: 20%;">'+JSVC_NUM.VAR_CFORMAT(QTY)+'</td>';
					RECEIPT += '<td style="text-align: center; vertical-align: middle; width: 20%;">=</td>'
					RECEIPT += '<td style="text-align: right; vertical-align: middle; width: 20%;">'+JSVC_NUM.VAR_CFORMAT(TOTAL)+'</td>';
				RECEIPT += '</tr>';
			}

			SUBTOTAL += TOTAL;
		});

		RECEIPT += '</table>';

		RECEIPT += '<hr style="border: 1px dashed black;">';

		RECEIPT += '<table border="0" style="width: 100%; border-collapse: collapse; font-size: 10px; margin-bottom: 0 !important;">';
			RECEIPT += '<thead>';
				RECEIPT += '<tr><td style="width: 60%">TOTAL: </td><td style="width: 40%; text-align: right;">'+JSVC_NUM.VAR_CFORMAT(SUBTOTAL)+'</td></tr>';
			RECEIPT += '</thead>';
		RECEIPT += '</table>';

		JSOC_DIALOG.VAR_MODAL("SHIFT_END_MODAL", false);
		JSOC_DIALOG.VAR_LOADING_SPINNER(false);

		alertify.confirm
		(
			'PeakPOS', 'Print Cash Breakdown Report?', 
			function() 
			{ 
				Android.CALL('PRINT', '<html><body>' + RECEIPT + '</body></html>');

				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SHIFT_END_MODAL_2") == true)
				{
					// Clear Modal
					if(JSVC_VAR.VAR_ISSET(INPUT_INSTANCE))
					{
						JSOC_WINDOW.VAR_INPUT_INSTANCE_RESTORE(INPUT_INSTANCE);
					}
												
					// Display Modal
					JSOC_ELEMENT.VAR_VALUE('SHIFT_END_NAME', JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_NAME);
					JSOC_ELEMENT.VAR_VALUE('SHIFT_END_START_TIME', JSVC_DATE.VAR_FORMAT(SHIFT_TIME_START, "MMM DD, YYYY hh:mm TT"));
					JSOC_ELEMENT.VAR_VALUE('SHIFT_END_END_TIME', JSVC_DATE.VAR_FORMAT(REPORT_DATE, "MMM DD, YYYY hh:mm TT"));
					JSOC_DIALOG.VAR_MODAL("SHIFT_END_MODAL_2", true);
					return;
				}

				CALLBACK_METHOD(true);
			}, 
			function() 
			{ 
				if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SHIFT_END_MODAL_2") == true)
				{												
					// Display Modal
					JSOC_ELEMENT.VAR_VALUE('SHIFT_END_NAME', JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_NAME);
					JSOC_ELEMENT.VAR_VALUE('SHIFT_END_START_TIME', JSVC_DATE.VAR_FORMAT(SHIFT_TIME_START, "MMM DD, YYYY hh:mm TT"));
					JSOC_ELEMENT.VAR_VALUE('SHIFT_END_END_TIME', JSVC_DATE.VAR_FORMAT(REPORT_DATE, "MMM DD, YYYY hh:mm TT"));
					JSOC_DIALOG.VAR_MODAL("SHIFT_END_MODAL_2", true);
					return;
				}

				CALLBACK_METHOD(true);
			}
		).set('closable', false, 'labels', {ok:'YES', cancel:'NO'});
	}