lib
{===============================
Form_Start =================================}
proc Form_Start()
mform = GetNewestForm
()
orient= GetParameter
("AU_MAILVIEWLEFTORRIGHT"
)
if (orient = "HORIZ"
) then
call CreateNestZones
("TYPE=SINGLE;ORIENT=HORIZ;CNT=1;PAGERS1=1;HEIGHT1=50"
,mform
)
else
call CreateNestZones
("TYPE=SINGLE;ORIENT=VERT;CNT=1;PAGERS1=1;HEIGHT1=50"
,mform
)
endif
call SetCaption
("Inbox"
)
call CollapseNavBar
()
call SetClass
("grid"
,"TStringGrid1"
)
end
{=============================== Form_Prepared =================================}
proc Form_Prepared
()
crdat = DateToNum
(crDate
)
crdat = crdat - 1
crdat = NumToDate
(crdat
)
if (DBModel = "MSACCESS"
) then
filter = strcat
("
(AU_MAIL.MDATE >= CDATE
('"
,crdat
,"'
))"
)
elseif (DBModel = "MSSQLSERVER"
) then
filter = strcat
("
(AU_MAIL.MDATE >= "
,crdat
,"
)"
)
endif
call BrowseFilter
(filter
)
call SetEditableFields
(mform
,"MLABEL"
)
end
{===============================
Panels_Start =================================}
proc Panels_Start()
READEDMAILFONTSTYLE = GetParameter
("AU_READEDMAILFONTSTYLE"
)
READEDMAILFONTCOLOR = GetParameter
("AU_READEDMAILFONTCOLOR"
)
mode = __params[4]
if (mode = ""
) then
mode = "ALL_MODE"
endif
if (mode = "USER_MODE"
) then
start_sql "DATA" "KOSMOS"
SELECT AU_ORGAN.KUSER
, AU_MAIL.AU_USER
, AU_MAIL.MDATE
, AU_MAIL.READ_FLAG
, AU_MAIL.IN_FLAG
, AU_MAIL.OUT_FLAG
,
AU_MAIL.SUBJECT
, AU_MAIL.MAIL_FROM
, AU_BUSINESS.TITLE
, AU_MAIL.AU_DOC
, AU_MAIL.AU_MAIL_POP3_MBOX
,
AU_MAIL.MTIME
, AU_MAIL.ATT_FLAG
, AU_MAIL.SENDER_FLAG
, AU_CONTACT.DISP_NAME
, AU_USER.UNAME
, AU_MAIL.MSGID
,
AU_MAIL.AU_MAIL
, AU_MAIL.MLABEL
, AU_MAIL.STATUS
, AU_CONTACT.AU_CONTACT
, AU_BUSINESS.AU_BUSINESS
, AU_DOC.STORED_FILE_NAME
FROM (((((AU_MAIL
LEFT JOIN AU_ORGAN
ON AU_MAIL.AU_POS = AU_ORGAN.AU_POS
) LEFT JOIN AU_USER
ON AU_MAIL.AU_USER = AU_USER.AU_USER
)
LEFT JOIN AU_MAIL_ADDR
ON AU_MAIL.AU_MAIL = AU_MAIL_ADDR.AU_MAIL
) LEFT JOIN
(AU_CONTACT_MAILADDR
LEFT JOIN AU_CONTACT
ON AU_CONTACT_MAILADDR.AU_CONTACT = AU_CONTACT.AU_CONTACT
)
ON AU_MAIL_ADDR.AU_MAILADDRESS = AU_CONTACT_MAILADDR.AU_MAILADDRESS
)
LEFT JOIN AU_BUSINESS
ON AU_CONTACT_MAILADDR.AU_BUSINESS = AU_BUSINESS.AU_BUSINESS
)
LEFT JOIN AU_DOC
ON AU_MAIL.AU_DOC = AU_DOC.AU_DOC
WHERE (((AU_ORGAN.KUSER=:U
) AND (AU_MAIL.AU_USER Is Null
)
AND (AU_MAIL.MFOLDER Like 'Inbox'
)) OR ((AU_ORGAN.KUSER Is Null
)
AND (AU_MAIL.AU_USER=:U
) AND (AU_MAIL.MFOLDER Like 'Inbox'
)))
AND (AU_MAIL_ADDR.MTYPE = 'FROM'
)
AND (AU_MAIL.AU_MAILBOUNCETYPE IS NULL
)
ORDER BY AU_MAIL.MDATE DESC
, AU_MAIL.READ_FLAG
end_sql
q = QueryByName
("DATA"
)
userid = GetUserId
()
call TSetParam
(q
,"U"
,userid
)
endif
if (mode = "ALL_MODE"
) then
start_sql "DATA" "KOSMOS"
SELECT AU_ORGAN.KUSER
, AU_MAIL.AU_USER
, AU_MAIL.MDATE
, AU_MAIL.READ_FLAG
, AU_MAIL.IN_FLAG
, AU_MAIL.OUT_FLAG
,
AU_MAIL.SUBJECT
, AU_MAIL.MAIL_FROM
, AU_BUSINESS.TITLE
, AU_MAIL.AU_DOC
, AU_MAIL.AU_MAIL_POP3_MBOX
,
AU_MAIL.MTIME
, AU_MAIL.ATT_FLAG
, AU_MAIL.SENDER_FLAG
, AU_CONTACT.DISP_NAME
, AU_USER.UNAME
, AU_MAIL.MSGID
,
AU_MAIL.AU_MAIL
, AU_MAIL.MLABEL
, AU_MAIL.STATUS
, AU_CONTACT.AU_CONTACT
, AU_BUSINESS.AU_BUSINESS
, AU_DOC.STORED_FILE_NAME
FROM (((((AU_MAIL
LEFT JOIN AU_ORGAN
ON AU_MAIL.AU_POS = AU_ORGAN.AU_POS
) LEFT JOIN AU_USER
ON AU_MAIL.AU_USER = AU_USER.AU_USER
)
LEFT JOIN AU_MAIL_ADDR
ON AU_MAIL.AU_MAIL = AU_MAIL_ADDR.AU_MAIL
) LEFT JOIN
(AU_CONTACT_MAILADDR
LEFT JOIN AU_CONTACT
ON AU_CONTACT_MAILADDR.AU_CONTACT = AU_CONTACT.AU_CONTACT
)
ON AU_MAIL_ADDR.AU_MAILADDRESS = AU_CONTACT_MAILADDR.AU_MAILADDRESS
)
LEFT JOIN AU_BUSINESS
ON AU_CONTACT_MAILADDR.AU_BUSINESS = AU_BUSINESS.AU_BUSINESS
)
LEFT JOIN AU_DOC
ON AU_MAIL.AU_DOC = AU_DOC.AU_DOC
WHERE (AU_MAIL.MFOLDER Like 'Inbox'
)
AND (AU_MAIL_ADDR.MTYPE = 'FROM'
)
AND (AU_MAIL.AU_MAILBOUNCETYPE IS NULL
)
ORDER BY AU_MAIL.MDATE DESC
, AU_MAIL.READ_FLAG
end_sql
q = QueryByName
("DATA"
)
userid = GetUserId
()
call TSetParam
(q
,"U"
,userid
)
endif
call TPrepare
(q
)
end
{===============================
Lst_DblClick =================================}
proc Lst_Click
()
mail_id = TGetFld
(q
,"AU_MAIL"
)
doc_id = TGetFld
(q
,"AU_DOC"
)
readed = TGetFld
(q
,"READED"
)
pp = PByName
(mform
,"DATA"
)
sfn = TGetFld
(q
,"STORED_FILE_NAME"
)
if (mail_id > 0
) then
call OnOpenForm_NestPager
("ZONE_FIRSTEMTPY"
,mform
)
call OpenMailForm
(mail_id
, doc_id
, readed
, pp
, sfn
)
endif
end
proc grid_MLABEL_Click
()
{....DO NOTHING BUT LET US CHANGE THE MAIL LABEL!}
end
proc grid_DISP_NAME_Click
()
cont_id = TGetFld
(q
,"AU_CONTACT"
)
if (cont_id > 0
) then
expr = strcat
(cont_id
,"=AU_CONTACT"
)
call OpenFormTop
("ptEdit"
,"
AU_CONTACT_E.FM"
,"WORK.AU_CONTACT"
,1
,expr
)
endif
end
proc grid_TITLE_Click
()
bus_id = TGetFld
(q
,"AU_BUSINESS"
)
if (bus_id > 0
) then
expr = strcat
(bus_id
,"=AU_BUSINESS"
)
call OpenFormTop
("ptEdit"
,"
AU_BUSINESS_E.FM"
,"WORK.AU_BUSINESS"
,1
,expr
)
endif
end
{===================================== Form_DrawCell ===========================}
proc Form_DrawCell
( grid
, fname
, fval
, q
)
readed = TGetFld
(q
,"READ_FLAG"
)
readed = val
(readed
)
if (readed = 0
) then
grid.Canvas.Font.Style = "[fsBold]"
grid.Canvas.Font.Color = "clBlack"
endif
if (readed = 1
) then
grid.Canvas.Font.Style = READEDMAILFONTSTYLE
grid.Canvas.Font.Color = READEDMAILFONTCOLOR
endif
end
{================================ refresh_mail ===============================}
proc refresh_mail
()
msgid = TGetFld
(q
,"MSGID"
)
mail_id = TGetFld
(q
,"AU_MAIL"
)
doc_id = TGetFld
(q
,"AU_DOC"
)
pop3_id = TGetFld
(q
,"AU_MAIL_POP3"
)
mbox_id = TGetFld
(q
,"AU_MAIL_POP3_MBOX"
)
call ReloadOneMail
(msgid
,mail_id
,doc_id
,pop3_id
,mbox_id
)
call RefreshActiveRow
(mform
,mail_id
,True
)
end
{================================ getallmail ==================================}
proc getallmail
()
call ExecuteServerAsynch
( "get_mail"
, ""
, "LAST2DAYS"
, ""
, ""
)
end
{============================ compose_mail ====================================}
proc compose_mail
()
call OpenNewMailForm
(""
,""
,0
)
end
{============================ answer_mail ====================================}
proc answer_mail
()
doc_id = TGetFld
(q
,"AU_DOC"
)
answer_addr = TGetFld
(q
,"MAIL_FROM"
)
call OpenNewMailForm
(answer_addr
,""
,doc_id
)
end
{============================ forward_mail ====================================}
proc forward_mail
()
doc_id = TGetFld
(q
,"AU_DOC"
)
call OpenNewMailForm
(""
,True
,doc_id
)
end
{================================= delete ===========================}
proc delete
()
mail_id = TGetFld
(q
,"AU_MAIL"
)
call UpdateTable
("AU_MAIL"
, mail_id
, "MFOLDER"
, "Junk"
, ""
)
call Refresh
(mform
)
call PlaySound
("MailBeep"
)
end