20150210
20150519

ALTER  PROCEDURE [dbo].[POS_SAVE_CASHIER_MGM]

	@CD_STORE 	    		VARCHAR(4),
	@YMD_CLOSE			VARCHAR(8),
	@NO_POS			VARCHAR(2),
	@CD_SAWON			VARCHAR(6),
	@AMT_ACCT_IN		INT,
	@AMT_ACCT_OUT		INT,
	@AMT_SALE			INT,
	@AMT_TAX			INT,
	@AMT_CASH			INT,
	@AMT_CARD			INT,
	@AMT_CHECK			INT,
	@AMT_TRUST			INT,
	@AMT_GIFT			INT,
	@AMT_POINT			INT,
	@AMT_LOSS			INT,
	@AMT_OKC			INT,
	@DC_MENU			INT,
	@DC_CODE			INT,
	@DC_RECEIPT			INT,
	@DC_MEMBER			INT,
	@DC_ENURI			INT,
	@DC_SPC			INT,
	@DC_COUPON			INT,
	@DC_CUT			INT,
	@DC_VAT			INT,
	@AMT_VOID			INT,
	@AMT_BANPUM		INT,
	@CNT_CUSTOMER		INT,
	@AMT_AVERAGE		INT,
	@AMT_LACK			INT,
	@AMT_CASHRCP		INT,
	@RCP_BEGIN			VARCHAR(4),
	@RCP_END			VARCHAR(4),
	@_CHECK			INT,
	@_50000			INT,
	@_10000			INT,
	@_5000			INT,
	@_1000			INT,
	@_500				INT,
	@_100				INT,
	@_50				INT,
	@_10				INT,
	@SEQ				INT OUTPUT
