COMPILE FUNCTION obj_Login(Method,Parms)

/*
	Methods for LSL2 window login
    
	4/16/2012 JCH - Initial Coding
     
    Properties:
     
    Methods:
    
   * LateShip				;* Returns Property
   
	
*/

DECLARE SUBROUTINE  Set_Status, Msg, obj_Tables, Send_Dyn, ErrMsg, obj_Appwindow, RList,obj_Notes, Send_Info
DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, NextKey, obj_Prod_Spec


EQU CRLF$	TO \0D0A\
EQU TAB$	TO \09\ 

$INSERT WO_LOG_EQUATES
$INSERT NOTIFICATION_EQU
$INSERT RLIST_EQUATES



ErrTitle = 'Error in Stored Procedure "obj_Login"'
ErrorMsg = ''

IF NOT(ASSIGNED(Method))	THEN ErrorMsg = 'Unassigned parameter "Method" passed to subroutine'
IF NOT(ASSIGNED(Parms))		THEN Parms = ''

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
	RETURN ''
END

Result = ''

BEGIN CASE
	CASE Method = 'LateShip'		; GOSUB LateShip
	CASE 1
		ErrorMsg = 'Unknown Method ':Method:' passed to object routine.'
END CASE

IF ErrorMsg NE '' THEN
	Set_Status(-1,ErrTitle:@SVM:ErrorMsg)
END

RETURN Result


* * * * * * *
LateShip:
* * * * * * *

RETURN
//DPC 3/3/2020 - obsolete code, commented out due to sometimes sending errant emails
* Checks for WO's with Commit_Date's that are passed due or due within 1 day

* CustNos = ''
* CustNos := '562':@FM		;* GMCH DSP & 5" 2 layer
* CustNos := '6622':@FM		;* GMCH Kokomo Semiconductor
* CustNos := '406':@FM		;* GMCH Procurement
* CustNos := '7049':@FM		;* OnSemi - Czech Republic
* CustNos := '7033':@FM		;* OnSemi - Gresham, OR
* CustNos := '6781'			;* OnSemi - Pocatello, ID
* 
* 
* Send_Info('Checking for late shipments ...')
* 
* IF Get_Status(errCode) THEN RETURN
* 
* CustCnt = COUNT(CustNos,@FM) + (CustNos NE '')
* 
* FOR I = 1 TO CustCnt
* 	IF I = 1 THEN
*		SelectStatement  = 'SELECT WO_LOG WITH CUST_NO = ':QUOTE(CustNos<I>):' '
* 	END ELSE
*		SelectStatement := ' ':QUOTE(CustNos<I>)
* 	END
* NEXT I
* 
* SelectStatement := ' AND WITH PROD_ORD_NO NE "" AND WITH WO_STOP_DT = "" BY COMMIT_DATE'
* 
* RList(SelectStatement, TARGET_ACTIVELIST$, '','','')
* 
* IF Get_Status(errCode) THEN
* 	ErrMsg(errCode)
* 	Msg(@WINDOW,MsgUp)
* 	RETURN
* END
* 
* OPEN 'WO_LOG' TO WOFile ELSE 
* 	ErrMsg('Unable to Open WO_LOG table in obj_Login("LateShip",... ')
* 	RETURN
* END
* 
* Mesg  = 'Customer Work Order(s) nearly due or past due.':CRLF$
* Mesg := 'WO No':TAB$:'Cust No':TAB$:'Prod Ord No':TAB$:'WO Start DTM':TAB$:TAB$:'Commit Date':TAB$:'Status':CRLF$:CRLF$
* 
* SendFlag = 0
* Done = 0
* 
* LOOP
* 	READNEXT WONo ELSE Done = 1
* UNTIL Done
* 	READ WORec FROM WOFile,WONo THEN
*		WOStopDt = WORec<WO_LOG_WO_STOP_DTM$>[1,'.']
*		MesgLine = ''
*		
*		IF WOStopDt = '' THEN
*		
*			CommitDt = WORec<WO_LOG_COMMIT_DATE$>
*			CurrDt	= Date()
*			
*			DateDelta = CommitDt - CurrDt
*			
*			BEGIN CASE
*			
*				CASE DateDelta = 1
*					MesgLine  = WONo:TAB$:WORec<WO_LOG_CUST_NO$>:TAB$:WORec<WO_LOG_PROD_ORD_NO$>:TAB$:OCONV(WORec<WO_LOG_WO_START_DTM$>,'DT4/^HS')
*					MesgLine := TAB$:OCONV(WORec<WO_LOG_COMMIT_DATE$>,'D4/'):TAB$:'Commit Date is tomorrow':CRLF$
*					SendFlag = 1
*					
*				CASE DateDelta = 0
*					MesgLine  = WONo:TAB$:WORec<WO_LOG_CUST_NO$>:TAB$:WORec<WO_LOG_PROD_ORD_NO$>:TAB$:OCONV(WORec<WO_LOG_WO_START_DTM$>,'DT4/^HS')
*					MesgLine := TAB$:OCONV(WORec<WO_LOG_COMMIT_DATE$>,'D4/'):TAB$:'Commit Date is today':CRLF$
*					SendFlag = 1
*					
*				CASE DateDelta < 0
*					MesgLine  = WONo:TAB$:WORec<WO_LOG_CUST_NO$>:TAB$:WORec<WO_LOG_PROD_ORD_NO$>:TAB$:OCONV(WORec<WO_LOG_WO_START_DTM$>,'DT4/^HS')
*					MesgLine := TAB$:OCONV(WORec<WO_LOG_COMMIT_DATE$>,'D4/'):TAB$:'Commit Date is ':ABS(DateDelta):' days past due':CRLF$
*					SendFlag = 1
*					
*				CASE 1
*					*MesgLine  = WONo:TAB$:WORec<WO_LOG_CUST_NO$>:TAB$:WORec<WO_LOG_PROD_ORD_NO$>:TAB$:OCONV(WORec<WO_LOG_WO_START_DTM$>,'DT4/^HS')
*					*MesgLine := TAB$:OCONV(WORec<WO_LOG_COMMIT_DATE$>,'D4/'):TAB$:'Commit Date is ':DateDelta:' days in the future':CRLF$
*					MesgLine = ''
*			
*			END CASE
*			
*			IF MesgLine NE '' THEN
*				Mesg := MesgLine
*			END
*			
*		END	;* End of check for WOStopDt
* 	
*		
* 	END	;* End of WORec Read
* REPEAT
* 
* Send_Info(' ')
* 
* IF SendFlag = 1 THEN
* 	Recipients		= @USER4
* 	SentFrom		= 'OpenInsight Login Process'
* 	Subject			= 'Merchant Customer Late Work Order Warning '
* 	Message			= Mesg
* 	AttachWindow	= ''
* 	AttachKey		= ''
* 	SendToGroup		= ''   
* 
* 	Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
* 	obj_Notes('Create',Parms)
* 
* 	IF Get_Status(errCode) THEN
*		ErrMsg(errCode)
* 	END
* END


RETURN
