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

	// ===============================================================
	// EditHandler Flags
	// ===============================================================	
	
	function HTTP_LOAD(JSON_OBJECT)
	{
		// Initialize
		// _______________________________________________________________________
		var GROUP_ID = JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "REC_PSCHEDULE_ACC_GROUP_ID", 1);
		var SCHEDULE_MONTH = JSRC_JSON.REF_READ_TO_DATE(JSON_OBJECT, "REC_PSCHEDULE_DATE", 1);
		
		
		// Locate JSON Index of current row ()Product)
		// _______________________________________________________________________
		var GET_INDEX_OF_PRODUCT = function(CAT_PRODUCT_ID)
		{
			// Initialize
			// ...........................................
			var JSON_COUNT = JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "JSON_COUNT");
			var JSON_INDEX = 1;
			
			// Locate Product
			// ...........................................
			while(JSON_COUNT >= JSON_INDEX)
			{
				try
				{
					if(JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "REC_PSCHEDULE_CAT_PRODUCT_ID", JSON_INDEX) == CAT_PRODUCT_ID)
					{
						return JSON_INDEX;
					}
				}
				catch(ERR)
				{
					console.error(ERR);
					console.error
					(
						[
							['JSON_OBJECT', JSON_OBJECT],
							['JSON_COUNT', JSON_COUNT],
							['JSON_INDEX', JSON_INDEX]
						]						
					);
					throw ERR;
				}
				JSON_INDEX ++;
			}
			
			// Not found
			// ...........................................
			return -1;
		};
		
		
		// Populate Data
		// _______________________________________________________________________	
		var LOAD_DATA_FROM_SCHEDULE = function()
		{
			var ROW_COUNT = PSCHEDULE_DGV.ROW.COUNT();
			var ROW_INDEX = 0;
			var CURRENT_JSON_INDEX = 0;
			
			while(ROW_COUNT > ROW_INDEX)
			{
				// Get ROW_INDEX to Load
				// ...........................................
				CURRENT_JSON_INDEX = GET_INDEX_OF_PRODUCT
				(
					PSCHEDULE_DGV.CELL.VALUE_NVALL("REC_PSCHEDULE_CAT_PRODUCT_ID", ROW_INDEX)
				);
				
				// Skip loading on New Product
				// ...........................................
				if(CURRENT_JSON_INDEX < 0)
				{
					ROW_INDEX ++;
					continue;
				}
				
				// Load Data
				// ...........................................
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_ID", ROW_INDEX, JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "REC_PSCHEDULE_ID", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_AMOUNT_COST", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_AMOUNT_COST", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_AMOUNT_PRICE", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_AMOUNT_PRICE", CURRENT_JSON_INDEX));
				
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D01", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D01", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D02", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D02", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D03", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D03", CURRENT_JSON_INDEX));			
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D04", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D04", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D05", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D05", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D06", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D06", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D07", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D07", CURRENT_JSON_INDEX));
				
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D08", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D08", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D09", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D09", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D10", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D10", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D11", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D11", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D12", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D12", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D13", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D13", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D14", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D14", CURRENT_JSON_INDEX));
				
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D15", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D15", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D16", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D16", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D17", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D17", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D18", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D18", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D19", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D19", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D20", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D20", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D21", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D21", CURRENT_JSON_INDEX));
				
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D22", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D22", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D23", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D23", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D24", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D24", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D25", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D25", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D26", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D26", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D27", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D27", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D28", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D28", CURRENT_JSON_INDEX));
				
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D29", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D29", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D30", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D30", CURRENT_JSON_INDEX));
				PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_QTY_D31", ROW_INDEX, JSRC_JSON.REF_READ_NVAL(JSON_OBJECT, "REC_PSCHEDULE_QTY_D31", CURRENT_JSON_INDEX));
	
				
	
				// Re-Compute
				// ...........................................
				PSCHEDULE_DGV.COLUMN.AUTO_COMPUTE_EXECUTE(ROW_INDEX);
				
				ROW_INDEX ++;
			}
				
			// Auto-total tool
			if(PSCHEDULE_DGV.COLUMN.TOTAL_IS_READY())
			{
				PSCHEDULE_DGV.COLUMN.TOTAL_REFRESH();
			}
		};
		
		
		// Prepare DGV COlumns as per Requested
		// _______________________________________________________________________
		NEW_SCHEDULE_PREPARE_DGV_COLS_CLEAR();
		NEW_SCHEDULE_PREPARE_DGV_COLS(GROUP_ID, SCHEDULE_MONTH);
		NEW_SCHEDULE_PREPARE_DGV_ROWS(GROUP_ID, SCHEDULE_MONTH, LOAD_DATA_FROM_SCHEDULE);
	};


	// ===============================================================
	// Trims empty spaces and perform convertion for numeric fields.
	// ===============================================================
	function FIX_INPUT()
	{
	};

		
	// ===============================================================
	// Request Save
	// ===============================================================
	function HTTP_SAVE(CALLBACK_METHOD, RESUME_INDEX = 0)
	{

		// 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 Negative [Numeric Input]
		// _______________________________________________________________________
		var CURRENT_COLUMN_NAME = '';
		var CURRENT_ELEMENT = '';
		var DAY_INDEX = 0;
		var ROW_INDEX = RESUME_INDEX;
		var ROW_COUNT = PSCHEDULE_DGV.ROW.COUNT();
		
		while(ROW_COUNT > ROW_INDEX)
		{
			DAY_INDEX = 1;
			while(31 >= DAY_INDEX)
			{
				CURRENT_COLUMN_NAME = 'REC_PSCHEDULE_QTY_D' + JSVC_STR.VAR_FIX(DAY_INDEX.toString(), null, 2, 2, "0"); 
				CURRENT_ELEMENT = PSCHEDULE_DGV.CELL.ELEMENT(CURRENT_COLUMN_NAME, ROW_INDEX);
				
				if(JSOC_INPUT_TEXT.CTL_NVAL(CURRENT_ELEMENT) < 0)
				{
					JSOC_DIALOG.VAR_MESSAGE_BOX
					(
						'Field : Quantity for Day ' + DAY_INDEX + ' cannot be negative.', 
						'Information',
						'OK', 'WARNING',
						function()
						{
							CURRENT_ELEMENT.style.borderColor = JSCUS_CACHE.SITE_ON_ERROR_BORDER_COLOR;
							CURRENT_ELEMENT.focus();
							CALLBACK_METHOD(false);
						}
					);	
					return;			
				}		
				DAY_INDEX ++;
				
			}		
			ROW_INDEX ++;
		}
		

		// Save item [Prepare]
		// _______________________________________________________________________
		var REQUEST_PARAM_BUNDLE_MAP_ARRAY = [];
		var SAVE_MAP_ARRAY = null;
		var CURRENT_DATE_INDEX = '';
		ROW_INDEX = RESUME_INDEX;
		
		while(ROW_COUNT > ROW_INDEX && REQUEST_PARAM_BUNDLE_MAP_ARRAY.length < 30)
		{
			// Save Map Array : Save Map Array Initial Data
			// ...........................................			
			var SAVE_MAP_ARRAY = JSCUS_SQL._RECORD._PSCHEDULE.CUS_PREPARE_MAPPED_ARRAY_FOR_SAVE();
			
			
			// Save Map Array : Save Map Array Initial Data
			// ...........................................
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_ID", PSCHEDULE_DGV.CELL.VALUE_NVALL("REC_PSCHEDULE_ID", ROW_INDEX));				
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_ACC_GROUP_ID", PSCHEDULE_DGV.CELL.VALUE_NVALL("REC_PSCHEDULE_ACC_GROUP_ID", ROW_INDEX));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_CAT_PRODUCT_ID", PSCHEDULE_DGV.CELL.VALUE_NVALL("REC_PSCHEDULE_CAT_PRODUCT_ID", ROW_INDEX));
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_AMOUNT_PRICE", PSCHEDULE_DGV.CELL.VALUE_NVAL("REC_PSCHEDULE_AMOUNT_PRICE", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_AMOUNT_COST", PSCHEDULE_DGV.CELL.VALUE_NVAL("REC_PSCHEDULE_AMOUNT_COST", ROW_INDEX));				
				
				
			// Populate per day preorders
			// ...........................................
			DAY_INDEX = 1;
			while(31 >= DAY_INDEX)
			{
				CURRENT_DATE_INDEX = JSVC_STR.VAR_FIX(DAY_INDEX.toString(), null, 2, 2, "0"); 
				JSVC_MAP_ARRAY.VAR_SET
				(
					SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_QTY_D" + CURRENT_DATE_INDEX, 
					PSCHEDULE_DGV.CELL.VALUE_NVAL("REC_PSCHEDULE_QTY_D" + CURRENT_DATE_INDEX, ROW_INDEX)
				);
				DAY_INDEX ++;
			}
			
			
			// Save Map Array : Save Map Array footer Data
			// ...........................................
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_QTY_TOTAL", PSCHEDULE_DGV.CELL.VALUE_NVAL("REC_PSCHEDULE_QTY_TOTAL", ROW_INDEX));	
			JSVC_MAP_ARRAY.VAR_SET
			(
				SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_DATE", JSVC_DATE.VAR_FORMAT
				(
					PSCHEDULE_DGV.CELL.VALUE_TO_DATE("REC_PSCHEDULE_DATE", ROW_INDEX), 
					"YYYY-MM-DD HH:mm:ss"
				) + ".000000"
			);
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_REMARKS", PSCHEDULE_DGV.CELL.VALUE("REC_PSCHEDULE_REMARKS", ROW_INDEX));					
			JSVC_MAP_ARRAY.VAR_SET(SAVE_MAP_ARRAY, "PARAM_REC_PSCHEDULE_STATUS", 2);
			
			
			// Push to Request bundle
			// ...........................................
			REQUEST_PARAM_BUNDLE_MAP_ARRAY.push(SAVE_MAP_ARRAY);
			ROW_INDEX ++;
		}
		
		
		// Declare Post Request Handler
		// _______________________________________________________________________
		var RESPONSE_HANDLER = function(IS_SUCCESS, HTTP_RESPONSE)
		{
			// Handle Error
			// ...........................................
			if(IS_SUCCESS === false)
			{
				CUS_SEND_DIALOG_TRY_DISMISS();
				METHOD_UNABLE_TO_SEND_REQUEST(CALLBACK_METHOD);	
				return;
			}
			
			
			// Catch JSON Error
			// ...........................................
			if(JSRC_JSON.REF_IS_JSTRING(HTTP_RESPONSE) == false)
			{
				CUS_SEND_DIALOG_TRY_DISMISS();
				METHOD_SERVER_ISSUE(CALLBACK_METHOD, HTTP_RESPONSE);
				return;			
			}
				
				
			// Failed Request (Server issued an error)
			// ...........................................
			var JSON_OBJECT = JSRC_JSON.REF_CREATE(HTTP_RESPONSE);
			if(JSRC_JSON.REF_IS_SUCCESS(JSON_OBJECT) === false)
			{
				CUS_SEND_DIALOG_TRY_DISMISS();
				METHOD_REQUEST_FAILURE(CALLBACK_METHOD, JSON_OBJECT);
				return;
			}
				
		
			// Copy Inserted ID to Saved Rows
			// ...........................................	
			var JSON_COUNT = JSRC_JSON.REF_READ_NVALL(JSON_OBJECT, "JSON_COUNT");
			var CURRENT_CAT_PRODUCT_ID = 0;
			var CURRENT_ROW_INDEX = 0;
			
			while(JSON_COUNT > 0)
			{
				CURRENT_CAT_PRODUCT_ID = JSRC_JSON.REF_READ(JSON_OBJECT, "CAT_PRODUCT_ID", JSON_COUNT);
				CURRENT_ROW_INDEX = PSCHEDULE_DGV.COLUMN.FIND("REC_PSCHEDULE_CAT_PRODUCT_ID", CURRENT_CAT_PRODUCT_ID);
				
				if(CURRENT_ROW_INDEX >= 0)
				{
					PSCHEDULE_DGV.CELL.VALUE
					(
						"REC_PSCHEDULE_ID", CURRENT_ROW_INDEX, 
						JSRC_JSON.REF_READ(JSON_OBJECT, "INSERTED_ID", JSON_COUNT)
					);
				}
				
				JSON_COUNT --;
			}
					
								
			// Loop unfinished save
			// ...........................................
			if(ROW_COUNT > ROW_INDEX)
			{
				HTTP_SAVE(CALLBACK_METHOD, RESUME_INDEX);
				return;
			}
				
				
			// Lift edit and Exit EditMode
			// ...........................................
			EDIT_HANDLER.REF_IS_MODIFIED = false;
			EDIT_HANDLER.HAS_NEWLY_SAVED_DATA = true;			
			CUS_SEND_DIALOG_TRY_DISMISS();
			CALLBACK_METHOD(true);	
													
		};
			
			
		// Save Item [Send Request]
		// _______________________________________________________________________
		RESUME_INDEX = ROW_INDEX;
		JSOC_DIALOG.VAR_LOADING_SPINNER(true);
		JSCUS_SQL._RECORD._PSCHEDULE.CUS_SAVE 
		(
			REQUEST_PARAM_BUNDLE_MAP_ARRAY,
			RESPONSE_HANDLER
		);
		
	};