COMPILE FUNCTION obj_Calib_List(Method,Parms) /* Methods for Calib_List table 3/18/2010 JCH - Initial Coding Properties: Methods: SendReminders ;* Send Notes reminding of calibrations coming due */ DECLARE FUNCTION Get_Status, Msg, Utility, obj_Tables, Dialog_Box, Popup DECLARE SUBROUTINE Set_Status, Msg, obj_Tables, RList, obj_Notes $INSERT MSG_EQUATES $INSERT CALIB_LIST_EQUATES $INSERT RLIST_EQUATES $INSERT NOTIFICATION_EQU EQU PDISPLAY$ TO 8 ;* From Popup_Equates EQU CRLF$ TO \0D0A\ ErrTitle = 'Error in Stored Procedure "obj_Calib_List"' 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 = 'SendReminders' ; GOSUB SendReminders CASE 1 END CASE IF ErrorMsg NE '' THEN Set_Status(-1,ErrTitle:@SVM:ErrorMsg) RETURN '' END RETURN Result * * * * * * * SendReminders: * * * * * * * OPEN 'CALIB_LIST' TO FileIn ELSE ErrorMsg = 'Unable to open "CALIB_LIST" table. (':Method:')' RETURN END CheckDt = OCONV(Date()+15,'D4/') SelectSent = 'SELECT CALIB_LIST WITH NEXT_CAL_DT < ':QUOTE(CheckDt):' BY NEXT_CAL_DT' RList(SelectSent,TARGET_ACTIVELIST$,'','','') NoteText = '' Depts = '' Done = 0 LOOP READNEXT CLNo ELSE Done = 1 UNTIL Done READ CLRec FROM FileIn,CLNo THEN NextCalDt = OCONV(XLATE('CALIB_LIST',CLNo,'NEXT_CAL_DT','X'),'D4/') IF NextCalDt NE '' THEN CLType = CLRec Dept = CLRec IF Dept = '' THEN Dept = 'MET' IF CLType = 'E' THEN Desc = CLRec SN = CLRec Loc = CLRec SN = CLRec Loc = CLRec NewLine = 'The NIST Standard ':Desc:' (S/N: ':SN:') located in the ':Loc:' is due for calibration on ':NextCalDt:CRLF$ END LOCATE Dept IN Depts USING @FM SETTING Pos ELSE Depts = INSERT(Depts,Pos,0,0,Dept) END NoteText = NoteText:NewLine END ;* End of check for NextCalDt END ;* End of CLRec read REPEAT DeptUsers = '' DeptDescs ='' PopupLiteral = XLATE('SYSREPOSPOPUPS',@APPID<1>:'**DEPT',PDISPLAY$,'X') CONVERT @VM:@SVM TO @FM:@VM IN PopupLiteral LiteralCnt = COUNT(PopupLiteral,@FM) + (PopupLiteral NE '') FOR I = 1 TO LiteralCnt Dept = PopupLiteral DeptDesc = PopupLiteral UserNames = PopupLiteral LOCATE Dept IN Depts USING @FM SETTING Pos THEN CONVERT ' ' TO '' IN UserNames CONVERT ',' TO @VM IN UserNames DeptUsers = UserNames DeptDescs = DeptDesc END NEXT I NoteSubject = "Equipment Calibration Reminder" DeptCnt = COUNT(Depts,@FM) + (Depts NE '') FOR I = 1 TO DeptCnt IF NoteText NE '' THEN *NoteText = 'Testing during development of new functionality - disregard':CRLF$:NoteText Recipients = DeptUsers LOCATE @USER4 IN Recipients SETTING Dummy THEN Recipient = @USER4 SentFrom = 'System' Subject = DeptDescs:" Department - Equipment Calibration Reminder" Message = NoteText AttachWindow = 'MASTER_CALIB_LIST' AttachKeys = '' SendToGroup = '' Obj_Notes('Create',Recipient:@RM:'System':@RM:NoteSubject:@RM:NoteText:@RM:'MASTER_CALIB_LIST') END END NEXT I RETURN