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

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

Powered by TurnKey Linux.