Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

236 рядки
13KB

  1. <%
  2. '=======================================================================================================================
  3. ' Order-related outbound email: the "continue your order" link and the order-details
  4. ' confirmation sent after SubmitOrderDetails.
  5. '=======================================================================================================================
  6. Class OrderMailer_Class
  7. Public Sub SendContinuationEmail(email, token)
  8. Dim continueUrl
  9. continueUrl = Routes().AppURL & "order/continue?token=" & Server.URLEncode(token)
  10. Dim inner
  11. inner = "<div style=""color:#7c3bc0; font-weight:800; font-size:11px; letter-spacing:0.06em; text-transform:uppercase;"">Order Request Received</div>" & _
  12. "<h1 style=""color:#201a27; font-size:22px; margin:6px 0 12px; font-family:Arial, Helvetica, sans-serif;"">Continue your election materials order</h1>" & _
  13. "<p style=""color:#6d6574; font-size:13px; margin:0 0 20px;"">Click the button below to pick up where you left off.</p>" & _
  14. "<p style=""margin:0 0 20px;""><a href=""" & H(continueUrl) & """ style=""display:inline-block; background:#6529a0; color:#ffffff; font-weight:700; font-size:14px; padding:12px 28px; border-radius:10px; text-decoration:none;"">Continue your order</a></p>" & _
  15. "<p style=""color:#6d6574; font-size:12px; margin:0;"">Or copy and paste this link into your browser:<br /><a href=""" & H(continueUrl) & """ style=""color:#6529a0;"">" & H(continueUrl) & "</a></p>" & _
  16. "<p style=""color:#6d6574; font-size:12px; margin-top:16px;"">This link expires in " & H(GetAppSetting("OrderTokenExpirationHours")) & " hours and can only be used once.</p>"
  17. Dim mail : Set mail = NewConfiguredMail()
  18. mail.Subject = "Continue your Purple Envelope order"
  19. mail.IsBodyHTML = True
  20. mail.Body = EmailShell(inner)
  21. mail.AddRecipient "To", email
  22. mail.Send
  23. End Sub
  24. ' Best-effort: the order is already safely persisted by the time a caller reaches this -
  25. ' an SMTP hiccup here should not turn a successful submission into a failed one.
  26. Public Sub SendOrderDetailsEmail(order, model)
  27. On Error Resume Next
  28. Dim mail : Set mail = NewConfiguredMail()
  29. mail.Subject = "Your Purple Envelope order details - Jurisdiction " & order("JurisdictionNumber")
  30. mail.IsBodyHTML = True
  31. mail.Body = BuildOrderDetailsEmailBody(order, model)
  32. mail.AddRecipient "To", order("Email")
  33. mail.Send
  34. Err.Clear
  35. On Error GoTo 0
  36. End Sub
  37. '-------------------------------------------------------------------------------------------------------------------
  38. ' Private helpers
  39. '-------------------------------------------------------------------------------------------------------------------
  40. Private Function NewConfiguredMail()
  41. Dim smtpPort : smtpPort = GetAppSetting("SmtpPort")
  42. If Not IsNumeric(smtpPort) Then smtpPort = 25
  43. Dim mail : Set mail = CDOEmail()
  44. mail.SMTPServer = GetAppSetting("SmtpServer")
  45. mail.SMTPPort = CInt(smtpPort)
  46. mail.SMTPUsername = GetAppSetting("SmtpUsername")
  47. mail.SMTPPassword = GetAppSetting("SmtpPassword")
  48. mail.SMTPUseSSL = (LCase(GetAppSetting("SmtpUseSSL")) = "true")
  49. mail.From = GetAppSetting("SmtpFromAddress")
  50. Set NewConfiguredMail = mail
  51. End Function
  52. Private Function BuildOrderDetailsEmailBody(order, model)
  53. Dim html
  54. html = "<div style=""color:#7c3bc0; font-weight:800; font-size:11px; letter-spacing:0.06em; text-transform:uppercase;"">Order Received</div>" & _
  55. "<h1 style=""color:#201a27; font-size:22px; margin:6px 0 4px; font-family:Arial, Helvetica, sans-serif;"">Thanks! We've received your order details.</h1>" & _
  56. "<p style=""color:#6d6574; font-size:13px; margin:0 0 8px;"">Jurisdiction number <strong style=""color:#201a27;"">" & H(order("JurisdictionNumber")) & "</strong>" & _
  57. " &middot; submitted " & H(EmailDate(model.SubmittedAt)) & "</p>"
  58. html = html & EmailSection("Contact Information", _
  59. EmailRow("Contact Name", model.ContactName) & _
  60. EmailRow("Municipality", model.Municipality) & _
  61. EmailRow("Phone", model.Phone))
  62. If IsTrue(model.PurpleWantsQuote) Then
  63. html = html & EmailSection("Purple Ballot Envelopes", _
  64. EmailRow("Permanent ballot list count", model.PurplePermanentBallotListCount) & _
  65. EmailRow("Envelope stock", LabelEnvelopeStock(model.PurpleEnvelopeStock)) & _
  66. EmailRow("Print option", LabelPrintOption(model.PurplePrintOption)) & _
  67. EmailRow("Print style", LabelPrintStyle(model.PurplePrintStyle)) & _
  68. EmailRow("Color coding by", LabelColorCodingBy(model.PurpleColorCodingBy)) & _
  69. EmailRow("Number of precincts", model.PurplePrecinctCount) & _
  70. EmailRow("Colors requested", model.PurpleColorNames) & _
  71. EmailRow("Track with TrackMI Ballot", EmailYesNo(model.PurpleTrackMIBallot)) & _
  72. EmailRow("Extra envelopes requested", model.PurpleExtraEnvelopeQty))
  73. End If
  74. If Not IsNull(model.BlueWantsQuote) Then
  75. Dim blueProviderLine
  76. blueProviderLine = LabelPurpleBlueProvider(model.PurpleBlueProvider)
  77. If blueProviderLine = "Other" And Len(Trim(model.PurpleBlueProviderOther & "")) > 0 Then
  78. blueProviderLine = model.PurpleBlueProviderOther
  79. End If
  80. ' City/permit number are collected for an own-organization permit - a permit
  81. ' lookup can't be done from the nonprofit authorization code alone.
  82. Dim bluePermitLine
  83. bluePermitLine = ""
  84. If LabelPermitOwnership(model.BluePermitOwnership) = "My organization's permit" Then
  85. bluePermitLine = bluePermitLine & _
  86. EmailRow("City of permit holder", model.BluePermitCity) & _
  87. EmailRow("Permit number", model.BluePermitNumber)
  88. End If
  89. html = html & EmailSection("Blue AV Envelopes", _
  90. EmailRow("Purchasing blue envelopes from KCI", EmailYesNo(model.BlueWantsQuote)) & _
  91. EmailRow("Additional office copies", model.BlueWantsOfficeCopies) & _
  92. EmailRow("Additional office copies requested", model.BlueOfficeCopiesQty) & _
  93. EmailRow("Blue envelope provider", blueProviderLine) & _
  94. EmailRow("Print permit", EmailYesNo(model.BluePrintPermit)) & _
  95. EmailRow("Permit ownership", LabelPermitOwnership(model.BluePermitOwnership)) & _
  96. EmailRow("Confirmed nonprofit status with USPS", LabelNonprofitStatus(model.BlueHasNonprofitStatus)) & _
  97. bluePermitLine)
  98. End If
  99. If IsTrue(model.MailingWantsService) Then
  100. Dim mailingAuthCodeLine
  101. mailingAuthCodeLine = ""
  102. If CStr(model.MailingHasNonprofitStatus & "") = "Yes" Then
  103. If IsTrue(model.MailingNonprofitAuthCodeUnknown) Then
  104. mailingAuthCodeLine = EmailRow("Nonprofit authorization code", "Unknown - customer needs help")
  105. Else
  106. mailingAuthCodeLine = EmailRow("Nonprofit authorization code", model.MailingNonprofitAuthCode)
  107. End If
  108. End If
  109. html = html & EmailSection("Ballot Mailing Service", _
  110. EmailRow("Postage", LabelPostageOption(model.MailingPostageOption)) & _
  111. EmailRow("Nonprofit status with USPS", LabelNonprofitStatus(model.MailingHasNonprofitStatus)) & _
  112. mailingAuthCodeLine & _
  113. EmailRow("Estimated quantity", model.MailingEstimatedQuantity) & _
  114. EmailRow("Preferred pickup date", EmailDate(model.MailingPickupDate)))
  115. End If
  116. If NumOrZero(model.SecrecySleevesQty) > 0 Or NumOrZero(model.IVotedStickerRolls) > 0 Or NumOrZero(model.FutureVoterStickerRolls) > 0 Or Len(Trim(model.SpecialRequests & "")) > 0 Then
  117. html = html & EmailSection("Additional Election Items", _
  118. EmailRow("Secrecy sleeves (quantity)", model.SecrecySleevesQty) & _
  119. EmailRow("""I Voted"" stickers (rolls of 250)", model.IVotedStickerRolls) & _
  120. EmailRow("""Future Voter"" stickers (rolls of 500)", model.FutureVoterStickerRolls) & _
  121. EmailRow("Special requests", model.SpecialRequests))
  122. End If
  123. html = html & "<p style=""color:#6d6574; font-size:12px; margin-top:24px;"">Questions about this order? Just reply to this email.</p>"
  124. BuildOrderDetailsEmailBody = EmailShell(html)
  125. End Function
  126. ' Wraps inner body HTML in the same header/footer chrome used across the website - the
  127. ' navy KCI Election Printing bar (matching the site header/footer) and white content card.
  128. Private Function EmailShell(innerHtml)
  129. Dim logoUrl : logoUrl = Routes().AppURL & "images/KCI%20ELECTION%20printing%20(white).png"
  130. EmailShell = "<!doctype html><html><body style=""margin:0; padding:0; background:#faf7fd; font-family:Arial, Helvetica, sans-serif;"">" & _
  131. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" style=""background:#faf7fd; padding:24px 0;""><tr><td align=""center"">" & _
  132. "<table role=""presentation"" width=""600"" cellpadding=""0"" cellspacing=""0"" style=""background:#ffffff; border-radius:12px; overflow:hidden; box-shadow:0 4px 16px rgba(36,16,58,0.08);"">" & _
  133. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  134. "<img src=""" & H(logoUrl) & """ alt=""KCI Election Printing"" width=""160"" style=""display:block; margin:0 auto; height:auto; max-width:160px;"" />" & _
  135. "</td></tr>" & _
  136. "<tr><td style=""padding:32px;"">" & innerHtml & "</td></tr>" & _
  137. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  138. "<div style=""color:#ffffff; font-size:12px; font-weight:700;"">KCI Election Printing</div>" & _
  139. "<div style=""color:rgba(255,255,255,0.75); font-size:11px; margin-top:4px;"">616.957.2120 &middot; info@kentcommunications.com</div>" & _
  140. "</td></tr>" & _
  141. "</table></td></tr></table></body></html>"
  142. End Function
  143. Private Function EmailSection(sectionTitle, rowsHtml)
  144. If Len(rowsHtml) = 0 Then
  145. EmailSection = ""
  146. Else
  147. EmailSection = "<h2 style=""color:#4d1d78; font-size:14px; margin:24px 0 8px; padding-top:16px; border-top:1px solid #f0e7f8; font-family:Arial, Helvetica, sans-serif;"">" & _
  148. H(sectionTitle) & "</h2>" & _
  149. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"">" & rowsHtml & "</table>"
  150. End If
  151. End Function
  152. Private Function EmailRow(label, value)
  153. If Len(Trim(value & "")) = 0 Then
  154. EmailRow = ""
  155. Else
  156. EmailRow = "<tr>" & _
  157. "<td style=""padding:6px 0; color:#6d6574; font-size:13px; width:45%; vertical-align:top;"">" & H(label) & "</td>" & _
  158. "<td style=""padding:6px 0; color:#201a27; font-size:13px; font-weight:600;"">" & H(value) & "</td>" & _
  159. "</tr>"
  160. End If
  161. End Function
  162. ' Null-safe boolean check for gating whole sections - a section's top-level "do you want
  163. ' this?" question isn't marked required client-side, so it may be missing (Null) rather
  164. ' than explicitly false.
  165. Private Function IsTrue(v)
  166. If IsNull(v) Then
  167. IsTrue = False
  168. Else
  169. IsTrue = CBool(v)
  170. End If
  171. End Function
  172. Private Function EmailYesNo(v)
  173. If IsNull(v) Then
  174. EmailYesNo = ""
  175. ElseIf CBool(v) Then
  176. EmailYesNo = "Yes"
  177. Else
  178. EmailYesNo = "No"
  179. End If
  180. End Function
  181. Private Function EmailDate(v)
  182. If IsNull(v) Then
  183. EmailDate = ""
  184. Else
  185. On Error Resume Next
  186. EmailDate = MonthName(Month(v)) & " " & Day(v) & ", " & Year(v)
  187. If Err.Number <> 0 Then EmailDate = ""
  188. Err.Clear
  189. On Error GoTo 0
  190. End If
  191. End Function
  192. Private Function NumOrZero(v)
  193. If IsNull(v) Or Not IsNumeric(v) Then
  194. NumOrZero = 0
  195. Else
  196. NumOrZero = CDbl(v)
  197. End If
  198. End Function
  199. End Class
  200. Dim OrderMailer_Class__Singleton
  201. Function OrderMailer()
  202. If IsEmpty(OrderMailer_Class__Singleton) Then
  203. Set OrderMailer_Class__Singleton = New OrderMailer_Class
  204. End If
  205. Set OrderMailer = OrderMailer_Class__Singleton
  206. End Function
  207. %>

Powered by TurnKey Linux.