Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

228 wiersze
12KB

  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. Dim purpleBlueProviderLine
  64. purpleBlueProviderLine = LabelPurpleBlueProvider(model.PurpleBlueProvider)
  65. If purpleBlueProviderLine = "Other" And Len(Trim(model.PurpleBlueProviderOther & "")) > 0 Then
  66. purpleBlueProviderLine = model.PurpleBlueProviderOther
  67. End If
  68. html = html & EmailSection("Purple Ballot Envelopes", _
  69. EmailRow("Permanent ballot list count", model.PurplePermanentBallotListCount) & _
  70. EmailRow("Envelope stock", LabelEnvelopeStock(model.PurpleEnvelopeStock)) & _
  71. EmailRow("Print option", LabelPrintOption(model.PurplePrintOption)) & _
  72. EmailRow("Also wants KCI blue envelopes", EmailYesNo(model.PurpleWantsBlueEnvelopes)) & _
  73. EmailRow("Blue envelope provider", purpleBlueProviderLine) & _
  74. EmailRow("Print style", LabelPrintStyle(model.PurplePrintStyle)) & _
  75. EmailRow("Color coding by", LabelColorCodingBy(model.PurpleColorCodingBy)) & _
  76. EmailRow("Number of precincts", model.PurplePrecinctCount) & _
  77. EmailRow("Colors requested", model.PurpleColorNames) & _
  78. EmailRow("Track with TrackMI Ballot", EmailYesNo(model.PurpleTrackMIBallot)) & _
  79. EmailRow("Extra envelopes requested", model.PurpleExtraEnvelopeQty))
  80. End If
  81. If IsTrue(model.BlueWantsQuote) Then
  82. ' Nonprofit status (and the auth code that follows a "Yes") is asked for either
  83. ' permit-ownership branch. City/permit number are additionally collected for an
  84. ' own-organization permit - a permit lookup can't be done from the nonprofit
  85. ' authorization code alone.
  86. Dim bluePermitLine
  87. bluePermitLine = ""
  88. If CStr(model.BlueHasNonprofitStatus & "") = "Yes" Then
  89. bluePermitLine = EmailRow("Nonprofit authorization code", model.BlueNonprofitAuthCode)
  90. End If
  91. If LabelPermitOwnership(model.BluePermitOwnership) = "My organization's permit" Then
  92. bluePermitLine = bluePermitLine & _
  93. EmailRow("City of permit holder", model.BluePermitCity) & _
  94. EmailRow("Permit number", model.BluePermitNumber)
  95. End If
  96. html = html & EmailSection("Blue AV Envelopes", _
  97. EmailRow("Print permit", EmailYesNo(model.BluePrintPermit)) & _
  98. EmailRow("Permit ownership", LabelPermitOwnership(model.BluePermitOwnership)) & _
  99. EmailRow("Confirmed nonprofit status with USPS", LabelNonprofitStatus(model.BlueHasNonprofitStatus)) & _
  100. bluePermitLine)
  101. End If
  102. If IsTrue(model.MailingWantsService) Then
  103. html = html & EmailSection("Ballot Mailing Service", _
  104. EmailRow("Postage", LabelPostageOption(model.MailingPostageOption)) & _
  105. EmailRow("Nonprofit status with USPS", LabelNonprofitStatus(model.MailingHasNonprofitStatus)) & _
  106. EmailRow("Estimated quantity", model.MailingEstimatedQuantity) & _
  107. EmailRow("Preferred pickup date", EmailDate(model.MailingPickupDate)))
  108. End If
  109. If NumOrZero(model.SecrecySleevesQty) > 0 Or NumOrZero(model.IVotedStickerRolls) > 0 Or NumOrZero(model.FutureVoterStickerRolls) > 0 Or Len(Trim(model.SpecialRequests & "")) > 0 Then
  110. html = html & EmailSection("Additional Election Items", _
  111. EmailRow("Secrecy sleeves (quantity)", model.SecrecySleevesQty) & _
  112. EmailRow("""I Voted"" stickers (rolls of 250)", model.IVotedStickerRolls) & _
  113. EmailRow("""Future Voter"" stickers (rolls of 500)", model.FutureVoterStickerRolls) & _
  114. EmailRow("Special requests", model.SpecialRequests))
  115. End If
  116. html = html & "<p style=""color:#6d6574; font-size:12px; margin-top:24px;"">Questions about this order? Just reply to this email.</p>"
  117. BuildOrderDetailsEmailBody = EmailShell(html)
  118. End Function
  119. ' Wraps inner body HTML in the same header/footer chrome used across the website - the
  120. ' navy KCI Election Printing bar (matching the site header/footer) and white content card.
  121. Private Function EmailShell(innerHtml)
  122. Dim logoUrl : logoUrl = Routes().AppURL & "images/KCI%20ELECTION%20printing%20(white).png"
  123. EmailShell = "<!doctype html><html><body style=""margin:0; padding:0; background:#faf7fd; font-family:Arial, Helvetica, sans-serif;"">" & _
  124. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"" style=""background:#faf7fd; padding:24px 0;""><tr><td align=""center"">" & _
  125. "<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);"">" & _
  126. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  127. "<img src=""" & H(logoUrl) & """ alt=""KCI Election Printing"" width=""160"" style=""display:block; margin:0 auto; height:auto; max-width:160px;"" />" & _
  128. "</td></tr>" & _
  129. "<tr><td style=""padding:32px;"">" & innerHtml & "</td></tr>" & _
  130. "<tr><td style=""background:#254B74; padding:20px 32px; text-align:center;"">" & _
  131. "<div style=""color:#ffffff; font-size:12px; font-weight:700;"">KCI Election Printing</div>" & _
  132. "<div style=""color:rgba(255,255,255,0.75); font-size:11px; margin-top:4px;"">616.957.2120 &middot; info@kentcommunications.com</div>" & _
  133. "</td></tr>" & _
  134. "</table></td></tr></table></body></html>"
  135. End Function
  136. Private Function EmailSection(sectionTitle, rowsHtml)
  137. If Len(rowsHtml) = 0 Then
  138. EmailSection = ""
  139. Else
  140. 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;"">" & _
  141. H(sectionTitle) & "</h2>" & _
  142. "<table role=""presentation"" width=""100%"" cellpadding=""0"" cellspacing=""0"">" & rowsHtml & "</table>"
  143. End If
  144. End Function
  145. Private Function EmailRow(label, value)
  146. If Len(Trim(value & "")) = 0 Then
  147. EmailRow = ""
  148. Else
  149. EmailRow = "<tr>" & _
  150. "<td style=""padding:6px 0; color:#6d6574; font-size:13px; width:45%; vertical-align:top;"">" & H(label) & "</td>" & _
  151. "<td style=""padding:6px 0; color:#201a27; font-size:13px; font-weight:600;"">" & H(value) & "</td>" & _
  152. "</tr>"
  153. End If
  154. End Function
  155. ' Null-safe boolean check for gating whole sections - a section's top-level "do you want
  156. ' this?" question isn't marked required client-side, so it may be missing (Null) rather
  157. ' than explicitly false.
  158. Private Function IsTrue(v)
  159. If IsNull(v) Then
  160. IsTrue = False
  161. Else
  162. IsTrue = CBool(v)
  163. End If
  164. End Function
  165. Private Function EmailYesNo(v)
  166. If IsNull(v) Then
  167. EmailYesNo = ""
  168. ElseIf CBool(v) Then
  169. EmailYesNo = "Yes"
  170. Else
  171. EmailYesNo = "No"
  172. End If
  173. End Function
  174. Private Function EmailDate(v)
  175. If IsNull(v) Then
  176. EmailDate = ""
  177. Else
  178. On Error Resume Next
  179. EmailDate = MonthName(Month(v)) & " " & Day(v) & ", " & Year(v)
  180. If Err.Number <> 0 Then EmailDate = ""
  181. Err.Clear
  182. On Error GoTo 0
  183. End If
  184. End Function
  185. Private Function NumOrZero(v)
  186. If IsNull(v) Or Not IsNumeric(v) Then
  187. NumOrZero = 0
  188. Else
  189. NumOrZero = CDbl(v)
  190. End If
  191. End Function
  192. End Class
  193. Dim OrderMailer_Class__Singleton
  194. Function OrderMailer()
  195. If IsEmpty(OrderMailer_Class__Singleton) Then
  196. Set OrderMailer_Class__Singleton = New OrderMailer_Class
  197. End If
  198. Set OrderMailer = OrderMailer_Class__Singleton
  199. End Function
  200. %>

Powered by TurnKey Linux.