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

431 строка
19KB

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

Powered by TurnKey Linux.