Guest User

Untitled

a guest
Jan 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. Set @TableTail = '</table></body></html>';
  2.  
  3. Set @TableHead = '<html><head>' +
  4.  
  5. '<p>Hello Team,</p><p> These are your open action items. Please note anything in yellow means the date is within 180 days and anything in red means the date is within 90 days.</p>' +
  6.  
  7. '<p><a class="btn btn-success" href="http://sjams2019.azurewebsites.net/ActionItems?sales=MW&status=openandpending&dueDate=all" target="_blank">Update</a></p>' +
  8.  
  9. '<style>' +
  10.  
  11. 'td {border: padding-left:5px;padding-right:5px;padding-top:1px;padding-bottom:1px;font-size:11pt;} ' +
  12.  
  13. '</style>' +
  14.  
  15. '</head>' +
  16.  
  17. '<body><table cellpadding=0 cellspacing=0 border=0>' +
  18.  
  19. '<tr bgcolor=#FFEFD8><td align=left><b>Principal</b></td>' +
  20.  
  21. '<td align=left><b>Company</b></td>' +
  22.  
  23. '<td align=left><b>Action Item</b></td>' +
  24.  
  25. '<td align=left><b>Sales</b></td>' +
  26.  
  27. '<td align=left><b>Due Date</b></td>' +
  28.  
  29. '<td align=left><b>Updated</b></td>' +
  30.  
  31. '<td align=left><b>Owner</b></td></tr>';
  32.  
  33. DECLARE @CNT as int, @SLS as NVARCHAR(10)
  34. select [employeeid], [Sales], [Email Address]
  35. into #loctempemployee from tblEmployees
  36.  
  37. Set @CNT = (Select COUNT (Distinct EmployeeID) from #loctempemployee)
  38. While (@CNT > 0)
  39.  
  40. begin
  41.  
  42. Set @message=
  43. (
  44. SELECT tr.Principal As [TD], tr.[Company Name] As [TD], ai.[Action Item] As [TD], ai.Owners As [TD], LEFT((ai.[Due Date]),10) As [TD], LEFT((ai.Updated),10) As [TD], em.Sales As [TD]
  45. FROM [tblActionItem] ai
  46. INNER JOIN tblTripReport tr ON ai.TripReportID = tr.tripreportID
  47. INNER JOIN tblCustomers cu ON cu.CustomerID = tr.[Customer ID]
  48. INNER JOIN tblEmployees em ON em.EmployeeID = cu.EmployeeID
  49. WHERE em.Sales = (Select sales from #loctempemployee Where EmployeeID = (Select top 1 EmployeeID from #loctempemployee))
  50. For XML raw('tr'), Elements
  51. )
  52.  
  53.  
  54.  
  55.  
  56.  
  57. Select @Body = (@message)
  58.  
  59.  
  60.  
  61.  
  62. Set @Body = Replace(@Body, '_x0020_', space(1))
  63.  
  64. Set @Body = Replace(@Body, '_x003D_', '=')
  65.  
  66. Set @Body = Replace(@Body, '<tr><TRRow>1</TRRow>', '<tr bgcolor=#C6CFFF>')
  67.  
  68. Set @Body = Replace(@Body, '<TRRow>0</TRRow>', '')
  69.  
  70.  
  71.  
  72. Select @Body = @TableHead + @Body + @TableTail
Add Comment
Please, Sign In to add comment