
DECLARE CONSTANT FLD_BookDefID		AS QUANTITY 2099
DECLARE CONSTANT FLD_InstrumentID 	AS QUANTITY 2051
DECLARE CONSTANT FLD_OwnerID		AS QUANTITY	2015
DECLARE CONSTANT FLD_Side	 		AS QUANTITY 2053
DECLARE CONSTANT FLD_Size	 		AS QUANTITY 10032
DECLARE CONSTANT FLD_RFQID 			AS QUANTITY 50021


DECLARE CONSTANT FLD_Submit		 	AS QUANTITY 80000

# Message box icons
DECLARE CONSTANT MSG_BOX_ICON_Critical	AS QUANTITY 0
DECLARE CONSTANT MSG_BOX_ICON_Question	AS QUANTITY 1
DECLARE CONSTANT MSG_BOX_ICON_Exclaim	AS QUANTITY 2
DECLARE CONSTANT MSG_BOX_ICON_Info		AS QUANTITY 3

# Message box types
DECLARE CONSTANT MSG_BOX_TYPE_AbortRetryIgnore	AS QUANTITY 0
DECLARE CONSTANT MSG_BOX_TYPE_Ok			AS QUANTITY 1
DECLARE CONSTANT MSG_BOX_TYPE_OkCancel		AS QUANTITY 2
DECLARE CONSTANT MSG_BOX_TYPE_RetryCancel		AS QUANTITY 3
DECLARE CONSTANT MSG_BOX_TYPE_YesNo		AS QUANTITY 4

# Message box reponse values
DECLARE CONSTANT MSG_BOX_RES_Yes	AS QUANTITY 6
DECLARE CONSTANT MSG_BOX_RES_No	AS QUANTITY 7


PROCEDURE PackMessage RETURNS QUANTITY DO
{
	SetFieldValueInCarrierMsg(FLD_RFQID,GetFieldValue1(FLD_RFQID));
	SetFieldValueInCarrierMsg(FLD_Side,GetFieldValue1(FLD_Side));
	SetFieldValueInCarrierMsg(FLD_Size,GetFieldValue1(FLD_Size));
	
	SetFieldValueInCarrierMsg(FLD_InstrumentID,GetInitialValueString("INSTRUMENT_ID"));
	SetFieldValueInCarrierMsg(FLD_BookDefID,GetInitialValueString("BOOK_ID"));
	SetFieldValueInCarrierMsg(FLD_OwnerID,GetInitialValueString("USER_ID"));
	
	RETURN 1;
}


PROCEDURE OnPress
        DECLARE PARAMETER nButtonID as QUANTITY
        DECLARE PARAMETER sButtonName as TEXT DO
{
	DECLARE VARIABLE nSuccess	AS QUANTITY
	DECLARE VARIABLE nConfirm	AS QUANTITY
	DECLARE VARIABLE nResponse	AS QUANTITY

	IF ([nButtonID] = FLD_Submit) DO
	{
		[nSuccess] := PackMessage();
		
		IF ( [nSuccess] = 1 ) DO
		{
			[nConfirm] := GetInitialValueInt("CONFIRM_SUBMIT");
			IF ( [nConfirm] = 1 ) THEN
			{
				[nResponse] := MessageBox("Send the Order?","Confirm",MSG_BOX_TYPE_YesNo,MSG_BOX_ICON_Question);
				
				IF ( [nResponse] = MSG_BOX_RES_Yes ) DO
				{
					SendMsg();
				}
			}
			ELSE
			{
				SendMsg();
			}
		}
	}
}


PROCEDURE OnReturnPage
        DECLARE PARAMETER nControlID as QUANTITY
        DECLARE PARAMETER sListName as TEXT DO
{
	DECLARE VARIABLE nSuccess	AS QUANTITY
	DECLARE VARIABLE nConfirm	AS QUANTITY
	DECLARE VARIABLE nResponse	AS QUANTITY
  
  	[nSuccess] := PackMessage();
		
	IF ( [nSuccess] = 1 ) DO
	{
		[nConfirm] := GetInitialValueInt("CONFIRM_SUBMIT");
		IF ( [nConfirm] = 1 ) THEN
		{
			[nResponse] := MessageBox("Send the Order?","Confirm",MSG_BOX_TYPE_YesNo,MSG_BOX_ICON_Question);
			
			IF ( [nResponse] = MSG_BOX_RES_Yes ) DO
			{
				SendMsg();
			}
		}
		ELSE
		{
			SendMsg();
		}
	}
}
