
var SEARCH_CMD = null;
var EXPORT_BBI = null;
var LOAD_PRODUCT_BBI = null;
var POS_SALE_LIST_DGV = null;
var TRANSFLOW_SMRY_DGV = null;

var DGV_INDEX = -1;

var SKIP = 0;


function FORM_INITIALIZE()
{
	if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_DATE_FROM_SALES_BY_PROD_DTP"))
	{
		JSOC_ELEMENT.VAR_VALUE("SEARCH_DATE_FROM_SALES_BY_PROD_DTP", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_ADD('DAY', 1, JSVC_DATE.VAR_BEGIN_OF_MONTH(JSVC_DATE.VAR_NOW())), "YYYY-MM-DD") + "T00:00");

	}

	if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_DATE_TO_SALES_BY_PROD_DTP"))
	{
		JSOC_ELEMENT.VAR_VALUE("SEARCH_DATE_TO_SALES_BY_PROD_DTP", JSVC_DATE.VAR_FORMAT(JSVC_DATE.VAR_ADD('DAY', 0, JSVC_DATE.VAR_NOW()), "YYYY-MM-DD") + "T00:00");
	}

	// Initialize: Ribbon Buttons [Add Search]
	// ...........................................
	if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("SEARCH_CMD"))
	{
		
		SKIP = 0; DGV_INDEX = -1;
		SEARCH_CMD = JSOC_ELEMENT.VAR_GET("SEARCH_CMD");
		SEARCH_CMD.onclick = function()
		{
			INITIALIZE_DGV();
			HTTP_LOAD_EOD_PERPROD();
		};
	}

	if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("LOAD_PRODUCT_BBI"))
	{
		SKIP = 0;
		LOAD_PRODUCT_BBI = JSOC_ELEMENT.VAR_GET("LOAD_PRODUCT_BBI");
		LOAD_PRODUCT_BBI.onclick = function(){HTTP_LOAD_PRODUCT()};
	}
	
	// Initialize: Ribbon Buttons [Add Search]
	// ...........................................
	if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("REMOVE_BBI"))
	{
		var REMOVE_BBI = JSOC_ELEMENT.VAR_GET("REMOVE_BBI");
		REMOVE_BBI.onclick = function()
		{
			var ROW_INDEX = 0;		
			while(TRANSFLOW_SMRY_DGV.ROW.COUNT() > ROW_INDEX)
			{
				if(TRANSFLOW_SMRY_DGV.CELL.VALUE("CHECK_CMD", ROW_INDEX) == false)
				{
					TRANSFLOW_SMRY_DGV.ROW.REMOVE_AT(ROW_INDEX);
					continue;
				}
				ROW_INDEX++;
			}
			
			DGV_SUM();
		};
	}	
	
	// Initialize: Ribbon Buttons [Add Search]
	// ...........................................
	if(JSOC_ELEMENT.VAR_ELEMENT_EXISTS("EXPORT_BBI"))
	{
		EXPORT_BBI = JSOC_ELEMENT.VAR_GET("EXPORT_BBI");
		EXPORT_BBI.onclick = function()
		{
			JSRC_EXCEL.REF_EXPORT('TRANSFLOW_SMRY_DGV');
		};
	}	
}