AS
BEGIN
	
	DECLARE @CNT INT

	SELECT @SEQ =ISNULL(MAX(SEQ),	(SELECT ISNULL(MAX(SEQ),0)+1
						   FROM SL_CASHIER_MGM
						WHERE CD_STORE 	=@CD_STORE
						      AND YMD_CLOSE	=@YMD_CLOSE
						      AND NO_POS	=@NO_POS
						      AND CD_SAWON	=@CD_SAWON
						      AND YN_CLOSE	='Y'
				)
			)
	  FROM SL_CASHIER_MGM 
	 WHERE CD_STORE 	=@CD_STORE
	   AND YMD_CLOSE	=@YMD_CLOSE
	   AND NO_POS		=@NO_POS
	   AND CD_SAWON	=@CD_SAWON
	   AND YN_CLOSE = 'N' 

	SELECT @CNT= COUNT(*)
	   FROM SL_CASHIER_MGM
	WHERE CD_STORE 	=@CD_STORE
	      AND YMD_CLOSE	=@YMD_CLOSE
	      AND NO_POS	=@NO_POS
	      AND CD_SAWON	=@CD_SAWON
	      AND SEQ		=@SEQ

	IF @CNT = 0
	BEGIN

	
		INSERT INTO SL_CASHIER_MGM(
							CD_STORE		,
							YMD_CLOSE		,
							NO_POS		,
							CD_SAWON		,
							SEQ			,
							AMT_ACCT_IN		,
							AMT_ACCT_OUT	,
							AMT_SALE		,
							AMT_TAX		,
							AMT_CASH		,
							AMT_CARD		,
							AMT_CHECK		,
							AMT_TRUST		,
							AMT_GIFT		,
							AMT_POINT		,
							AMT_LOSS		,
							AMT_OKC		,
							DC_MENU		,
							DC_CODE		,
							DC_RECEIPT		,
							DC_MEMBER		,
							DC_ENURI		,
							DC_SPC		,
							DC_COUPON		,
							DC_CUT		,
							DC_VAT		,
							AMT_VOID		,
							AMT_BANPUM		,
							CNT_CUSTOMER	,
							AMT_AVERAGE	,
							AMT_LACK		,
							AMT_CASHRCP	,
							RCP_BEGIN		,
							RCP_END		,
							_CHECK,
							_50000,
							_10000,
							_5000,
							_1000,
							_500,
							_100,
							_50,
							_10,
							YN_CLOSE,
							DT_CHANGE		
						)
					VALUES
						(
							 @CD_STORE		,
							 @YMD_CLOSE		,
							 @NO_POS		,
							 @CD_SAWON		,
							 @SEQ			,
							 @AMT_ACCT_IN	,
							 @AMT_ACCT_OUT	,
							 @AMT_SALE		,
							 @AMT_TAX		,
							 @AMT_CASH		,
							 @AMT_CARD		,
							 @AMT_CHECK		,
							 @AMT_TRUST	,
							 @AMT_GIFT		,
							 @AMT_POINT		,
							 @AMT_LOSS		,
							 @AMT_OKC		,
							 @DC_MENU		,
							 @DC_CODE		,
							 @DC_RECEIPT	,
							 @DC_MEMBER	,
							 @DC_ENURI		,
							 @DC_SPC		,
							 @DC_COUPON	,
							 @DC_CUT		,
							 @DC_VAT		,
							 @AMT_VOID		,
							 @AMT_BANPUM	,
							 @CNT_CUSTOMER	,
							 @AMT_AVERAGE	,
							 @AMT_LACK		,
							 @AMT_CASHRCP	,
							 @RCP_BEGIN		,
							 @RCP_END		,
							 @_CHECK,
							 @_50000,
							 @_10000,
							 @_5000,
							 @_1000,
							 @_500,
							 @_100,
							 @_50,
							 @_10,
							 'Y',
							 GETDATE()
						)
	END
	ELSE
	BEGIN
		UPDATE SL_CASHIER_MGM SET 
							
						AMT_SALE	 	=@AMT_SALE		,
						AMT_TAX		=@AMT_TAX		,
						AMT_CASH		=@AMT_CASH		,
						AMT_CARD	 	=@AMT_CARD		,
						AMT_CHECK	 	=@AMT_CHECK	,
						AMT_TRUST	 	=@AMT_TRUST	,
						AMT_GIFT	 	=@AMT_GIFT		,
						AMT_POINT	 	=@AMT_POINT		,
						AMT_LOSS	 	=@AMT_LOSS		,
						AMT_OKC		=@AMT_OKC		,
						DC_MENU	 	=@DC_MENU		,
						DC_CODE	 	=@DC_CODE		,
						DC_RECEIPT	 	=@DC_RECEIPT	,
						DC_MEMBER	 	=@DC_MEMBER	,
						DC_ENURI	 	=@DC_ENURI		,
						DC_SPC	 	=@DC_SPC		,
						DC_COUPON		=@DC_COUPON		,
						DC_CUT		=@DC_CUT		,
						DC_VAT		=@DC_VAT		,
						AMT_VOID	 	=@AMT_VOID		,
						AMT_BANPUM		=@AMT_BANPUM	,
						CNT_CUSTOMER	=@CNT_CUSTOMER	,
						AMT_AVERAGE	=@AMT_AVERAGE	,
						AMT_LACK		=@AMT_LACK		,
						AMT_CASHRCP	=@AMT_CASHRCP	,
						RCP_BEGIN	 	=@RCP_BEGIN		,
						RCP_END	 	=@RCP_END		,
						_CHECK		=@_CHECK		,
						_50000			=@_50000		,
						_10000			=@_10000		,
						_5000			=@_5000		,
						_1000			=@_1000		,
						_500			=@_500		,
						_100			=@_100		,
						_50			=@_50			,
						_10			=@_10			,
						DT_CHANGE		=GETDATE()		,
						YN_CLOSE		= 'Y'
			WHERE CD_STORE 	=@CD_STORE
			      AND YMD_CLOSE	=@YMD_CLOSE
			      AND NO_POS	=@NO_POS
			      AND CD_SAWON	=@CD_SAWON
			      AND SEQ		=@SEQ
	END

	--매출헤더에 계산원마감 번호 셋팅
	UPDATE SL_SALE_H SET NO_CLOSE = @SEQ
	WHERE CD_STORE	=@CD_STORE	
	      AND YMD_SALE	=@YMD_CLOSE
	      AND NO_POS	=@NO_POS
	      AND CD_SAWON	=@CD_SAWON
	      AND NO_CLOSE	=0

	--현금출납에 계산원마감 번호 셋팅
	UPDATE SL_ACCT SET NO_CLOSE = @SEQ
	WHERE CD_STORE		=@CD_STORE	
	      AND YMD_OCCUR		=@YMD_CLOSE
	      AND NO_POS		=@NO_POS
	      AND CD_SAWON_CHG	=@CD_SAWON
	      AND NO_CLOSE		=0
