COMPILE ROUTINE FIX_NOTES(Dummy)
ROWDEF (CHARSTR)

DECLARE SUBROUTINE SEND_INFO, SEND_DYN, RList,Btree.Extract, Set_Status, Get_Status


$INSERT NOTES_EQU


OPEN 'NOTES' TO FileIn ELSE
	Send_Info('Puked on NOTES table open.')
	GOTO Bail
END

SELECT FileIn

/*
equ NOTES_MESSAGE_TYPE$ to 1
equ NOTES_ENTRY_DATE$ to 2
equ NOTES_ENTRY_TIME$ to 3
equ NOTES_SEND_TO$ to 4
equ NOTES_FROM$ to 5
equ NOTES_COMPANY$ to 6
equ NOTES_PHONE$ to 7
equ NOTES_INTL_PHONE$ to 8
equ NOTES_MESSAGE$ to 9
equ NOTES_ENTRY_ID$ to 10
equ NOTES_PT_PHONED$ to 11
equ NOTES_PT_CALL_BACK$ to 12
equ NOTES_PT_RET_CALL$ to 13
equ NOTES_PT_WANTS_SEE$ to 14
equ NOTES_PT_WILL_CALL$ to 15
equ NOTES_PT_WAS_IN$ to 16
equ NOTES_PT_URGENT$ to 17
equ NOTES_SUBJECT$ to 18
equ NOTES_ATTACH_WINDOW$ to 19
equ NOTES_ATTACH_KEYS$ to 20
equ NOTES_MSG_GROUPS_IDS$ to 21
*/

DEBUG

CutOffDt = ICONV('12/31/2013','D')			;* Purge up to and including this entry date

Done = 0
RecCnt = 0
FixCnt = 0
LOOP
	READNEXT NoteID ELSE Done = 1
UNTIL Done 
	READ NoteRec FROM FileIn,NoteID THEN
		RecCnt += 1
		IF NoteRec<NOTES_ENTRY_DATE$> LE CutOffDt THEN
		
			FixCnt += 1
		
			EntryDate = OCONV(NoteRec<NOTES_ENTRY_DATE$>,'D4/')
			EntryID = NoteRec<NOTES_ENTRY_ID$>
			From	= NoteRec<NOTES_FROM$>
			Subject = NoteRec<NOTES_SUBJECT$>
			
			*Send_Dyn(NoteID:' ':EntryID:' ':From:' ':Subject)				
			
				*DELETE FileIn,NoteID THEN
					
					Send_Info(RecCnt:' ':FixCnt)
				*END
				
			
		END
	END
REPEAT


GOTO BAIL



* * * * * * *
Bail:
* * * * * * *

END
