25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

473 satır
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. clearInvisibleValues: "onHidden",
  68. completedHtml: "<h3>Thank you for submitting your order.</h3>",
  69. pages: [
  70. {
  71. name: "contact",
  72. title: "1. Contact Information",
  73. elements: [
  74. { type: "text", name: "ContactName", title: "Contact Name", isRequired: true },
  75. {
  76. type: "text", name: "Municipality", title: "Municipality", isRequired: true,
  77. defaultValue: "<%= H(municipalityName) %>",
  78. readOnly: <%= municipalityIsReadOnlyJs %>,
  79. description: "<%= H(municipalityDescription) %>"
  80. },
  81. { type: "text", name: "Phone", title: "Phone Number", inputType: "tel", isRequired: true }
  82. ]
  83. },
  84. {
  85. name: "purpleEnvelope",
  86. title: "2. Purple Ballot Envelope Order Form",
  87. elements: [
  88. {
  89. type: "boolean", name: "PurpleWantsQuote", labelTrue: "Yes", labelFalse: "No",
  90. title: "Would you like for KCI to print your purple AV envelopes?",
  91. isRequired: true
  92. },
  93. {
  94. type: "text", name: "PurplePermanentBallotListCount",
  95. title: "How many are on your permanent ballot list?",
  96. inputType: "number", min: 0,
  97. visibleIf: "{PurpleWantsQuote} = true",
  98. isRequired: true
  99. },
  100. {
  101. type: "radiogroup", name: "PurpleEnvelopeStock",
  102. title: "Are you planning to use KCI's purple envelopes or from your own stock?",
  103. visibleIf: "{PurpleWantsQuote} = true",
  104. isRequired: true,
  105. choices: [
  106. { value: "KCIStock", text: "KCI's stock" },
  107. { value: "OwnStock", text: "My own stock" }
  108. ]
  109. },
  110. {
  111. type: "radiogroup", name: "PurplePrintOption",
  112. title: "Would you like KCI to print voter addresses on your purple envelopes or state of Michigan permit only?",
  113. visibleIf: "{PurpleWantsQuote} = true",
  114. isRequired: true,
  115. choices: [
  116. { value: "AddressesAndPermit", text: "Voter Addresses and state of Michigan permit" },
  117. { value: "PermitOnly", text: "State of Michigan permit only" }
  118. ]
  119. },
  120. {
  121. type: "radiogroup", name: "PurplePrintStyle",
  122. title: "Would you like your envelopes printed with color coding or black ink only?",
  123. visibleIf: "{PurplePrintOption} = 'AddressesAndPermit'",
  124. isRequired: true,
  125. choices: [
  126. { value: "ColorCoding", text: "Color Coding" },
  127. { value: "BlackOnly", text: "Black Ink Only" }
  128. ]
  129. },
  130. {
  131. type: "radiogroup", name: "PurpleColorCodingBy",
  132. title: "Color coding by precinct or by election?",
  133. visibleIf: "{PurplePrintStyle} = 'ColorCoding'",
  134. isRequired: true,
  135. choices: [
  136. { value: "Precinct", text: "Precinct" },
  137. { value: "Election", text: "Election" }
  138. ]
  139. },
  140. {
  141. type: "text", name: "PurplePrecinctCount", title: "How many precincts?",
  142. inputType: "number", min: 0,
  143. visibleIf: "{PurpleColorCodingBy} = 'Precinct'",
  144. isRequired: true
  145. },
  146. {
  147. type: "html",
  148. visibleIf: "{PurplePrintStyle} = 'ColorCoding'",
  149. html: "<button type=\"button\" id=\"openColorPickerBtn\" class=\"button button-secondary\">Choose Colors&hellip;</button>"
  150. },
  151. {
  152. type: "text", name: "PurpleColorNames", readOnly: true,
  153. title: "Which colors would you like to use?",
  154. description: "Use the \"Choose Colors…\" button above to pick from KCI's available envelope colors.",
  155. visibleIf: "{PurplePrintStyle} = 'ColorCoding'",
  156. isRequired: true
  157. },
  158. {
  159. type: "boolean", name: "PurpleTrackMIBallot", labelTrue: "Yes", labelFalse: "No",
  160. title: "Would you like to track ballots using TrackMI Ballot?",
  161. visibleIf: "{PurplePrintOption} = 'AddressesAndPermit'",
  162. isRequired: true
  163. },
  164. {
  165. type: "text", name: "PurpleExtraEnvelopeQty",
  166. title: "How many extra purple envelopes would you like? (If none, please put zero)",
  167. inputType: "number", min: 0,
  168. visibleIf: "{PurplePrintOption} = 'AddressesAndPermit'",
  169. isRequired: true
  170. },
  171. {
  172. type: "html",
  173. visibleIf: "{PurpleWantsQuote} = true",
  174. html: "<p>Purple envelopes are usually delivered or shipped 3 to 5 days after proof is approved.</p>"
  175. }
  176. ]
  177. },
  178. {
  179. name: "blueEnvelope",
  180. title: "3. Blue AV Envelope Order Form",
  181. elements: [
  182. {
  183. type: "boolean", name: "BlueWantsQuote", labelTrue: "Yes", labelFalse: "No",
  184. title: "Would you like to purchase blue AV envelopes from KCI?",
  185. isRequired: true
  186. },
  187. {
  188. type: "radiogroup", name: "PurpleBlueProvider",
  189. title: "Who is your blue envelope provider?",
  190. visibleIf: "{BlueWantsQuote} = false",
  191. isRequired: true,
  192. choices: [
  193. { value: "ElectionSource", text: "ElectionSource" },
  194. { value: "PSI", text: "PSI" },
  195. { value: "Spectrum", text: "Spectrum" },
  196. { value: "Other", text: "Other" }
  197. ]
  198. },
  199. {
  200. type: "text", name: "PurpleBlueProviderOther",
  201. title: "Please specify your blue envelope provider",
  202. visibleIf: "{PurpleBlueProvider} = 'Other'",
  203. isRequired: true
  204. },
  205. {
  206. type: "boolean", name: "BluePrintPermit", labelTrue: "Yes", labelFalse: "No",
  207. title: "Would you like KCI to print a permit on your blue envelope?",
  208. isRequired: true
  209. },
  210. {
  211. type: "radiogroup", name: "BluePermitOwnership",
  212. title: "Will you be using KCI's permit or your own?",
  213. visibleIf: "{BluePrintPermit} = true",
  214. isRequired: true,
  215. choices: [
  216. { value: "KCIPermit", text: "KCI permit" },
  217. { value: "OwnPermit", text: "My organization's permit" }
  218. ]
  219. },
  220. {
  221. type: "html",
  222. visibleIf: "{BluePermitOwnership} = 'KCIPermit'",
  223. html: "<p><strong>Please note, envelopes with KCI's permit MUST be mailed from KCI.</strong></p>"
  224. },
  225. {
  226. type: "radiogroup", name: "BlueHasNonprofitStatus",
  227. title: "Does your organization have confirmed nonprofit status with USPS?",
  228. visibleIf: "{BluePrintPermit} = true",
  229. isRequired: true,
  230. choices: [
  231. { value: "Yes", text: "Yes" },
  232. { value: "No", text: "No" },
  233. { value: "Unsure", text: "Unsure (That's okay, we can help you!)" }
  234. ]
  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: "MailingNonprofitAuthCode",
  283. title: "Please provide your nonprofit authorization code.",
  284. visibleIf: "{MailingHasNonprofitStatus} = 'Yes' and {MailingNonprofitAuthCodeUnknown} <> true",
  285. isRequired: true
  286. },
  287. {
  288. type: "boolean", name: "MailingNonprofitAuthCodeUnknown",
  289. title: "I don't know my authorization code",
  290. renderAs: "checkbox",
  291. visibleIf: "{MailingHasNonprofitStatus} = 'Yes'",
  292. defaultValue: false
  293. },
  294. {
  295. type: "text", name: "MailingEstimatedQuantity",
  296. title: "Please provide your estimated quantity.",
  297. inputType: "number", min: 0,
  298. visibleIf: "{MailingWantsService} = true",
  299. isRequired: true
  300. },
  301. {
  302. type: "dropdown", name: "MailingPickupDate",
  303. title: "What is your preferred (first) pickup date?",
  304. visibleIf: "{MailingWantsService} = true",
  305. isRequired: true,
  306. choices: [
  307. { value: "2026-09-21", text: "September 21, 2026" },
  308. { value: "2026-09-22", text: "September 22, 2026" },
  309. { value: "2026-09-23", text: "September 23, 2026" },
  310. { value: "2026-09-24", text: "September 24, 2026" },
  311. { value: "2026-09-25", text: "September 25, 2026" },
  312. { value: "2026-09-28", text: "September 28, 2026" },
  313. { value: "2026-09-29", text: "September 29, 2026" },
  314. { value: "2026-09-30", text: "September 30, 2026" },
  315. { value: "2026-10-01", text: "October 1, 2026" },
  316. { value: "2026-10-02", text: "October 2, 2026" }
  317. ]
  318. }
  319. ]
  320. },
  321. {
  322. name: "additionalItems",
  323. title: "5. Additional Election Items Request",
  324. elements: [
  325. {
  326. type: "text", name: "SecrecySleevesQty", title: "Secrecy Sleeves (quantity)",
  327. inputType: "number", min: 0, defaultValue: 0,
  328. isRequired: true
  329. },
  330. {
  331. type: "text", name: "IVotedStickerRolls", title: "\"I Voted\" Stickers - number of rolls (rolls of 250)",
  332. inputType: "number", min: 0, defaultValue: 0,
  333. isRequired: true
  334. },
  335. {
  336. type: "text", name: "FutureVoterStickerRolls", title: "\"Future Voter\" Stickers - number of rolls (rolls of 500)",
  337. inputType: "number", min: 0, defaultValue: 0,
  338. isRequired: true
  339. },
  340. {
  341. type: "comment", name: "SpecialRequests",
  342. 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."
  343. }
  344. ]
  345. }
  346. ]
  347. };
  348. var survey = new Survey.Model(surveyJson);
  349. // Color picker modal for the "Which colors would you like to use?" question. Swatches are
  350. // the pre-converted PNGs in public/images/purple-envelope-colors/ (converted from the
  351. // original public/images/Purple_ballot_envelopes colors/*.bmp - those BMPs were ~400KB
  352. // each; PNG compresses these flat-color swatches down to ~1-4KB each).
  353. (function () {
  354. var COLOR_FILES = [
  355. "Aqua", "Black", "Blue", "Brown", "BurlyWood", "Chocolate", "Clay", "Coral",
  356. "CornflowerBlue", "Crimson", "DarkOrange", "DeepPink", "DeepSkyBlue", "DimGray",
  357. "DodgerBlue", "FireBrick", "ForestGreen", "Fuchsia", "Gold", "Goldenrod", "Green",
  358. "HotPink", "Indigo", "LightSeaGreen", "Lime", "LimeGreen", "LtGreen", "MediumOrchid",
  359. "MediumPurple", "MediumTurquoise", "MintGreen", "Navy", "Olive", "OliveDrab", "Orange",
  360. "OrangeRed", "Orchid", "PastelBlue", "PastelPink", "PastelPurple", "PastelYellow",
  361. "Peru", "Pink", "Purple", "Red", "RoyalBlue", "SaddleBrown", "SeaGreen", "Sienna",
  362. "Silver", "SkyBlue", "SteelBlue", "Tan", "Teal", "Tomato", "Turquoise", "Violet",
  363. "White", "Yellow"
  364. ];
  365. var colorImageBaseUrl = "<%= H(Routes().AppURL & "images/purple-envelope-colors/") %>";
  366. var overlay = document.getElementById("colorPickerOverlay");
  367. var grid = document.getElementById("colorPickerGrid");
  368. function colorLabel(fileName) {
  369. return fileName.replace(/([a-z])([A-Z])/g, "$1 $2");
  370. }
  371. COLOR_FILES.forEach(function (fileName) {
  372. var label = colorLabel(fileName);
  373. var item = document.createElement("label");
  374. item.style.cssText = "display:flex; flex-direction:column; gap:6px; border:1px solid #f0e7f8; border-radius:8px; padding:8px; cursor:pointer;";
  375. item.innerHTML =
  376. '<img src="' + colorImageBaseUrl + encodeURIComponent(fileName) + '.png" alt="" ' +
  377. 'style="width:100%; height:36px; border-radius:4px; object-fit:cover; border:1px solid #e5d9f2;" />' +
  378. '<span style="display:flex; align-items:center; gap:6px; font-size:13px; color:#201a27;">' +
  379. '<input type="checkbox" class="color-picker-checkbox" value="' + label.replace(/"/g, "&quot;") + '" /> ' +
  380. label + "</span>";
  381. grid.appendChild(item);
  382. });
  383. function openColorPicker() {
  384. var current = (survey.getValue("PurpleColorNames") || "")
  385. .split(",")
  386. .map(function (s) { return s.trim(); })
  387. .filter(Boolean);
  388. var currentSet = {};
  389. current.forEach(function (c) { currentSet[c] = true; });
  390. var checkboxes = grid.querySelectorAll(".color-picker-checkbox");
  391. checkboxes.forEach(function (cb) { cb.checked = !!currentSet[cb.value]; });
  392. overlay.style.display = "flex";
  393. }
  394. function closeColorPicker() {
  395. overlay.style.display = "none";
  396. }
  397. function applyColorPicker() {
  398. var checked = grid.querySelectorAll(".color-picker-checkbox:checked");
  399. var selected = Array.prototype.map.call(checked, function (cb) { return cb.value; });
  400. survey.setValue("PurpleColorNames", selected.join(", "));
  401. closeColorPicker();
  402. }
  403. document.getElementById("colorPickerCloseBtn").addEventListener("click", closeColorPicker);
  404. document.getElementById("colorPickerCancelBtn").addEventListener("click", closeColorPicker);
  405. document.getElementById("colorPickerApplyBtn").addEventListener("click", applyColorPicker);
  406. overlay.addEventListener("click", function (event) {
  407. if (event.target === overlay) closeColorPicker();
  408. });
  409. // The "Choose Colors..." button is rendered by SurveyJS as an html question, so it
  410. // doesn't exist in the DOM until that page is shown - delegate from a stable ancestor.
  411. document.addEventListener("click", function (event) {
  412. if (event.target && event.target.id === "openColorPickerBtn") {
  413. event.preventDefault();
  414. openColorPicker();
  415. }
  416. });
  417. })();
  418. survey.onCompleting.add(function (sender, options) {
  419. if (!turnstileToken) {
  420. options.allowComplete = false;
  421. alert("Please complete the verification challenge above before submitting.");
  422. }
  423. });
  424. survey.onComplete.add(function (sender) {
  425. fetch(submitUrl, {
  426. method: "POST",
  427. headers: {
  428. "Content-Type": "application/json",
  429. "X-CSRF-Token": csrfToken,
  430. "X-Turnstile-Token": turnstileToken
  431. },
  432. body: JSON.stringify(sender.data)
  433. })
  434. .then(function (res) {
  435. return res.json().catch(function () { return {}; }).then(function (body) {
  436. return { ok: res.ok, body: body };
  437. });
  438. })
  439. .then(function (result) {
  440. if (result.ok && result.body && result.body.success) {
  441. window.location.href = "<%= H(Routes().AppURL) %>";
  442. } else {
  443. alert((result.body && result.body.error) || "Something went wrong submitting your order. Please try again.");
  444. }
  445. })
  446. .catch(function () {
  447. alert("Something went wrong submitting your order. Please check your connection and try again.");
  448. });
  449. });
  450. survey.render(document.getElementById("surveyContainer"));
  451. })();
  452. </script>
  453. <% End If %>

Powered by TurnKey Linux.