END
GO

if not exists (select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'MS_MENU' and COLUMN_NAME = 'DS_PARKINGTICKET')
  alter table dbo.MS_MENU add
    DS_PARKINGTICKET varchar(2) 
GO


if not exists (select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'MS_STORE' and COLUMN_NAME = 'parkingticketno1')
  alter table dbo.MS_STORE add
    parkingticketno1 varchar(4)  
GO

if not exists (select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'MS_STORE' and COLUMN_NAME = 'parkingticketno2')
  alter table dbo.MS_STORE add
    parkingticketno2 varchar(3)  
GO



ALTER  PROCEDURE SAVE_MS_MENU

	@CD_STORE 	    	VARCHAR(4),
	@CD_MENU      		VARCHAR(14),
	@NM_MENU		    	VARCHAR(50),
	@NM_MENU_SHORT	    	VARCHAR(50),
	@DS_MENU_TYPE    		VARCHAR(1),
	@DS_GENDER			VARCHAR(1),
	@CD_UPJANG			VARCHAR(4),
	@PR_TIP			INTEGER,
	@PR_SALE     			INTEGER,
	@PR_SALE1			INTEGER,
	@DS_TAX 	    		VARCHAR(1),
	@YN_DC			VARCHAR(1),
	@YN_POINT			VARCHAR(1),
	@YN_OKC			VARCHAR(1),
	@CD_CLASS 	    		VARCHAR(8),
	@YN_USE			VARCHAR(1),
	@DS_STOCK			VARCHAR(1),
	@STOCK_CLASS		VARCHAR(3),
	@NM_UNIT			VARCHAR(30),
	@CD_TRDPL			VARCHAR(6),
	@PR_BUY			INT,
	@QTY_SAFETY		INT,
	@CD_SAWON_CHG   		VARCHAR(6),
	@YN_DAMDANG		VARCHAR(1),
        @DS_PARKINGTICKET             VARCHAR(2),
	@I_SW           			CHAR(1)
AS

