

	function createItem(COL_NAME, COL_VALUE) 
	{
		localStorage.setItem(COL_NAME, COL_VALUE); 
	}

	function getValue(COL_NAME) 
	{
		return localStorage.getItem(COL_NAME);  
	}

	function NTBSYNC()
	{
		var NTBSYNC = 0;
		if(getValue('GROSS_CTR') !== null)
			//NTBSYNC  += JSVC_NUM.VAR_NVALL(getValue('GROSS_CTR'));
			NTBSYNC  += parseInt(getValue('GROSS_CTR'));

		if(getValue('RES_CTR') !== null)
			//NTBSYNC  += JSVC_NUM.VAR_NVALL(getValue('RES_CTR'));
			NTBSYNC  += parseInt(getValue('RES_CTR'));

		if(getValue('JO_CTR') !== null)
			//NTBSYNC  += JSVC_NUM.VAR_NVALL(getValue('JO_CTR'));
			NTBSYNC  += parseInt(getValue('JO_CTR'));

		if(getValue('JO_CAN_RES_CTR') !== null)
			//NTBSYNC  += JSVC_NUM.VAR_NVALL(getValue('JO_CAN_RES_CTR'));
			NTBSYNC  += parseInt(getValue('JO_CAN_RES_CTR'));

		if(getValue('DEL_RESLINE_CTR') !== null)
			//NTBSYNC  += JSVC_NUM.VAR_NVALL(getValue('DEL_RESLINE_CTR'));
			NTBSYNC  += parseInt(getValue('DEL_RESLINE_CTR'));

		// JSOC_ELEMENT.VAR_INNER_HTML("MENU_UPLOAD_BBI", "Upload Data [" + NTBSYNC + "]");
		document.querySelector('#MENU_UPLOAD_BBI').innerHTML = 'Upload Data [' + NTBSYNC + ']';
	}

	function UPDATA()
	{
		JSOC_DIALOG.VAR_MESSAGE_BOX
		(
			'Internet connection is required to do this operation. Are you sure you want to upload all transactions?', 
			'Information',
			'YES NO', 'QUESTION',
			function(MESSAGE_RESPONSE)
			{
				if(MESSAGE_RESPONSE == 2)
				{
					JSOC_DIALOG.VAR_LOADING_SPINNER(true);
					GROSSCALL_SCHEDULER_SAVE()
				}
			}
		);
	}

	function GROSSCALL_SCHEDULER_SAVE()
	{
		console.log("GROSSCALL_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		if(getValue('GROSS_CTR_HOLDER') === null)
		{
			// Go to Reservation
			console.log("GROSSCALL_SCHEDULER_SAVE : No Requests Found");
			DELETE_RESLINE_SCHEDULER_SAVE();
			return;
		}
		else
			CTR = getValue('GROSS_CTR_HOLDER') ;

		if(CTR > JSVC_NUM.VAR_NVALL(getValue('GROSS_CTR')))
		{
			console.log("GROSSCALL_SCHEDULER_SAVE : No Requests Found");
			DELETE_RESLINE_SCHEDULER_SAVE();
			return;
		}

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue('GROSS_SAVE_MAP_ARRAY' + CTR));

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("GROSSCALL_SCHEDULER_SAVE : Receive Gross Call Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						GROSSCALL_SCHEDULER_SAVE();
					},
					60000
				);
				alert("GROSSCALL_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						GROSSCALL_SCHEDULER_SAVE();
					},
					30000
				);
				alert("GROSSCALL_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							GROSSCALL_SCHEDULER_SAVE();
						},
						5000
					);
					alert("GROSSCALL_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("GROSSCALL_SCHEDULER_SAVE : Success");
					createItem('GROSS_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
					GROSSCALL_SCHEDULER_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("GROSSCALL_SCHEDULER_SAVE : Send Gross Call Request");
		JSCUS_SQL._RECORD._GROSS_CALL.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function DELETE_RESLINE_SCHEDULER_SAVE()
	{
		console.log("DELETE_RESLINE_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		if(getValue('DEL_RESLINE_CTR_HOLDER') === null)
		{
			// Go to Reservation
			console.log("DELETE_RESLINE_SCHEDULER_SAVE : No Requests Found");
			RESERVATION_SCHEDULER_SAVE();
			return;
		}
		else
			CTR = getValue('DEL_RESLINE_CTR_HOLDER') ;

		if(CTR > JSVC_NUM.VAR_NVALL(getValue('DEL_RESLINE_CTR')))
		{
			console.log("DELETE_RESLINE_SCHEDULER_SAVE : No Requests Found");
			RESERVATION_SCHEDULER_SAVE();
			return;
		}

		var RESLINE_ID = JSVC_NUM.VAR_NVALL(getValue('DEL_RESLINE_ID' + CTR));

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("DELETE_RESLINE_SCHEDULER_SAVE : Receive Reservation Line Delete Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						DELETE_RESLINE_SCHEDULER_SAVE();
					},
					60000
				);
				alert("DELETE_RESLINE_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						DELETE_RESLINE_SCHEDULER_SAVE();
					},
					30000
				);
				alert("DELETE_RESLINE_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							DELETE_RESLINE_SCHEDULER_SAVE();
						},
						5000
					);
					alert("DELETE_RESLINE_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("DELETE_RESLINE_SCHEDULER_SAVE : Success");
					createItem('DEL_RESLINE_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
					DELETE_RESLINE_SCHEDULER_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("DELETE_RESLINE_SCHEDULER_SAVE : Send Reservation Line Delete Request");
		JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_DELETE
		(
			RESLINE_ID,
			RESPONSE_HANDLER
		)
		return;
	}

	function RESERVATION_SCHEDULER_SAVE()
	{
		console.log("RESERVATION_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		if(getValue('RES_CTR_HOLDER') === null)
		{
			// Go to Job Order
			console.log("RESERVATION_SCHEDULER_SAVE : No Requests Found");
			JORDER_SCHEDULER_SAVE();
			return;
		}
		else
			CTR = getValue('RES_CTR_HOLDER') ;

		if(CTR > JSVC_NUM.VAR_NVALL(getValue('RES_CTR')))
		{
			console.log("RESERVATION_SCHEDULER_SAVE : No Requests Found");
			JORDER_SCHEDULER_SAVE();
			return;
		}

		//INDICATE MODULE WHERE TO START
		if(JSVC_NUM.VAR_NVALL(getValue('RES_SAVE_HOLDER')) == 2)
		{
			RESERVATION_LINE_SCHEDULER_SAVE();
			return;
		}
		else if(JSVC_NUM.VAR_NVALL(getValue('RES_SAVE_HOLDER')) == 3)
		{
			RESERVATION_JO_SCHEDULER_SAVE();
			return;
		}
		else if(JSVC_NUM.VAR_NVALL(getValue('RES_SAVE_HOLDER')) == 4)
		{
			RESERVATION_JO_LINE_SCHEDULER_SAVE();
			return;
		}
		else if(JSVC_NUM.VAR_NVALL(getValue('RES_SAVE_HOLDER')) == 5)
		{
			JO_OFFLINE_SCHEDULER_SAVE();
			return;
		}
		else if(JSVC_NUM.VAR_NVALL(getValue('RES_SAVE_HOLDER')) == 7)
		{
			JO_REB_OFFLINE_STOCKIN_SAVE();
			return;
		}
		else if(JSVC_NUM.VAR_NVALL(getValue('RES_SAVE_HOLDER')) == 8)
		{
			JO_CUSTOMER_OFFLINE_INV_SAVE();
			return;
		}

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue('RES_SAVE_MAP_ARRAY' + CTR))

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("RESERVATION_SCHEDULER_SAVE : Receive Reservation Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_SCHEDULER_SAVE();
					},
					60000
				);
				alert("RESERVATION_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_SCHEDULER_SAVE();
					},
					30000
				);
				alert("RESERVATION_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							RESERVATION_SCHEDULER_SAVE();
						},
						5000
					);
					alert("RESERVATION_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					//GET INSERTED ID
					createItem('RES_ID_HOLDER', JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1")));

					console.log("RESERVATION_SCHEDULER_SAVE : Success");
					createItem('RES_SAVE_HOLDER', 2); // 2 - RES LINE NA
					GET_RESERVATION_REF_NO();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("RESERVATION_SCHEDULER_SAVE : Send Reservation Request");
		JSCUS_SQL._RECORD._POS_RESERVE.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function GET_RESERVATION_REF_NO()
	{
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_POSRESERVE_ID', JSVC_NUM.VAR_NVALL(getValue('RES_ID_HOLDER')));

		var RESPONSE_HANDLER =
			function HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING)
			{
				// Validate
				// _______________________________________________________________________
				if(IS_SUCCESS === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							GET_RESERVATION_REF_NO();
						},
						60000
					);
					alert("GET_RESERVATION_REF_NO : Connection Failure");
					return;
				}

				// Validate JSON Response
				// _______________________________________________________________________
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							GET_RESERVATION_REF_NO();
						},
						5000
					);
					alert("GET_RESERVATION_REF_NO : ERROR = " + HTTP_RESPONSE);
					return;
				}

				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
				{
					alert("GET_RESERVATION_REF_NO() = GET_RESERVATION_REF_NO : No Data Retrieved");
					GET_RESERVATION_REF_NO();
				}
				else
				{
					createItem('RES_CODE_HOLDER', JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_POSRESERVE_CODE", 1)));
					createItem('RES_SAVE_HOLDER', 2); // 2 - RES LINE NA
					RESERVATION_LINE_SCHEDULER_SAVE();
				}
			}

		console.log("GET_RESERVATION_REF_NO : Send Reservation ID");
		JSCUS_SQL._RECORD._POS_RESERVE.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);
		return;
	}

	function RESERVATION_LINE_SCHEDULER_SAVE()
	{
		console.log("RESERVATION_LINE_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('RES_CTR_HOLDER') ;

		var INDEX = 0;
		while(INDEX <= 9999)
		{
			if(getValue(CTR + 'RES_LINE_BUNDLE_MAP_ARRAY' + INDEX) === null)
				break;

			SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'RES_LINE_BUNDLE_MAP_ARRAY' + INDEX));
			SAVE_MAP_ARRAY['PARAM_REC_POSRESERVE_LIST_REC_POSRESERVE_ID'] = getValue('RES_ID_HOLDER');
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

			INDEX++;
		}

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("RESERVATION_LINE_SCHEDULER_SAVE : Receive Reservation Line Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_LINE_SCHEDULER_SAVE();
					},
					60000
				);
				alert("RESERVATION_LINE_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_LINE_SCHEDULER_SAVE();
					},
					30000
				);
				alert("RESERVATION_LINE_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							RESERVATION_LINE_SCHEDULER_SAVE();
						},
						5000
					);
					alert("RESERVATION_LINE_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("RESERVATION_LINE_SCHEDULER_SAVE : Success");
					createItem('RES_SAVE_HOLDER', 3); // 3 - JO LINE NA
					RESERVATION_JO_SCHEDULER_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("RESERVATION_LINE_SCHEDULER_SAVE : Send Reservation Line Request");
		JSCUS_SQL._RECORD._POS_RESERVE_LIST.CUS_SAVE 
		(
			BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function RESERVATION_JO_SCHEDULER_SAVE()
	{
		console.log("RESERVATION_JO_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('RES_CTR_HOLDER');

		if(getValue(CTR + 'RES_JO_SAVE_MAP_ARRAY') === null)
		{
			createItem('RES_SAVE_HOLDER', 1);
			createItem('RES_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
			console.log("RESERVATION_JO_SCHEDULER_SAVE : No Requests Found");
			RESERVATION_SCHEDULER_SAVE();
			return;
		}

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'RES_JO_SAVE_MAP_ARRAY'))
		SAVE_MAP_ARRAY['PARAM_REC_JORDER_LONG_A'] = getValue('RES_ID_HOLDER');
		SAVE_MAP_ARRAY['PARAM_REC_JORDER_REFERENCE_NUMBER'] = getValue('RES_CODE_HOLDER');

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("Receive Reservation Job Order Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_JO_SCHEDULER_SAVE();
					},
					60000
				);
				alert("RESERVATION_JO_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_JO_SCHEDULER_SAVE();
					},
					30000
				);
				alert("RESERVATION_JO_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							RESERVATION_JO_SCHEDULER_SAVE();
						},
						5000
					);
					alert("RESERVATION_JO_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					//GET INSERTED ID
					createItem('RES_JO_ID_HOLDER', JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1")));

					console.log("RESERVATION_JO_SCHEDULER_SAVE : Success");
					createItem('RES_SAVE_HOLDER', 4); // 4 - JO LINE NA
					RESERVATION_JO_LINE_SCHEDULER_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("RESERVATION_JO_SCHEDULER_SAVE : Send Reservation Request");
		JSCUS_SQL._RECORD._JOB_ORDER.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function RESERVATION_JO_LINE_SCHEDULER_SAVE()
	{
		console.log("RESERVATION_JO_LINE_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('RES_CTR_HOLDER') ;

		var INDEX = 0;
		while(INDEX <= 9999)
		{
			if(getValue(CTR + 'RES_JO_LINE_BUNDLE_MAP_ARRAY' + INDEX) === null)
				break;

			SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'RES_JO_LINE_BUNDLE_MAP_ARRAY' + INDEX));
			SAVE_MAP_ARRAY['PARAM_REC_JORDER_TASK_LONG_A'] = getValue('RES_JO_ID_HOLDER');
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

			INDEX++;
		}

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("RESERVATION_JO_LINE_SCHEDULER_SAVE : Receive Reservation Job Order Line Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_JO_LINE_SCHEDULER_SAVE();
					},
					60000
				);
				alert("RESERVATION_JO_LINE_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						RESERVATION_JO_LINE_SCHEDULER_SAVE();
					},
					30000
				);
				alert("RESERVATION_JO_LINE_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							RESERVATION_JO_LINE_SCHEDULER_SAVE();
						},
						5000
					);
					alert("RESERVATION_JO_LINE_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("RESERVATION_JO_LINE_SCHEDULER_SAVE : Success");
					createItem('RES_SAVE_HOLDER', 5); // 5 - Check bka may JO na same index then na process
					JO_OFFLINE_SCHEDULER_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("RESERVATION_JO_LINE_SCHEDULER_SAVE : Send Reservation Job Order Line Request");
		JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_SAVE
		(
			BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function JO_OFFLINE_SCHEDULER_SAVE()
	{
		console.log("JO_OFFLINE_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('RES_CTR_HOLDER');

		if(getValue(CTR + 'JO_SAVE_MAP_ARRAYX') === null)
		{
			createItem('RES_SAVE_HOLDER', 1);
			createItem('RES_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
			RESERVATION_SCHEDULER_SAVE();
			return;
		}

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'JO_SAVE_MAP_ARRAYX'))
		SAVE_MAP_ARRAY['PARAM_REC_JORDER_ID'] = getValue('RES_JO_ID_HOLDER');

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("JO_OFFLINE_SCHEDULER_SAVE : Receive Job Order Offline Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JO_OFFLINE_SCHEDULER_SAVE();
					},
					60000
				);
				alert("JO_OFFLINE_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JO_OFFLINE_SCHEDULER_SAVE();
					},
					30000
				);
				alert("JO_OFFLINE_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JO_OFFLINE_SCHEDULER_SAVE();
						},
						5000
					);
					alert("JO_OFFLINE_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("JO_OFFLINE_SCHEDULER_SAVE : Success");
					
					if(getValue(CTR + 'JO_REB_STOCKIN_SAVE_MAP_ARRAYX' + 0) !== null)
					{
						createItem('RES_SAVE_HOLDER', 7); // 7 - Go to REB Stock in
						JO_REB_OFFLINE_STOCKIN_SAVE();
					}
					else if(getValue(CTR + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAYX') !== null)
					{
						createItem('RES_SAVE_HOLDER', 8); // 8 - Add customer inv
						JO_CUSTOMER_OFFLINE_INV_SAVE();
					}
					else
					{
						createItem('RES_SAVE_HOLDER', 1); // 1 - BACK TO Reservation
						createItem('RES_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
						RESERVATION_SCHEDULER_SAVE();
					}
					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("JO_OFFLINE_SCHEDULER_SAVE : Send Job Order Offline Request");
		JSCUS_SQL._RECORD._JOB_ORDER.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function JO_REB_OFFLINE_STOCKIN_SAVE()
	{
		console.log("JO_REB_OFFLINE_STOCKIN_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('RES_CTR_HOLDER') ;

		var INDEX = 0;
		while(INDEX <= 9999)
		{
			if(getValue(CTR + 'JO_REB_STOCKIN_SAVE_MAP_ARRAYX' + INDEX) === null)
				break;

			SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'JO_REB_STOCKIN_SAVE_MAP_ARRAYX' + INDEX));
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);
			INDEX++;
		}

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("JO_REB_OFFLINE_STOCKIN_SAVE : Receive Job Order REB Offline Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JO_REB_OFFLINE_STOCKIN_SAVE();
					},
					60000
				);
				alert("JO_REB_OFFLINE_STOCKIN_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JO_REB_OFFLINE_STOCKIN_SAVE();
					},
					30000
				);
				alert("JO_REB_OFFLINE_STOCKIN_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JO_REB_OFFLINE_STOCKIN_SAVE();
						},
						5000
					);
					alert("JO_REB_OFFLINE_STOCKIN_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("JO_REB_OFFLINE_STOCKIN_SAVE : Success");

					if(getValue(CTR + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAYX') !== null)
					{
						createItem('RES_SAVE_HOLDER', 8); // 8 - Add customer inv
						JO_CUSTOMER_OFFLINE_INV_SAVE();
					}
					else
					{
						createItem('RES_SAVE_HOLDER', 1); // 1 - BACK TO Reservation
						createItem('RES_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
						RESERVATION_SCHEDULER_SAVE();
					}
					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("JO_REB_OFFLINE_STOCKIN_SAVE : Send Job Order REB Offline Request");
		JSCUS_SQL._RECORD._STOCK_CARD.CUS_SAVE
		(
			BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function JO_CUSTOMER_OFFLINE_INV_SAVE()
	{
		console.log("JO_CUSTOMER_OFFLINE_INV_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('RES_CTR_HOLDER');

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAYX'))
		
		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_CUSTOMER_INV_REC_CLIENT_ID', JSVC_NUM.VAR_NVALL(SAVE_MAP_ARRAY['PARAM_REC_CUSTOMER_INV_REC_CLIENT_ID']));

		var RESPONSE_HANDLER =
			function HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING)
			{
				// Validate
				// _______________________________________________________________________
				if(IS_SUCCESS === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JO_CUSTOMER_OFFLINE_INV_SAVE();
						},
						60000
					);
					alert("JO_CUSTOMER_OFFLINE_INV_SAVE : Connection Failure");
					return;
				}

				// Validate JSON Response
				// _______________________________________________________________________
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JO_CUSTOMER_OFFLINE_INV_SAVE();
						},
						5000
					);
					alert("JO_CUSTOMER_OFFLINE_INV_SAVE : ERROR = " + HTTP_RESPONSE);
					return;
				}
				
				// JSON Empty
				// _______________________________________________________________________
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
					var SAVE_MAP_ARRAY2 = SAVE_MAP_ARRAY;
				else
				{
					var CUSTOMER_INV_ID = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CUSTOMER_INV_ID", 1));

					var SAVE_MAP_ARRAY2 = JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY2, "PARAM_REC_CUSTOMER_INV_ID", CUSTOMER_INV_ID);
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY2, "PARAM_REC_CUSTOMER_INV_QUANTITY", JSVC_NUM.VAR_NVAL(SAVE_MAP_ARRAY['PARAM_REC_CUSTOMER_INV_QUANTITY']));
				}

				// Declare Post Request Handler
				// _______________________________________________________________________
				var RESPONSE_HANDLER2 = function(IS_SUCCESS, HTTP_RESPONSE)
				{
					console.log("JO_CUSTOMER_OFFLINE_INV_SAVE : Receive Job Order Customer Inventory Offline Request Response");
					
					// Handle Error
					// _______________________________________________________________________
					if(IS_SUCCESS === false)
					{
						JSRC_THREAD.REF_POST_DELAYED
						(
							function()
							{
								JO_CUSTOMER_OFFLINE_INV_SAVE();
							},
							60000
						);
						alert("JO_CUSTOMER_OFFLINE_INV_SAVE2 : Connection Failure");
						return;
					}
					
					// Catch JSON Error
					// _______________________________________________________________________
					else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
					{
						JSRC_THREAD.REF_POST_DELAYED
						(
							function()
							{
								JO_CUSTOMER_OFFLINE_INV_SAVE();
							},
							30000
						);
						alert("JO_CUSTOMER_OFFLINE_INV_SAVE2 : JSON Failure = " + HTTP_RESPONSE);
						return;
					}
						
					// Read Response
					// _______________________________________________________________________
					else
					{
						// Check if legit JSON response is made
						// ...........................................
						var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
						if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
						{
							JSRC_THREAD.REF_POST_DELAYED
							(
								function()
								{
									JO_CUSTOMER_OFFLINE_INV_SAVE();
								},
								5000
							);
							alert("JO_CUSTOMER_OFFLINE_INV_SAVE2 : No Inserted Index = " + HTTP_RESPONSE);
							return;
						}
						
						// Legit JSON response
						// ...........................................
						else
						{
							console.log("JO_CUSTOMER_OFFLINE_INV_SAVE : Success");
							createItem('RES_SAVE_HOLDER', 1); // 1 - Bact To Reservation
							createItem('RES_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
							RESERVATION_SCHEDULER_SAVE();

							return;
						}
					}
				};

				console.log("JO_REB_OFFLINE_STOCKIN_SAVE : Send Job Order REB Offline Request");
				JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_SAVE
				(
					SAVE_MAP_ARRAY2,
					RESPONSE_HANDLER2
				);
			}

		console.log("JO_REB_OFFLINE_STOCKIN_SAVE : Send Customer ID Request");
		JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);
		return;
	}

	function JORDER_SCHEDULER_SAVE()
	{
		console.log("JORDER_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		if(getValue('JO_CTR_HOLDER') === null)
		{
			// Go to Cancellation
			console.log("JORDER_SCHEDULER_SAVE : No Requests Found");
			JORDER_CANCEL_RESERVATION_SAVE();
			return;
		}
		else
			CTR = getValue('JO_CTR_HOLDER') ;

		if(CTR > JSVC_NUM.VAR_NVALL(getValue('JO_CTR')))
		{
			console.log("JORDER_SCHEDULER_SAVE : No Requests Found");
			JORDER_CANCEL_RESERVATION_SAVE();
			return;
		}

		//INDICATE MODULE WHERE TO START
		if(JSVC_NUM.VAR_NVALL(getValue('JO_SAVE_HOLDER')) == 2)
		{
			JORDER_LINE_SCHEDULER_SAVE();
			return;
		}
		else if(JSVC_NUM.VAR_NVALL(getValue('JO_SAVE_HOLDER')) == 3)
		{
			JORDER_REB_STOCKIN_SAVE();
			return;
		}
		else if(JSVC_NUM.VAR_NVALL(getValue('JO_SAVE_HOLDER')) == 4)
		{
			JORDER_CUSTOMER_INV_SAVE();
			return;
		}

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue('JO_SAVE_MAP_ARRAY' + CTR))

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("JORDER_SCHEDULER_SAVE : Receive Job Order Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_SCHEDULER_SAVE();
					},
					60000
				);
				alert("JORDER_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_SCHEDULER_SAVE();
					},
					30000
				);
				alert("JORDER_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JORDER_SCHEDULER_SAVE();
						},
						5000
					);
					alert("JORDER_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					//GET INSERTED ID
					createItem('JO_ID_HOLDER', JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", "1")));

					console.log("JORDER_SCHEDULER_SAVE : Success");
					createItem('JO_SAVE_HOLDER', 2); // 2 - JO LINE NA
					JORDER_LINE_SCHEDULER_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("JORDER_SCHEDULER_SAVE : Send Job Order Request");
		JSCUS_SQL._RECORD._JOB_ORDER.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function JORDER_LINE_SCHEDULER_SAVE()
	{
		console.log("JORDER_LINE_SCHEDULER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('JO_CTR_HOLDER') ;

		var INDEX = 0;
		while(INDEX <= 9999)
		{
			if(getValue(CTR + 'JO_LINE_SAVE_MAP_ARRAY' + INDEX) === null)
				break;

			SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'JO_LINE_SAVE_MAP_ARRAY' + INDEX));
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);

			INDEX++;
		}

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("JORDER_LINE_SCHEDULER_SAVE : Receive Job Order Line Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_LINE_SCHEDULER_SAVE();
					},
					60000
				);
				alert("JORDER_LINE_SCHEDULER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_LINE_SCHEDULER_SAVE();
					},
					30000
				);
				alert("JORDER_LINE_SCHEDULER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JORDER_LINE_SCHEDULER_SAVE();
						},
						5000
					);
					alert("JORDER_LINE_SCHEDULER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("JORDER_LINE_SCHEDULER_SAVE : Success");

					if(getValue(CTR + 'JO_REB_STOCKIN_SAVE_MAP_ARRAY' + 0) !== null)
					{
						createItem('JO_SAVE_HOLDER', 3); // 3 - Go to REB Stock in
						JORDER_REB_STOCKIN_SAVE();
					}
					else if(getValue(CTR + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAY') !== null)
					{
						createItem('JO_SAVE_HOLDER', 4); // 4 - Add customer inv
						JORDER_CUSTOMER_INV_SAVE();
					}
					else
					{
						createItem('JO_SAVE_HOLDER', 1); // 1 - BACK TO Reservation
						createItem('JO_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
						JORDER_SCHEDULER_SAVE();
					}
					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("JORDER_LINE_SCHEDULER_SAVE : Send Job Order Line Request");
		JSCUS_SQL._RECORD._JOB_ORDER_TASK.CUS_SAVE
		(
			BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function JORDER_REB_STOCKIN_SAVE()
	{
		console.log("JORDER_REB_STOCKIN_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;
		var SAVE_MAP_ARRAY = [];
		var BUNDLE_MAP_ARRAY = [];

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('JO_CTR_HOLDER') ;

		var INDEX = 0;
		while(INDEX <= 9999)
		{
			if(getValue(CTR + 'JO_REB_STOCKIN_SAVE_MAP_ARRAY' + INDEX) === null)
				break;

			SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'JO_REB_STOCKIN_SAVE_MAP_ARRAY' + INDEX));
			BUNDLE_MAP_ARRAY = JSCUS_SQL._RECORD._STOCK_CARD.CUS_ADD_MAPPED_ARRAY_FOR_SAVE(BUNDLE_MAP_ARRAY, SAVE_MAP_ARRAY);
			INDEX++;
		}

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("JORDER_REB_STOCKIN_SAVE : Receive Job Order REB Offline Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_REB_STOCKIN_SAVE();
					},
					60000
				);
				alert("JORDER_REB_STOCKIN_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_REB_STOCKIN_SAVE();
					},
					30000
				);
				alert("JORDER_REB_STOCKIN_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JORDER_REB_STOCKIN_SAVE();
						},
						5000
					);
					alert("JORDER_REB_STOCKIN_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("JORDER_REB_STOCKIN_SAVE : Success");

					if(getValue(CTR + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAY') !== null)
					{
						createItem('JO_SAVE_HOLDER', 8); // 8 - Add customer inv
						JORDER_CUSTOMER_INV_SAVE();
					}
					else
					{
						createItem('JO_SAVE_HOLDER', 1); // 1 - BACK TO Reservation
						createItem('JO_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
						JORDER_SCHEDULER_SAVE();
					}
					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("JO_REB_OFFLINE_STOCKIN_SAVE : Send Job Order REB Offline Request");
		JSCUS_SQL._RECORD._STOCK_CARD.CUS_SAVE
		(
			BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function JORDER_CUSTOMER_INV_SAVE()
	{
		console.log("JORDER_CUSTOMER_INV_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		CTR = getValue('JO_CTR_HOLDER');

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue(CTR + 'JO_CUSTOMER_INV_SAVE_MAP_ARRAY'))
		

		var GET_MAP_ARRAY = JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_PREPARE_MAPPED_ARRAY_FOR_GET();
		JSVC_MAP_ARRAY.VAR_SET(GET_MAP_ARRAY, 'PARAM_REC_CUSTOMER_INV_REC_CLIENT_ID', JSVC_NUM.VAR_NVALL(SAVE_MAP_ARRAY['PARAM_REC_CUSTOMER_INV_REC_CLIENT_ID']));

		var RESPONSE_HANDLER =
			function HTTP_SEARCH_CALLBACK(IS_SUCCESS, RESPONSE_STRING)
			{
				// Validate
				// _______________________________________________________________________
				if(IS_SUCCESS === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JORDER_CUSTOMER_INV_SAVE();
						},
						60000
					);
					alert("JORDER_CUSTOMER_INV_SAVE : Connection Failure");
					return;
				}

				// Validate JSON Response
				// _______________________________________________________________________
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(RESPONSE_STRING);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JORDER_CUSTOMER_INV_SAVE();
						},
						5000
					);
					alert("JORDER_CUSTOMER_INV_SAVE : ERROR = " + HTTP_RESPONSE);
					return;
				}
				
				// JSON Empty
				// _______________________________________________________________________
				if(JSRC_JSON.REF_READ(JSON_OBJECT, "JSON_COUNT") <= 0)
					var SAVE_MAP_ARRAY2 = SAVE_MAP_ARRAY;
				else
				{
					var CUSTOMER_INV_ID = JSVC_NUM.VAR_NVALL(JSRC_JSON.REF_READ(JSON_OBJECT, "REC_CUSTOMER_INV_ID", 1));

					var SAVE_MAP_ARRAY2 = JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY2, "PARAM_REC_CUSTOMER_INV_ID", CUSTOMER_INV_ID);
					JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY2, "PARAM_REC_CUSTOMER_INV_QUANTITY", JSVC_NUM.VAR_NVAL(SAVE_MAP_ARRAY['PARAM_REC_CUSTOMER_INV_QUANTITY']));
				}

				// Declare Post Request Handler
				// _______________________________________________________________________
				var RESPONSE_HANDLER2 = function(IS_SUCCESS, HTTP_RESPONSE)
				{
					console.log("JORDER_CUSTOMER_INV_SAVE : Receive Job Order Customer Inventory Request Response");
					
					// Handle Error
					// _______________________________________________________________________
					if(IS_SUCCESS === false)
					{
						JSRC_THREAD.REF_POST_DELAYED
						(
							function()
							{
								JORDER_CUSTOMER_INV_SAVE();
							},
							60000
						);
						alert("JORDER_CUSTOMER_INV_SAVE2 : Connection Failure");
						return;
					}
					
					// Catch JSON Error
					// _______________________________________________________________________
					else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
					{
						JSRC_THREAD.REF_POST_DELAYED
						(
							function()
							{
								JORDER_CUSTOMER_INV_SAVE();
							},
							30000
						);
						alert("JORDER_CUSTOMER_INV_SAVE2 : JSON Failure = " + HTTP_RESPONSE);
						return;
					}
						
					// Read Response
					// _______________________________________________________________________
					else
					{
						// Check if legit JSON response is made
						// ...........................................
						var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
						if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
						{
							JSRC_THREAD.REF_POST_DELAYED
							(
								function()
								{
									JORDER_CUSTOMER_INV_SAVE();
								},
								5000
							);
							alert("JORDER_CUSTOMER_INV_SAVE2 : No Inserted Index = " + HTTP_RESPONSE);
							return;
						}
						
						// Legit JSON response
						// ...........................................
						else
						{
							console.log("JORDER_CUSTOMER_INV_SAVE : Success");
							createItem('JO_SAVE_HOLDER', 1); // 1 - Bact To Job Order
							createItem('JO_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
							JORDER_SCHEDULER_SAVE();

							return;
						}
					}
				};

				console.log("JORDER_CUSTOMER_INV_SAVE : Send Job Order REB Request");
				JSOC_DIALOG.VAR_LOADING_SPINNER(true);
				JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_SAVE
				(
					SAVE_MAP_ARRAY2,
					RESPONSE_HANDLER2
				);
			}

		console.log("JORDER_CUSTOMER_INV_SAVE : Send Customer ID Request");
		JSCUS_SQL._RECORD._CUSTOMER_INV.CUS_GET
		(
			GET_MAP_ARRAY,
			RESPONSE_HANDLER,
			true
		);
		return;
	}

	function JORDER_CANCEL_RESERVATION_SAVE()
	{
		console.log("JORDER_CANCEL_RESERVATION_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		if(getValue('JO_CAN_RES_CTR_HOLDER') === null)
		{
			// Go to Reservation
			console.log("JORDER_CANCEL_RESERVATION_SAVE : No Requests Found");
			JORDER_CANCEL_JORDER_SAVE();
			return;
		}
		else
			CTR = getValue('JO_CAN_RES_CTR_HOLDER') ;

		if(CTR > JSVC_NUM.VAR_NVALL(getValue('JO_CAN_RES_CTR')))
		{
			console.log("JORDER_CANCEL_RESERVATION_SAVE : No Requests Found");
			JORDER_CANCEL_JORDER_SAVE();
			return;
		}

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue('JO_CAN_RES_SAVE_MAP_ARRAY' + CTR));

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("JORDER_CANCEL_RESERVATION_SAVE : Receive Job Order Cancel Reservation Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_CANCEL_RESERVATION_SAVE();
					},
					60000
				);
				alert("JORDER_CANCEL_RESERVATION_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_CANCEL_RESERVATION_SAVE();
					},
					30000
				);
				alert("JORDER_CANCEL_RESERVATION_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JORDER_CANCEL_RESERVATION_SAVE();
						},
						5000
					);
					alert("JORDER_CANCEL_RESERVATION_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("JORDER_CANCEL_RESERVATION_SAVE : Success");
					createItem('JO_CAN_RES_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
					JORDER_CANCEL_RESERVATION_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("JORDER_CANCEL_RESERVATION_SAVE : Send Job Order Cancel Reservation Request");
		JSCUS_SQL._RECORD._POS_RESERVE.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	function JORDER_CANCEL_JORDER_SAVE()
	{
		console.log("JORDER_CANCEL_JORDER_SAVE : New Requests");

		// Initialize
		// ------------------------------------------------------------
		var CTR = 0;

		// Check if pending request exists
		// ------------------------------------------------------------
		if(getValue('JO_CAN_JO_CTR_HOLDER') === null)
		{
			// LS Complete
			console.log("JORDER_CANCEL_JORDER_SAVE : No Requests Found");
			CUS_SEND_DIALOG_TRY_DISMISS();

			localStorage.clear();
			console.log("LOCAL_STORAGE : All Data Cleared");

			window.location = JSCUS_CACHE.SERVER_URL + '/p/water/hub2/offline_hub.html';

			NTBSYNC();
			return;
		}
		else
			CTR = getValue('JO_CAN_JO_CTR_HOLDER') ;

		if(CTR > JSVC_NUM.VAR_NVALL(getValue('JO_CAN_JO_CTR')))
		{
			console.log("JORDER_CANCEL_JORDER_SAVE : No Requests Found");
			CUS_SEND_DIALOG_TRY_DISMISS();

			localStorage.clear();
			console.log("LOCAL_STORAGE : All Data Cleared");

			window.location = JSCUS_CACHE.SERVER_URL + '/p/water/hub2/offline_hub.html';

			NTBSYNC();
			return;
		}

		var SAVE_MAP_ARRAY = JSVC_MAP_ARRAY.VAR_TO_MAP_ARRAY(getValue('JO_CAN_JO_SAVE_MAP_ARRAY' + CTR));

		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			console.log("JORDER_CANCEL_JORDER_SAVE : Receive Job Order Cancel Job Order Request Response");
			
			// Handle Error
			// _______________________________________________________________________
			if(IS_SUCCESS === false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_CANCEL_JORDER_SAVE();
					},
					60000
				);
				alert("JORDER_CANCEL_JORDER_SAVE : Connection Failure");
				return;
			}
			
			// Catch JSON Error
			// _______________________________________________________________________
			else if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				JSRC_THREAD.REF_POST_DELAYED
				(
					function()
					{
						JORDER_CANCEL_JORDER_SAVE();
					},
					30000
				);
				alert("JORDER_CANCEL_JORDER_SAVE : JSON Failure = " + HTTP_RESPONSE);
				return;
			}
				
			// Read Response
			// _______________________________________________________________________
			else
			{
				// Check if legit JSON response is made
				// ...........................................
				var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
				if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
				{
					JSRC_THREAD.REF_POST_DELAYED
					(
						function()
						{
							JORDER_CANCEL_JORDER_SAVE();
						},
						5000
					);
					alert("JORDER_CANCEL_JORDER_SAVE : No Inserted Index = " + HTTP_RESPONSE);
					return;
				}
				
				// Legit JSON response
				// ...........................................
				else
				{
					console.log("JORDER_CANCEL_JORDER_SAVE : Success");
					createItem('JO_CAN_JO_CTR_HOLDER', JSVC_NUM.VAR_NVALL(CTR) + 1);
					JORDER_CANCEL_JORDER_SAVE();

					return;
				}
			}
		};
		
		// Send Request
		// ------------------------------------------------------------
		console.log("JORDER_CANCEL_JORDER_SAVE : Send Job Order Cancel Job Order Request");
		JSCUS_SQL._RECORD._JOB_ORDER.CUS_SAVE 
		(
			SAVE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		return;
	}

	NTBSYNC();


	

