Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

481 строка
21KB

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

Powered by TurnKey Linux.