BEGIN
    DECLARE @CNT INT

    IF @I_SW = 0
    BEGIN
		INSERT INTO  MS_MENU (	CD_STORE, 	 
						CD_MENU,     
						CD_CLASS, 	
						CD_UPJANG, 
						NM_MENU,	
						NM_MENU_SHORT,	 
						DS_MENU_TYPE,
						DS_GENDER,
						PR_TIP,	
						PR_SALE,     
						PR_SALE1,
						DS_TAX, 	
						YN_DC,    
						YN_POINT,
						YN_OKC,
						DS_STOCK,
						STOCK_CLASS,
						NM_UNIT,
						CD_TRDPL,
						PR_BUY,
						QTY_SAFETY,
						YN_USE,		
						CD_SAWON_CHG,
						YN_DAMDANG,
                                                DS_PARKINGTICKET)

   VALUES(	@CD_STORE, 	 
						@CD_MENU,     
						@CD_CLASS, 	 
						@CD_UPJANG,
						@NM_MENU,		
						@NM_MENU_SHORT, 
						@DS_MENU_TYPE,
						@DS_GENDER,
						@PR_TIP,	
						@PR_SALE,     
						@PR_SALE1,
						@DS_TAX, 	   
						@YN_DC, 
						@YN_POINT,
						@YN_OKC,
						@DS_STOCK,
						@STOCK_CLASS,
						@NM_UNIT,
						@CD_TRDPL,
						@PR_BUY,
						@QTY_SAFETY,
						@YN_USE,		
						@CD_SAWON_CHG,
						@YN_DAMDANG,
                                                @DS_PARKINGTICKET)			
    END
    ELSE 
    BEGIN
		UPDATE  MS_MENU     SET 
						CD_CLASS		=@CD_CLASS, 	 
						CD_UPJANG		=@CD_UPJANG,
						NM_MENU		=@NM_MENU, 
						NM_MENU_SHORT        =@NM_MENU_SHORT,						
						DS_MENU_TYPE	=@DS_MENU_TYPE,
						DS_GENDER		=@DS_GENDER,
						PR_TIP		=@PR_TIP,
						PR_SALE		=@PR_SALE,     
						PR_SALE1		=@PR_SALE1,
						DS_TAX 		=@DS_TAX,    
						YN_DC			=@YN_DC,
						YN_POINT		=@YN_POINT,
						YN_OKC		=@YN_OKC,
						DS_STOCK		=@DS_STOCK,
						STOCK_CLASS		=@STOCK_CLASS,
						NM_UNIT		=@NM_UNIT,
						CD_TRDPL		=@CD_TRDPL,
						PR_BUY		=@PR_BUY,
						QTY_SAFETY		=@QTY_SAFETY,
						YN_USE		=@YN_USE,
						CD_SAWON_CHG	=@CD_SAWON_CHG,
						YN_DAMDANG		=@YN_DAMDANG,
                                                DS_PARKINGTICKET    =@DS_PARKINGTICKET,
						DT_CHANGE          	=GETDATE()
		WHERE   CD_STORE 		= @CD_STORE 
			AND   CD_MENU 		= @CD_MENU
    END
END
GO

