	// ===============================================================
	// 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
		// ...........................................
		
		
		
		// Clear Changes due to loading
		// ...........................................
	}



	function HTTP_SAVE(IS_IN, CALLBACK_METHOD)
	{
		var AMOUNT = 0;
		var NOTES = '';

		var SAVE_MAP_ARRAY = [];

		if(IS_IN == true)
		{
			AMOUNT = JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE('CASHIN_AMOUNT'));
			NOTES = JSOC_ELEMENT.VAR_VALUE('CASHIN_NOTES');
		}
		else
		{
			AMOUNT = JSVC_NUM.VAR_NVAL(JSOC_ELEMENT.VAR_VALUE('CASHOUT_AMOUNT'));
			NOTES = JSOC_ELEMENT.VAR_VALUE('CASHOUT_NOTES');
		}

		SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_CASHFLOW.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();

		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSCASHFLOW_IS_IN", IS_IN);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSCASHFLOW_AMOUNT", AMOUNT);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSCASHFLOW_REMARKS", NOTES);
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSCASHFLOW_DATE_PROCESSED", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_NOW(), "YYYY-MM-DD HH:mm:ss") + ".999999");
				
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSCASHFLOW_REC_POSDEVICE_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._RECORD._POSDEVICE._LOGIN.REC_POSDEVICE_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSCASHFLOW_ACC_ACCOUNT_ID", JSVC_NUM.VAR_NVALL(JSCUS_SQL._ACCOUNT._LOGIN.ACC_ACCOUNT_ID));
		JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_POSCASHFLOW_STATUS", 2); 

		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;
					}
					else 
					{
						if(IS_IN == 1)
							JSOC_DIALOG.VAR_MODAL("CASHIN_MODAL", false);
						else
							JSOC_DIALOG.VAR_MODAL("CASHOUT_MODAL", false);

						alertify.success('Transaction saved.');
						CALLBACK_METHOD(true);
					}
				}
			};

		JSCUS_SQL._RECORD._POS_CASHFLOW.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'});
	}