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.

464 lines
20KB

  1. <section style="padding: 48px 0; max-width: 640px; margin: 0 auto; text-align: center;">
  2. <% If isValid Then %>
  3. <span class="eyebrow">Order link verified</span>
  4. <h1>Your order link is valid.</h1>
  5. <p>Jurisdiction number: <strong><%= H(order("JurisdictionNumber")) %></strong></p>
  6. <% Else %>
  7. <span class="eyebrow">Link problem</span>
  8. <h1>This link is invalid or has expired.</h1>
  9. <p>
  10. Please <a href="<%= H(Routes().AppURL & "request-order") %>">request a new order</a>
  11. to receive a fresh link.
  12. </p>
  13. <% End If %>
  14. </section>
  15. <% If isValid Then
  16. Dim municipalityIsReadOnlyJs, municipalityDescription
  17. If Len(Trim(municipalityName)) > 0 Then
  18. municipalityIsReadOnlyJs = "true"
  19. municipalityDescription = "Matched automatically from your jurisdiction number."
  20. Else
  21. municipalityIsReadOnlyJs = "false"
  22. municipalityDescription = "We couldn't automatically match your jurisdiction number - please enter your municipality."
  23. End If
  24. %>
  25. <link href="https://cdn.jsdelivr.net/npm/survey-core@2.5.36/survey-core.min.css" rel="stylesheet">
  26. <div style="max-width: 760px; margin: 0 auto; padding: 0 16px;">
  27. <div class="cf-turnstile" style="margin-bottom: 24px;"
  28. data-sitekey="<%= H(turnstileSiteKey) %>"
  29. data-callback="onTurnstileVerified"></div>
  30. </div>
  31. <div id="surveyContainer" style="max-width: 760px; margin: 0 auto 64px; padding: 0 16px;"></div>
  32. <div id="colorPickerOverlay" style="display:none; position:fixed; inset:0; background:rgba(36,16,58,0.55); z-index:1000; align-items:center; justify-content:center; padding:16px;">
  33. <div style="background:#fff; border-radius:14px; max-width:640px; width:100%; max-height:85vh; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 12px 40px rgba(36,16,58,0.35);">
  34. <div style="display:flex; align-items:center; justify-content:space-between; padding:20px 24px; border-bottom:1px solid #f0e7f8;">
  35. <h3 style="margin:0; color:#201a27; font-size:18px;">Choose your colors</h3>
  36. <button type="button" id="colorPickerCloseBtn" aria-label="Close" style="background:none; border:none; font-size:22px; line-height:1; color:#6d6574; cursor:pointer; padding:4px 8px;">&times;</button>
  37. </div>
  38. <div id="colorPickerGrid" style="overflow-y:auto; padding:20px 24px; display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:12px;"></div>
  39. <div style="display:flex; justify-content:flex-end; gap:10px; padding:16px 24px; border-top:1px solid #f0e7f8;">
  40. <button type="button" id="colorPickerCancelBtn" class="button button-secondary">Cancel</button>
  41. <button type="button" id="colorPickerApplyBtn" class="button button-primary">Apply</button>
  42. </div>
  43. </div>
  44. </div>
  45. <script src="https://cdn.jsdelivr.net/npm/survey-core@2.5.36/survey.core.min.js"></script>
  46. <script src="https://cdn.jsdelivr.net/npm/survey-js-ui@2.5.36/survey-js-ui.min.js"></script>
  47. <script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
  48. <script>
  49. (function () {
  50. "use strict";
  51. var submitUrl = "<%= H(Routes().AppURL & "order/submit?token=" & Server.URLEncode(token)) %>";
  52. var csrfToken = "<%= H(csrfToken) %>";
  53. var turnstileToken = "";
  54. window.onTurnstileVerified = function (token) {
  55. turnstileToken = token;
  56. };
  57. // Election-materials order form. Field (name) values match the OrderDetails table
  58. // columns 1:1 - see db/migrations/20260728145000_create_order_details_table.asp and
  59. // db/migrations/20260804153857_revise_order_details_columns.asp.
  60. // Content and branching sourced from docs/lucid/*.pdf (the "(1)" files are the current
  61. // revision - see docs/lucid for both the original and revised versions).
  62. var surveyJson = {
  63. showProgressBar: "top",
  64. showQuestionNumbers: "off",
  65. completeText: "Submit Order",
  66. checkErrorsMode: "onNextPage",
  67. completedHtml: "<h3>Thank you for submitting your order.</h3>",
  68. pages: [
  69. {
  70. name: "contact",
  71. title: "1. Contact Information",
  72. elements: [
  73. { type: "text", name: "ContactName", title: "Contact Name", isRequired: true },
  74. {
  75. type: "text", name: "Municipality", title: "Municipality", isRequired: true,
  76. defaultValue: "<%= H(municipalityName) %>",
  77. readOnly: <%= municipalityIsReadOnlyJs %>,
  78. description: "<%= H(municipalityDescription) %>"
  79. },
  80. { type: "text", name: "Phone", title: "Phone Number", inputType: "tel", isRequired: true }
  81. ]
  82. },
  83. {
  84. name: "purpleEnvelope",
  85. title: "2. Purple Ballot Envelope Order Form",
  86. elements: [
  87. {
  88. type: "boolean", name: "PurpleWantsQuote", labelTrue: "Yes", labelFalse: "No",
  89. title: "Would you like for KCI to print your purple AV envelopes?",
  90. isRequired: true
  91. },
  92. {
  93. type: "radiogroup", name: "PurpleEnvelopeStock",
  94. title: "Are you planning to use KCI's purple envelopes or from your own stock?",
  95. visibleIf: "{PurpleWantsQuote} = true",
  96. isRequired: true,
  97. choices: [
  98. { value: "KCIStock", text: "KCI's stock" },
  99. { value: "OwnStock", text: "My own stock" }
  100. ]
  101. },
  102. {
  103. type: "radiogroup", name: "PurplePrintOption",
  104. title: "Would you like KCI to print addresses on your purple envelopes or state of Michigan permit only?",
  105. visibleIf: "{PurpleWantsQuote} = true",
  106. isRequired: true,
  107. choices: [
  108. { value: "AddressesAndPermit", text: "Addresses and state of Michigan permit" },
  109. { value: "PermitOnly", text: "State of Michigan permit only" }
  110. ]
  111. },
  112. {
  113. type: "boolean", name: "PurpleWantsBlueEnvelopes", labelTrue: "Yes", labelFalse: "No",
  114. title: "Are you planning to use KCI blue envelopes?",
  115. visibleIf: "{PurplePrintOption} = 'AddressesAndPermit'",
  116. isRequired: true
  117. },
  118. {
  119. type: "radiogroup", name: "PurpleBlueProvider",
  120. title: "Who is your blue envelope provider?",
  121. visibleIf: "{PurpleWantsBlueEnvelopes} = false",
  122. isRequired: true,
  123. choices: [
  124. { value: "ElectionSource", text: "ElectionSource" },
  125. { value: "PSI", text: "PSI" },
  126. { value: "Spectrum", text: "Spectrum" },
  127. { value: "Other", text: "Other" }
  128. ]
  129. },
  130. {
  131. type: "text", name: "PurpleBlueProviderOther",
  132. title: "Please specify your blue envelope provider",
  133. visibleIf: "{PurpleBlueProvider} = 'Other'",
  134. isRequired: true
  135. },
  136. {
  137. type: "radiogroup", name: "PurplePrintStyle",
  138. title: "Would you like your envelopes printed with color coding or black ink only?",
  139. visibleIf: "{PurplePrintOption} = 'AddressesAndPermit'",
  140. isRequired: true,
  141. choices: [
  142. { value: "ColorCoding", text: "Color Coding" },
  143. { value: "BlackOnly", text: "Black Ink Only" }
  144. ]
  145. },
  146. {
  147. type: "radiogroup", name: "PurpleColorCodingBy",
  148. title: "Color coding by precinct or by election?",
  149. visibleIf: "{PurplePrintStyle} = 'ColorCoding'",
  150. isRequired: true,
  151. choices: [
  152. { value: "Precinct", text: "Precinct" },
  153. { value: "Election", text: "Election" }
  154. ]
  155. },
  156. {
  157. type: "text", name: "PurplePrecinctCount", title: "How many precincts?",
  158. inputType: "number", min: 0,
  159. visibleIf: "{PurpleColorCodingBy} = 'Precinct'",
  160. isRequired: true
  161. },
  162. {
  163. type: "html",
  164. visibleIf: "{PurplePrintStyle} = 'ColorCoding'",
  165. html: "<button type=\"button\" id=\"openColorPickerBtn\" class=\"button button-secondary\">Choose Colors&hellip;</button>"
  166. },
  167. {
  168. type: "text", name: "PurpleColorNames", readOnly: true,
  169. title: "Which colors would you like to use?",
  170. description: "Use the \"Choose Colors…\" button above to pick from KCI's available envelope colors.",
  171. visibleIf: "{PurplePrintStyle} = 'ColorCoding'",
  172. isRequired: true
  173. },
  174. {
  175. type: "boolean", name: "PurpleTrackMIBallot", labelTrue: "Yes", labelFalse: "No",
  176. title: "Would you like to track ballots using TrackMI Ballot?",
  177. visibleIf: "{PurplePrintOption} = 'AddressesAndPermit'",
  178. isRequired: true
  179. },
  180. {
  181. type: "text", name: "PurpleExtraEnvelopeQty",
  182. title: "How many extra purple envelopes would you like? (If none, please put zero)",
  183. inputType: "number", min: 0,
  184. visibleIf: "{PurplePrintOption} = 'AddressesAndPermit'",
  185. isRequired: true
  186. },
  187. {
  188. type: "html",
  189. visibleIf: "{PurpleWantsQuote} = true",
  190. html: "<p>Purple envelopes are usually delivered or shipped 3 to 5 days after proof is approved.</p>"
  191. }
  192. ]
  193. },
  194. {
  195. name: "blueEnvelope",
  196. title: "3. Blue AV Envelope Order Form",
  197. elements: [
  198. {
  199. type: "boolean", name: "BlueWantsQuote", labelTrue: "Yes", labelFalse: "No",
  200. title: "Would you like to purchase blue AV envelopes from KCI?",
  201. isRequired: true
  202. },
  203. {
  204. type: "boolean", name: "BluePrintPermit", labelTrue: "Yes", labelFalse: "No",
  205. title: "Would you like KCI to print a permit on your blue envelope?",
  206. visibleIf: "{BlueWantsQuote} = true",
  207. isRequired: true
  208. },
  209. {
  210. type: "radiogroup", name: "BluePermitOwnership",
  211. title: "Will you be using KCI's permit or your own?",
  212. visibleIf: "{BluePrintPermit} = true",
  213. isRequired: true,
  214. choices: [
  215. { value: "KCIPermit", text: "KCI permit" },
  216. { value: "OwnPermit", text: "My organization's permit" }
  217. ]
  218. },
  219. {
  220. type: "html",
  221. visibleIf: "{BluePermitOwnership} = 'KCIPermit'",
  222. html: "<p><strong>Please note, envelopes with KCI's permit MUST be mailed from KCI.</strong></p>"
  223. },
  224. {
  225. type: "boolean", name: "BlueHasNonprofitStatus", labelTrue: "Yes", labelFalse: "No",
  226. title: "Does your organization have confirmed nonprofit status with USPS?",
  227. visibleIf: "{BluePermitOwnership} = 'OwnPermit'",
  228. isRequired: true
  229. },
  230. {
  231. type: "text", name: "BlueNonprofitAuthCode",
  232. title: "Please provide your nonprofit authorization code.",
  233. visibleIf: "{BlueHasNonprofitStatus} = true",
  234. isRequired: true
  235. },
  236. {
  237. type: "text", name: "BluePermitCity", title: "City of permit holder",
  238. description: "A permit lookup can't be done from the authorization code alone, so please also provide the following information.",
  239. visibleIf: "{BluePermitOwnership} = 'OwnPermit'",
  240. isRequired: true
  241. },
  242. {
  243. type: "text", name: "BluePermitNumber", title: "Permit Number",
  244. visibleIf: "{BluePermitOwnership} = 'OwnPermit'",
  245. isRequired: true
  246. }
  247. ]
  248. },
  249. {
  250. name: "mailingService",
  251. title: "4. Ballot Mailing Service",
  252. elements: [
  253. {
  254. type: "boolean", name: "MailingWantsService", labelTrue: "Yes", labelFalse: "No",
  255. title: "Would you like to save postage and have KCI mail your ballots?",
  256. isRequired: true
  257. },
  258. {
  259. type: "radiogroup", name: "MailingPostageOption",
  260. title: "Would you like KCI to apply postage?",
  261. visibleIf: "{MailingWantsService} = true",
  262. isRequired: true,
  263. choices: [
  264. { value: "FirstClass", text: "Yes, at First Class Rate ($0.721/pc.)" },
  265. { value: "NonprofitRate", text: "Yes, at Nonprofit Rate ($0.263/pc.)" },
  266. { value: "PresortStandard", text: "Yes, at Presort Standard Rate ($0.473/pc.)" },
  267. { value: "No", text: "No" }
  268. ]
  269. },
  270. {
  271. type: "radiogroup", name: "MailingHasNonprofitStatus",
  272. title: "Do you have Nonprofit Status with the USPS?",
  273. visibleIf: "{MailingPostageOption} = 'NonprofitRate'",
  274. isRequired: true,
  275. choices: [
  276. { value: "Yes", text: "Yes" },
  277. { value: "No", text: "No" },
  278. { value: "NotSure", text: "I'm not sure (that's okay, we can help you!)" }
  279. ]
  280. },
  281. {
  282. type: "text", name: "MailingEstimatedQuantity",
  283. title: "Please provide your estimated quantity.",
  284. inputType: "number", min: 0,
  285. visibleIf: "{MailingWantsService} = true",
  286. isRequired: true
  287. },
  288. {
  289. type: "dropdown", name: "MailingPickupDate",
  290. title: "What is your preferred (first) pickup date?",
  291. visibleIf: "{MailingWantsService} = true",
  292. isRequired: true,
  293. choices: [
  294. { value: "2026-09-21", text: "September 21, 2026" },
  295. { value: "2026-09-22", text: "September 22, 2026" },
  296. { value: "2026-09-23", text: "September 23, 2026" },
  297. { value: "2026-09-24", text: "September 24, 2026" },
  298. { value: "2026-09-25", text: "September 25, 2026" },
  299. { value: "2026-09-28", text: "September 28, 2026" },
  300. { value: "2026-09-29", text: "September 29, 2026" },
  301. { value: "2026-09-30", text: "September 30, 2026" },
  302. { value: "2026-10-01", text: "October 1, 2026" },
  303. { value: "2026-10-02", text: "October 2, 2026" }
  304. ]
  305. }
  306. ]
  307. },
  308. {
  309. name: "additionalItems",
  310. title: "5. Additional Election Items Request",
  311. elements: [
  312. {
  313. type: "text", name: "SecrecySleevesQty", title: "Secrecy Sleeves (quantity)",
  314. inputType: "number", min: 0, defaultValue: 0,
  315. isRequired: true
  316. },
  317. {
  318. type: "text", name: "IVotedStickerRolls", title: "\"I Voted\" Stickers - number of rolls (rolls of 250)",
  319. inputType: "number", min: 0, defaultValue: 0,
  320. isRequired: true
  321. },
  322. {
  323. type: "text", name: "FutureVoterStickerRolls", title: "\"Future Voter\" Stickers - number of rolls (rolls of 500)",
  324. inputType: "number", min: 0, defaultValue: 0,
  325. isRequired: true
  326. },
  327. {
  328. type: "comment", name: "SpecialRequests",
  329. title: "We will send you a copy of your price quote upon completion of this order form. If you have any special requests for any of your orders, please let us know here."
  330. }
  331. ]
  332. }
  333. ]
  334. };
  335. var survey = new Survey.Model(surveyJson);
  336. // Color picker modal for the "Which colors would you like to use?" question. Swatches are
  337. // the pre-converted PNGs in public/images/purple-envelope-colors/ (converted from the
  338. // original public/images/Purple_ballot_envelopes colors/*.bmp - those BMPs were ~400KB
  339. // each; PNG compresses these flat-color swatches down to ~1-4KB each).
  340. (function () {
  341. var COLOR_FILES = [
  342. "Aqua", "Black", "Blue", "Brown", "BurlyWood", "Chocolate", "Clay", "Coral",
  343. "CornflowerBlue", "Crimson", "DarkOrange", "DeepPink", "DeepSkyBlue", "DimGray",
  344. "DodgerBlue", "FireBrick", "ForestGreen", "Fuchsia", "Gold", "Goldenrod", "Green",
  345. "HotPink", "Indigo", "LightSeaGreen", "Lime", "LimeGreen", "LtGreen", "MediumOrchid",
  346. "MediumPurple", "MediumTurquoise", "MintGreen", "Navy", "Olive", "OliveDrab", "Orange",
  347. "OrangeRed", "Orchid", "PastelBlue", "PastelPink", "PastelPurple", "PastelYellow",
  348. "Peru", "Pink", "Purple", "Red", "RoyalBlue", "SaddleBrown", "SeaGreen", "Sienna",
  349. "Silver", "SkyBlue", "SteelBlue", "Tan", "Teal", "Tomato", "Turquoise", "Violet",
  350. "White", "Yellow"
  351. ];
  352. var colorImageBaseUrl = "<%= H(Routes().AppURL & "images/purple-envelope-colors/") %>";
  353. var overlay = document.getElementById("colorPickerOverlay");
  354. var grid = document.getElementById("colorPickerGrid");
  355. function colorLabel(fileName) {
  356. return fileName.replace(/([a-z])([A-Z])/g, "$1 $2");
  357. }
  358. COLOR_FILES.forEach(function (fileName) {
  359. var label = colorLabel(fileName);
  360. var item = document.createElement("label");
  361. item.style.cssText = "display:flex; flex-direction:column; gap:6px; border:1px solid #f0e7f8; border-radius:8px; padding:8px; cursor:pointer;";
  362. item.innerHTML =
  363. '<img src="' + colorImageBaseUrl + encodeURIComponent(fileName) + '.png" alt="" ' +
  364. 'style="width:100%; height:36px; border-radius:4px; object-fit:cover; border:1px solid #e5d9f2;" />' +
  365. '<span style="display:flex; align-items:center; gap:6px; font-size:13px; color:#201a27;">' +
  366. '<input type="checkbox" class="color-picker-checkbox" value="' + label.replace(/"/g, "&quot;") + '" /> ' +
  367. label + "</span>";
  368. grid.appendChild(item);
  369. });
  370. function openColorPicker() {
  371. var current = (survey.getValue("PurpleColorNames") || "")
  372. .split(",")
  373. .map(function (s) { return s.trim(); })
  374. .filter(Boolean);
  375. var currentSet = {};
  376. current.forEach(function (c) { currentSet[c] = true; });
  377. var checkboxes = grid.querySelectorAll(".color-picker-checkbox");
  378. checkboxes.forEach(function (cb) { cb.checked = !!currentSet[cb.value]; });
  379. overlay.style.display = "flex";
  380. }
  381. function closeColorPicker() {
  382. overlay.style.display = "none";
  383. }
  384. function applyColorPicker() {
  385. var checked = grid.querySelectorAll(".color-picker-checkbox:checked");
  386. var selected = Array.prototype.map.call(checked, function (cb) { return cb.value; });
  387. survey.setValue("PurpleColorNames", selected.join(", "));
  388. closeColorPicker();
  389. }
  390. document.getElementById("colorPickerCloseBtn").addEventListener("click", closeColorPicker);
  391. document.getElementById("colorPickerCancelBtn").addEventListener("click", closeColorPicker);
  392. document.getElementById("colorPickerApplyBtn").addEventListener("click", applyColorPicker);
  393. overlay.addEventListener("click", function (event) {
  394. if (event.target === overlay) closeColorPicker();
  395. });
  396. // The "Choose Colors..." button is rendered by SurveyJS as an html question, so it
  397. // doesn't exist in the DOM until that page is shown - delegate from a stable ancestor.
  398. document.addEventListener("click", function (event) {
  399. if (event.target && event.target.id === "openColorPickerBtn") {
  400. event.preventDefault();
  401. openColorPicker();
  402. }
  403. });
  404. })();
  405. survey.onCompleting.add(function (sender, options) {
  406. if (!turnstileToken) {
  407. options.allowComplete = false;
  408. alert("Please complete the verification challenge above before submitting.");
  409. }
  410. });
  411. survey.onComplete.add(function (sender) {
  412. fetch(submitUrl, {
  413. method: "POST",
  414. headers: {
  415. "Content-Type": "application/json",
  416. "X-CSRF-Token": csrfToken,
  417. "X-Turnstile-Token": turnstileToken
  418. },
  419. body: JSON.stringify(sender.data)
  420. })
  421. .then(function (res) {
  422. return res.json().catch(function () { return {}; }).then(function (body) {
  423. return { ok: res.ok, body: body };
  424. });
  425. })
  426. .then(function (result) {
  427. var container = document.getElementById("surveyContainer");
  428. if (result.ok && result.body && result.body.success) {
  429. container.innerHTML =
  430. '<p style="text-align:center; padding: 32px 0;">' +
  431. "Thank you for submitting your order." +
  432. "</p>";
  433. } else {
  434. alert((result.body && result.body.error) || "Something went wrong submitting your order. Please try again.");
  435. }
  436. })
  437. .catch(function () {
  438. alert("Something went wrong submitting your order. Please check your connection and try again.");
  439. });
  440. });
  441. survey.render(document.getElementById("surveyContainer"));
  442. })();
  443. </script>
  444. <% End If %>

Powered by TurnKey Linux.