ALTER   PROCEDURE SAVE_MS_STORE
	@CD_STORE 		VARCHAR(4),
	@CD_SAWON_CHG 	VARCHAR(6),
	@I_SW    	  	CHAR(1),
	@NM_STORE  	 	VARCHAR(30),
	@NM_BOSS   	 	VARCHAR(10),
	@NO_BIZER  	 	VARCHAR(12),
	@NM_UPTAE  	 	VARCHAR(30),
	@NM_UPJONG 	VARCHAR(30),
	@TEL_OFFICE 	 	VARCHAR(13),
	@TEL_MOBIL1		VARCHAR(13),
	@TEL_MOBIL2		VARCHAR(13),
	@TEL_FAX   		VARCHAR(13),
	@NO_POST  	 	VARCHAR(6),
	@ADDR1     	 	VARCHAR(40),
	@ADDR2    	 	VARCHAR(40),
	@PNT_MIN_USE 	INT,
	@RCP_TITLE1	 	VARCHAR(42),
	@RCP_TITLE2	 	VARCHAR(42),
	@RCP_TITLE3 	 	VARCHAR(42),
	@RCP_TITLE4	 	VARCHAR(42),
	@CARD_TITLE1	VARCHAR(42),
	@CARD_TITLE2	VARCHAR(42),
	@CARD_TITLE3 	VARCHAR(42),
	@CARD_TITLE4	VARCHAR(42),
	@RCP_END1 		VARCHAR(42),
	@RCP_END2 		VARCHAR(42),
	@RCP_END3 		VARCHAR(42),
	@TICKET_END1	VARCHAR(42),
	@TICKET_END2	VARCHAR(42),
	@TICKET_END3	VARCHAR(42),
	@TICKET_END4	VARCHAR(42),
	@TICKET_END5	VARCHAR(42),
	@TICKET_END6	VARCHAR(42),
	@TICKET_END7	VARCHAR(42),
	@TICKET_END8	VARCHAR(42),
	@TICKET_END9	VARCHAR(42),
	@TICKET_END10	VARCHAR(42),
	@CDP_ACCOUNT 	VARCHAR(40),
	@CDP_READY  	VARCHAR(40),
	@CONF        	 	VARCHAR(200),
	@USE_MENU		VARCHAR(50),
	@REMARK    		VARCHAR(100),
	@DC_UNIT		INT,
	@LEN_CARD		INT,
	@PREFIX		VARCHAR(20),
	@NO_POS		VARCHAR(2),
	@LEN_MENU		INT,
	@CASHAMT_STD	INT,
	@CASH_POINT		INT,
	@CARDAMT_STD	INT,
	@CARD_POINT	INT,
	@CASHRCPAMT_STD	INT,
	@CASHRCP_POINT	INT,
	@POINT_MIN		INT,
	@RT_ONEVAN		INT,
	@AMT_LIMIT		INT,
	@CUST_TITLE		VARCHAR(30),
	@RPT_PWD		VARCHAR(20),
	@SIMPLE_RCP		VARCHAR(50),
	@MIN_AFTER		INT,
	@MIN_EACH		INT,
	@AMT_ADD		INT,
	@ADD_MENU		VARCHAR(14),
	@CLSTEP1		INT,
	@CLSTEP2		INT,
	@CLSTEP3		INT,
	@CLCOLOR1		VARCHAR(30),
	@CLCOLOR2		VARCHAR(30),
	@CLCOLOR3		VARCHAR(30),
	@LOCK_X		INT,
	@LOCK_Y		INT,
	@LOCKPOS_X		INT,
	@LOCKPOS_Y		INT,
	@LOCKPOS_F		INT,
	@CLIPBOARD		VARCHAR(30),
	@TICKET_TITLE	VARCHAR(20),
	@LEN_COUPON	INT,
	@DAYTIME_BEGIN	VARCHAR(5),
	@DAYTIME_END	VARCHAR(5),
	@NIGHTTIME_BEGIN	VARCHAR(5),
	@NIGHTTIME_END	VARCHAR(5),
	@BACKUP_DIR		VARCHAR(100),
	@AMT_DEFREADY	INT,
	@CARD_FEE		NUMERIC(3,1),
	@POSJOINMENU	VARCHAR(13),
	@POSFILLMENU	VARCHAR(13),
	@POSFILLCODE	VARCHAR(3),
	@POINTMEMBER	VARCHAR(3),
	@POSUSEMENU1	VARCHAR(4),
	@POSUSEMENU2	VARCHAR(4),
  @PARKINGTICKETNO1 VARCHAR(4),
  @PARKINGTICKETNO2 VARCHAR(3)


