ALTER PROCEDURE [dbo].[PDSCMBSSALESDOCSTATUS]
(
	@DocType VARCHAR(20)
	,@MenuID VARCHAR(250)
)
AS

--DECLARE @DocType VARCHAR(20) = ''
--DECLARE @MenuID VARCHAR(250) = 'SALESORDERREQ'

IF(@MenuID = 'SALESINQDRAFT')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocStatus = '1' AND DocType = 'SINQ'
END
ELSE IF(@MenuID = 'SALESINQ')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocType = 'SINQ'
END
ELSE IF(@MenuID = 'SALESORDERDRAFT')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocStatus IN ('4') AND DocType = 'SORD'--DocStatus IN ('7','9') AND DocType = 'SORD'
END
ELSE IF(@MenuID = 'SALESORDERREQ')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocStatus IN ('4','1','5') AND DocType = 'SORD'
END
ELSE IF(@MenuID = 'SALESORDERAPR')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocStatus IN ('1','3','5') AND DocType = 'SORD'
END
ELSE IF(@MenuID = 'SALESORDER')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocType = 'SORD'
END
ELSE IF(@MenuID = 'SALESQUOTADRAFT')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocStatus IN ('1') AND DocType = 'SQUO'
END
ELSE IF(@MenuID = 'SALESQUOTAREQ')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocStatus IN ('4','1','5') AND DocType = 'SQUO'
END
ELSE IF(@MenuID = 'SALESQUOTAAPR')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocStatus IN ('1','3','5') AND DocType = 'SQUO'
END
ELSE IF(@MenuID = 'SALESQUOTA')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocType = 'SQUO'
END
ELSE IF(@MenuID = 'SALESRETURN')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocType = 'SRTN'
END
ELSE IF(@MenuID = 'PREORDER')
BEGIN
	SELECT * 
	FROM dbo.PCMBSSALESDOCSTATUS
	WHERE DocType = 'PREOD'
END
ELSE
BEGIN
	SELECT DISTINCT *
	FROM dbo.PCMBSSALESDOCSTATUS
END