11 lines
4.5 KiB
JSON
11 lines
4.5 KiB
JSON
{
|
|
"header": {
|
|
"version": 1,
|
|
"type": "record"
|
|
},
|
|
"body": {
|
|
"record1": {
|
|
"<1>": "declare function msg, end_window\r\ndeclare subroutine rlist, record_lock, update_index, create_note\r\n$insert logical\r\n$insert rlist_equates\r\n$insert msg_equates\r\n$insert quote_equ\r\n$insert quote_sigs_equ\r\n\r\nCurrentSize = .gasbar->size\r\nNewSize = CurrentSize\r\nNewSize<3> = 0\r\n.gasbar->size = NewSize\r\n.gasbar->visible = 1\r\nopen 'QUOTE' to QuoteTable else\r\n Void = msg( '', 'Unable to open QUOTE table...' )\r\n return 0\r\nend\r\n* DON'T SET QUOTES TO EXPIRED IF THEY ARE CLOSED\r\nToday = date()\r\nMonthFromNow = date()+30\r\nMonthFromNowOut = oconv( MonthFromNow, 'D2/' )\r\nWeekFromNow = date()+7\r\nStatement = 'SELECT QUOTE WITH STATUS <> \"C\" AND WITH EXP_DATE < ':quote(MonthFromNowOut)\r\nrlist( Statement, target_activelist$, '', '', '' )\r\n@rn.counter = 0\r\nEof = false$\r\nOnePercent = iconv( @reccount*.01, 'MD0' )\r\nloop\r\n readnext Id else Eof = true$\r\nuntil Eof\r\n * ONLY CLOSE THE QUOTES THAT ARE ACTUALLY EXPIRED\r\n read QuoteRec from QuoteTable, Id else\r\n Void = msg( '', 'Unable to read ':Id:' from quote table.' )\r\n return 0\r\n end\r\n ExpDate = QuoteRec<quote_exp_date$>\r\n if ExpDate <= date() then\r\n\t record_lock( QuoteTable, 'Quote', Id )\r\n\t * NEED TO REREAD\r\n\t read QuoteRec from QuoteTable, Id else\r\n\t Void = msg( '', 'Unable to read ':Id:' from quote table.' )\r\n\t return 0\r\n\t end\r\n\t QuoteRec<quote_status$> = 'E' ;* expired\r\n\t write QuoteRec on QuoteTable, Id else\r\n\t Void = msg( '', 'Unable to write ':Id:' on quote table.' )\r\n\t return 0\r\n\t end\r\n\t unlock QuoteTable, Id else\r\n\t Void = msg( '', 'Unable to unlock ':Id:' in quote table.' )\r\n\t return 0\r\n\t end\r\n end else\r\n DaysForExp = ExpDate-Today \r\n if DaysForExp > 30 else\r\n\t * NOW SEE IF WE SHOULD WARN ABOUT EXPIRING\r\n\t ExpWarn = QuoteRec<quote_exp_date_warn$>\r\n\t \t SignatureInfo = xlate( 'CONFIG', 'QUOTE_SIGS', '', 'X' )\r\n\t Notify = xlate( 'CONFIG', 'QUOTE_SIGS', ExpiredQuotesNotif$, 'X' )\r\n\t * REMMED THE BELOW CODE CAUSE THERE WERE TOO MANY MESSAGES\r\n\t *if DaysForExp <= 7 then\r\n\t * * ONLY A WEEK LEFT NOW WARN EVERY DAY\r\n\t * NoteSubject = 'Quote ':Id:' about to expire'\r\n\t * NoteText = 'Quote ':Id:' will expire on ':oconv( ExpDate, 'D2/' ):'...Please see attachment.'\r\n * create_note( Notify, 'System', NoteSubject, NoteText, 'QUOTE', Id )\t \r\n\t *end else\r\n\t * IS BETWEEN 8 AND 30 DAYS BEFORE EXPIRATION ONLY WARN IF THIS QUOTE HAS\r\n\t * NOT ALREADY BEEN USED FOR WARNING\r\n\t if ExpWarn else\r\n\t\t NoteSubject = 'Quote ':Id:' about to expire'\r\n\t\t NoteText = 'Quote ':Id:' will expire on ':oconv( ExpDate, 'D2/' ):'...Please see attachment.'\r\n\t create_note( Notify, 'System', NoteSubject, NoteText, 'QUOTE', Id )\r\n\t end\r\n\t *end\r\n\t if ExpWarn else\r\n\t * HAVE NOT BEEN WARNED ABOUT THIS QUOTE\r\n\t\t\t record_lock( QuoteTable, 'Quote', Id )\r\n\t\t\t * NEED TO REREAD\r\n\t\t\t read QuoteRec from QuoteTable, Id else\r\n\t\t\t Void = msg( '', 'Unable to read ':Id:' from quote table.' )\r\n\t\t\t return 0\r\n\t\t\t end\r\n\t\t\t QuoteRec<quote_exp_date_warn$> = 1 ;* flag \r\n\t\t\t write QuoteRec on QuoteTable, Id else\r\n\t\t\t Void = msg( '', 'Unable to write ':Id:' on quote table.' )\r\n\t\t\t return 0\r\n\t\t\t end\r\n\t\t\t unlock QuoteTable, Id else\r\n\t\t\t Void = msg( '', 'Unable to unlock ':Id:' in quote table.' )\r\n\t\t\t return 0\r\n\t\t\t end\r\n\t end\r\n\t end\r\n end\r\n if mod( @rn.counter, OnePercent ) else\r\n\t NewWidth = CurrentSize<3> * @rn.counter/@reccount\r\n\t .percent_complete->text = oconv(iconv( @rn.counter/@reccount*100, 'MD0' ), 'MD0' ):'%'\r\n\t NewSize<3> = NewWidth\r\n\t .gasbar->redraw = 0\r\n\t .gasbar->size = NewSize\r\n\t .gasbar->redraw = 1\r\n end\r\nrepeat\r\nif @rn.counter > 0 and @reccount > 0 then\r\n\tNewWidth = CurrentSize<3> * @rn.counter/@reccount\r\n\t.percent_complete->text = oconv(iconv( @rn.counter/@reccount*100, 'MD0' ), 'MD0' ):'%'\r\n\tNewSize<3> = NewWidth\r\n\t.gasbar->redraw = 0\r\n\t.gasbar->size = NewSize\r\n\t.gasbar->redraw = 1\r\nend\r\nreturn 1"
|
|
}
|
|
}
|
|
} |