You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
9.8 KiB

  1. ------------------------------------
  2. --γ~Gd߸ƫH
  3. --ئW١GMidWeb
  4. --CreateGTed
  5. --ɶG2014/05/26
  6. --exec OSP_Common_DDL_GetModuleListByUserGroupId 'apadmin'
  7. ------------------------------------
  8. ALTER PROCEDURE [dbo].[OSP_Common_DDL_GetAlltipsListByUserId]
  9. @UserID VARCHAR(50) ,
  10. @OrganizationID VARCHAR(50)
  11. AS
  12. WITH AlltipsList ( TipsName, TipsID, PageID, PKID, IsRead )
  13. AS ( SELECT '�ݿ��q��:' + EventName AS EventName ,
  14. EventID ,
  15. 'Task_Upd' ,
  16. 'EventID' ,
  17. 'N' AS IsRead
  18. FROM OTB_MNG_Task
  19. WHERE OrganizationID = @OrganizationID
  20. AND Owner = @UserID
  21. AND ( ReadTime = ''
  22. OR ReadTime IS NULL
  23. )
  24. AND IsAlert = 'Y'
  25. AND AlertTime <= GETDATE()
  26. UNION ALL
  27. SELECT '�а��ӽ�:'
  28. + ( CASE WHEN LEN(AskUser) > 30
  29. THEN LEFT([dbo].OFN_SYS_GetMemberListNameByMemberIDList(AskUser,
  30. @OrganizationID),
  31. 10) + '...'
  32. ELSE [dbo].OFN_SYS_GetMemberListNameByMemberIDList(AskUser,
  33. @OrganizationID)
  34. END ) + '('
  35. + CONVERT(VARCHAR(100), LeaveDateStart, 111) + '~'
  36. + CONVERT(VARCHAR(100), LeaveDateEnd, 111) + ')' AS EventName ,
  37. AskLeaveGuid ,
  38. 'AskLeave_Upd' ,
  39. 'AskLeaveGuid' ,
  40. Checkerread AS IsRead
  41. FROM dbo.OTB_HR_AskLeave AL
  42. WHERE OrganizationID = @OrganizationID
  43. AND CHARINDEX(@UserID,
  44. ( SELECT CheckUserID + ','
  45. FROM dbo.OTB_HR_CheckAskLeave
  46. WHERE OrganizationID = @OrganizationID
  47. AND AskLeaveGuid = AL.AskLeaveGuid
  48. FOR
  49. XML PATH('')
  50. )) > 0
  51. AND CheckStatue <> 'AO'
  52. AND CheckStatue <> 'AN'
  53. AND IsMailChecker = 'Y'
  54. AND LeaveDateStart <= DATEADD(d, 3, GETDATE())
  55. UNION ALL
  56. SELECT '�а��ӽмf�֦^��:'
  57. + ( CASE WHEN LEN(AskUser) > 30
  58. THEN LEFT([dbo].OFN_SYS_GetMemberListNameByMemberIDList(AskUser,
  59. @OrganizationID),
  60. 10) + '...'
  61. ELSE [dbo].OFN_SYS_GetMemberListNameByMemberIDList(AskUser,
  62. @OrganizationID)
  63. END ) + '('
  64. + CONVERT(VARCHAR(100), LeaveDateStart, 111) + '~'
  65. + CONVERT(VARCHAR(100), LeaveDateEnd, 111) + ')' AS EventName ,
  66. AskLeaveGuid ,
  67. 'AskLeave_Upd' ,
  68. 'AskLeaveGuid' ,
  69. 'M' AS IsRead
  70. FROM dbo.OTB_HR_AskLeave AL
  71. WHERE OrganizationID = @OrganizationID
  72. AND CHARINDEX(@UserID, AskUser) > 0
  73. AND IsMailAsker = ''
  74. UNION ALL
  75. SELECT '�M�ץ��ȫ���:' + EventName AS EventName ,
  76. EventID ,
  77. 'PrjTaskPop' ,
  78. '' ,
  79. 'N' AS IsRead
  80. FROM OTB_PRJ_TaskDetail
  81. WHERE OrganizationID = @OrganizationID
  82. AND Owner = @UserID
  83. AND Status = 'U'
  84. UNION ALL
  85. SELECT '�M�סy'
  86. + dbo.OFN_SYS_ProjectNameByProjectNumber(ProjectNumber)
  87. + '�z�ݨD�ܧ����T�{ �D���G' + OrderTitle AS EventName ,
  88. ECOrderNumber AS EventID ,
  89. 'RequestOrderMaintain_Upd' ,
  90. 'ECOrderNumber' ,
  91. 'N' AS IsRead
  92. FROM OTB_PRJ_RequestOrder
  93. WHERE OrganizationID = @OrganizationID
  94. AND Undertaker = @UserID
  95. AND Orgread = ''
  96. UNION ALL
  97. SELECT '�{���y'
  98. + dbo.OFN_SYS_ProgramNameByProgramID(ProgramID)
  99. + '�zSD�T�{�]�M�סG'
  100. + dbo.OFN_SYS_ProjectNameByProjectNumber(ProjectNumber)
  101. + '�^' AS EventName ,
  102. ProgramSequence AS EventID ,
  103. 'DesignDocument_Upd' ,
  104. 'ProgramSequence' ,
  105. 'N' AS IsRead
  106. FROM OTB_DEV_DesignDocument
  107. WHERE OrganizationID = @OrganizationID
  108. AND CreateUser = @UserID
  109. AND Orgread = ''
  110. UNION ALL
  111. SELECT '���ƾ��ܽСy' + dbo.OFN_SYS_MemberNameByMemberID(UserID,
  112. @OrganizationID)
  113. + '�z�]�D���G' + [Subject] + '�^' AS EventName ,
  114. EventID ,
  115. 'Calendar_CheckPop' ,
  116. 'EventID' ,
  117. ( CASE CHARINDEX(@UserID, ISNULL(ReadMember, ''))
  118. WHEN 0 THEN 'N'
  119. ELSE 'Y'
  120. END ) AS IsRead
  121. FROM [OTB_MNG_Calendar]
  122. WHERE OrganizationID = @OrganizationID
  123. AND CHARINDEX(@UserID, ISNULL(RqMember, '')) > 0
  124. AND CHARINDEX(@UserID, ISNULL(RqMemberCheck, '')) = 0
  125. AND CHARINDEX(@UserID, ISNULL(RqMemberCheckNo, '')) = 0
  126. AND EndDate > GETDATE()--Add by Alina 20151016 jeɶ
  127. UNION ALL
  128. SELECT '�~�Ⱦ��|�l��:' + ( SELECT ProjectName
  129. FROM dbo.OTB_SAL_BusinessChance
  130. WHERE CaseID = cr.CaseID
  131. ) + '('
  132. + ( SELECT ContractCustomers
  133. FROM dbo.OTB_SAL_BusinessChance
  134. WHERE CaseID = cr.CaseID
  135. ) + ')'
  136. + ( CASE WHEN LEN(ToDoMemo) > 10
  137. THEN LEFT(ToDoMemo, 10) + '...'
  138. ELSE ( CASE ISNULL(ToDoMemo, '')
  139. WHEN '' THEN ''
  140. ELSE ToDoMemo
  141. END )
  142. END ) AS EventName ,
  143. CaseID ,
  144. 'BusinessChance_Upd' ,
  145. 'CaseID' ,
  146. 'N' AS IsRead
  147. FROM dbo.OTB_SAL_ContactRecords AS cr
  148. WHERE OrganizationID = @OrganizationID
  149. AND ( SELECT Person
  150. FROM dbo.OTB_SAL_BusinessChance
  151. WHERE CaseID = cr.CaseID
  152. ) = @UserID
  153. AND ( ReadTime = ''
  154. OR ReadTime IS NULL
  155. )
  156. AND Remind = 'Y'
  157. AND cr.NextTime <= GETDATE()
  158. )
  159. SELECT *
  160. FROM AlltipsList
  161. SELECT '�ݿ��q��:' + EventName AS TipsName ,
  162. EventID AS TipsID ,
  163. 'Task_Upd' AS PageID ,
  164. 'EventID' AS PKID ,
  165. CONVERT(VARCHAR(100), AlertTime, 121) AS AlertTime
  166. FROM OTB_MNG_Task
  167. WHERE OrganizationID = @OrganizationID
  168. AND Owner = @UserID
  169. AND ( ReadTime = ''
  170. OR ReadTime IS NULL
  171. )
  172. AND AlertTime > GETDATE()
  173. --UNION ALL
  174. -- SELECT DISTINCT '�~�Ⱦ��|�l?:' + (SELECT ProjectName FROM dbo.OTB_SAL_BusinessChance WHERE CaseID=cr.CaseID)+'('+(SELECT ContractCustomers FROM dbo.OTB_SAL_BusinessChance WHERE CaseID=cr.CaseID)+')' AS TipsName ,
  175. -- CaseID AS TipsID,
  176. -- 'BusinessChance_Upd' AS PageID ,
  177. -- 'CaseID' AS PKID ,
  178. -- CONVERT(VARCHAR(100), RemindTime, 121) AS AlertTime
  179. -- FROM dbo.OTB_SAL_ContactRecords AS cr
  180. -- WHERE OrganizationID = @OrganizationID
  181. -- AND (SELECT Person FROM dbo.OTB_SAL_BusinessChance WHERE CaseID=cr.CaseID) = @UserID
  182. -- AND ( ReadTime = '' OR ReadTime IS NULL
  183. -- )
  184. -- AND Remind='Y'
  185. -- AND cr.NextTime > GETDATE()