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

	// ===============================================================
	// EditHandler Flags
	// ===============================================================	
	
	function HTTP_LOAD(CALLBACK_FUNCTION)
	{
		// Escape if new item
		// ...........................................
		if(JSRC_FLAG.IS_NULL_BIGINT(PROPERTY_REC_POSSALE_ID, 1, 1))
		{
			return;
		}
		
		
		// Load DB data of item
		// ...........................................
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		

		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_SALE_LIST.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();

		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_LIST_REC_POSSALE_ID', PROPERTY_REC_POSSALE_ID); 
		//JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSSALE_LIST_STATUS', 2); 


		var RESPONSE_HANDLER = 
			function(IS_SUCCESS, RESPONSE_STRING)
			{
				// 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;
				}
				
				// JSON Empty (Clears the DataGrodView)
				// _______________________________________________________________________
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					POS_SALE_LIST_DGV.ROW.CLEAR();

					JSOC_DIALOG.VAR_MESSAGE_BOX
					(
						'Cannot find transaction',
						'Information',
						'OK', 'ERROR',
						function() {}
					);
					return;
				}

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

				JSOC_ELEMENT.VAR_VALUE('SUBTOTAL_TXT', JSVC_NUM.VAR_CFORMAT(POS_SALE_LIST_DGV.COLUMN.SUM('REC_POSSALE_LIST_TOPAY_SUBTOTAL')));
				JSOC_ELEMENT.VAR_VALUE('DISCOUNT_TXT', JSVC_NUM.VAR_CFORMAT(POS_SALE_LIST_DGV.COLUMN.SUM('REC_POSSALE_TOTAL_DISCOUNT')));
				JSOC_ELEMENT.VAR_VALUE('TOTAL_TXT', JSVC_NUM.VAR_CFORMAT(JSVC_NUM.VAR_NVAL(POS_SALE_LIST_DGV.COLUMN.SUM('REC_POSSALE_LIST_TOPAY_SUBTOTAL')) - JSVC_NUM.VAR_NVAL(POS_SALE_LIST_DGV.COLUMN.SUM('REC_POSSALE_TOTAL_DISCOUNT'))));
			};

			
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);

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

	}


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


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

		
	// ===============================================================
	// Request Save
	// ===============================================================
	function HTTP_SAVE(CALLBACK_METHOD)
	{

		// Sanitize User Inputs
		// _______________________________________________________________________
		FIX_INPUT();
	
	
		// Check Edit Status
		// _______________________________________________________________________
		if(EDIT_HANDLER.REF_IS_MODIFIED == false)
		{
			JSVC_INFO.VAR_NOTHING_TO_SAVE(function(){CALLBACK_METHOD(false);})	
			return;		
		}


		// Validate Null [String Input]
		// _______________________________________________________________________
		if(JSOC_INPUT_TEXT.CTL_VALIDATE(REC_POSSALE_CODE_TXT, "Transaction Code", null, 1, 150) == false)
		{
			REC_POSSALE_CODE_TXT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
			REC_POSSALE_CODE_TXT.focus();
			return false;
		}
		
		
		// Validate Zero [Numeric Input]
		// _______________________________________________________________________
	
	
		// Validate Negative [Numeric Input]
		// _______________________________________________________________________
		
		
		// Validate Range [Numeric Input]
		// _______________________________________________________________________	


		// Foreign key check
		// _______________________________________________________________________
		if
		(
			JSVC_VAR.VAR_ISSET(REC_POSSALE_REC_POSDEVICE_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_POSSALE_REC_POSDEVICE_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_REC_POSDEVICE_ID_CMB)) < 0
			)
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Device is required.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_POSSALE_REC_POSDEVICE_ID_CMB.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_POSSALE_REC_POSDEVICE_ID_CMB.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		if
		(
			JSVC_VAR.VAR_ISSET(REC_POSSALE_REC_CLIENT_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_POSSALE_REC_CLIENT_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_REC_CLIENT_ID_CMB)) < 0
			)
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Client is required.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_POSSALE_REC_CLIENT_ID_CMB.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_POSSALE_REC_CLIENT_ID_CMB.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		if
		(
			JSVC_VAR.VAR_ISSET(REC_POSSALE_REC_LOYALTY_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_POSSALE_REC_LOYALTY_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_REC_LOYALTY_ID_CMB)) < 0
			)
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Loyalty Card is required.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_POSSALE_REC_LOYALTY_ID_CMB.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_POSSALE_REC_LOYALTY_ID_CMB.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		if
		(
			JSVC_VAR.VAR_ISSET(REC_POSSALE_ACC_ACCOUNT_ID_CMB) &&
			(
				JSOC_CMB.VAR_SELECTED_INDEX(REC_POSSALE_ACC_ACCOUNT_ID_CMB) < 0 ||
				JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_ACC_ACCOUNT_ID_CMB)) < 0
			)
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Field Cashier is required.', 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					REC_POSSALE_ACC_ACCOUNT_ID_CMB.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					REC_POSSALE_ACC_ACCOUNT_ID_CMB.focus();
					CALLBACK_METHOD(false);
				}
			);	
			return;			
		}
		

		// Validate Duplicates
		// _______________________________________________________________________
		var EXCEPTION_ROW_INDEX = -1;
		if(PROPERTY_REC_POSSALE_ID >= 0)
		{
			EXCEPTION_ROW_INDEX = PROPERTY_EDIT_ROW_INDEX;
		}
			

		
		
		// Password Items (if available)
		// _______________________________________________________________________
		
		
		// CheckBox Items (if available)
		// _______________________________________________________________________

	
		// File is required
		// _______________________________________________________________________
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_REC_POSSALE_ID_FILE_FP") &&
			PARAM_REC_POSSALE_ID_FILE_FP.files.length <= 0
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				JSVC_ERROR.VAR_ARGUMENT_EXCEPTION_MISSING_INPUT("Upload File", false), 
				'Information',
				'OK', 'WARNING',
				function(MESSAGE_RESPONSE)
				{
					PARAM_REC_POSSALE_ID_FILE_FP.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
					CALLBACK_METHOD(false);
				}
			);		
			return;	
		}
		
	
		// File is too large (Sample Code : 3mb)
		// _______________________________________________________________________
		if
		(
			JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_REC_POSSALE_ID_FILE_FP") &&
			PARAM_REC_POSSALE_ID_FILE_FP.files[0].size > 1024 * 1024 * 3
		)
		{
			JSOC_DIALOG.VAR_MESSAGE_BOX
			(
				'Selected file is too large. File size is restricted to 3mb or below',
				'Information',
				'OK', 'ERROR',
				function()
				{
					CALLBACK_METHOD(false);
				}
			);	
		   PARAM_REC_POSSALE_ID_FILE_FP.value = "";
		   return;
		};
		
		 

		
		// Save item [Prepare]
		// _______________________________________________________________________
		var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_SALE.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
		// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', PROPERTY_PARENT_ID);		// Parent ID Sample
		// JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_PARENT_ID', INPUT_FILE_ELEMENT_FP);		// File Upload Sample
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_ID", PROPERTY_REC_POSSALE_ID);				
		
			
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_REC_POSDEVICE_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_REC_POSDEVICE_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_REC_CLIENT_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_REC_CLIENT_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_REC_LOYALTY_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_REC_LOYALTY_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_CODE", JSOC_ELEMENT.VAR_VALUE(REC_POSSALE_CODE_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_DATE_DUE", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE(REC_POSSALE_DATE_DUE_DTP)), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_REMARKS", JSOC_ELEMENT.VAR_VALUE(REC_POSSALE_REMARKS_TXT));					
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_ACC_ACCOUNT_ID", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_ACC_ACCOUNT_ID_CMB)));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_DATE_TRANSACT", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_END_OF_DAY(JSOC_ELEMENT.VAR_VALUE(REC_POSSALE_DATE_TRANSACT_DTP)), "YYYY-MM-DD HH:mm:ss") + '.999999');
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_STATUS", JSVC_NUM.VAR_NVALL(JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_STATUS_CMB)));
		if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("PARAM_REC_POSSALE_ID_FILE_FP"))
		{
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSSALE_ID_FILE", PARAM_REC_POSSALE_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
					{				
						// Update Changes to DataGridView
						if(PROPERTY_REC_POSSALE_ID > 0)
						{
							HTTP_SEARCH(PROPERTY_REC_POSSALE_ID, PROPERTY_EDIT_ROW_INDEX);
						}
						
						// Load new item into the DataGridView
						else
						{
							// Retrieve Inserted ID
							PROPERTY_REC_POSSALE_ID = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1"));
							
							// Add new line
							POS_SALE_DGV.ROW.INSERT_AT(0);
							HTTP_SEARCH(PROPERTY_REC_POSSALE_ID, 0);
						}	

						// Lift edit and Exit EditMode
						EDIT_HANDLER.REF_IS_MODIFIED = false;
						EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;			
						if
						(
							JSOC_ELEMENT.VAR_ELEMENT_EXISTS('POS_SALE_MODAL') == true
						)
						{
							JSOC_DIALOG.VAR_MODAL('POS_SALE_MODAL', false);
						}
						
						//SWAP_EDIT_MODE(false);
						CALLBACK_METHOD(true);											
					}
				}
			};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._POS_SALE.CUS_SAVE 
		(
			SAVE_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 = POS_SALE_DGV.CELL.VALUE('REC_POSSALE_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
				{
					POS_SALE_DGV.ROW.REMOVE_AT(ROW_INDEX);
					POS_SALE_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._POS_SALE.CUS_DELETE
				(
					POS_SALE_DGV.CELL.VALUE('REC_POSSALE_ID', ROW_INDEX),
					RESPONSE_HANDLER
				)
			}
		);
	}
	
	
	// ===============================================================
	// Request Void
	// ===============================================================
	function HTTP_VOID(CALLBACK_METHOD, ROW_INDEX)
	{
		
		// Escape if Disabled
		// _______________________________________________________________________
		if
		(
			JSVC_VAR.VAR_ISSET(POS_SALE_DGV.CELL.ELEMENT('REC_POSSALE_STATUS', ROW_INDEX)) && 
			POS_SALE_DGV.CELL.ELEMENT('REC_POSSALE_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(POS_SALE_DGV.CELL.VALUE('REC_POSSALE_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 = POS_SALE_DGV.CELL.VALUE('4792', ROW_INDEX);
					PROPERTY_EDIT_ROW_INDEX = ROW_INDEX;
					HTTP_LOAD
					(
						function()
						{
							JSOC_CMB.VAR_SELECTED_VALUE(REC_POSSALE_STATUS_CMB, 3);

							JSOC_DIALOG.VAR_MODAL("POS_SALE_MODAL", true);
							JSOC_ELEMENT.VAR_GET("POS_SALE_MODAL").style.top = '20%';
							
							EDIT_HANDLER.REF_IS_MODIFIED = true;				
						}
					);
				}
			}
		);
		
	}
	
	// ===============================================================
	// 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'});
	}