AS
BEGIN
	UPDATE MS_STORE 
	   SET 	NM_STORE		  =@NM_STORE,
					NM_BOSS		    =@NM_BOSS,
					NO_BIZER		  =@NO_BIZER,
					NM_UPTAE		  =@NM_UPTAE,
					NM_UPJONG 	  =@NM_UPJONG,
			    TEL_OFFICE	  =@TEL_OFFICE,
					TEL_MOBIL1	  =@TEL_MOBIL1,
					TEL_MOBIL2	  =@TEL_MOBIL2,
					TEL_FAX		    =@TEL_FAX,
					NO_POST		    =@NO_POST,
					ADDR1			    =@ADDR1,
					ADDR2			    =@ADDR2,
					PNT_MIN_USE		=@PNT_MIN_USE,
					RCP_TITLE1		=@RCP_TITLE1,
					RCP_TITLE2		=@RCP_TITLE2,
					RCP_TITLE3		=@RCP_TITLE3,
					RCP_TITLE4		=@RCP_TITLE4,
					CARD_TITLE1		=@CARD_TITLE1,
					CARD_TITLE2		=@CARD_TITLE2,
					CARD_TITLE3		=@CARD_TITLE3,
					CARD_TITLE4		=@CARD_TITLE4,
					RCP_END1		  =@RCP_END1,
					RCP_END2		  =@RCP_END2,
			    RCP_END3		  =@RCP_END3,
					TICKET_END1		=@TICKET_END1,
					TICKET_END2		=@TICKET_END2,
			    TICKET_END3		=@TICKET_END3,
			    TICKET_END4		=@TICKET_END4,
			    TICKET_END5		=@TICKET_END5,
			    TICKET_END6		=@TICKET_END6,
			    TICKET_END7		=@TICKET_END7,
			    TICKET_END8		=@TICKET_END8,
			    TICKET_END9		=@TICKET_END9,
			    TICKET_END10	=@TICKET_END10,
					CDP_ACCOUNT	  =@CDP_ACCOUNT,
					CDP_READY		  =@CDP_READY,
					CONF 			    =@CONF,
					USE_MENU		  =@USE_MENU,
					REMARK 		    =@REMARK,
					DC_UNIT		    =@DC_UNIT,
					LEN_CARD		  =@LEN_CARD,
					PREFIX			  =@PREFIX,
					NO_POS		    =@NO_POS,
					LEN_MENU		  =@LEN_MENU,
					CASHAMT_STD	  =@CASHAMT_STD,
					CASH_POINT		=@CASH_POINT,
					CARDAMT_STD	  =@CARDAMT_STD,
					CARD_POINT		=@CARD_POINT,
					CASHRCPAMT_STD	=@CASHRCPAMT_STD,
					CASHRCP_POINT	=@CASHRCP_POINT,
					POINT_MIN		  =@POINT_MIN,
					RT_ONEVAN		  =@RT_ONEVAN,
					CUST_TITLE		=@CUST_TITLE,
					POSRPT_PWD		=@RPT_PWD,
					SIMPLE_RCP		=@SIMPLE_RCP,
					AMT_LIMIT		  =@AMT_LIMIT,
					MIN_AFTER		  =@MIN_AFTER,
					MIN_EACH		  =@MIN_EACH,
					AMT_ADD		    =@AMT_ADD,
					ADD_MENU		  =@ADD_MENU,
					CLSTEP1		    =@CLSTEP1,
					CLSTEP2		    =@CLSTEP2,
					CLSTEP3		    =@CLSTEP3,
					CLCOLOR1		  =@CLCOLOR1,
					CLCOLOR2		  =@CLCOLOR2,
					CLCOLOR3		  =@CLCOLOR3,
					LOCK_X		    =@LOCK_X,
					LOCK_Y		    =@LOCK_Y,
					LOCKPOS_X		  =@LOCKPOS_X,
					LOCKPOS_Y		  =@LOCKPOS_Y,
					LOCKPOS_F		  =@LOCKPOS_F,
					CLIPBOARD		  =@CLIPBOARD,
					TICKET_TITLE	=@TICKET_TITLE,
					LEN_COUPON		=@LEN_COUPON,
					DAYTIME_BEGIN	=@DAYTIME_BEGIN,
					DAYTIME_END		=@DAYTIME_END,
					NIGHTTIME_BEGIN	=@NIGHTTIME_BEGIN,
					NIGHTTIME_END	=@NIGHTTIME_END,
					BACKUP_DIR		=@BACKUP_DIR,
					AMT_DEFREADY	=@AMT_DEFREADY,
					CARD_FEE		  =@CARD_FEE,
					POSJOINMENU		=@POSJOINMENU,
					POSFILLMENU		=@POSFILLMENU,
					POSFILLCODE		=@POSFILLCODE,
					POINTMEMBER	  =@POINTMEMBER,
					POSUSEMENU1	  =@POSUSEMENU1,
					POSUSEMENU2	  =@POSUSEMENU2,
          PARKINGTICKETNO1    =@PARKINGTICKETNO1,
          PARKINGTICKETNO2    =@PARKINGTICKETNO2,
					DT_CHANGE		  =GETDATE()
	  WHERE CD_STORE=@CD_STORE
END
GO
